protected override void Initialize() { base.Initialize(); ViewCommand.Initialize(this); DelayAddSkipLoadingRegistryKey(); }
public Signature7ViewModel() { _strokes = new StrokeCollection(); ink = new InkCanvas(); (_strokes as INotifyCollectionChanged).CollectionChanged += Signature7ViewModel_CollectionChanged; this.ViewProperty = new ViewCommand(this); }
public static CommandInput GetType(string[] commands, string message) { if (commands.Length <= 1) { return(UnknownCommand.Generate(message)); } switch (commands[1]) { case CommandTypes.Add: return(AddCommand.Generate(message)); case CommandTypes.View: return(ViewCommand.Generate(message)); case CommandTypes.Delete: return(DeleteCommand.Generate(message)); case CommandTypes.Help: return(HelpCommand.Generate(message)); case CommandTypes.Update: return(UpdateCommand.Generate(message)); default: return(UnknownCommand.Generate(message)); } }
///// <summary> ///// 状態を保持 ///// </summary> ///// <param name="table"></param> //public void SetStateCommand(object source, DataTable table) //{ // if(table != null) // { // UndoCommand.Command cmd = new ViewCommand(); // //this.F_StateCommand.Append(cmd); // this.F_StateCommand.Execute(); // } //} ///// <summary> ///// 状態を保持 ///// </summary> ///// <param name="table"></param> //public void SetViewMemento(DataTable table) //{ // if (table != null) // { // ViewMemento cmd = new ViewMemento(); // cmd.F_DataTable = table; // this.F_StateCommand.Append(cmd); // } //} /// <summary> /// 状態を保持 /// </summary> /// <param name="view"></param> public void SetViewMemento(DataGridView view) { if (view != null) { var dataTbl = new DataTable(); var columns = view.Columns; foreach (DataGridViewColumn col in columns) { dataTbl.Columns.Add(col.Name, col.ValueType); } var rows = view.Rows; foreach (DataGridViewRow row in rows) { var list = new List <object>(); foreach (DataGridViewCell cell in row.Cells) { list.Add(cell.Value); } dataTbl.Rows.Add(list.ToArray()); } var cmd = new ViewCommand(); cmd.F_DataTable = dataTbl; this.F_StateCommand.Append(cmd); } }
/// <summary> /// Initializes a new instance of the <see cref="TemplateManagerModel"/> class. /// </summary> /// <param name="templateManager">Template manager.</param> public TemplateManagerModel(TemplateManager templateManager) { TemplateManager = templateManager; SetTemplateBundleLocation = new ViewCommand(ExecuteSetTemplateBundleLocation); AddTemplateBundle = new ViewCommand(ExecuteAddTemplateBundle, CanExecuteAddTemplateBundle); RemoveTemplateBundle = new ViewCommand(ExecuteRemoveTemplateBundle, CanExecuteRemoveTemplateBundle); ReloadTemplateBundle = new ViewCommand(ExecuteReloadTemplateBundle); }
private static void _SafeExecuteCommand(ViewCommand command) { Assert.IsNotNull(command); if (command.CanExecute(ServiceProvider.ViewManager.CurrentNavigator)) { command.Execute(ServiceProvider.ViewManager.CurrentNavigator); } }
public void View_Command_Instantiation_Should_Return_Appropriate_Value() { var cmd = ViewCommand.Generate("app -view somedomaintoview"); Assert.IsTrue(cmd.CommandName == "View"); Assert.IsTrue(cmd.Command == "-view"); Assert.IsTrue(cmd.Inputs.ContainsKey("message_1")); Assert.IsTrue(cmd.Inputs["message_1"] == "somedomaintoview"); }
/// <summary> /// Initializes a new instance of the <see cref="TestSpecificationReportModel"/> class for the console extension /// </summary> /// <param name="syncServiceDocumentModel">The <see cref="ISyncServiceModel"/> to obtain document settings.</param> /// <param name="testAdapter"><see cref="ITfsTestAdapter"/> to examine test information.</param> /// <param name="sort"></param> /// <param name="testReportingProgressCancellationService">The progess cancellation service used to check at certain points if a cancellation has been triggered and further steps should be skipped.</param> /// <param name="plan">The selected <see cref="ITfsTestPlan"/> used for the report generation.</param> /// <param name="suite">The selected <see cref="ITfsTestSuite"/> used for the report generation.</param> /// <param name="documentStructure">The information if a document structure should be created.</param> /// <param name="skipLevels">The level count to ignore generation.</param> /// <param name="structureType"></param> public TestSpecificationReportModel(ISyncServiceDocumentModel syncServiceDocumentModel, ITfsTestAdapter testAdapter, ITfsTestPlan plan, ITfsTestSuite suite, bool documentStructure, int skipLevels, DocumentStructureType structureType, TestCaseSortType sort, ITestReportingProgressCancellationService testReportingProgressCancellationService) : base(syncServiceDocumentModel, testAdapter, testReportingProgressCancellationService) { SelectedTestPlan = plan; SelectedTestSuite = suite; CreateDocumentStructure = documentStructure; SkipLevels = skipLevels; SelectedDocumentStructureType = structureType; SelectedTestCaseSortType = sort; CreateReportCommand = new ViewCommand(ExecuteCreateReportCommand, CanExecuteCreateReportCommand); WordDocument = syncServiceDocumentModel.WordDocument as Document; }
private void InitializeButtons() { BackToSearchButtonCommand = new BackCommand <T>(this); NewButtonCommand = new AddCommand <T>(this); ViewButtonCommand = new ViewCommand <T>(this); EditButtonCommand = new EditCommand <T>(this); SaveButtonCommand = new SaveCommand <T>(this); SaveAndNewButtonCommand = new SaveAndNewCommand <T>(this); DeleteButtonCommand = new DeleteCommand <T>(this); SearchButtonCommand = new SearchCommand <T>(this); ClearButtonCommand = new ClearCommand <T>(this); }
/// <summary> /// Initializes a new instance of the <see cref="TestSpecificationReportModel"/> class. /// </summary> /// <param name="syncServiceDocumentModel">The <see cref="ISyncServiceModel"/> to obtain document settings.</param> /// <param name="dispatcher">Dispatcher of associated view.</param> /// <param name="testAdapter"><see cref="ITfsTestAdapter"/> to examine test information.</param> /// <param name="wordRibbon">Interface to the word ribbon</param> /// <param name="testReportingProgressCancellationService">The progess cancellation service used to check at certain points if a cancellation has been triggered and further steps should be skipped.</param> public TestSpecificationReportModel(ISyncServiceDocumentModel syncServiceDocumentModel, IViewDispatcher dispatcher, ITfsTestAdapter testAdapter, IWordRibbon wordRibbon, ITestReportingProgressCancellationService testReportingProgressCancellationService) : base(syncServiceDocumentModel, dispatcher, testAdapter, wordRibbon, testReportingProgressCancellationService) { CreateDocumentStructure = StoredCreateDocumentStructure; SkipLevels = StoredSkipLevels; SelectedDocumentStructureType = StoredSelectedDocumentStructureType; SelectedTestCaseSortType = StoredSelectedTestCaseSortType; CreateReportCommand = new ViewCommand(ExecuteCreateReportCommand, CanExecuteCreateReportCommand); SetTestReportDefaults(syncServiceDocumentModel.Configuration.ConfigurationTest.ConfigurationTestSpecification.DefaultValues); WordDocument = syncServiceDocumentModel.WordDocument as Document; }
/// <summary> /// Method to dispatch the MouseWheel event from the ScenePanel. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void scenePanel_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e) { System.Diagnostics.Debug.Assert(mainFrm != null); // Store previous view command ViewCommand vcmd = viewCmd; // Execute zoom step viewCmd = (ViewCommand)commands["zoomstep"]; GraphicViewManager.Instance.SavePreviousActiveView(); viewCmd.MouseWheel(GraphicViewManager.Instance.ActiveView, e); GraphicViewManager.Instance.updateView(false); // Restore previous view command viewCmd = vcmd; if (viewCmd == SelectionCommand && EndViewCommand != null) { EndViewCommand(this, new EndViewCommandArgs((ViewCommand)commands["zoomstep"])); } }
/// <summary> /// Este método es llamado como resultado de una acción del usuario, no de algún otro comando. /// Por esto sus mensajes de error se mandan al usuario como avisos y se resuelven aquí mismo /// en lugar de aventar excepciones. /// </summary> /// <param name="command">El nombre del comando a ejecutar</param> /// <returns>True if the command executed successfully. False otherwise.</returns> public bool Execute(string command) { // Clean command command = command.Trim().ToLowerInvariant(); // Check cancel first if (command.Equals("cancel")) { // Cancel View Command, Model Command and Selection if applicable // (in that order, only one action per cancel) if ((viewCmd != SelectionCommand || Canguro.View.GraphicViewManager.Instance.ActiveView.ModelRenderer.RenderOptions.ShowAnimated) && EndViewCommand != null) { EndViewCommand(this, new EndViewCommandArgs(viewCmd)); } else { if (modelCmd != null) { if (!modelCmd.AllowCancel()) { return(false); } endModelCommand(); } else { // If there was no ModelCommand, clear and reset selection Canguro.Model.Model.Instance.UnSelectAll(); SelectionCommand.Reset(); } } IdleReset(); viewCmd = SelectionCommand; if (StartViewCommand != null) { StartViewCommand(this, EventArgs.Empty); } mainFrm.ScenePanel.Cursor = SelectionCommand.DefaultCursor; return(true); } // Check if command exists if (!commands.ContainsKey(command)) { System.Windows.Forms.MessageBox.Show(Culture.Get("CommandNotFound") + ": '" + command + "'", Culture.Get("ActionNotPossibleTitle"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return(false); } // Execute Command // Prioritize View Commands Command cmd = commands[command]; if (cmd is ViewCommand) { // If a series of viewCommands has ended (entered SelectionCommand) // then send the EndViewCommand signal // If Selection was doing anything and the viewCmd changes to zoom, pan, rotate, etc. // (exits selection mode), reset SelectionCommand if ((cmd == SelectionCommand) && (viewCmd != SelectionCommand) && (EndViewCommand != null)) { EndViewCommand(this, new EndViewCommandArgs(viewCmd)); } else if ((cmd != SelectionCommand) && (viewCmd == SelectionCommand)) { // Tal vez en lugar de un Reset sea mejor un Cancel, para no perder el tracking SelectionCommand.Reset(); } // Instantiate and run new ViewCommand ViewCommand lastViewCmd = viewCmd; viewCmd = (ViewCommand)cmd; if (StartViewCommand != null) { StartViewCommand(this, EventArgs.Empty); } if (viewCmd.SavePrevious) { GraphicViewManager.Instance.SavePreviousActiveView(); //System.Console.WriteLine("SavePrevious"); } if (viewCmd.IsInteractive) { mainFrm.ScenePanel.Cursor = viewCmd.Cursor; } else { viewCmd.Run(GraphicViewManager.Instance.ActiveView); GraphicViewManager.Instance.updateView(false); if (EndViewCommand != null) { EndViewCommand(this, new EndViewCommandArgs(viewCmd)); } if (lastViewCmd == SelectionCommand) { viewCmd = SelectionCommand; } else { //if (lastViewCmd.SavePrevious && viewCmd != Commands.View.ZoomPrevious.Instance) //{ // GraphicViewManager.Instance.SavePreviousActiveView(); // System.Console.WriteLine("SavePrevious"); //} //viewCmd = lastViewCmd; Execute("select"); } if (StartViewCommand != null) { StartViewCommand(this, EventArgs.Empty); } } } else if (cmd is ModelCommand) { if (modelCmd == null) { // Por el momento funcionan en el mismo hilo, por lo que al terminar la // llamada a Run se puede asignar modelCmd = null y services = null modelCmd = (ModelCommand)cmd; modelCmd.Cancel = false; try { if (StartModelCommand != null) { StartModelCommand(this, EventArgs.Empty); } modelCmd.Run(services = new CommandServices(this)); } catch (CancelCommandException) { Model.Model.Instance.Undo.Rollback(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Controller.Execute: {0}", ex.Message); } finally { endModelCommand(); } } else { System.Windows.Forms.MessageBox.Show(Culture.Get("ModelCmdAlreadyExecuting"), Culture.Get("ActionNotPossibleTitle"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return(false); } } return(true); }
public void SetView(ViewCommand view) { SendCommand(SetViewCommand, view.ViewName); SetLocalViews(view); }
protected async Task HandleViewCommandAsync(ViewCommand command) { try { if (command == null) { return; } if (command is ReturnCommand) { if (_previousParameterCommand != null) { command = _previousParameterCommand; } } switch (command) { case NavigateCommand navigateCommand: if (NavigationManager.Uri == new Uri(new Uri(NavigationManager.BaseUri), navigateCommand.Uri).AbsoluteUri) { // escape from New Action = Constants.Edit; await LoadDataAsync(); } else { NavigationManager.NavigateTo(navigateCommand.Uri); } break; case UpdateParameterCommand parameterCommand: _previousParameterCommand = new UpdateParameterCommand { Action = Action, CollectionAlias = CollectionAlias, Id = Id, ParentPath = Path, VariantAlias = VariantAlias }; var data = new Dictionary <string, object>() { { nameof(Action), parameterCommand.Action }, { nameof(CollectionAlias), parameterCommand.CollectionAlias } }; if (parameterCommand.VariantAlias != null) { data.Add(nameof(VariantAlias), parameterCommand.VariantAlias); } if (parameterCommand.Id != null) { data.Add(nameof(Id), parameterCommand.Id); } if (parameterCommand.ParentPath != null) { data.Add(nameof(Path), parameterCommand.ParentPath); } var update = ParameterView.FromDictionary(data); await SetParametersAsync(update); break; case ReloadCommand reloadCommand: await LoadDataAsync(reloadCommand.EntityId); break; case NoOperationCommand _: default: StateHasChanged(); break; } } catch (Exception ex) { HandleException(ex); } }
void SetLocalViews(ViewCommand view) { currentViewName = view.ViewName; foreach (var host in Hosts) { host.SetView(view.CreateView); } }
public EndViewCommandArgs(ViewCommand command) { this.command = command; }
protected async Task HandleViewCommandAsync(ViewCommand command) { try { if (command == null) { return; } if (command is ReturnCommand) { if (_previousParameterCommand != null) { command = _previousParameterCommand; } else { command = new NavigateBackCommand(); } } switch (command) { case NavigateCommand navigateCommand: UriHelper.NavigateTo(navigateCommand.Uri); break; case NavigateBackCommand navigateBackCommand: // TODO: improve this await JSRuntime.InvokeAsync <bool>("history.back"); break; case UpdateParameterCommand parameterCommand: _previousParameterCommand = new UpdateParameterCommand { Action = Action, CollectionAlias = CollectionAlias, Id = Id, ParentId = ParentId, VariantAlias = VariantAlias }; var data = new Dictionary <string, object>() { { "Action", parameterCommand.Action }, { "CollectionAlias", parameterCommand.CollectionAlias } }; if (parameterCommand.VariantAlias != null) { data.Add("VariantAlias", parameterCommand.VariantAlias); } if (parameterCommand.Id != null) { data.Add("Id", parameterCommand.Id); } if (parameterCommand.ParentId != null) { data.Add("ParentId", parameterCommand.ParentId); } var update = ParameterView.FromDictionary(data); await SetParametersAsync(update); break; case ReloadCommand reloadCommand: await LoadDataAsync(reloadCommand.EntityId); break; case NoOperationCommand _: default: StateHasChanged(); break; } } catch (Exception ex) { HandleException(ex); } }
public void InvokeViewCommand(ViewCommand cmd) { throw new System.NotImplementedException(); }