当前位置: 首页>>代码示例>>C#>>正文


C# Device.ShowCursor方法代码示例

本文整理汇总了C#中Device.ShowCursor方法的典型用法代码示例。如果您正苦于以下问题:C# Device.ShowCursor方法的具体用法?C# Device.ShowCursor怎么用?C# Device.ShowCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.ShowCursor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize3DEnvironment

        private void Initialize3DEnvironment()
        {
            DisplayAdapter adapterInfo = graphicsSettings.DisplayAdapter;
            DisplayDevice deviceInfo = graphicsSettings.DisplayDevice;

            isWindowed = graphicsSettings.IsWindowed;

            // Prepare window for possible windowed/fullscreen change
            // AdjustWindowForChange();

            // Set up the presentation parameters
            RefreshPresentParameters();

            if(deviceInfo.Caps.PrimitiveMiscCaps.IsNullReference)
            {
                // Warn user about null ref device that can't render anything
                throw new ApplicationException("null reference device");
            }

            CreateFlags createFlags = new CreateFlags();
            switch(graphicsSettings.VertexProcessingType)
            {
                case VertexProcessingType.Software:
                    createFlags = CreateFlags.SoftwareVertexProcessing;
                    break;
                case VertexProcessingType.Mixed:
                    createFlags = CreateFlags.MixedVertexProcessing;
                    break;
                case VertexProcessingType.Hardware:
                    createFlags = CreateFlags.HardwareVertexProcessing;
                    break;
                case VertexProcessingType.PureHardware:
                    createFlags = CreateFlags.HardwareVertexProcessing | CreateFlags.PureDevice;
                    break;
                default:
                    throw new ApplicationException("Unable to determine vertex processing method.");
            }

            // Create the device
            device = new Device(graphicsSettings.AdapterOrdinal,
                graphicsSettings.DisplayDevice.DeviceType,
                this.viewport,
                createFlags,
                this.presentParameters);

            if( device != null )
            {
                // Cache our local objects
                renderStates = device.RenderState;
                samplerStates = device.SamplerState;
                textureStates = device.TextureState;
                // When moving from fullscreen to windowed mode, it is important to
                // adjust the window size after recreating the device rather than
                // beforehand to ensure that you get the window size you want.  For
                // example, when switching from 640x480 fullscreen to windowed with
                // a 1000x600 window on a 1024x768 desktop, it is impossible to set
                // the window size to 1000x600 until after the display mode has
                // changed to 1024x768, because windows cannot be larger than the
                // desktop.
                if(graphicsSettings.IsWindowed && (this.viewport is System.Windows.Forms.Form))
                {
                    // Make sure main window isn't topmost, so error message is visible
                    this.viewport.Location = new System.Drawing.Point(rectWindowBounds.Left, rectWindowBounds.Top);
                    this.viewport.Size = new System.Drawing.Size(( rectWindowBounds.Right - rectWindowBounds.Left ), ( rectWindowBounds.Bottom - rectWindowBounds.Top));
                }

                // Store device Caps
                graphicsCaps = device.DeviceCaps;
                behavior = createFlags;

                // Store render target surface desc
                Surface BackBuffer = device.GetBackBuffer(0,0, BackBufferType.Mono);
                backBufferDesc = BackBuffer.Description;
                BackBuffer.Dispose();
                BackBuffer = null;

                // Set up the fullscreen cursor
                if(showFullScreenCursor && !graphicsSettings.IsWindowed)
                {
                    System.Windows.Forms.Cursor ourCursor = this.viewport.Cursor;
                    device.SetCursor(ourCursor, true);
                    device.ShowCursor(true);
                }

                // Confine cursor to fullscreen window
                if(clipFullScreenCursor)
                {
                    if (!isWindowed)
                    {
                        System.Drawing.Rectangle rcWindow = this.viewport.ClientRectangle;
                    }
                }

                // Setup the event handlers for our device
                device.DeviceLost += InvalidateDeviceObjects;
                device.DeviceReset += RestoreDeviceObjects;
                device.Disposing += DeleteDeviceObjects;
                device.DeviceResizing += new CancelEventHandler(EnvironmentResized);

                // Initialize the app's device-dependent objects
//.........这里部分代码省略.........
开发者ID:deobald,项目名称:midget,代码行数:101,代码来源:Direct3DHost.cs

示例2: PrepareDevice

            /// <summary>
            /// Prepares a new or resetting device by with cursor info and
            /// store backbuffer desc and caps from the device
            /// </summary>
            private void PrepareDevice(Device device)
            {
            // Update the device stats text
            UpdateStaticFrameStats();

            // Store render target surface desc
            using(Surface backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono))
            {
                State.BackBufferSurfaceDesc = backBuffer.Description;
            }

            // Update the state's copy of caps
            State.Caps = device.DeviceCaps;

            // Setup the full screen cursor
            if (State.IsShowingCursorWhenFullScreen && !IsWindowed)
            {
                // Get a valid cursor
                System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursor.Current;
                if (cursor == null)
                    cursor = System.Windows.Forms.Cursors.Default;

                device.SetCursor(cursor, false);
                device.ShowCursor(true);
            }

            // Confine cursor to full screen window
            if (State.IsCursorClippedWhenFullScreen)
            {
                if (!IsWindowed)
                {
                    // Turn on clipping for the full screen window
                    System.Windows.Forms.Cursor.Clip = State.FullScreenClientRectangle;
                }
                else
                {
                    // Turn off clipping
                    System.Windows.Forms.Cursor.Clip = System.Drawing.Rectangle.Empty;
                }
            }
            }
开发者ID:JamesTryand,项目名称:simergy,代码行数:45,代码来源:dxmut.cs

示例3: InitializeEnvironment


//.........这里部分代码省略.........
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // Store device description
            if (deviceInfo.DevType == DeviceType.Reference)
                sb.Append("REF");
            else if (deviceInfo.DevType == DeviceType.Hardware)
                sb.Append("HAL");
            else if (deviceInfo.DevType == DeviceType.Software)
                sb.Append("SW");

            BehaviorFlags behaviorFlags = new BehaviorFlags(createFlags);
            if ((behaviorFlags.HardwareVertexProcessing) &&
                (behaviorFlags.PureDevice)) {
                if (deviceInfo.DevType == DeviceType.Hardware)
                    sb.Append(" (pure hw vp)");
                else
                    sb.Append(" (simulated pure hw vp)");
            }
            else if (behaviorFlags.HardwareVertexProcessing) {
                if (deviceInfo.DevType == DeviceType.Hardware)
                    sb.Append(" (hw vp)");
                else
                    sb.Append(" (simulated hw vp)");
            }
            else if (behaviorFlags.MixedVertexProcessing) {
                if (deviceInfo.DevType == DeviceType.Hardware)
                    sb.Append(" (mixed vp)");
                else
                    sb.Append(" (simulated mixed vp)");
            }
            else if (behaviorFlags.SoftwareVertexProcessing) {
                sb.Append(" (sw vp)");
            }

            if (deviceInfo.DevType == DeviceType.Hardware) {
                sb.Append(": ");
                sb.Append(adapterInfo.AdapterDetails.Description);
            }

            // Set device stats string
            deviceStats = sb.ToString();

            // Set up the fullscreen cursor
            if (showCursorWhenFullscreen && !windowed) {
                System.Windows.Forms.Cursor ourCursor = this.Cursor;
                device.SetCursor(ourCursor, true);
                device.ShowCursor(true);
            }

            // Confine cursor to fullscreen window
            if (clipCursorWhenFullscreen) {
                if (!windowed) {
                    System.Drawing.Rectangle rcWindow = this.ClientRectangle;
                }
            }

            // Setup the event handlers for our device
            device.DeviceLost += new System.EventHandler(this.InvalidateDeviceObjects);
            device.DeviceReset += new System.EventHandler(this.RestoreDeviceObjects);
            device.Disposing += new System.EventHandler(this.DeleteDeviceObjects);
            device.DeviceResizing += new System.ComponentModel.CancelEventHandler(this.EnvironmentResized);

            // Initialize the app's device-dependent objects
            try {
                InitializeDeviceObjects();
                RestoreDeviceObjects(null, null);
                active = true;
                return;
            }
            catch {
                // Cleanup before we try again
                InvalidateDeviceObjects(null, null);
                DeleteDeviceObjects(null, null);
                device.Dispose();
                device = null;
                if (this.Disposing)
                    return;
            }
        }
        catch {
            // If that failed, fall back to the reference rasterizer
            if (deviceInfo.DevType == DeviceType.Hardware) {
                if (FindBestWindowedMode(false, true)) {
                    windowed = true;

                    // Make sure main window isn't topmost, so error message is visible
                    System.Drawing.Size currentClientSize = this.ClientSize;
                    this.Size = this.ClientSize;
                    this.SendToBack();
                    this.BringToFront();
                    this.ClientSize = currentClientSize;

                    // Let the user know we are switching from HAL to the reference rasterizer
                    HandleSampleException(null, ApplicationMessage.WarnSwitchToRef);

                    InitializeEnvironment();
                }
            }
        }
    }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:101,代码来源:d3dapp.cs


注:本文中的Device.ShowCursor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。