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


C# Forms.Screen类代码示例

本文整理汇总了C#中System.Windows.Forms.Screen的典型用法代码示例。如果您正苦于以下问题:C# Screen类的具体用法?C# Screen怎么用?C# Screen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Screen类属于System.Windows.Forms命名空间,在下文中一共展示了Screen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLoaded

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            //Get references to window, screen, toastNotification and mainViewModel
            window = Window.GetWindow(this);
            screen = window.GetScreen();
            toastNotification = VisualAndLogicalTreeHelper.FindLogicalChildren<ToastNotification>(this).First();
            var mainViewModel = DataContext as MainViewModel;

            //Handle ToastNotification event
            mainViewModel.ToastNotification += (o, args) =>
            {
                SetSizeAndPosition();

                Title = args.Title;
                Content = args.Content;
                NotificationType = args.NotificationType;

                Action closePopup = () =>
                {
                    if (IsOpen)
                    {
                        IsOpen = false;
                        if (args.Callback != null)
                        {
                            args.Callback();
                        }
                    }
                };

                AnimateTarget(args.Content, toastNotification, closePopup);
                IsOpen = true;
            };
        }
开发者ID:masonyang,项目名称:OptiKey,代码行数:33,代码来源:ToastNotificationPopup.cs

示例2: SizeToScreen

 /// <summary>
 /// Sizes to screen.
 /// </summary>
 /// <param name="screen">
 /// The screen.
 /// </param>
 public void SizeToScreen(Screen screen)
 {
     this.Left = screen.WorkingArea.Left;
     this.Top = screen.WorkingArea.Top;
     this.Width = screen.WorkingArea.Width;
     this.Height = screen.WorkingArea.Height;
 }
开发者ID:bradsjm,项目名称:LaJustPowerMeter,代码行数:13,代码来源:ExternalView.xaml.cs

示例3: AddPanel

        private void AddPanel(Screen screen)
        {
            switch (screen)
            {
                case Screen.Product:
                    if (_UC_PRODUCT == null) _UC_PRODUCT = new UcDataProduct();
                    _USER_CONTROL = _UC_PRODUCT;
                    break;
                case Screen.Claim:
                    if (_UC_CLAIM == null) _UC_CLAIM = new UcClaim();
                    _USER_CONTROL = _UC_CLAIM;
                    break;
                case Screen.StockMonitor:
                    if (_UC_STOCK_MONITOR == null) _UC_STOCK_MONITOR = new UcStockMonitor();
                    _USER_CONTROL = _UC_STOCK_MONITOR;
                    break;
                case Screen.Report:
                    if (_UC_REPORT == null) _UC_REPORT = new UcReport();
                    _USER_CONTROL = _UC_REPORT;
                    break;
                case Screen.Member:
                    if (_UC_MEMBER == null) _UC_MEMBER = new UcMember();
                    _USER_CONTROL = _UC_MEMBER;
                    break;
            }

            if (!pnlMain.Contains(_USER_CONTROL))
            {
                pnlMain.Controls.Clear();
                _USER_CONTROL.Dock = DockStyle.Fill;
                pnlMain.Controls.Add(_USER_CONTROL);
            }
        }
开发者ID:PowerDD,项目名称:PowerBackend,代码行数:33,代码来源:Main.cs

示例4: Grab

        /// <summary>
        /// Takes a screenshot of the specified screens (and any screens between them)
        /// </summary>
        /// <param name="screens">The screens to take a screenshot of</param>
        /// <returns>A Image of the screenshot</returns>
        public static Image Grab(Screen[] screens)
        {
            if( screens == null )
                throw new ArgumentNullException("screens");

            if( screens.Length == 0 )
                throw new ArgumentException("Empty array", "screens");

            var start = new Point(0, 0);
            var end = new Point(0, 0);

            //get bounds of total screen space
            foreach( var tempScreen in screens )
            {
                if( tempScreen.Bounds.X < start.X )
                    start.X = tempScreen.Bounds.X;

                if( tempScreen.Bounds.Y < start.Y )
                    start.Y = tempScreen.Bounds.Y;

                if( tempScreen.Bounds.X + tempScreen.Bounds.Width > end.X )
                    end.X = tempScreen.Bounds.X + tempScreen.Bounds.Width;

                if( tempScreen.Bounds.Y + tempScreen.Bounds.Height > end.Y )
                    end.Y = tempScreen.Bounds.Y + tempScreen.Bounds.Height;
            }

            return Grab(start, end);
        }
开发者ID:spencerhakim,项目名称:SpencerHakimNET,代码行数:34,代码来源:Screenshot.cs

示例5: GetDpiX

 public double GetDpiX(Screen screen)
 {
     uint dpiX;
       uint dpiY;
       screen.GetDpi(DpiType.Effective, out dpiX, out dpiY);
       return Convert.ToDouble(dpiX);
 }
开发者ID:meinsiedler,项目名称:ExcelTableConverter,代码行数:7,代码来源:TableConverterDialog.cs

示例6: TakeScreenshot

 private static Bitmap TakeScreenshot(Screen screen)
 {
     Bitmap bitmap = new Bitmap(screen.Bounds.Width, screen.Bounds.Height, PixelFormat.Format32bppArgb);
     Graphics graphics = Graphics.FromImage(bitmap);
     graphics.CopyFromScreen(screen.Bounds.X, screen.Bounds.Y, 0, 0, screen.Bounds.Size, CopyPixelOperation.SourceCopy);
     return bitmap;
 }
开发者ID:ByShev,项目名称:userControlProgram,代码行数:7,代码来源:ScreenshotMaker.cs

示例7: CreateControl

        void CreateControl(Screen current)
        {
            Type type = current.Type;

            // create new instance on gui thread
            if (MainControl.InvokeRequired)
            {
                MainControl.Invoke((MethodInvoker) delegate
                {
                    current.Control = (MyUserControl) Activator.CreateInstance(type);
                });
            }
            else
            {
                try
                {
                    current.Control = (MyUserControl) Activator.CreateInstance(type);
                }
                catch
                {
                    try
                    {
                        current.Control = (MyUserControl) Activator.CreateInstance(type);
                    }
                    catch
                    {
                    }
                }
            }

            // set the next new instance as not visible
            current.Control.Visible = false;
        }
开发者ID:jmachuca77,项目名称:MissionPlanner,代码行数:33,代码来源:MainSwitcher.cs

示例8: ScreenIsVirtual

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether or not the specified screen is a virtual device. Virtual displays
		/// can usually be ignored.
		/// </summary>
		/// <param name="scrn">Screen to test.</param>
		/// <returns>True if screen is virtual. Otherwise, guess</returns>
		/// ------------------------------------------------------------------------------------
		public static bool ScreenIsVirtual(Screen scrn)
		{
			// We're really looking for a string containing DISPLAYV, but something is *goofy*
			// in the DeviceName string. It will not compare correctly despite all common sense.
			// Best we can do is test for "ISPLAYV".
			return (scrn.DeviceName.ToUpper().IndexOf("ISPLAYV") >= 0);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:ScreenUtils.cs

示例9: SizeDialog

        public static Size SizeDialog(IDeviceContext dc, string mainInstruction, string content, Screen screen, Font mainInstructionFallbackFont, Font contentFallbackFont, int horizontalSpacing, int verticalSpacing, int minimumWidth, int textMinimumHeight)
        {
            int width = minimumWidth - horizontalSpacing;
            int height = GetTextHeight(dc, mainInstruction, content, mainInstructionFallbackFont, contentFallbackFont, width);

            while( height > width )
            {
                int area = height * width;
                width = (int)(Math.Sqrt(area) * 1.1);
                height = GetTextHeight(dc, mainInstruction, content, mainInstructionFallbackFont, contentFallbackFont, width);
            }

            if( height < textMinimumHeight )
                height = textMinimumHeight;

            int newWidth = width + horizontalSpacing;
            int newHeight = height + verticalSpacing;

            Rectangle workingArea = screen.WorkingArea;
            if( newHeight > 0.9 * workingArea.Height )
            {
                int area = height * width;
                newHeight = (int)(0.9 * workingArea.Height);
                height = newHeight - verticalSpacing;
                width = area / height;
                newWidth = width + horizontalSpacing;
            }

            // If this happens the text won't display correctly, but even at 800x600 you need
            // to put so much text in the input box for this to happen that I don't care.
            if( newWidth > 0.9 * workingArea.Width )
                newWidth = (int)(0.9 * workingArea.Width);

            return new Size(newWidth, newHeight);
        }
开发者ID:RogovaTatiana,项目名称:FilesSync,代码行数:35,代码来源:DialogHelper.cs

示例10: CalibrationWpf

        public CalibrationWpf(Screen current)
        {
            InitializeComponent();
            screen = current;

            // Create the calibration target
            calibrationPointWpf = new CalibrationPointWpf(new Size(screen.Bounds.Width, screen.Bounds.Height));
            CalibrationCanvas.Children.Add(calibrationPointWpf);

            Opacity = 0;
            IsAborted = false;

            // Create the animation-out object and close form when completed
            animateOut = new DoubleAnimation(0, TimeSpan.FromSeconds(FADE_OUT_TIME))
            {
                From = 1.0,
                To = 0.0,
                AutoReverse = false
            };

            animateOut.Completed += delegate
            {
                Close();
            };
        }
开发者ID:kgram,项目名称:tet-csharp-samples,代码行数:25,代码来源:CalibrationWPF.xaml.cs

示例11: CursorControl

 public CursorControl(Screen screen, bool enabled, bool smooth)
 {
     GazeManager.Instance.AddGazeListener(this);
     ActiveScreen = screen;
     Enabled = enabled;
     Smooth = smooth;
 }
开发者ID:hide1980,项目名称:tet-csharp-samples,代码行数:7,代码来源:CursorControl.cs

示例12: Show

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shows the splash screen
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void Show(Screen display)
		{
#if !__MonoCS__
			if (m_thread != null)
				return;
#endif

			m_displayToUse = display;
			m_waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);

#if __MonoCS__
			// mono winforms can't create items not on main thread.
			StartSplashScreen(); // Create Modeless dialog on Main GUI thread
#else
			m_thread = new Thread(StartSplashScreen);
			m_thread.IsBackground = true;
			m_thread.SetApartmentState(ApartmentState.STA);
			m_thread.Name = "SplashScreen";
			// Copy the UI culture from the main thread to the splash screen thread.
			m_thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
			m_thread.Start();
			m_waitHandle.WaitOne();
#endif

			Debug.Assert(m_splashScreen != null);
			Message = string.Empty;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:32,代码来源:TxlSplashScreen.cs

示例13: FindAdapter

        public DXGIScreen FindAdapter(Screen wscreen, bool refresh = false)
        {
            if (refresh) { this.Refresh(); }

            foreach (DXGIScreen screen in this.screens)
            {
                if (screen.Monitor.Description.Name.EndsWith(wscreen.DeviceName))
                {
                    return screen;
                }
            }

            //If not found force a refresh and try again
            if (!refresh) { this.Refresh(); }

            foreach (DXGIScreen screen in this.screens)
            {
                if (screen.Monitor.Description.Name.EndsWith(wscreen.DeviceName))
                {
                    return screen;
                }
            }

            //Blank object if not found
            return new DXGIScreen();
        }
开发者ID:kopffarben,项目名称:dx11-vvvv,代码行数:26,代码来源:DX11DisplayManager.cs

示例14: GetVisibleRectangle

        static Rectangle GetVisibleRectangle(WindowInfo wi, Screen s)
        {
            Rectangle resultWindowRect = new Rectangle(
                wi.rcWindow.left,
                wi.rcWindow.top,
                wi.rcWindow.right - wi.rcWindow.left,
                wi.rcWindow.bottom - wi.rcWindow.top
            );

            WindowBorderOnScreenFlags flags = new WindowBorderOnScreenFlags(wi, s);

            if(!flags.leftBorderOnScreen)
                resultWindowRect.X = s.WorkingArea.X;
            else {
                resultWindowRect.X = !flags.rightBorderOnScreen ?
                    s.WorkingArea.Right - wi.rcWindow.right + wi.rcWindow.left :
                    wi.rcWindow.left;
            }

            if(!flags.topBorderOnScreen)
                resultWindowRect.Y = s.WorkingArea.Y;
            else {
                resultWindowRect.Y = !flags.bottomBorderOnScreen ?
                    s.WorkingArea.Bottom - wi.rcWindow.bottom + wi.rcWindow.top :
                    wi.rcWindow.top;
            }

            return resultWindowRect;
        }
开发者ID:inikulin,项目名称:testcafe-browser-natives,代码行数:29,代码来源:Program.cs

示例15: AddPanel

        private void AddPanel(Screen screen)
        {
            switch (screen)
            {
                case Screen.Sale:
                    if (_UC_SALE == null) _UC_SALE = new UcSale();
                    _USER_CONTROL = _UC_SALE;
                    break;
                case Screen.ReceiveProduct:
                    if (_UC_RECEIVE_PRODUCT == null) _UC_RECEIVE_PRODUCT = new UcReceiveProduct();
                    _USER_CONTROL = _UC_RECEIVE_PRODUCT;
                    break;
                case Screen.Stock:
                    if (_UC_STOCK == null) _UC_STOCK = new UcStock();
                    _USER_CONTROL = _UC_STOCK;
                    break;
            }

            if (!panelMain.Contains(_USER_CONTROL))
            {
                panelMain.Controls.Clear();
                _USER_CONTROL.Dock = DockStyle.Fill;
                panelMain.Controls.Add(_USER_CONTROL);
            }
        }
开发者ID:PowerDD,项目名称:PowerPOS,代码行数:25,代码来源:Main.cs


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