• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.Screen类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetScreenBitmap

        public static Bitmap GetScreenBitmap(Screen screen, int ratio)
        {
            int sourceWidth = screen.Bounds.Width;
            int sourceHeight = screen.Bounds.Height;

            int destinationWidth = sourceWidth;
            int destinationHeight = sourceHeight;

            if (ratio < IMAGE_RESOLUTION_RATIO_MIN || ratio > IMAGE_RESOLUTION_RATIO_MAX) { ratio = 100; }

            float imageResolutionRatio = (float)ratio / 100;

            destinationWidth = (int)(sourceWidth * imageResolutionRatio);
            destinationHeight = (int)(sourceHeight * imageResolutionRatio);

            Bitmap bitmapSource = new Bitmap(sourceWidth, sourceHeight);
            Graphics graphicsSource = Graphics.FromImage(bitmapSource);
            graphicsSource.CopyFromScreen(screen.Bounds.X, screen.Bounds.Y, 0, 0, screen.Bounds.Size);

            Bitmap bitmapDestination = new Bitmap(destinationWidth, destinationHeight);
            Graphics graphicsDestination = Graphics.FromImage(bitmapDestination);
            graphicsDestination.DrawImage(bitmapSource, 0, 0, destinationWidth, destinationHeight);

            graphicsSource.Flush();
            graphicsDestination.Flush();

            return bitmapDestination;
        }
开发者ID:gavinkendall,项目名称:autoscreen,代码行数:28,代码来源:ScreenCapture.cs


示例17: Register

        public static void Register(Form form, AppBarEdge edge, Screen screen)
        {
            Rectangle screenArea = screen.WorkingArea;
            if (edge == AppBarEdge.Top || edge == AppBarEdge.Bottom)
            {
                form.Left = screenArea.Left;
                form.Width = screenArea.Width;
                form.Top = edge == AppBarEdge.Top ? screenArea.Top : screenArea.Bottom - form.Height;
            }
            else
            {
                form.Left = edge == AppBarEdge.Left ? screenArea.Left : screenArea.Right - form.Width;
                form.Height = screenArea.Height;
                form.Top = screenArea.Top;
            }
            form.FormBorderStyle = FormBorderStyle.None;
            uint callbackId = RegisterWindowMessage(form.GetHashCode().ToString("x"));

            APPBARDATA appData = new APPBARDATA();
            appData.cbSize = (uint)Marshal.SizeOf(appData);
            appData.uCallbackMessage = callbackId;
            appData.hWnd = form.Handle;

            uint ret = SHAppBarMessage(AppBarMessage.New, ref appData);
            if (ret != 0)
            {
                _appBars.Add(form);
                form.FormClosing += (s, e) => Unregister(form);
                AppBarPosition(form, edge, AppBarMessage.QueryPos);
                AppBarPosition(form, edge, AppBarMessage.SetPos);
            }
        }
开发者ID:bsandru,项目名称:tasksharp,代码行数:32,代码来源:AppBar.cs


示例18: NeedsNudge

        // Check if we need to nudge the mosue down and by how much
        private bool NeedsNudge(Screen ActiveScreen, TabAlignment Dir, out Point NudgeAmount)
        {
            NudgeAmount = new Point(0, 0);

            if (Dir == TabAlignment.Left)
            {
                // Hack to get the screen to the left, I couldn't find any API call to get the layout of the screens so this should do for most cases
                Screen Left = Screen.FromPoint(new Point(Cursor.Position.X - ScreenNudgeMargin * 2, ActiveScreen.Bounds.Bottom - ActiveScreen.Bounds.Height / 2));

                if (Cursor.Position.Y <= Left.Bounds.Top)
                    NudgeAmount.Y = Left.Bounds.Top;
                else if (Cursor.Position.Y > Left.Bounds.Bottom)
                    NudgeAmount.Y = Left.Bounds.Bottom;
                else
                    return false;

                return true;
            }
            else if (Dir == TabAlignment.Right)
            {
                Screen Right = Screen.FromPoint(new Point(Cursor.Position.X + ScreenNudgeMargin * 2, ActiveScreen.Bounds.Bottom - ActiveScreen.Bounds.Height / 2));

                if (Cursor.Position.Y <= Right.Bounds.Top)
                    NudgeAmount.Y = Right.Bounds.Top;
                else if (Cursor.Position.Y > Right.Bounds.Bottom)
                    NudgeAmount.Y = Right.Bounds.Bottom;
                else
                    return false;

                return true;
            }

            return false;
        }
开发者ID:GoomiChan,项目名称:MouseNudge,代码行数:35,代码来源:MouseNudger.cs


示例19: ShowScreenSaver

        /// <summary>
        /// Shows screen saver by creating one instance of Screen for each monitor.
        /// 
        /// Note: uses WinForms's Screen class to get monitor info.
        /// </summary>
        void ShowScreenSaver()
        {
            //creates window on primary screen
            Screen primaryWindow = new Screen();
            primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            System.Drawing.Rectangle location = WinForms.Screen.PrimaryScreen.Bounds;
            primaryWindow.WindowState = WindowState.Maximized;

            //creates window on other screens
            foreach (var screen in WinForms.Screen.AllScreens)
            {
                if (screen == WinForms.Screen.PrimaryScreen)
                    continue;

                var window = new Screen();
                window.WindowStartupLocation = WindowStartupLocation.Manual;
                location = screen.Bounds;

                //covers entire monitor
                window.Left = location.X - 7;
                window.Top = location.Y - 7;
                window.Width = location.Width + 14;
                window.Height = location.Height + 14;
            }

            //show non-primary screen windows
            foreach (var window in Current.Windows)
                if (window != primaryWindow)
                    window.Show();

            ///shows primary screen window last
            primaryWindow.Show();
        }
开发者ID:MathewSachin,项目名称:ScreenSaver,代码行数:38,代码来源:App.xaml.cs


示例20: ScreenCapture

        public ScreenCapture(int fps, Screen screen)
        {
            string x = System.DateTime.Now.ToString();
            x = x.Replace(@"/", ".");
            x = x.Replace(@":", ".");

            strPath = @"/Videos/";

            intTop = screen.Bounds.X;
            intleft = screen.Bounds.Y;
            intWidth = screen.Bounds.Width;
            intHeight = screen.Bounds.Height;
            size = screen.Bounds.Size;

            capture();

            aviMan = new AviManager(x + ".avi", false);
            videoStream = aviMan.AddVideoStream(true, 30, printscreen);
            printscreen.Dispose();

            Console.WriteLine(strPath);
            System.IO.Directory.CreateDirectory(strPath);

            System.Timers.Timer aTimer;
            aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 1000 / fps;
            aTimer.Enabled = true;
        }
开发者ID:aaronhance,项目名称:SharpLapse,代码行数:29,代码来源:ScreenCapture.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.ScrollBar类代码示例发布时间:2022-05-26
下一篇:
C# Forms.SaveFileDialog类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap