Esempio n. 1
0
        private void ActivateMainWindow()
        {
            var mainWindow = new MainWindow();

            // registers a callback to intercept WM_SHOWFIRSTINSTANCE messages so that when a second
            // instance broadcasts that message, original instance will be able to receive it and respond
            // by activating itself and making sure it isn't hidden.
            mainWindow.SourceInitialized += ( sender, e ) =>
            {
                HwndSource source = HwndSource.FromHwnd( new WindowInteropHelper( mainWindow ).Handle );
                source.AddHook( new HwndSourceHook( ShowFirstInstanceWinHook ) );
            };

            mainWindow.Show();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializing constructor
        /// </summary>
        /// <param name="parent">Reference to the parent window</param>
        public MainWindowResizer( MainWindow parent )
        {
            _parent = parent;

            // Parent window starts off being auto-sized based on its content. We must make this call
            // in order to enable resizing of the parent. However, we want to change the attribute only
            // after the window initialization is complete.  Otherwise, instead of the center of the
            // screen, the window shows up in the corner.
            _parent.Dispatcher.BeginInvoke( new Action( () =>
            {
                SetManualSizingOnParent();
            } ) );

            ResizeBarControl resizer = (ResizeBarControl)_parent.FindName( "Resizer" );

            resizer.Resize += OnResize;
            resizer.ResizeComplete += OnResizeComplete;

            _siteCellSize = CalculateSiteCellSize();
        }