public FormController(FormView view, IList list) { _view = view; _view.SetController(this); _list = list; }
/// <summary> /// Trata el evento de cierre de un documento /// </summary> private bool TreatEventCloseForm(PaneViewModel paneViewModel) { bool canClose = true; IFormView formView = paneViewModel?.GetFormView(); // Comprueba el ViewModel del control para comprobar si se puede cerrar if (formView != null && formView.FormView.ViewModel.IsUpdated) { SystemControllerEnums.ResultType result; // Pregunta si se debe grabar el documento result = Globals.HostController.ControllerWindow.ShowQuestionCancel("Se han realizado modificaciones que aún no se han grabado. ¿Desea grabarlas ahora?"); // Graba el documento si es necesario if (result == SystemControllerEnums.ResultType.Yes) { // Graba el documento (formView.FormView.ViewModel as BaseFormViewModel)?.SaveCommand.Execute(null); // Comprueba si se puede cerrar la ventana canClose = !formView.FormView.IsUpdated; } else { canClose = result != SystemControllerEnums.ResultType.Cancel; } } // Si se puede borrar, elimina la ventana de la colección if (canClose) { Documents.Remove(paneViewModel.WindowID); formView.FormView.CloseViewModel(); } // Devuelve el valor que indica si se puede cerrar return(canClose); }
private PopupInfo( IFormCanvas <HTMLElement> canvas, IBareForm <HTMLElement> form, IFormView <HTMLElement> formView) { Canvas = canvas; Form = form; FormView = formView; }
private static HTMLElement BuildBody(IFormView <HTMLElement> newMaster) { var result = new HTMLDivElement(); var templateWithParams = BuildTemplateAndParams(newMaster.Render(result)); Logger.Debug(typeof(FormCanvasExtensions), "BuildBody() got template={0} and params={1}", templateWithParams.Item1, templateWithParams.Item2.Values.PrettyToString()); result.InnerHTML = templateWithParams.Item1; foreach (var idToView in templateWithParams.Item2) { var id = idToView.Key + ""; var toBeReplaced = result.FindContainedElementByIdOrNull(id); var replaceTo = idToView.Value; //Logger.Debug(typeof(FormCanvasExtensions),"BuildBody() will replace {0} having id={1} with iview {2}", toBeReplaced.InnerHTML, id, replaceTo.InnerHTML); toBeReplaced.ParentNode.ReplaceChild( replaceTo, toBeReplaced); //Logger.Debug(typeof(FormCanvasExtensions),"BuildBody() replaced and container is now {0}", result.InnerHTML); } Logger.Debug(typeof(FormCanvasExtensions), "BuildBody() ending"); return(result); }
public FormPresenter(IFormView view, IFormModel model) { this.view = view; this.model = model; this.view.SubmitButtonClick += OnSubmitButtonClick; view.ViewLoad += OnViewLoad; }
public AllFieldsFilledDataEntryForm() { var view = new AllFieldsFilledDataEntryFormView(); var ended = new Observable.Publisher <Unit>(); Ended = ended; View = view; var strEntry = LocalValueFieldBuilder.Build( view.StringEntry, (x, errors) => errors.IfTrueAdd( string.IsNullOrWhiteSpace(x) || x.Length < 4, "Text must be at least 4 chars long"), (x, errors) => errors.IfTrueAdd( string.IsNullOrWhiteSpace(x) || x.Length > 10, "Text must be no longer than 10 chars long") ); var intEntry = LocalValueFieldBuilder.BuildNullableInt( view.IntEntry, (x, errors) => errors.IfTrueAdd(!x.HasValue || x < 1234, "Number must be bigger than 1234") ); var decEntry = LocalValueFieldBuilder.BuildNullableDecimal( view.DecimalEntry, DecimalFormat.WithTwoDecPlaces, (x, errors) => errors.IfTrueAdd(!x.HasValue || x < 5.6m, "Number must be bigger than " + I18n.Localize(5.6m, DecimalFormat.WithOneDecPlace)) ); //this field is used to show that values on screen are not necessarily values within model. //In other words: when validator rejected value from user wrong value and error message stays on screen BUT model keeps its last-accepted-value var summaryLine = LocalValueFieldBuilder.Build("", view.SummaryLine); void UpdateSummaryLine() { var decVal = !decEntry.Value.HasValue ? "" : I18n.Localize(decEntry.Value.Value, DecimalFormat.WithOneDecPlace); summaryLine.DoProgrammaticChange( $@"Accepted vals: Text={strEntry.Value} Int={intEntry.Value} Decimal={decVal}" ); } strEntry.Changed += (_, __, ___, ____, _____) => UpdateSummaryLine(); intEntry.Changed += (_, __, ___, ____, _____) => UpdateSummaryLine(); decEntry.Changed += (_, __, ___, ____, _____) => UpdateSummaryLine(); UpdateSummaryLine(); var confirm = LocalActionBuilder.Build(view.ConfirmAction, () => ended.Fire(Unit.Instance)); confirm.BindEnableAndInitializeAsObserving(x => { x.Observes(strEntry); x.Observes(intEntry); x.Observes(decEntry); }); }
public Controller(IFormView formView) { _formView = formView; _imgProccesServise = new ImageProccesingServise(); _stateStorageService = new StateStorageService(); _clusterServise = new ClusterServise(); _messageServise = new MessageServise(); _graphServise = new GraphServise(); _interpritateServise = new InterpritateServise(); _excelServise = new ExcelServise(); }
public ConfirmMessageForm(ConfirmMessageFormView view, string messageOrNull = null, string titleOrNull = null) { Title = titleOrNull ?? I18n.Translate("Confirmation"); View = view; _message = new LocalValue <string>(messageOrNull ?? I18n.Translate("Without message")); view.Message.BindReadOnlyAndInitialize(_message); LocalActionBuilder.Build(view.Confirm, () => Ended?.Invoke(this, CompletedOrCanceled.Completed)); LocalActionBuilder.Build(view.Cancel, () => Ended?.Invoke(this, CompletedOrCanceled.Canceled)); }
/// <summary> /// Disposes the instance of <see cref="FormView"/> /// </summary> public override void Dispose() { base.Dispose(); if (FormView == null) { return; } FormView.Dispose(); FormView = null; }
public TestRunnerForm(IReadOnlyCollection <TestModel> tests) { void RunAll() { foreach (var test in tests) { test.Run(); } } RunAll(); var view = new TestRunnerView(); BaseUnboundColumnBuilder <TestModel> Column(string x) => UnboundDataGridColumnBuilder.For <TestModel>(x); ValueContainingUnboundColumnBuilder <TestModel, string> TextColumn(string x, Func <TestModel, string> val) => UnboundDataGridColumnBuilder.For <TestModel>(x).WithValue(val); var gridGuts = DataGridModel <TestModel> .CreateAndBindNonReloadable( view.Grid, Toolkit.DefaultTableBodyHeightProvider(-50), TextColumn("Name", x => x.Name) .TransformableDefault() .Build() .With(x => x.MinimumWidth = 500), Column("Outcome").WithValueAsText(x => x.Outcome, x => x.ToString()) .TransformableAsText() .Observes(x => nameof(x.Outcome)) .Build().With(x => x.MinimumWidth = 30), TextColumn("Log", x => x.Log) .TransformableDefault() .Observes(x => nameof(x.Log)) .Build().With(x => x.MinimumWidth = 400) ); gridGuts.model.Items.Replace(tests); gridGuts.model.Selected.Changed += (insertedAt, inserted, removed) => { switch (inserted.FirstOrDefault()) { case null: view.SummaryText = ""; break; case var x: view.SummaryText = x.Log; break; } }; View = view; }
public MenuForm(IMenuFormView view, IEnumerable <MenuItemUserModel> menuItemsRaw) { View = view; _menuModel = new MenuModel(); _menuModel.ItemsChanged += menuItems => menuItems .Where(x => x.IsExit) .ForEach(x => x.Action.ActionExecuted += _ => Ended?.Invoke(this, Unit.Instance)); _menuModel.BindAndInitialize(view.MenuBar); _menuModel.ReplaceItems(menuItemsRaw.ToList()); }
public SampleFormPresenter(IToggleModel model, IFormView view, IAgdAdapter agdAdapter) { Console.WriteLine("SampleFormPresenter.ctor()"); _model = model; _model.VisibilityStateChanged += VisibilityChangedHandler; _view = view; _view.Closing += HandleViewClosed; _view.Show(); _agdAdapter = agdAdapter; }
/// <summary> /// Opens a form as a modal dialog /// </summary> /// <typeparam name="T">Presenter of the UI</typeparam> /// <param name="owner">The owner of the form as <see cref="IFormView"/></param> /// <param name="displayWaitCursor">Set to <c>true</c> to display a busy cursor during instantiation</param> /// <returns>Returns the <see cref="DialogResult"/> returned by the displayed form</returns> public static DialogResult OpenModalDialog <T>(IFormView owner, bool displayWaitCursor) where T : FormPresenter, new() { using (var presenter = CreatePresenter <T>(displayWaitCursor)) { if (!(presenter.FormView is Form)) { throw new ArgumentException("the FormView of the presenter parameter is not of type Form"); } var form = GetForm(presenter); SetFormOwner(owner, form); return(form.ShowDialog()); } }
public FormController(IFormView view, FormModel model) { _view = view; _model = model; _view.SetController(this); // Subscribing event handlers to events _model.AUVTemperatureChanged += BindAUVTemperature; _model.AUVLatLonChanged += BindAUVLatLon; _model.SharkDistanceChanged += BindSharkDistance; _model.SharkBearingChanged += BindSharkBearing; _model.AUVXYChanged += BindAUVXY; _model.SharkXYChanged += BindSharkXY; _model.FrontReadingChanged += _view.UpdateFrontBoardInfo; _model.BackReadingChanged += _view.UpdateBackBoardInfo; }
public void ClearMaster() { Logger.Debug(GetType(), "ClearMaster() _masterFormView={0} _masterAdaptedView={1}", _masterFormView, _masterAdaptedView); if (_masterAdaptedView != null) { _masterCanvas.Hide(); _masterAdaptedView = null; } if (_masterFormView == null) { return; } _masterCanvas.Unrender(); _masterFormView = null; _masterForm = null; }
public void ReplaceMaster(IBareForm <HTMLElement> newForm) { var isSame = newForm.View == _masterFormView; Logger.Debug(GetType(), "ReplaceMaster() with {0}. Same as now?{0}", newForm, isSame); ClearMaster(); _masterCanvas.RenderForm( newForm, () => { _masterFormView = newForm.View; _masterForm = newForm; }); _masterCanvas.Title = newForm.Title; //don't steal focus from popup (if any) if (MaybeGetTopMostDialog() == null) { TryPutFocusOnForm(_masterCanvas); } (newForm as IOnShownNeedingForm <HTMLElement>)?.OnShown(); }
/// <summary> /// Opens a Form /// </summary> /// <param name="owner">The owner of the dialog</param> /// <param name="presenter">The presenter of the form to display</param> /// <param name="modalDialog"> /// Set to <c>true</c> to display the about box as a modal dialog, otherwise <c>false</c>, /// </param> /// <returns>Returns the <see cref="DialogResult"/> returned by the displayed form</returns> public static DialogResult OpenDialog(IFormView owner, FormPresenter presenter, bool modalDialog) { if (presenter == null) { throw new ArgumentNullException("presenter"); } if (!(presenter.FormView is Form)) { throw new ArgumentException("the FormView of the presenter parameter is not of type Form"); } var form = GetForm(presenter); SetFormOwner(owner, form); if (modalDialog) { return(form.ShowDialog()); } form.Show(); return(DialogResult.None); }
public ChannelDriverPack(IChannelDriver driver, IFormView view = null) { Driver = driver; View = view; }
/// <summary> /// Sets the current <see cref="IFormView"/> /// </summary> /// <param name="view">Instance of <see cref="IFormView"/></param> protected FormPresenter(IFormView view) { FormView = view; AttachView(); }
public FormViewModel(IFormView view) { _view = view; _view.Bind(this); Parts = new ObservableCollection<PartViewModel>(); }
/// <summary> /// Opens a form as a modal dialog /// </summary> /// <typeparam name="T">Presenter of the UI</typeparam> /// <param name="owner">The owner of the form as <see cref="IFormView"/></param> /// <returns>Returns the <see cref="DialogResult"/> returned by the displayed form</returns> public static DialogResult OpenModalDialog <T>(IFormView owner) where T : FormPresenter, new() { return(OpenModalDialog <T>(owner, false)); }
public Form1Presenter(IFormView view, ITextRepository dataRepo) { _view = view; _dataRepo = dataRepo; }
/// <summary> /// Creates an instance of a View. This method automatically sets the Parent and Owner properties of the Form /// </summary> /// <typeparam name="T">The view to instantiate</typeparam> /// <param name="view">The owner and parent of this view</param> /// <param name="displayWaitCursor">Set to <c>true</c> to display a busy cursor during instantiation</param> /// <returns>Returns an instance of <see cref="T"/></returns> public static T CreateView <T>(IFormView view, bool displayWaitCursor) where T : Form, new() { return(CreateView <T>(view as Form, displayWaitCursor)); }
public static PopupInfo Create( IFormCanvas <HTMLElement> canvas, IBareForm <HTMLElement> form, IFormView <HTMLElement> formView) => new PopupInfo(canvas, form, formView);
protected internal FatturaFormPresenter(IFormView <FatturaFormDataObject> view) : base(view) { }
public FormViewModel(IFormView view) { _view = view; _view.Bind(this); Parts = new ObservableCollection <PartViewModel>(); }
/// <summary> /// Creates an instance of a View. This method automatically sets the Parent and Owner properties of the Form /// </summary> /// <typeparam name="T">The view to instantiate</typeparam> /// <param name="view">The owner and parent of this view</param> /// <returns>Returns an instance of <see cref="T"/></returns> public static T CreateView <T>(IFormView view) where T : Form, new() { return(CreateView <T>(view as Form, false)); }