--------------------------------------------------------------------------------
-- <auto-generated>                                                           --
--     This code was generated by a tool.                                     --
--                                                                            --
--     Changes to this file may cause incorrect behavior and will be lost if  --
--     the code is regenerated.                                               --
-- </auto-generated>                                                          --
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--                                                                            --
--    Copyright(c) 2018 Alexander Gamper, All Rights Reserved.                --
--                                                                            --
--    Ada-WinRT                                                               --
--                                                                            --
-- This program is free software: you can redistribute it and / or modify     --
-- it under the terms of the GNU Lesser General Public License as published by--
-- the Free Software Foundation, either version 3 of the License, or          --
-- (at your option) any later version.                                        --
--                                                                            --
-- This program is distributed in the hope that it will be useful,            --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of             --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               --
-- GNU Lesser General Public License for more details.                        --
--                                                                            --
-- You should have received a copy of the GNU Lesser General Public License   --
-- along with this program.If not, see http://www.gnu.org/licenses            --
--                                                                            --
--------------------------------------------------------------------------------
with Windows.Devices.Display;
with Windows.Graphics;
with Windows.Graphics.DirectX;
with Windows.Graphics.DirectX.Direct3D11;
with Windows.Storage.Streams;
with Ada.Unchecked_Conversion;
--------------------------------------------------------------------------------
package body Windows.Devices.Display.Core is

   ------------------------------------------------------------------------
   -- Delegates/Events
   ------------------------------------------------------------------------
   
   function Invoke
   (
      This       : access TypedEventHandler_IDisplayManager_add_Changed_Interface
      ; sender : Windows.Devices.Display.Core.IDisplayManager
      ; args : Windows.Devices.Display.Core.IDisplayManagerChangedEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.Devices.Display.Core.IDisplayManager(sender), Windows.Devices.Display.Core.IDisplayManagerChangedEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IDisplayManager_add_Disabled_Interface
      ; sender : Windows.Devices.Display.Core.IDisplayManager
      ; args : Windows.Devices.Display.Core.IDisplayManagerDisabledEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.Devices.Display.Core.IDisplayManager(sender), Windows.Devices.Display.Core.IDisplayManagerDisabledEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IDisplayManager_add_Enabled_Interface
      ; sender : Windows.Devices.Display.Core.IDisplayManager
      ; args : Windows.Devices.Display.Core.IDisplayManagerEnabledEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.Devices.Display.Core.IDisplayManager(sender), Windows.Devices.Display.Core.IDisplayManagerEnabledEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IDisplayManager_add_PathsFailedOrInvalidated_Interface
      ; sender : Windows.Devices.Display.Core.IDisplayManager
      ; args : Windows.Devices.Display.Core.IDisplayManagerPathsFailedOrInvalidatedEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.Devices.Display.Core.IDisplayManager(sender), Windows.Devices.Display.Core.IDisplayManagerPathsFailedOrInvalidatedEventArgs(args));
      return Hr;
   end;
   
   ------------------------------------------------------------------------
   -- Create functions (for activatable classes)
   ------------------------------------------------------------------------
   
   function CreateInstance
   (
      width : Windows.UInt32
      ; height : Windows.UInt32
      ; pixelFormat : Windows.Graphics.DirectX.DirectXPixelFormat
      ; colorSpace : Windows.Graphics.DirectX.DirectXColorSpace
      ; isStereo : Windows.Boolean
      ; multisampleDescription : Windows.Graphics.DirectX.Direct3D11.Direct3DMultisampleDescription
   )
   return Windows.Devices.Display.Core.IDisplayPrimaryDescription is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.Devices.Display.Core.DisplayPrimaryDescription");
      m_Factory     : Windows.Devices.Display.Core.IDisplayPrimaryDescriptionFactory := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Devices.Display.Core.IDisplayPrimaryDescription := null;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDisplayPrimaryDescriptionFactory'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.CreateInstance(width, height, pixelFormat, colorSpace, isStereo, multisampleDescription, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function CreateInstance
   (
      pixelEncoding : Windows.Devices.Display.Core.DisplayWireFormatPixelEncoding
      ; bitsPerChannel : Windows.Int32
      ; colorSpace : Windows.Devices.Display.Core.DisplayWireFormatColorSpace
      ; eotf : Windows.Devices.Display.Core.DisplayWireFormatEotf
      ; hdrMetadata : Windows.Devices.Display.Core.DisplayWireFormatHdrMetadata
   )
   return Windows.Devices.Display.Core.IDisplayWireFormat is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.Devices.Display.Core.DisplayWireFormat");
      m_Factory     : Windows.Devices.Display.Core.IDisplayWireFormatFactory := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Devices.Display.Core.IDisplayWireFormat := null;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDisplayWireFormatFactory'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.CreateInstance(pixelEncoding, bitsPerChannel, colorSpace, eotf, hdrMetadata, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   ------------------------------------------------------------------------
   -- Override Implementations
   ------------------------------------------------------------------------
   
   ------------------------------------------------------------------------
   -- Static procedures/functions
   ------------------------------------------------------------------------
   
   function FromId
   (
      id : Windows.Graphics.DisplayAdapterId
   )
   return Windows.Devices.Display.Core.IDisplayAdapter is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.Devices.Display.Core.DisplayAdapter");
      m_Factory     : IDisplayAdapterStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Devices.Display.Core.IDisplayAdapter;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDisplayAdapterStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.FromId(id, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function Create
   (
      options : Windows.Devices.Display.Core.DisplayManagerOptions
   )
   return Windows.Devices.Display.Core.IDisplayManager is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.Devices.Display.Core.DisplayManager");
      m_Factory     : IDisplayManagerStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Devices.Display.Core.IDisplayManager;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDisplayManagerStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.Create(options, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function CreateWithProperties
   (
      extraProperties : Windows.Address
      ; width : Windows.UInt32
      ; height : Windows.UInt32
      ; pixelFormat : Windows.Graphics.DirectX.DirectXPixelFormat
      ; colorSpace : Windows.Graphics.DirectX.DirectXColorSpace
      ; isStereo : Windows.Boolean
      ; multisampleDescription : Windows.Graphics.DirectX.Direct3D11.Direct3DMultisampleDescription
   )
   return Windows.Devices.Display.Core.IDisplayPrimaryDescription is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.Devices.Display.Core.DisplayPrimaryDescription");
      m_Factory     : IDisplayPrimaryDescriptionStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Devices.Display.Core.IDisplayPrimaryDescription;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDisplayPrimaryDescriptionStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.CreateWithProperties(extraProperties, width, height, pixelFormat, colorSpace, isStereo, multisampleDescription, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function CreateWithProperties
   (
      extraProperties : Windows.Address
      ; pixelEncoding : Windows.Devices.Display.Core.DisplayWireFormatPixelEncoding
      ; bitsPerChannel : Windows.Int32
      ; colorSpace : Windows.Devices.Display.Core.DisplayWireFormatColorSpace
      ; eotf : Windows.Devices.Display.Core.DisplayWireFormatEotf
      ; hdrMetadata : Windows.Devices.Display.Core.DisplayWireFormatHdrMetadata
   )
   return Windows.Devices.Display.Core.IDisplayWireFormat is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.Devices.Display.Core.DisplayWireFormat");
      m_Factory     : IDisplayWireFormatStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Devices.Display.Core.IDisplayWireFormat;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDisplayWireFormatStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.CreateWithProperties(extraProperties, pixelEncoding, bitsPerChannel, colorSpace, eotf, hdrMetadata, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
end;
