Exemple #1
0
        private void OnCollageWindowClosed(object sender, EventArgs e)
        {
            PhotoCollageWindow senderWindow = (PhotoCollageWindow)sender;

            _photoCollageWindows.Remove(senderWindow.WindowId);
            //HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper((Window)sender).Handle);
            //source.RemoveHook(new HwndSourceHook(WndProc));
        }
Exemple #2
0
        private void NewCollageWindow_Click(object sender, RoutedEventArgs e)
        {
            PhotoCollageWindow collageWindow = new PhotoCollageWindow(_dialogExtender);

            collageWindow.WindowId = GetNextWindowId();
            _photoCollageWindows.Add(collageWindow.WindowId, collageWindow);

            collageWindow.Closed += new EventHandler(OnCollageWindowClosed);
            collageWindow.Loaded += new RoutedEventHandler(collageWindow_Loaded);
            collageWindow.Show();
        }
Exemple #3
0
        /*
         * private void LaunchWindow_Click(object sender, RoutedEventArgs e)
         * {
         *  if (_photoCollageWindow == null)
         *  {
         *      _photoCollageWindow = new PhotoCollageWindow();
         *  }
         *
         *  _photoCollageWindow.Show();
         * }
         *
         * private void SaveWindowAsPhoto_Click(object sender, RoutedEventArgs e)
         * {
         *  if (_photoCollageWindow != null)
         *  {
         *      _photoCollageWindow.SaveCollage("SavedImage.png");
         *  }
         *  else
         *  {
         *      MessageBox.Show("Create the PhotoCollageWindow by clicking Launch Window");
         *  }
         * }
         *
         * private void UndoLastCommand_Click(object sender, RoutedEventArgs e)
         * {
         *  if (_photoCollageWindow != null)
         *      _photoCollageWindow.Undo();
         * }
         *
         * private void DisplayAdornment_Click(object sender, RoutedEventArgs e)
         * {
         *  if (_photoCollageWindow != null)
         *      _photoCollageWindow.AddAdornement();
         * }
         * */

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            //Do this for all existing collage windows
            while (_photoCollageWindows.Count > 0)
            {
                //Get the first window key
                string windowKey = _photoCollageWindows.Keys.FirstOrDefault(x => true);
                //Get the window
                PhotoCollageWindow photoCollageWindow = _photoCollageWindows[windowKey];
                //Try closing the window
                photoCollageWindow.Close();

                //If window exists in the collection that means it was not closed
                //Cancel closing the application
                //We are subscribing to the window closed event below where this
                //key will be removed from the collection.
                if (_photoCollageWindows.ContainsKey(windowKey))
                {
                    e.Cancel = true;
                    break;
                }
            }
            base.OnClosing(e);
        }