public static CommandBindingManager RegisterCommand(this CommandBindingManager cmdBindingManager, BoundCommand command, object sourceObject, string sourceEvent = "Click") { var commandBinding = new CommandBinding(command, sourceObject, sourceEvent); cmdBindingManager.CommandBindings.Add(commandBinding); return cmdBindingManager; }
public static CommandBindingManager RegisterCommand(this CommandBindingManager cmdBindingManager, object source, Action<object> execute, Func<object, bool> canExecute, string sourceEvent = "Click") { var command = new BoundCommand(execute, canExecute, null); var commandBinding = new CommandBinding(command, source, sourceEvent); cmdBindingManager.CommandBindings.Add(commandBinding); return cmdBindingManager; }
// private PathManager _pathManagerEx;//= new PathManager(); public MainFormViewModel() { // _pathManagerEx = pm; //AddEntryCommand = new BoundCommand(AddEntryAction, o=>true, null); //RemoveEntryCommand = new BoundCommand(RemoveEntryAction, o => true, null); ExportCommand = new BoundCommand(ExportyAction, o => true, null); PathTextCommand = new BoundCommand(PathTextAction, o => true, null); // RefreshCommand = new BoundCommand(RefreshAction, o => true, null); }
private void OnLoad(object sender, EventArgs eventArgs) { try { var commandBindingManager = new CommandBindingManager(); var commandBinding = new CommandBinding(); _saveCommandButton = new BoundCommand(SaveMessage, CanSave, "Button"); commandBinding.SourceObject = Save; commandBinding.SourceEvent = ControlEvent.Click.ToString(); commandBinding.Command = _saveCommandButton; commandBindingManager.CommandBindings.Add(commandBinding); _saveCommandToolStrip = new BoundCommand(SaveMessage, CanSave, "ToolStrip"); commandBindingManager.CommandBindings.Add(new CommandBinding(_saveCommandToolStrip, Tool, ToolStripItemEvent.Click.ToString())); _closeComamand = new BoundCommand(Close, CanClose, null); commandBindingManager.CommandBindings.Add(new CommandBinding(_closeComamand, CloseForm, ControlEvent.Click.ToString())); var bindingManager = new BindingManager(); bindingManager.Bindings.Add(new TypedBinding<MainForm, TextBox>(this, t => t.FullNameText, FullName, s => s.Text)); } catch (Exception e) { MessageBox.Show(e.Message); } }
public AddPathViewModel() { InstalledPrograms = new List<string>(); InstalledAppsInfo = new List<ProgramInfo>(); InstalledAppsInfo = GetInstalledApps(); foreach (var item in InstalledAppsInfo) InstalledPrograms.Add(item.InstallLocation); BrowseCommand = new BoundCommand(BrowseAction, CanBrowse, null); }