private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            CleanUp(e);

            if (e.Cancel)
            {
                return;
            }

            //Handle the case where
            //the preview panes are shown
            //according to settings
            //but hidden during startup shortcuts
            //if they were visible on startup
            //then reshow them before saving layout
            if (Preview2DPane != null && preview2DWasVisibleOnLoad &&
                StartupShortcuts.Visibility == Visibility.Visible)
            {
                Preview2DPane.Show();
            }

            if (Preview3DPane != null && preview3DWasVisibleOnLoad &&
                StartupShortcuts.Visibility == Visibility.Visible)
            {
                Preview3DPane.Show();
            }

            //save layout
            SaveLayout();

            popupShelf?.Close();
            popupShelf = null;
        }
Beispiel #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BuildRecentSubMenu();
            MateriaInputManager.Init();
            RegisterInputActions();

            popupShelf       = new UIPopupShelf();
            popupShelf.Owner = this;
            popupShelf.Hide();

            if (App.Current.Properties.Contains("OpenFile"))
            {
                try
                {
                    string path = (string)App.Current.Properties["OpenFile"];
                    if (string.IsNullOrEmpty(path))
                    {
                        return;
                    }
                    HandleOpen(path);
                }
                catch
                {
                }
            }

            Log.Info("Main Window Loaded");
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BuildRecentSubMenu();
            BuildRecentShortcuts();
            MateriaInputManager.Init();
            RegisterInputActions();

            popupShelf       = new UIPopupShelf();
            popupShelf.Owner = this;
            popupShelf.Hide();

            Log.Info("Main Window Loaded");
        }
Beispiel #4
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            CleanUp(e);

            if (e.Cancel)
            {
                return;
            }

            //save layout
            SaveLayout();

            popupShelf.Close();
            popupShelf = null;
        }
        private void PopupShelf_Closed(object sender, EventArgs e)
        {
            popupShelf.Closed -= PopupShelf_Closed;
            popupShelf         = null;

            Task.Delay(25).ContinueWith(t =>
            {
                Activate();
                BringIntoView();
                Focus();

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];
                    g.Focus();
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
        private void RegisterInputActions()
        {
            MateriaInputManager.Add(InputManagerCommand.Clear, (e) =>
            {
                UINodePoint.SelectOrigin = null;
                popupShelf?.Close();
                popupShelf = null;
            });
            MateriaInputManager.Add(InputManagerCommand.Copy, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];
                    g.TryAndCopy();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Paste, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];
                    g.TryAndPaste();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Save, (e) =>
            {
                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g   = graphs[GraphDocuments.SelectedContentIndex];
                    var doc = documents[GraphDocuments.SelectedContentIndex];
                    HandleSave(g, doc);
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Delete, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];
                    g.TryAndDelete();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Undo, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];

                    Point m2 = Mouse.GetPosition(g.ViewPort);

                    if (m2.X < 0 || m2.Y < 0 || m2.X > g.ViewPort.ActualWidth || m2.Y > g.ViewPort.ActualHeight)
                    {
                        return;
                    }

                    g.TryAndUndo();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Redo, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];

                    Point m2 = Mouse.GetPosition(g.ViewPort);

                    if (m2.X < 0 || m2.Y < 0 || m2.X > g.ViewPort.ActualWidth || m2.Y > g.ViewPort.ActualHeight)
                    {
                        return;
                    }

                    g.TryAndRedo();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.PopupShelf, (e) =>
            {
                if (popupShelf != null && popupShelf.IsActive)
                {
                    return;
                }

                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g    = graphs[GraphDocuments.SelectedContentIndex];
                    Point m  = Mouse.GetPosition(this);
                    Point m2 = Mouse.GetPosition(g.ViewPort);

                    if (m2.X < 0 || m2.Y < 0 || m2.X > g.ViewPort.ActualWidth || m2.Y > g.ViewPort.ActualHeight)
                    {
                        return;
                    }
                    g.PrepareInsert();
                    popupShelf?.Close();
                    popupShelf         = new UIPopupShelf();
                    popupShelf.Closed += PopupShelf_Closed;
                    popupShelf.Hide();
                    popupShelf.Graph = g;
                    popupShelf.Open(m.X, m.Y);
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Comment, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];

                    Point m2 = Mouse.GetPosition(g.ViewPort);

                    if (m2.X < 0 || m2.Y < 0 || m2.X > g.ViewPort.ActualWidth || m2.Y > g.ViewPort.ActualHeight)
                    {
                        return;
                    }

                    g.TryAndComment();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.Pin, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g = graphs[GraphDocuments.SelectedContentIndex];

                    Point m2 = Mouse.GetPosition(g.ViewPort);

                    if (m2.X < 0 || m2.Y < 0 || m2.X > g.ViewPort.ActualWidth || m2.Y > g.ViewPort.ActualHeight)
                    {
                        return;
                    }

                    g.TryAndPin();
                }
            });
            MateriaInputManager.Add(InputManagerCommand.NextPin, (e) =>
            {
                if (!(Keyboard.FocusedElement is IUIGraphNode) && !(Keyboard.FocusedElement is UIGraph) &&
                    Keyboard.FocusedElement != this && !(Keyboard.FocusedElement is LayoutDocument) && !(Keyboard.FocusedElement is LayerItem) &&
                    !(Keyboard.FocusedElement is UILayers))
                {
                    return;
                }

                if (GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    var g     = graphs[GraphDocuments.SelectedContentIndex];
                    e.Handled = true;
                    g.NextPin();
                }
            });
        }