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;
        }
        private void UI3DInstance_OnReady()
        {
            Task.Delay(25).ContinueWith(t =>
            {
                if (Preview3DPane != null)
                {
                    Preview3DPane.Hide();
                }
                if (Preview2DPane != null)
                {
                    Preview2DPane.Hide();
                }

                if (App.Current.Properties.Contains("OpenFile"))
                {
                    try
                    {
                        string path = (string)App.Current.Properties["OpenFile"];
                        if (string.IsNullOrEmpty(path))
                        {
                            return;
                        }
                        HandleOpen(path);
                    }
                    catch
                    {
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
        private void Docker_Loaded(object sender, RoutedEventArgs e)
        {
            if (Preview3DPane != null)
            {
                Preview3DPane.Show();
            }

            if (Preview2DPane != null)
            {
                Preview2DPane.Show();
            }

            if (UI3DPreview.Instance != null)
            {
                UI3DPreview.Instance.OnReady += UI3DInstance_OnReady;
            }
        }
        void HideStartup()
        {
            StartupShortcuts.Visibility = Visibility.Collapsed;

            WindowsMenu.Visibility = Visibility.Visible;
            EditMenu.Visibility    = Visibility.Visible;

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

            if (preview2DWasVisibleOnLoad && Preview2DPane != null)
            {
                Preview2DPane.Show();
            }
        }
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;

            ///edit
            if (item.Header.ToString().Equals(Properties.Resources.MENU_GRAPH_SETTINGS))
            {
                if (UINodeParameters.Instance != null && graphs.Count > 0)
                {
                    if (GraphDocuments.SelectedContentIndex > -1)
                    {
                        var graph = graphs[GraphDocuments.SelectedContentIndex];
                        if (graph.Graph != null)
                        {
                            UINodeParameters.Instance.SetActive(graph.Graph);
                        }
                    }
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_REDO))
            {
                if (GraphDocuments.SelectedContentIndex > -1)
                {
                    var graph = graphs[GraphDocuments.SelectedContentIndex];
                    graph.TryAndRedo();
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_UNDO))
            {
                if (GraphDocuments.SelectedContentIndex > -1)
                {
                    var graph = graphs[GraphDocuments.SelectedContentIndex];
                    graph.TryAndUndo();
                }
            }
            ///windows
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_3D_PREVIEW))
            {
                if (Preview3DPane.IsVisible)
                {
                    Preview3DPane.Hide();
                }
                else
                {
                    Preview3DPane.Show();
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_2D_PREVIEW))
            {
                if (Preview2DPane.IsVisible)
                {
                    Preview2DPane.Hide();
                }
                else
                {
                    Preview2DPane.Show();
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_PARAMETERS))
            {
                if (ParametersPane.IsVisible)
                {
                    ParametersPane.Hide();
                }
                else
                {
                    ParametersPane.Show();
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_SHELF))
            {
                if (ShelfPane.IsVisible)
                {
                    ShelfPane.Hide();
                }
                else
                {
                    ShelfPane.Show();
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_LOG))
            {
                if (LogPane.IsVisible)
                {
                    LogPane.Hide();
                }
                else
                {
                    LogPane.Show();
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_CLOSE_ALL))
            {
                for (int i = 0; i < documents.Count; ++i)
                {
                    var doc = documents[i];
                    doc.Close();
                }
            }
            //file menu
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_SAVE_AS))
            {
                if (graphs.Count > 0 && GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    UIGraph        graph = graphs[GraphDocuments.SelectedContentIndex];
                    LayoutDocument doc   = documents[GraphDocuments.SelectedContentIndex];
                    ShowSaveDialog(graph, doc, true);
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_SAVE))
            {
                if (graphs.Count > 0 && GraphDocuments.SelectedContentIndex > -1 && GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    UIGraph        graph = graphs[GraphDocuments.SelectedContentIndex];
                    LayoutDocument doc   = documents[GraphDocuments.SelectedContentIndex];
                    HandleSave(graph, doc);
                }
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_OPEN))
            {
                ShowOpenDialog();
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_NEW))
            {
                HandleCreate();
            }
            else if (item.Header.ToString().Equals(Properties.Resources.MENU_EXPORT_OUTPUTS))
            {
                if (graphs.Count > 0 && GraphDocuments.SelectedContentIndex > -1 &&
                    GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    UIExportOutputs exportdialog = new UIExportOutputs(graphs[GraphDocuments.SelectedContentIndex]);
                    exportdialog.ShowDialog();
                }
            }
            else if (item.Header.ToString().Equals("_Layers"))
            {
                if (LayersPane.IsVisible)
                {
                    LayersPane.Hide();
                }
                else
                {
                    LayersPane.Show();
                }
            }
        }
Beispiel #6
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;

            ///edit
            if (item.Header.ToString().ToLower().Contains("graph setting"))
            {
                if (UINodeParameters.Instance != null && graphs.Count > 0)
                {
                    if (GraphDocuments.SelectedContentIndex > -1)
                    {
                        var graph = graphs[GraphDocuments.SelectedContentIndex];
                        if (graph.Graph != null)
                        {
                            UINodeParameters.Instance.SetActive(graph.Graph);
                        }
                    }
                }
            }
            else if (item.Header.ToString().ToLower().Contains("redo"))
            {
                if (GraphDocuments.SelectedContentIndex > -1)
                {
                    var graph = graphs[GraphDocuments.SelectedContentIndex];
                    graph.TryAndRedo();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("undo"))
            {
                if (GraphDocuments.SelectedContentIndex > -1)
                {
                    var graph = graphs[GraphDocuments.SelectedContentIndex];
                    graph.TryAndUndo();
                }
            }
            ///windows
            else if (item.Header.ToString().ToLower().Contains("3d"))
            {
                if (Preview3DPane.IsVisible)
                {
                    Preview3DPane.Hide();
                }
                else
                {
                    Preview3DPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("2d"))
            {
                if (Preview2DPane.IsVisible)
                {
                    Preview2DPane.Hide();
                }
                else
                {
                    Preview2DPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("parameters"))
            {
                if (ParametersPane.IsVisible)
                {
                    ParametersPane.Hide();
                }
                else
                {
                    ParametersPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("shelf"))
            {
                if (ShelfPane.IsVisible)
                {
                    ShelfPane.Hide();
                }
                else
                {
                    ShelfPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("log"))
            {
                if (LogPane.IsVisible)
                {
                    LogPane.Hide();
                }
                else
                {
                    LogPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("close all graph"))
            {
                for (int i = 0; i < documents.Count; i++)
                {
                    var doc = documents[i];
                    doc.Close();
                }
            }
            //file menu
            else if (item.Header.ToString().ToLower().Contains("save as"))
            {
                if (graphs.Count > 0)
                {
                    System.Windows.Forms.SaveFileDialog svf = new System.Windows.Forms.SaveFileDialog();
                    svf.CheckPathExists = true;
                    svf.DefaultExt      = ".mtg";
                    svf.Filter          = "Materia Graph (*.mtg)|*.mtg|Materia Graph Archive (*.mtga)|*.mtga";

                    if (svf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        UIGraph g = graphs[GraphDocuments.SelectedContentIndex];
                        if (g != null)
                        {
                            g.Save(svf.FileName, true);

                            var doc = documents[GraphDocuments.SelectedContentIndex];
                            doc.Title = g.GraphName;

                            recent.Add(svf.FileName);
                            BuildRecentSubMenu();
                        }
                    }
                }
            }
            else if (item.Header.ToString().ToLower().Contains("save"))
            {
                if (graphs.Count > 0)
                {
                    UIGraph g = graphs[GraphDocuments.SelectedContentIndex];
                    HandleSave(g);
                    var doc = documents[GraphDocuments.SelectedContentIndex];
                    doc.Title = g.GraphName;
                }
            }
            else if (item.Header.ToString().ToLower().Contains("open"))
            {
                System.Windows.Forms.OpenFileDialog ovf = new System.Windows.Forms.OpenFileDialog();
                ovf.CheckFileExists = true;
                ovf.CheckPathExists = true;
                ovf.DefaultExt      = ".mtg";
                ovf.Filter          = "Materia Graph (*.mtg;*.mtga)|*.mtg;*.mtga";

                if (ovf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    HandleOpen(ovf.FileName);
                }
            }
            else if (item.Header.ToString().ToLower().Contains("new"))
            {
                UINewGraph ngraphDialog = new UINewGraph();

                ngraphDialog.Owner = this;

                if (ngraphDialog.ShowDialog() == false)
                {
                    return;
                }

                NewGraph(ngraphDialog.Result);
                Log.Info("New Graph Created");
            }
            else if (item.Header.ToString().ToLower().Contains("export output"))
            {
                if (graphs.Count > 0 && GraphDocuments.SelectedContentIndex > -1 &&
                    GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    UIExportOutputs exportdialog = new UIExportOutputs(graphs[GraphDocuments.SelectedContentIndex]);
                    exportdialog.ShowDialog();
                }
            }
        }
Beispiel #7
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;

            ///edit
            if (item.Header.ToString().ToLower().Contains("graph setting"))
            {
                if (UINodeParameters.Instance != null && graphs.Count > 0)
                {
                    if (GraphDocuments.SelectedContentIndex > -1)
                    {
                        var graph = graphs[GraphDocuments.SelectedContentIndex];
                        UINodeParameters.Instance.SetActive(graph.Graph);
                    }
                }
            }
            ///windows
            else if (item.Header.ToString().ToLower().Contains("3d"))
            {
                if (Preview3DPane.IsVisible)
                {
                    Preview3DPane.Hide();
                }
                else
                {
                    Preview3DPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("2d"))
            {
                if (Preview2DPane.IsVisible)
                {
                    Preview2DPane.Hide();
                }
                else
                {
                    Preview2DPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("parameters"))
            {
                if (ParametersPane.IsVisible)
                {
                    ParametersPane.Hide();
                }
                else
                {
                    ParametersPane.Show();
                }
            }
            else if (item.Header.ToString().ToLower().Contains("shelf"))
            {
                if (ShelfPane.IsVisible)
                {
                    ShelfPane.Hide();
                }
                else
                {
                    ShelfPane.Show();
                }
            }
            //file menu
            else if (item.Header.ToString().ToLower().Contains("save as"))
            {
                if (graphs.Count > 0)
                {
                    System.Windows.Forms.SaveFileDialog svf = new System.Windows.Forms.SaveFileDialog();
                    svf.CheckPathExists = true;
                    svf.DefaultExt      = ".mtg";
                    svf.Filter          = "Materia Graph (*.mtg)|*.mtg";

                    if (svf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        UIGraph g = graphs[GraphDocuments.SelectedContentIndex];
                        if (g != null)
                        {
                            g.SaveAs(svf.FileName);

                            var doc = documents[GraphDocuments.SelectedContentIndex];
                            doc.Title = g.Graph.Name;
                        }
                    }
                }
            }
            else if (item.Header.ToString().ToLower().Contains("save"))
            {
                if (graphs.Count > 0)
                {
                    UIGraph g = graphs[GraphDocuments.SelectedContentIndex];
                    HandleSave(g);
                    var doc = documents[GraphDocuments.SelectedContentIndex];
                    doc.Title = g.Graph.Name;
                }
            }
            else if (item.Header.ToString().ToLower().Contains("open"))
            {
                System.Windows.Forms.OpenFileDialog ovf = new System.Windows.Forms.OpenFileDialog();
                ovf.CheckFileExists = true;
                ovf.CheckPathExists = true;
                ovf.DefaultExt      = ".mtg";
                ovf.Filter          = "Materia Graph (*.mtg)|*.mtg";

                if (ovf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    HandleOpen(ovf.FileName);
                }
            }
            else if (item.Header.ToString().ToLower().Contains("new"))
            {
                NewGraph();
            }
            else if (item.Header.ToString().ToLower().Contains("export output"))
            {
                if (graphs.Count > 0 && GraphDocuments.SelectedContentIndex > -1 &&
                    GraphDocuments.SelectedContentIndex < graphs.Count)
                {
                    UIExportOutputs exportdialog = new UIExportOutputs(graphs[GraphDocuments.SelectedContentIndex]);
                    exportdialog.ShowDialog();
                }
            }
        }