예제 #1
0
        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();
                }
            }
        }
예제 #2
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();
                }
            }
        }