public void Execute(IMenuCommand command) { IDiagram diagram = this.DiagramContext.CurrentDiagram; IModelStore modelStore = diagram.ModelStore; string SqlFile = @"C:\MyLoStore\MyLoStorePostgres.sql"; string PythonFile = @"C:\MyLoStore\MyLoStore.py"; FolderBrowserDialog openFolderDialog1 = new FolderBrowserDialog(); openFolderDialog1.RootFolder = Environment.SpecialFolder.MyComputer; openFolderDialog1.Description = "Select the directory that you want to use for generated output"; if (openFolderDialog1.ShowDialog() == DialogResult.OK) { string folderName = openFolderDialog1.SelectedPath; SqlFile = folderName + @"\MyLoStorePostgres.sql"; PythonFile = folderName + @"\MyLoStore.py"; using (StreamWriter fsSql = new StreamWriter(SqlFile, false)) { using (StreamWriter fsPy = new StreamWriter(PythonFile, false)) { SQLWriter mySql = new SQLWriter(SQLGenerateRun.Postgres); PythonClassWriter py = new PythonClassWriter(); SQLGenerator sqlGen = new SQLGenerator(fsSql, mySql, fsPy, py, modelStore); sqlGen.GenerateMySQL(); } } } }
public void Execute(IMenuCommand command) { string cacheKey; using (TextWriter writer = m_winPane.CreateTextWriter()) { IEnumerable<ProjectItemWithCustomTool> projectItems = GetProjectItems(out cacheKey); if (command.CommandIndex > 0) { var tools = GetTools(); if (command.CommandIndex > tools.Count) { writer.WriteLine("new tool with index found."); return; } projectItems = projectItems.Where(pi => pi.CustomTool == tools[command.CommandIndex - 1]); } projectItems = projectItems.ToArray(); Toolkit.RunWithProgress((progress, ct) => System.Threading.Tasks.Task.Run(async () => { foreach (var projectItemEntry in projectItems.AsSmartEnumerable()) { var projectItem = projectItemEntry.Value; await ThreadHelper.Generic.InvokeAsync(() => m_winPane.WriteLine($"Running custom tool {projectItem.CustomTool} on {projectItem.ProjectItem.Name}")); progress.Report(new ProgressInfo() { CurrentStep = projectItemEntry.Index, TotalSteps = projectItems.Count(), ProgressText = "ProgressText", WaitText = "WaitText" }); await System.Threading.Tasks.Task.Delay(1000, ct); } }), "Title"); } }
public void Execute(IMenuCommand command) { IDiagram diagram = this.DiagramContext.CurrentDiagram; IModelStore modelStore = diagram.ModelStore; const string newPath = @"C:\PLDB"; System.IO.Directory.CreateDirectory(newPath); string SqlFile = Path.Combine(newPath, @"PLDBmysql.sql"); string PythonFile = Path.Combine(newPath, @"PLDB.py"); using (StreamWriter fsSql = new StreamWriter(SqlFile)) { using (StreamWriter fsPy = new StreamWriter(PythonFile)) { SQLWriter mySql = new SQLWriter(SQLGenerateRun.INNODB); //DjangoWriter py = new DjangoWriter(); PythonClassWriter py = new PythonClassWriter(); SQLGenerator sqlGen = new SQLGenerator(fsSql, mySql, fsPy, py, modelStore); sqlGen.GenerateMySQL(); } } // TODO debug this code: seems like I'm missing an assembly reference! //var outWindow = Package.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; //Guid generalPaneGuid = VSConstants.GUID_OutWindowGeneralPane; //IVsOutputWindowPane generalPane; //outWindow.GetPane(ref generalPaneGuid, out generalPane); //generalPane.OutputString("============= SQL Generation Successful ================="); //generalPane.Activate(); // Brings this pane into view }
public void Execute(IMenuCommand command) { // Get the diagram of the underlying implementation. Diagram dslDiagram = Context.CurrentDiagram.GetObject<Diagram>(); if (dslDiagram != null) { var type = dslDiagram.ModelElement.GetType(); var model = dslDiagram.ModelElement as RootModel; SaveFileDialog dialog = GetSaveDialog(); dialog.FileName = model.Name; string imageFileName = dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null; if (!string.IsNullOrEmpty(imageFileName)) { switch (dialog.FilterIndex) { case 1: case 2: case 4: Bitmap bitmap = dslDiagram.CreateBitmap( dslDiagram.NestedChildShapes, Diagram.CreateBitmapPreference.FavorClarityOverSmallSize); bitmap.Save(imageFileName, GetImageType(imageFileName)); break; case 3: Metafile metafile = dslDiagram.CreateMetafile( dslDiagram.NestedChildShapes); metafile.Save(imageFileName, GetImageType(imageFileName)); break; } } } }
public void Execute(IMenuCommand command) { var dslDiagram = DiagramContext.CurrentDiagram.GetObject<Diagram>(); if (dslDiagram == null) return; var dialog = new SaveFileDialog { AddExtension = true, DefaultExt = "image.bmp", Filter = "Bitmap ( *.bmp )|*.bmp|JPEG File ( *.jpg )|*.jpg|Enhanced Metafile (*.emf )|*.emf|Portable Network Graphic ( *.png )|*.png", FilterIndex = 1, Title = "Save Diagram to Image" }; if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.FileName)) { var bitmap = dslDiagram.CreateBitmap(dslDiagram.NestedChildShapes, Diagram.CreateBitmapPreference.FavorClarityOverSmallSize); bitmap.Save(dialog.FileName, GetImageType(dialog.FilterIndex)); bitmap.Dispose(); } dialog.Dispose(); }
/// <summary> /// Is the command visible and active? /// This is called when the user right-clicks. /// </summary> public void QueryStatus(IMenuCommand command) { command.Visible = true; // Is there any selected DomainClasses in the Dsl explorer? command.Enabled = SelectionContext.AtLeastOneSelected<Entity>(); // Is there any selected ClassShape on the design surface? command.Enabled |= (SelectionContext.GetCurrentSelection<Entity>().Any()); }
public void QueryStatus(IMenuCommand command) { if (DiagramContext.CurrentDiagram != null && DiagramContext.CurrentDiagram.ChildShapes.Count() > 0) { command.Enabled = true; } else { command.Enabled = false; } }
public void QueryStatus(IMenuCommand command) { // TODO: Add logic to control the display of your menu item // // Example: // // IShape selshape = context.CurrentDiagram.SelectedShapes.FirstOrDefault(); // command.Enabled = selshape.Element is IClass; // // Note: Setting command.Visible=false can have unintended interactions with other extensions. }
public void QueryStatus(IMenuCommand command) { command.Enabled = console.IsInitialized && !console.IsBusy; if (!console.IsInitialized) { command.Text = Strings.Uninstall.Text + " " + Strings.InitializingConsole; } if (console.IsBusy) { command.Text = Strings.Uninstall.Text + " " + Strings.ExecutingCommand; } }
/// <summary> /// Returns the guidance extension that owns the given command to execute. /// </summary> protected virtual IGuidanceExtension OnQueryStatus(IMenuCommand command) { var extension = this.GuidanceInstanceLocator.LocateInstance(); var status = this.QueryStatusStrategy.QueryStatus(extension); var canExecute = this.CanExecute(extension); command.Enabled = status.Enabled && canExecute; command.Visible = status.Visible && canExecute; return(extension); }
public void Execute(IMenuCommand command) { var items = devEnv.SolutionExplorer() .Solution .Traverse() .Count(); devEnv.MessageBoxService.ShowInformation(string.Format( "Clide Version: {0}, Solution Nodes: {1}", typeof(IDevEnv).Assembly.GetName().Version, items)); }
public void Execute(IMenuCommand command) { // TODO: Add the logic for your command extension here // The following example creates a new class in the model store // and displays it on the current diagram. IClassDiagram diagram = context.CurrentDiagram as IClassDiagram; IModelStore store = diagram.ModelStore; IPackage rootPackage = store.Root; IClass newClass = rootPackage.CreateClass(); newClass.Name = "CommandExtension1"; diagram.Display(newClass); }
private static CompositeMenuCommand GetTypeMenuItem(this Type type, IMenuCommand parent) { if (type == null) { throw new ArgumentNullException(nameof(type)); } var result = new CompositeMenuCommand(type.FullName, parent); result.AddCommands(type.GetMembers().OrderBy(x => x.MemberType).ThenBy(x => x.Name).Select(x => GetMemberMenuItem(x, result))); return(result); }
public MenuCommandBridge(string header) { if (String.IsNullOrEmpty(header)) { throw new ArgumentException("header is null or empty.", "header"); } this.Header = header; _menuCommand = new MenuCommand() { Title = header }; }
public void QueryStatus(IMenuCommand command) { command.Enabled = console.IsInitialized && !console.IsBusy && !Trial.CheckPending; if (!console.IsInitialized) { command.Text = Strings.Update.Text + " " + Strings.InitializingConsole; } if (console.IsBusy) { command.Text = Strings.Update.Text + " " + Strings.ExecutingCommand; } Trial.IncrementUsage(); }
public void AddCommand(IMenuCommand menuCommand) { if (menuCommand == null) { throw new ArgumentNullException(nameof(menuCommand)); } if (ReferenceEquals(this, menuCommand)) { throw new InvalidOperationException("Can't add reference to self."); } menuCommand.Parent = this; subMenus.Add(index++, menuCommand); }
/// <summary> /// Called when the user selects this command. /// </summary> /// <param name="command"></param> public void Execute(IMenuCommand command) { // Transaction is required if you want to update elements. //using (Transaction t = SelectionContext.CurrentStore // .TransactionManager.BeginTransaction("fix names")) { foreach (ShapeElement shape in SelectionContext.CurrentSelection) { ModelElement element = shape.ModelElement; MessageBox.Show(element.GetDomainClass().Name); } //t.Commit(); } }
public void Execute(IMenuCommand command) { try { System.Threading.Tasks.Task.Run(() => provider.GetService <DTE>().ExecuteCommand("Tools.OpenInDevStore", NuGetReferences.Constants.VsixIdentifier)); } catch (Exception) { } finally { Trial.ResetUsage(); } }
public static void AddCommandFilter(IVsTextView viewAdapter, IMenuCommand commandFilter) { if (!commandFilter.IsAdded) { // Get the view adapter from the editor factory IOleCommandTarget next; int hr = viewAdapter.AddCommandFilter(commandFilter, out next); if (hr == VSConstants.S_OK) { commandFilter.IsAdded = true; // You'll need the next target for Exec and QueryStatus if (next != null) commandFilter.NextTarget = next; } } }
public void Execute(IMenuCommand command) { tracer.Info("Uninstall"); if (package.Value.SelectedNode != null) { var project = package.Value.DevEnv.SolutionExplorer().SelectedNodes.OfType<IItemNode>().First().OwningProject; var nuget = package.Value.SelectedNode.Node.GetValue<IVsPackageMetadata>(ReferencesGraphSchema.PackageProperty); var psCommand = "Uninstall-Package " + nuget.Id + " -ProjectName " + project.DisplayName; tracer.Info("Uninstalling package " + nuget.Id); console.Show(); console.Execute(psCommand); } }
public void Execute(IMenuCommand command) { tracer.Info("Uninstall"); if (package.Value.SelectedNode != null) { var project = package.Value.DevEnv.SolutionExplorer().SelectedNodes.OfType <IItemNode>().First().OwningProject; var nuget = package.Value.SelectedNode.Node.GetValue <IVsPackageMetadata>(ReferencesGraphSchema.PackageProperty); var psCommand = "Uninstall-Package " + nuget.Id + " -ProjectName " + project.DisplayName; tracer.Info("Uninstalling package " + nuget.Id); console.Show(); console.Execute(psCommand); } }
public static void FillButton(IMenuCommand command, ButtonBase button) { if (command == null || button == null) { return; } button.Command = command; if (command.Icon == null) { if (!string.IsNullOrWhiteSpace(command.Text)) { if (command.Text.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.SetBinding(button, Button.ContentProperty, new BLoc(command.Text.Remove(0, 4))); } else { button.Content = command.Text; } } } else { if (command.Icon is string) { button.Content = GetImage(command); } else { button.Content = command.Icon; } if (!string.IsNullOrWhiteSpace(command.Text)) { if (command.Text.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.SetBinding(button, Button.ToolTipProperty, new BLoc(command.Text.Remove(0, 4))); } else { button.ToolTip = command.Text; } } } }
public void Execute(IMenuCommand command) { // TODO: Perform whatever you want this extension to do // // Example: // // IClassDiagram diagram = context.CurrentDiagram as IClassDiagram; // IModelStore store = diagram.ModelStore; // IPackage rootPackage = store.Root; // IClass newClass = rootPackage.CreateClass(); // newClass.Name = "New Class"; // diagram.Display(newClass); frmSignalDefinition ruleUI = new frmSignalDefinition(rules); ruleUI.ShowDialog(); }
public AutomationCommand(MenuOptionViewModel parent, IAutomationExtension automation) { this.parent = parent; this.automation = automation; this.menu = (IMenuCommand)automation; this.status = automation as ICommandStatus ?? new NullQueryStatus(); parent.IsVisible = this.menu.Visible; parent.IsEnabled = this.menu.Enabled; var propertyChanged = automation as INotifyPropertyChanged; if (propertyChanged != null) { propertyChanged.PropertyChanged += this.OnMenuPropertyChanged; } }
public AutomationCommand(MenuOptionViewModel parent, IAutomationExtension automation) { this.parent = parent; this.automation = automation; menu = automation as IMenuCommand; status = automation as ICommandStatus ?? new NullQueryStatus(); parent.IsVisible = menu == null || menu.Visible; parent.IsEnabled = menu == null || menu.Enabled; var propertyChanged = automation as INotifyPropertyChanged; if (propertyChanged != null) { propertyChanged.PropertyChanged += OnMenuPropertyChanged; } }
public void Execute(IMenuCommand command) { // TODO: Add the logic for your command extension here frmTypeDefUI typeUI = new frmTypeDefUI(types); typeUI.ShowDialog(); // The following example creates a new class in the model store // and displays it on the current diagram. //IClassDiagram diagram = context.CurrentDiagram as IClassDiagram; //IModelStore store = diagram.ModelStore; //IPackage rootPackage = store.Root; //IClass newClass = rootPackage.CreateClass(); //newClass.Name = "TypeDefinitionExtension"; //diagram.Display(newClass); }
public MenuItem AddOrGetMenuItem(IReadOnlyList <MenuGroupItem> path, IMenuCommand menuCommand) { if (path.Count == 0) { throw new InvalidOperationException("Menu item path undefined"); } var menuItem = RootMenu; foreach (var element in path) { menuItem = menuItem.AddOrGetMenuItem(element); } // last item added is a leaf, so add command UpdateMenuItemProperties(menuCommand, menuItem); return(menuItem); }
public static void FillMenuItem(IMenuCommand command, MenuItem menuItem) { if (command == null || menuItem == null) { return; } menuItem.Command = command; if (!string.IsNullOrWhiteSpace(command.Text)) { if (command.Text.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.SetBinding(menuItem, MenuItem.HeaderProperty, new BLoc(command.Text.Remove(0, 4))); } else { menuItem.Header = command.Text; } } if (command.KeyGesture != null && !string.IsNullOrWhiteSpace(command.KeyGesture.DisplayString)) { if (command.KeyGesture.DisplayString.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.SetBinding(menuItem, MenuItem.InputGestureTextProperty, new BLoc(command.KeyGesture.DisplayString.Remove(0, 4))); } else { menuItem.InputGestureText = command.KeyGesture.DisplayString; } } if (command.Icon != null) { if (command.Icon is string) { menuItem.Icon = GetImage(command); } else { menuItem.Icon = command.Icon; } } }
/// <summary> /// Adds a single submenu command into an existing menu command /// </summary> /// <param name="parent">Parent menu command</param> /// <param name="submenuCommand">Submenu command</param> public void AddMenuItems(IMenuCommand parent, IMenuCommand submenuCommand) { if (parent == null) { throw new ArgumentNullException("parent", "parent is null."); } if (submenuCommand == null) { throw new ArgumentNullException("submenuCommand", "command is null."); } var parentMenuItem = GetParentMenuCommandBridge(parent); if (parentMenuItem != null) { parentMenuItem.Items.Add(new MenuCommandBridge(submenuCommand)); } }
public override void Execute(IMenuCommand command) { var clientView = this.View.CurrentDesigner.DiagramClientView; var diagram = clientView.Diagram; // Layout current view shape var patternModel = diagram.ModelElement as PatternModelSchema; var view = patternModel.Pattern.Store.GetCurrentView(); if (view != null) { var viewShape = view.GetShape <ViewShape>(); if (viewShape != null) { viewShape.Layout(); } } }
public void Execute(IMenuCommand command) { tracer.Info("Update"); if (package.Value.SelectedNode != null) { var project = package.Value.DevEnv.SolutionExplorer().SelectedNodes.OfType <IItemNode>().First().OwningProject; // TODO: doesn't work // package.Value.SelectedNode.Node.SetValue<string>(DgmlNodeProperties.Icon, GraphIcons.PackageUpdate); var nuget = package.Value.SelectedNode.Node.GetValue <IVsPackageMetadata>(ReferencesGraphSchema.PackageProperty); var psCommand = "Update-Package " + nuget.Id + " -ProjectName " + project.DisplayName; tracer.Info("Updating package " + nuget.Id); console.Show(); console.Execute(psCommand); } }
public void Execute(IMenuCommand command) { tracer.Info("Update"); if (package.Value.SelectedNode != null) { var project = package.Value.DevEnv.SolutionExplorer().SelectedNodes.OfType<IItemNode>().First().OwningProject; // TODO: doesn't work // package.Value.SelectedNode.Node.SetValue<string>(DgmlNodeProperties.Icon, GraphIcons.PackageUpdate); var nuget = package.Value.SelectedNode.Node.GetValue<IVsPackageMetadata>(ReferencesGraphSchema.PackageProperty); var psCommand = "Update-Package " + nuget.Id + " -ProjectName " + project.DisplayName; tracer.Info("Updating package " + nuget.Id); console.Show(); console.Execute(psCommand); } }
public void Execute(IMenuCommand command) { // A selection of starting points: IDiagram diagram = this.DiagramContext.CurrentDiagram; IModelStore modelStore = diagram.ModelStore; var classesInPackages = modelStore.AllInstances<IClass>() .GroupBy(i => i.Package.Name) .ToDictionary(i => i.Key, i => i.ToList()); foreach (var package in classesInPackages) { var pathToWrite = this.DiagramContext.CurrentDiagram.FileName; pathToWrite = pathToWrite.Replace(this.DiagramContext.CurrentDiagram.Name, "").Replace(".classdiagram", ""); new XSDWriter(pathToWrite).Write(package); } }
/// <summary> /// 当用户单击菜单项(如果它可见并已启用)时调用。 /// </summary> /// <param name="command"></param> public void Execute(IMenuCommand command) { var dslDiagram = context.CurrentDiagram.GetObject <Microsoft.VisualStudio.Modeling.Diagrams.Diagram>(); if (dslDiagram != null) { var dialog = new SaveFileDialog { AddExtension = true, DefaultExt = "image.bmp", Filter = "Bitmap ( *.bmp )|*.bmp|" + "JPEG File ( *.jpg )|*.jpg|" + "Enhanced Metafile (*.emf )|*.emf|" + "Portable Network Graphic ( *.png )|*.png", FilterIndex = 1, Title = "Save Diagram to Image" }; if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.FileName)) { var bitmap = dslDiagram.CreateBitmap(dslDiagram.NestedChildShapes, Diagram.CreateBitmapPreference.FavorClarityOverSmallSize); bitmap.Save(dialog.FileName, GetImageType(dialog.FilterIndex)); } IDiagram diagram = this.context.CurrentDiagram; //foreach (IShape<IElement> shape in diagram.GetSelectedShapes<IElement>()) //{ // IElement element = shape.Element; //} IModelStore modelStore = diagram.ModelStore; IModel model = modelStore.Root; IEnumerable <IElement> eList = model.OwnedElements; foreach (IElement element in model.OwnedElements) { //string str = element.Shapes(); } //foreach (IElement element in modelStore.AllInstances<IClass>()) //{ //} } }
public override void Execute(IMenuCommand command) { var viewModel = new AddAutomationExtensionViewModel(this.AutomationSettings.Select(l => l.Metadata)); var view = this.DialogFactory(viewModel); if (view.ShowDialog().GetValueOrDefault()) { var diagramItems = new DiagramItemCollection(); var clientView = this.View.CurrentDesigner.DiagramClientView; foreach (var target in this.CurrentSelection) { var element = target as IPatternElementSchema; var automationSchema = element.CreateAutomationSettingsSchema(aes => { var aesMel = (ModelElement)aes; var extension = aesMel.AddExtension(viewModel.CurrentExportedAutomation.ExportingType); string displayName = extension.GetDomainClass().DisplayName; aes.Name = aesMel.GetUniqueName(SanitizeName(displayName)); aes.AutomationType = displayName; aes.Classification = ((IAutomationSettings)extension).Classification; }); var shape = PresentationViewsSubject.GetPresentation((PatternElementSchema)element).OfType <CompartmentShape>().FirstOrDefault(); if (shape != null) { var diagramItem = shape.FindDiagramItem <AutomationSettingsSchema>(a => a.Id == automationSchema.Id); if (diagramItem != null) { diagramItems.Add(diagramItem); } } } clientView.Selection.Set(diagramItems); } }
public CompositeMenuCommand(string name, IMenuCommand parent, IEnumerable <IMenuCommand> menuCommands = null) : base(name) { subMenus = new SortedDictionary <int, IMenuCommand>() { [0] = Parent = new GoBackMenuCommand(parent ?? ExitMenuCommand.Instance) }; index = 1; if (menuCommands != null) { foreach (var nestedItem in menuCommands) { nestedItem.Parent = this; subMenus.Add(index++, nestedItem); } } }
public static void AddCommandFilter(IVsTextView viewAdapter, IMenuCommand commandFilter) { if (!commandFilter.IsAdded) { // Get the view adapter from the editor factory IOleCommandTarget next; int hr = viewAdapter.AddCommandFilter(commandFilter, out next); if (hr == VSConstants.S_OK) { commandFilter.IsAdded = true; // You'll need the next target for Exec and QueryStatus if (next != null) { commandFilter.NextTarget = next; } } } }
public void Execute(IMenuCommand command) { IDiagram diagram = this.DiagramContext.CurrentDiagram; IModelStore modelStore = diagram.ModelStore; const string SqlFile = @"C:\PLDB\PLDBmysql.sql"; const string PythonFile = @"C:\PLDB\PLDB.py"; using (StreamWriter fsSql = new StreamWriter(SqlFile)) { using (StreamWriter fsPy = new StreamWriter(PythonFile)) { SQLWriter mySql = new SQLWriter(SQLGenerateRun.MyISAM); PythonClassWriter py = new PythonClassWriter(); SQLGenerator sqlGen = new SQLGenerator(fsSql, mySql, fsPy, py, modelStore); sqlGen.GenerateMySQL(); } } }
public void Execute(IMenuCommand command) { // Get the diagram of the underlying implementation. Diagram dslDiagram = Context.CurrentDiagram.GetObject <Diagram>(); if (dslDiagram == null) { return; } //var type = dslDiagram.ModelElement.GetType(); var model = dslDiagram.ModelElement as RootModel; SaveFileDialog dialog = GetSaveDialog(); if (model != null) { dialog.FileName = model.Name; } string imageFileName = dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null; if (!string.IsNullOrEmpty(imageFileName)) { switch (dialog.FilterIndex) { case 1: case 2: case 4: Bitmap bitmap = dslDiagram.CreateBitmap( dslDiagram.NestedChildShapes, Diagram.CreateBitmapPreference.FavorClarityOverSmallSize); bitmap.Save(imageFileName, GetImageType(imageFileName)); break; case 3: Metafile metafile = dslDiagram.CreateMetafile( dslDiagram.NestedChildShapes); metafile.Save(imageFileName, GetImageType(imageFileName)); break; } } }
private MenuCommandBridge GetParentMenuCommandBridge(IMenuCommand parentMenuCommand) { if (parentMenuCommand == null) { throw new ArgumentNullException("parentMenuCommand", "parentMenuCommand is null."); } MenuCommandBridge parentMenuCommandBridge = null; foreach (MenuCommandBridge item in _regionTarget.Items) { if (item.MenuCommand == parentMenuCommand) { parentMenuCommandBridge = item; break; } } return(parentMenuCommandBridge); }
public void QueryStatus(IMenuCommand command) { var tools = GetTools(); int index = command.CommandIndex; if (index == 0) { command.Visible = true; command.Enabled = tools.Count > 0; command.Text = tools.Count > 0 ? "All" : "<no custom tools available>"; } else { index = index - 1; command.Visible = tools.Count > index; command.Enabled = tools.Count > index; command.Text = command.Enabled ? tools[index] : "Disabled"; } }
/// <summary> /// Adds several submenu commands into an existing menu command /// </summary> /// <param name="parent">Parent menu command</param> /// <param name="submenuCommands">Submenu commands</param> public void AddMenuItems(IMenuCommand parent, IEnumerable <IMenuCommand> submenuCommands) { if (parent == null) { throw new ArgumentNullException("parent", "parent is null."); } if (submenuCommands == null) { throw new ArgumentNullException("submenuCommands", "commands is null."); } var parentMenuCommand = GetParentMenuCommandBridge(parent); if (parentMenuCommand != null) { foreach (var submenuCommand in submenuCommands) { parentMenuCommand.Items.Add(new MenuCommandBridge(submenuCommand)); } } }
public static void UnFillButton(IMenuCommand command, ButtonBase button) { if (command == null || button == null) { return; } button.Command = null; if (command.Icon == null) { if (!string.IsNullOrWhiteSpace(command.Text)) { if (command.Text.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.ClearBinding(button, Button.ContentProperty); } else { button.Content = null; } } } else { button.Content = null; if (!string.IsNullOrWhiteSpace(command.Text)) { if (command.Text.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.ClearBinding(button, Button.ToolTipProperty); } else { button.ToolTip = null; } } } }
public MenuCommandBridge(string header, Action action) { if (String.IsNullOrEmpty(header)) { throw new ArgumentException("header is null or empty.", "header"); } if (action == null) { throw new ArgumentNullException("action", "action is null."); } this.Header = header; var command = ReactiveCommand.Create(action); this.Command = command; _menuCommand = new MenuCommand() { Title = header }; }
/// <summary> /// Executes the specified command. /// </summary> /// <param name="command">The command.</param> public override void Execute(IMenuCommand command) { var propertyContainerSchemas = this.CurrentSelection.Cast <PatternElementSchema>(); // Warn user if changing tailored extension point contract var extensionPoints = propertyContainerSchemas.OfType <ExtensionPointSchema>(); if (extensionPoints.Any(ext => ext.IsInheritedFromBase) && extensionPoints.Any(ext => ext.Properties.All(p => p.IsInheritedFromBase))) { var resume = this.MessageService.PromptWarning(Properties.ShellResources.AddVariablePropertyCommand_BreakContractWarning); if (!resume) { return; } } var diagramItems = new DiagramItemCollection(); var clientView = this.View.CurrentDesigner.DiagramClientView; foreach (var propertyContainerSchema in propertyContainerSchemas) { var property = propertyContainerSchema.Create <PropertySchema>(); var shape = PresentationViewsSubject.GetPresentation(propertyContainerSchema).OfType <CompartmentShape>().FirstOrDefault(); if (shape != null) { var diagramItem = shape.FindDiagramItem <PropertySchema>(p => p.Id == property.Id); if (diagramItem != null) { diagramItems.Add(diagramItem); } } } clientView.Selection.Set(diagramItems); }
public static void UnFillMenuItem(IMenuCommand command, MenuItem menuItem) { if (command == null || menuItem == null) { return; } menuItem.Command = null; if (!string.IsNullOrWhiteSpace(command.Text)) { if (command.Text.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.ClearBinding(menuItem, MenuItem.HeaderProperty); } else { menuItem.Header = null; } } if (command.KeyGesture != null && !string.IsNullOrWhiteSpace(command.KeyGesture.DisplayString)) { if (command.KeyGesture.DisplayString.StartsWith(locPrefix, StringComparison.OrdinalIgnoreCase)) { BindingOperations.ClearBinding(menuItem, MenuItem.InputGestureTextProperty); } else { menuItem.InputGestureText = null; } } if (command.Icon != null) { menuItem.Icon = null; } }
public void QueryStatus(IMenuCommand command) { command.Enabled = console.IsInitialized && !console.IsBusy; if (!console.IsInitialized) command.Text = Strings.Update.Text + " " + Strings.InitializingConsole; if (console.IsBusy) command.Text = Strings.Update.Text + " " + Strings.ExecutingCommand; }
public SideMenuButtonViewModel(IMenuCommand command) { _command = command; }
public void QueryStatus(IMenuCommand command) { command.Enabled = command.Visible = false; }
public void Execute(IMenuCommand command) { tracer.Info("Reinstall"); MessageBox.Show("Reinstalling package..."); }
public void QueryStatus(IMenuCommand command) { QueryStatusCalled = true; }
/// <summary> /// Called when the user right-clicks the diagram. /// Set Enabled and Visible to specify the menu item status. /// </summary> /// <param name="command"></param> public void QueryStatus(IMenuCommand command) { command.Enabled = Context.CurrentDiagram != null && Context.CurrentDiagram.ChildShapes.Count() > 0; }
/// <summary> /// Queries the status of the command. /// </summary> /// <param name="adapter">The adapter to set the status.</param> public virtual void QueryStatus(IMenuCommand adapter) { Guard.NotNull(() => adapter, adapter); adapter.Enabled = adapter.Visible = true; }
static void Main(string[] args) { var commands = new IMenuCommand[] { new ShowPlaylistCommand(), new AddNewTrackCommand(), new DeleteTrackCommand(), new SearchTrackCommand() //new LoadTracksFromFileCommand(), //new SaveTracksToFileCommand () }.ToDictionary(c => c.Name, c => c); string mode; menu cmdPerformer = new menu(); Console.WriteLine("Enter url: "); cmdPerformer.httpClient = new HttpClient(Console.ReadLine()); cmdPerformer.ShowUsage(); do { mode = cmdPerformer.Mode(); IMenuCommand cmd; if (commands.TryGetValue(mode, out cmd)) { cmd.PerformWith(cmdPerformer); } else { cmdPerformer.ShowUsage(); } } while (!mode.Equals("quit")); }
public void QueryStatus(IMenuCommand menu) { }
/// <summary> /// Returns the guidance extension that owns the given command to execute. /// </summary> protected virtual IGuidanceExtension OnQueryStatus(IMenuCommand command) { var extension = this.GuidanceInstanceLocator.LocateInstance(); var status = this.QueryStatusStrategy.QueryStatus(extension); var canExecute = this.CanExecute(extension); command.Enabled = status.Enabled && canExecute; command.Visible = status.Visible && canExecute; return extension; }
public void QueryStatus(IMenuCommand command) { // Set command.Visible or command.Enabled to false // to disable the menu command. command.Visible = command.Enabled = true; }
public MenuEventHandler(object owner, IMenuCommand action) { this.action = action; this.action.Owner = owner; }