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


C# Window.Activate方法代码示例

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


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

示例1: ShowModal

        /// <summary>
        ///     Shows the modal.
        /// </summary>
        /// <param name="owner">The owner.</param>
        public void ShowModal(Window owner, IUserInputManager userInputManager = null)
        {
            _userInputManager = userInputManager;

            WindowStyle = WindowStyle.None;
            ResizeMode = ResizeMode.NoResize;
            ShowInTaskbar = false;
            WindowStartupLocation = WindowStartupLocation.Manual;
            AllowsTransparency = true;

            Width = owner.Width;
            Height = owner.Height;
            Top = owner.Top;
            Left = owner.Left;
            WindowState = owner.WindowState;
            Owner = owner;

            EventHandler closedHanlder = null;
            closedHanlder = (sender, e) => {
                owner.Activate();
                Closed -= closedHanlder;
            };

            Closed += closedHanlder;

            Show();
        }
开发者ID:TomGillen,项目名称:MBT,代码行数:31,代码来源:BaseModalWindow.cs

示例2: Initialize

		public void Initialize(Window window, bool activate = true)
		{
			if (window.Content == null)
				window.Content = RootFrame;
			if (activate)
				window.Activate();
		}
开发者ID:CarverLab,项目名称:onCore.root,代码行数:7,代码来源:NavigationService.cs

示例3: TryActivateMainWindow

 static void TryActivateMainWindow(Window mainWindow) {
     try {
         mainWindow.Show();
         mainWindow.Activate();
     } catch (InvalidOperationException e) {
         MainLog.Logger.FormattedDebugException(e);
     }
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:8,代码来源:DialogHelper.cs

示例4: ExampleTest

 public void ExampleTest()
 {
     var window = new Window() {Width = 100, Height = 100};
     window.Show();
     window.Activate();
     window.Dispatcher.InvokeShutdown();
     window.Close();
 }
开发者ID:p69,项目名称:magellan-framework,代码行数:8,代码来源:SampleUnitTests.cs

示例5: BringToFrontWindow

 public static void BringToFrontWindow(Window w)
 {
     ExecuteUIHelper(w, () =>
     {
         if (w.WindowState == WindowState.Minimized) w.WindowState = WindowState.Normal;
         w.Show();
         w.Activate();
     });
 }
开发者ID:ThiConcept,项目名称:SharpMail,代码行数:9,代码来源:UIUtil.cs

示例6: ActivateWindow

 public static void ActivateWindow(Window window)
 {
     var interopHelper = new WindowInteropHelper(window);
     var currentForegroundWindow = GetForegroundWindow();
     var thisWindowThreadId = GetWindowThreadProcessId(interopHelper.Handle, IntPtr.Zero);
     var currentForegroundWindowThreadId = GetWindowThreadProcessId(currentForegroundWindow, IntPtr.Zero);
     AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, true);
     SetWindowPos(interopHelper.Handle, new IntPtr(0), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
     AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, false);
     window.Show();
     window.Activate();
 }
开发者ID:seveian,项目名称:RNS,代码行数:12,代码来源:KeyboardHook.cs

示例7: BringToForeground

        public static void BringToForeground(Window mainWindow)
        {
            if (mainWindow.WindowState == WindowState.Minimized || mainWindow.Visibility == Visibility.Hidden)
            {
                mainWindow.Show();
                mainWindow.WindowState = WindowState.Normal;
            }

            // According to some sources these steps gurantee that an app will be brought to foreground.
            mainWindow.Activate();
            mainWindow.Topmost = true;
            mainWindow.Topmost = false;
            mainWindow.Focus();
            mainWindow.ShowInTaskbar = true;
        }
开发者ID:bhattvishal,项目名称:CalendarSyncplus,代码行数:15,代码来源:Utilities.cs

示例8: ActivateForm

		public override void ActivateForm(Window form, Window window, IntPtr hwnd) {
			var fHandle = (PresentationSource.FromVisual(form) as HwndSource).Handle;
			var wHandle = (PresentationSource.FromVisual(window) as HwndSource).Handle;
			if (window == null || wHandle != fHandle) { 

				// bring to top
				form.Topmost = true;
				form.Topmost = false;

				// set as active form in task bar
				form.Activate();

				// stop flashing...happens occassionally when switching quickly when activate manuver is fails
				Shell32.FlashWindow(fHandle, 0);
			}
		}
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:16,代码来源:WindowActivator.cs

示例9: ActivateWindow

        private void ActivateWindow(Window window)
        {
            if (!window.IsVisible)
            {
                window.Show();
            }

            if (window.WindowState == WindowState.Minimized)
            {
                window.WindowState = WindowState.Normal;
            }

            window.Activate();
            window.Topmost = true;  
            window.Topmost = false; 
            window.Focus();      
        }
开发者ID:mikel785,项目名称:Logazmic,代码行数:17,代码来源:App.xaml.cs

示例10: ShowModal

        /// <summary>
        /// Shows the modal.
        /// </summary>
        /// <param name="owner">The owner.</param>
        public void ShowModal(Window owner)
        {
            WindowStyle = WindowStyle.None;
            ResizeMode = ResizeMode.NoResize;
            ShowInTaskbar = false;
            WindowStartupLocation = WindowStartupLocation.Manual;
            AllowsTransparency = true;

            Width = owner.Width;
            Height = owner.Height;
            Top = owner.Top;
            Left = owner.Left;
            WindowState = owner.WindowState;
            Owner = owner;

            ShowDialog();

            owner.Activate();
        }
开发者ID:jfrankelp,项目名称:MediaBrowser.Theater,代码行数:23,代码来源:BaseModalWindow.cs

示例11: ActivateWindow

 private static void ActivateWindow(Window window)
 {
     window.Dispatcher.Invoke(
         new SendOrPostCallback(
             delegate(object ignored)
             {
                 window.Activate();
             }),
             String.Empty);
 }
开发者ID:40a,项目名称:PowerShell,代码行数:10,代码来源:ShowCommandHelper.cs

示例12: WinCondition

 public static void WinCondition()
 {
     Window win = new Window();
     win.Title = "You win!";
     win.Activate();
 }
开发者ID:vattercw,项目名称:SentinelsOfTheMultiverse,代码行数:6,代码来源:GameBoard.xaml.cs

示例13: LoseCondition

 internal static void LoseCondition()
 {
     Window lose = new Window();
     lose.Title = "You lose!";
     lose.Activate();
 }
开发者ID:vattercw,项目名称:SentinelsOfTheMultiverse,代码行数:6,代码来源:GameBoard.xaml.cs

示例14: GetSetWndPosition

        // ReSharper restore UnusedParameter.Local
        /// <summary>
        /// Locates the window passed as if it is a Progman, the Start Menu.
        /// First, by screenPoint passed calculates active screen.
        /// By it's bounds determines the location of TaskBar.
        /// Finally, calculates the position of target window.
        /// Shows window except if it is a Placement rectangle.
        /// Focuses window if it is a ButtonStack.
        /// </summary>
        /// <param name="w">Window to locate</param>
        /// <param name="screenPoint">Unmanaged struct containing absolute screen coordinates, in px.</param>
        /// <param name="ignoreTaskbarPosition">Flag instructing method to ignore the location of task bar
        /// locating w simply in the corner closest to the screenPoint. E.g. to show BtnStch by Alt+Z.</param>
        private static void GetSetWndPosition(Window w, API.POINT screenPoint, bool ignoreTaskbarPosition)
        {
            var resPoint = new Point();
            var screen = Screen.FromPoint(new System.Drawing.Point(screenPoint.X, screenPoint.Y));
            //We show stack in the corner closest to the mouse
            bool isHideTaskBarOptionOn = (screen.WorkingArea.Width == screen.Bounds.Width &&
                                         screen.WorkingArea.Height == screen.Bounds.Height)
                                         || ignoreTaskbarPosition;

            //taskbar is vertical @ left or horizontal
            if ((isHideTaskBarOptionOn && screenPoint.X <= screen.WorkingArea.X + screen.WorkingArea.Width/2)
                || screen.WorkingArea.X > screen.Bounds.X
                || (screen.WorkingArea.Width == screen.Bounds.Width & !isHideTaskBarOptionOn))
                resPoint.X = screen.WorkingArea.X;
            else //vertical @ right
                resPoint.X = (screen.WorkingArea.Width + screen.WorkingArea.X - w.Width*SystemScale)/SystemScale;

            //taskbar is horizontal @ top or vertical
            if ((isHideTaskBarOptionOn && screenPoint.Y <= screen.WorkingArea.Y + screen.WorkingArea.Height/2)
                || screen.WorkingArea.Y > screen.Bounds.Y
                || (screen.WorkingArea.Height == screen.Bounds.Height & !isHideTaskBarOptionOn))
                resPoint.Y = screen.WorkingArea.Y;
            else //horizontal @ bottom
                resPoint.Y = (screen.WorkingArea.Height + screen.WorkingArea.Y - w.Height*SystemScale)/SystemScale;

            w.Left = resPoint.X;
            w.Top = resPoint.Y;
            // ReSharper disable PossibleUnintendedReferenceComparison
            if(w != PlacementWnd)
                w.Activate();
            // ReSharper restore PossibleUnintendedReferenceComparison
            var b = w as BtnStck;
            if (b != null)
                b.Focus();//Focus() is __new on ButtonStack, must explicitly type
        }
开发者ID:beavis28,项目名称:power8,代码行数:48,代码来源:MainWindow.xaml.cs

示例15: BringToFront

    private void BringToFront(Window window)
    {
      if (window.WindowState == WindowState.Minimized)
        window.WindowState = WindowState.Normal;

      window.Activate();
      window.Topmost = true;
      window.Topmost = false;
      window.Focus();
    }
开发者ID:grarup,项目名称:SharpE,代码行数:10,代码来源:DialogHelper.cs


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