public DeviceContextWpf(DeviceSettings settings)
        {
            Contract.Requires(settings != null);

            Settings = settings;
            LogEvent.Engine.Log(settings.ToString());

            eventHandlerList = new EventHandlerList();

            LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreating);
            //SwapChainDescription swapChainDesc = new SwapChainDescription
            //                                         {
            //                                             BufferCount = 1,
            //                                             ModeDescription =
            //                                                 new ModeDescription(Settings.ScreenWidth, Settings.ScreenHeight,
            //                                                                     new Rational(120, 1), Settings.Format),
            //                                             IsWindowed = true,
            //                                             OutputHandle =(new System.Windows.Interop.WindowInteropHelper(Global.Window)).Handle,
            //                                             SampleDescription = Settings.SampleDescription,
            //                                             SwapEffect = SwapEffect.Discard,
            //                                             Usage = Usage.RenderTargetOutput,
            //                                         };

            //LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreating);
            //Device.CreateWithSwapChain(DriverType.Hardware, Settings.CreationFlags, swapChainDesc, out device, out swapChain);
            device = new Device(DriverType.Hardware, Settings.CreationFlags, FeatureLevel.Level_11_0);

            //if (!Settings.IsWindowed)

            immediate = device.ImmediateContext;

            CreateTargets();
            LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreated);
            device.ImmediateContext.Flush();
        }
        public DeviceContext11(IntPtr handle, DeviceSettings settings)
        {
            Contract.Requires(handle != IntPtr.Zero);
            Contract.Requires(settings != null);

            Settings = settings;
            LogEvent.Engine.Log(settings.ToString());

            eventHandlerList = new EventHandlerList();
            SwapChainDescription swapChainDesc = new SwapChainDescription
                                                     {
                                                         BufferCount = 1,
                                                         IsWindowed = Settings.IsWindowed,
                                                         ModeDescription =
                                                             new ModeDescription{
                                                                 Width = Settings.ScreenWidth,
                                                                 Height = Settings.ScreenHeight,
                                                                 RefreshRate= new Rational(0, 1),
                                                                 Format = Settings.Format,
                                                                 Scaling = DisplayModeScaling.Unspecified,
                                                                 ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified,
                                                             },

                                                         //new Rational(120, 1), Settings.Format),
                                                         OutputHandle = handle,
                                                         SampleDescription = Settings.SampleDescription,
                                                         Flags = SwapChainFlags.AllowModeSwitch,
                                                         SwapEffect = SwapEffect.Discard,
                                                         Usage = Usage.RenderTargetOutput,
                                                     };

            FeatureLevel[] featureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 };
            LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreating);
            Device.CreateWithSwapChain(DriverType.Hardware, Settings.CreationFlags, featureLevels, swapChainDesc, out device, out swapChain);

            factory = swapChain.GetParent<Factory>();
            factory.SetWindowAssociation(handle, WindowAssociationFlags.IgnoreAltEnter | WindowAssociationFlags.IgnoreAll);

            immediate = device.ImmediateContext;

            CreateTargets();
            LogEvent.Engine.Log(Resources.INFO_OE_DeviceCreated);
        }