コード例 #1
0
        public void selectSource_Click(object sender, RoutedEventArgs e)
        {
            var openDialog = new FolderBrowserDialog
            {
                ShowNewFolderButton = true
            };

            if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FindUngroupedViewModel vm = (FindUngroupedViewModel)findUngroupedPanel.DataContext;
                vm.OnBatchFixUngroupedClicked(openDialog.SelectedPath);
            }
        }
コード例 #2
0
        public void Loaded(ViewLoadedParams p)
        {
            var monitoMenuItem = new MenuItem {
                Header = "DynaMonito"
            };
            var      VM = p.DynamoWindow.DataContext as DynamoViewModel;
            MenuItem subMenuItem;

            #region FIND_UNGROUPED
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableFindUngrouped"))
            {
                subMenuItem = new MenuItem {
                    Header = "Find and Fix Ungrouped"
                };
                subMenuItem.ToolTip = new ToolTip {
                    Content = "Identify nodes and notes that don't belong to a group.."
                };
                subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new FindUngroupedViewModel(p, VM);
                    var window    = new FindUngroupedWindow
                    {
                        findUngroupedPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top  = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion FIND_UNGROUPED

            #region ISOLATE_IN_GEOMETRY_PREVIEW
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableIsolateInGeometryPreview"))
            {
                subMenuItem = new MenuItem {
                    Header = "Isolate in Geometry Preview"
                };
                subMenuItem.ToolTip = new ToolTip {
                    Content = "Quickly isolate the current selection in geometry preview..."
                };
                subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new IsolateInPreviewViewModel(p, VM, p.DynamoWindow);
                    var window    = new IsolateInPreviewWindow
                    {
                        isolatePreviewPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top  = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion ISOLATE_IN_GEOMETRY_PREVIEW

            #region PLAYER_INPUTS
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnablePlayerInputs"))
            {
                subMenuItem = new MenuItem {
                    Header = "Manage Dynamo Player Inputs"
                };
                subMenuItem.ToolTip = new ToolTip {
                    Content = "Manage which input nodes should be displayed by Dynamo Player..."
                };
                subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new PlayerInputsViewModel(p, VM);
                    var window    = new PlayerInputsWindow
                    {
                        playerInputsPanel = { DataContext = viewModel },
                        Owner             = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top  = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion PLAYER INPUTS

            #region MY_GRAPHS
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableMyGraphs"))
            {
                // Read list of graph directories from config
                var topDirs = monitoSettings["MyGraphsDirectoryPaths"].Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (topDirs.Length > 0)
                {
                    subMenuItem = new MenuItem {
                        Header = "My Graphs"
                    };
                    subMenuItem.ToolTip = new ToolTip {
                        Content = "Quick access to all your graphs..."
                    };
                    if (topDirs.Length == 1)
                    {
                        subMenuItem = BuildMyGraphsMenu(topDirs[0], subMenuItem, VM);
                    }
                    else
                    {
                        foreach (string topDir in topDirs)
                        {
                            string   topDirName     = Path.GetFileName(topDir);
                            MenuItem topDirMenuItem = new MenuItem {
                                Header = topDirName
                            };
                            topDirMenuItem.ToolTip = new ToolTip {
                                Content = topDir
                            };
                            topDirMenuItem = BuildMyGraphsMenu(topDir, topDirMenuItem, VM);
                            subMenuItem.Items.Add(topDirMenuItem);
                        }
                    }
                    if (subMenuItem != null)
                    {
                        monitoMenuItem.Items.Add(subMenuItem);
                    }
                }
            }
            #endregion MY_GRAPHS

            #region MY_TEMPLATES
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableMyTemplates"))
            {
                var tplDir = monitoSettings["MyTemplatesDirectoryPath"].Value;
                if (Directory.Exists(tplDir))
                {
                    // Create a menu item for each template
                    List <MenuItem> tempMenuItems = new List <MenuItem>();
                    var             templates     = Directory.GetFiles(tplDir, "*.dyn");
                    foreach (string t in templates)
                    {
                        string   tplName = Path.GetFileNameWithoutExtension(t);
                        MenuItem tplMenu = new MenuItem {
                            Header = tplName
                        };
                        tplMenu.ToolTip = new ToolTip {
                            Content = t
                        };
                        tplMenu.Click += (sender, args) =>
                        {
                            if (File.Exists(t))
                            {
                                // Close current home workspace, open template and set to manual mode
                                VM.CloseHomeWorkspaceCommand.Execute(null);
                                VM.OpenCommand.Execute(t);
                                VM.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType = RunType.Manual;
                                // Select all nodes and notes as well as annotations and copy everything
                                VM.SelectAllCommand.Execute(null);
                                foreach (var anno in VM.HomeSpaceViewModel.Model.Annotations)
                                {
                                    VM.AddToSelectionCommand.Execute(anno);
                                }
                                VM.CopyCommand.Execute(null);
                                // Create new home workspace, set to manual mode and paste template content
                                VM.NewHomeWorkspaceCommand.Execute(null);
                                VM.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType = RunType.Manual;
                                VM.Model.Paste();
                                GeneralUtils.ClearSelection();
                                VM.CurrentSpaceViewModel.ResetFitViewToggleCommand.Execute(null);
                                VM.FitViewCommand.Execute(null);
                            }
                            else
                            {
                                MessageBox.Show("Template " + tplName + " has been moved, renamed or deleted...");
                            }
                        };
                        tempMenuItems.Add(tplMenu);
                    }
                    // Only show the templates menu item if templates exist
                    if (tempMenuItems.Count > 0)
                    {
                        subMenuItem = new MenuItem {
                            Header = "New Workspace from Template"
                        };
                        subMenuItem.ToolTip = new ToolTip {
                            Content = "Quick access to all your templates..."
                        };
                        foreach (MenuItem tempMenuItem in tempMenuItems)
                        {
                            subMenuItem.Items.Add(tempMenuItem);
                        }
                        monitoMenuItem.Items.Add(subMenuItem);
                    }
                }
            }
            #endregion MY_TEMPLATES

            #region PACKAGE_DIRECTORIES
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnablePackageDirectories"))
            {
                subMenuItem = new MenuItem {
                    Header = "Package Directories"
                };
                subMenuItem.ToolTip = new ToolTip {
                    Content = "Quick access to all your package directories..."
                };
                foreach (string packageDir in startupParams.Preferences.CustomPackageFolders)
                {
                    if (Directory.Exists(packageDir))
                    {
                        MenuItem monitoPackageDirMenuItem = new MenuItem {
                            Header = packageDir
                        };
                        monitoPackageDirMenuItem.ToolTip = new ToolTip {
                            Content = "Show contents of " + packageDir + " ..."
                        };
                        monitoPackageDirMenuItem.Click += (sender, args) =>
                        {
                            if (Directory.Exists(packageDir))
                            {
                                Process.Start(@"" + packageDir);
                            }
                            else
                            {
                                MessageBox.Show("Directory " + packageDir + " has been moved, renamed or deleted...");
                            }
                        };
                        subMenuItem.Items.Add(monitoPackageDirMenuItem);
                    }
                }
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion PACKAGE_DIRECTORIES

            #region SEARCH_IN_WORKSPACE
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableSearchInWorkspace"))
            {
                subMenuItem = new MenuItem {
                    Header = "Search in Workspace"
                };
                subMenuItem.ToolTip = new ToolTip {
                    Content = "Search for nodes, notes and groups in the current workspace..."
                };
                subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new SearchInWorkspaceViewModel(p, VM, monitoSettings);
                    var window    = new SearchInWorkspaceWindow
                    {
                        searchPanel = { DataContext = viewModel },
                        Owner       = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top  = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion SEARCH_IN_WORKSPACE

            #region UNFANCIFY
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableUnfancify"))
            {
                subMenuItem = new MenuItem {
                    Header = "Unfancify"
                };
                subMenuItem.ToolTip = new ToolTip {
                    Content = "Simplify your graph..."
                };
                subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new UnfancifyViewModel(p, VM, monitoSettings, p.DynamoWindow);
                    var window    = new UnfancifyWindow
                    {
                        unfancifyPanel = { DataContext = viewModel },
                        Owner          = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top  = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion UNFANCIFY

            #region ABOUT
            subMenuItem = new MenuItem {
                Header = "About DynaMonito"
            };
            subMenuItem.Click += (sender, args) =>
            {
                var window = new AboutWindow
                {
                    aboutPanel = { DataContext = this },
                    Owner      = p.DynamoWindow
                };
                window.Left = window.Owner.Left + 400;
                window.Top  = window.Owner.Top + 200;
                window.Show();
            };
            if (monitoMenuItem.Items.Count > 0)
            {
                monitoMenuItem.Items.Add(new Separator());
            }
            monitoMenuItem.Items.Add(subMenuItem);
            #endregion ABOUT

            p.dynamoMenu.Items.Add(monitoMenuItem);
        }