public SimpleUITriggerFluentAPIUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; CheckEdit checkEdit = new CheckEdit(); checkEdit.Dock = DockStyle.Top; checkEdit.Text = "IsActive"; LabelControl label = new LabelControl(); label.Dock = DockStyle.Top; label.AutoSizeMode = LabelAutoSizeMode.Vertical; label.Text = "Inactive"; label.Parent = this; checkEdit.Parent = this; #endregion SetUp #region #simpleUITriggerFluentAPI // Set type of POCO-ViewModel mvvmContext.ViewModelType = typeof(UIViewModel); // Data binding for the IsActive property var fluentAPI = mvvmContext.OfType <UIViewModel>(); fluentAPI.SetBinding(checkEdit, c => c.Checked, x => x.IsActive); // Property-change Trigger for the IsActive property fluentAPI.SetTrigger(x => x.IsActive, (active) => { label.Text = active ? "Active" : "Inactive"; }); #endregion #simpleUITriggerFluentAPI }
public RibbonDialogServiceUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; SimpleButton commandButton = new SimpleButton(); commandButton.Text = "Execute Command"; commandButton.Dock = DockStyle.Top; MemoEdit memo = new MemoEdit(); memo.Dock = DockStyle.Top; memo.Properties.ReadOnly = true; memo.MinimumSize = new System.Drawing.Size(0, 100); commandButton.Parent = this; memo.Parent = this; #endregion SetUp #region #ribbonDialogService // Force use the RibbonDialogService MVVMContext.RegisterRibbonDialogService(); // mvvmContext.ViewModelType = typeof(NotesViewModel); // UI binding for Notes mvvmContext.SetBinding(memo, m => m.EditValue, "Notes"); // UI binding for button mvvmContext.BindCommand <NotesViewModel>(commandButton, x => x.EditNotes()); #endregion #ribbonDialogService }
public FluentAPIForCommandsUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; ProgressBarControl progressBar = new ProgressBarControl(); progressBar.Dock = DockStyle.Top; SimpleButton commandButton = new SimpleButton(); commandButton.Text = "Start Command Execution"; commandButton.Dock = DockStyle.Top; SimpleButton cancelButton = new SimpleButton(); cancelButton.Text = "Cancel Command Execution"; cancelButton.Dock = DockStyle.Top; cancelButton.Parent = this; commandButton.Parent = this; progressBar.Parent = this; #endregion SetUp #region #fluentAPIForCommands mvvmContext.ViewModelType = typeof(ViewModelWithAsyncCommandAndCancellation); var fluentAPI = mvvmContext.OfType <ViewModelWithAsyncCommandAndCancellation>(); // UI binding for button fluentAPI.BindCommand(commandButton, x => x.DoSomethingAsynchronously()); // UI binding for cancelation fluentAPI.BindCancelCommand(cancelButton, x => x.DoSomethingAsynchronously()); // UI binding for progress fluentAPI.SetBinding(progressBar, p => p.EditValue, x => x.Progress); #endregion #fluentAPIForCommands }
public DataBindingViaMVVMContextFluentAPIUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; TextEdit editor = new TextEdit(); editor.Dock = DockStyle.Top; editor.Properties.NullValuePrompt = "Please, enter the Title here..."; editor.Properties.NullValuePromptShowForEmptyValue = true; SimpleButton commandButton = new SimpleButton(); commandButton.Dock = DockStyle.Top; commandButton.Text = "Report the Title property value"; commandButton.Parent = this; editor.Parent = this; #endregion SetUp #region #dataBindingViaMVVMContextFluentAPI var legacyViewModel = new LegacyViewModel("Legacy ViewModel"); // initialize the MVVMContext with the specific ViewModel's instance mvvmContext.SetViewModel(typeof(LegacyViewModel), legacyViewModel); // Data binding for the Title property (via MVVMContext API) var fluentAPI = mvvmContext.OfType <LegacyViewModel>(); fluentAPI.SetBinding(editor, e => e.EditValue, x => x.Title); // UI binding for the Report command commandButton.Click += (s, e) => XtraMessageBox.Show(legacyViewModel.Title); #endregion #dataBindingViaMVVMContextFluentAPI }
private void InitializeBindings() { var context = new MVVMContext(); context.ContainerControl = this; context.ViewModelType = typeof(UCStatusBarInfoViewModel); var fluent = context.OfType <UCStatusBarInfoViewModel>(); var viewModel = context.GetViewModel <UCStatusBarInfoViewModel>(); fluent.WithEvent <ItemClickEventArgs>(this.barManager1, "ItemClick") .EventToCommand(x => x.MakeOperation(0), args => this.HandlePopupClickInfo(args)); #region Property fluent.SetBinding(this.labelCanvasPos, e => e.Text, x => x.CanvasPos, canvasPos => $"{canvasPos.X.ToString("0.00")}, {canvasPos.Y.ToString("0.00")}"); fluent.SetBinding(this.dropBtnCoordinate, e => e.Text, x => x.CurrentPos, currentPos => $"(X:{currentPos.X.ToString("0.00")}, Y:{currentPos.Y.ToString("0.00")})"); fluent.SetBinding(this.checkBtnFine, e => e.Checked, x => x.FineEnabled); fluent.SetBinding(this.labelOperation, e => e.Text, x => x.Operation); fluent.SetBinding(this.barButtonItem3, e => e.Enabled, x => x.OperEnabled); fluent.SetBinding(this.barButtonItem4, e => e.Enabled, x => x.OperEnabled); fluent.SetBinding(this.barButtonItem5, e => e.Enabled, x => x.OperEnabled); this.ucInputDis.DataBindings.Add("Enabled", this.checkBtnFine, "Checked"); this.ucInputDis.Number = viewModel.Distance; this.ucInputDis.NumberChanged += (sender, e) => viewModel.Distance = this.ucInputDis.Number; fluent.SetTrigger(x => x.Distance, distance => this.ucInputDis.Number = distance); #endregion }
public SimpleCommandUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; ProgressBarControl progressBar = new ProgressBarControl(); progressBar.Dock = DockStyle.Top; SimpleButton commandButton = new SimpleButton(); commandButton.Text = "Start Command Execution"; commandButton.Dock = DockStyle.Top; SimpleButton cancelButton = new SimpleButton(); cancelButton.Text = "Cancel Command Execution"; cancelButton.Dock = DockStyle.Top; cancelButton.Parent = this; commandButton.Parent = this; progressBar.Parent = this; #endregion SetUp #region #simpleCommand cancelButton.Visible = false; progressBar.Visible = false; // mvvmContext.ViewModelType = typeof(ViewModelWithAsyncCommand); // UI binding for button mvvmContext.BindCommand <ViewModelWithAsyncCommand>(commandButton, x => x.DoSomethingAsynchronously()); #endregion #simpleCommand }
public DataBindingToNestedPropertiesFluentAPIUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; TextEdit editor = new TextEdit(); editor.Dock = DockStyle.Top; editor.Properties.NullValuePrompt = "Please, enter the Title here..."; editor.Properties.NullValuePromptShowForEmptyValue = true; SimpleButton commandButton = new SimpleButton(); commandButton.Dock = DockStyle.Top; commandButton.Text = "Report the Title property value"; commandButton.Parent = this; editor.Parent = this; #endregion SetUp #region #dataBindingToNestedPropertiesFluentAPI // Set type of POCO-ViewModel mvvmContext.ViewModelType = typeof(ViewModel); // Data binding for the Title property of nested ViewModel (via MVVMContext FluentAPI) var fluent = mvvmContext.OfType <ViewModel>(); fluent.SetBinding(editor, e => e.EditValue, x => x.Child.Title); // UI binding for the Report command ViewModel viewModel = mvvmContext.GetViewModel <ViewModel>(); commandButton.Click += (s, e) => XtraMessageBox.Show(viewModel.GetChildTitleAsHumanReadableString()); #endregion #dataBindingToNestedPropertiesFluentAPI }
public SendingAndReceivingTokenizedMessagesUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; SimpleButton sendMessageButton = new SimpleButton(); sendMessageButton.Text = "Send Message"; sendMessageButton.Dock = DockStyle.Top; sendMessageButton.Parent = this; #endregion SetUp #region #sendingAndReceivingTokenizedMessages // add another view TokenizedMessagesAwareView msgView = new TokenizedMessagesAwareView(); msgView.Parent = sendMessageButton.Parent; msgView.BringToFront(); // start listening the ViewModel's custom messages in View msgView.RegisterAsCustomMessageRecepient(); mvvmContext.ViewModelType = typeof(ViewModelWithTokenizedMessages); // UI bindings for SendCustomMessage commands var fluentAPI = mvvmContext.OfType <ViewModelWithTokenizedMessages>(); fluentAPI.BindCommand(sendMessageButton, x => x.SendTokenizedMessage()); #endregion #sendingAndReceivingTokenizedMessages }
public PassingParametersToCommandsUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; PanelControl panel = new PanelControl(); panel.Dock = DockStyle.Top; panel.Parent = this; LabelControl label = new LabelControl(); label.Text = "Click to Execute Command"; label.Dock = DockStyle.Fill; label.AutoSizeMode = LabelAutoSizeMode.None; label.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; label.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center; label.Parent = panel; #endregion SetUp #region #passingParametersToCommands mvvmContext.ViewModelType = typeof(MouseDownAwareViewModel); // UI binding for the EventToCommand behavior mvvmContext.OfType <MouseDownAwareViewModel>() .WithEvent <MouseEventArgs>(label, "MouseDown") .EventToCommand(x => x.Report((string)null), x => x.Message); #endregion #passingParametersToCommands }
public ConfirmationBehaviorGenericConfirmationBehaviorClassUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; CheckEdit editor = new CheckEdit(); editor.Dock = DockStyle.Top; editor.Text = "Please, try to change checked state of this editor"; editor.Parent = this; #endregion SetUp #region #confirmationBehaviorGenericConfirmationBehaviorClass // UI binding for the generic ConfirmationBehavior behavior with some specific parameters mvvmContext.AttachBehavior <ConfirmationBehavior <ChangingEventArgs> >(editor, behavior => { behavior.Caption = "CheckEdit State changing"; behavior.Text = "This checkEdit's checked-state is about to be changed. Are you sure?"; behavior.Buttons = ConfirmationButtons.YesNo; behavior.ShowQuestionIcon = true; }, "EditValueChanging"); #endregion #confirmationBehaviorGenericConfirmationBehaviorClass }
public DataBindingViaDefaultConvertersFluentAPIUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; TrackBarControl trackBar = new TrackBarControl(); trackBar.Dock = DockStyle.Top; trackBar.Properties.Minimum = 0; trackBar.Properties.Maximum = 100; TextEdit editor = new TextEdit(); editor.Dock = DockStyle.Top; editor.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; editor.Properties.Mask.EditMask = "P0"; editor.Properties.Mask.UseMaskAsDisplayFormat = true; editor.Parent = this; trackBar.Parent = this; #endregion SetUp #region #dataBindingViaDefaultConvertersFluentAPI // Set type of POCO-ViewModel mvvmContext.ViewModelType = typeof(ViewModel); // Data binding for the Progress property (via MVVMContext FluentAPI) var fluent = mvvmContext.OfType <ViewModel>(); fluent.SetBinding(trackBar, e => e.EditValue, x => x.Progress); fluent.SetBinding(editor, e => e.EditValue, x => x.Progress); #endregion #dataBindingViaDefaultConvertersFluentAPI }
public void SetDataContext(FrmCircleViewModel viewModel) { var context = new MVVMContext(); context.ContainerControl = this; context.SetViewModel(typeof(FrmCircleViewModel), viewModel); var fluent = context.OfType <FrmCircleViewModel>(); //this.ucInputCnt.Number = viewModel.Count; //this.ucInputCnt.NumberChanged += (sender, e) => viewModel.Count = (int)this.ucInputCnt.Number; //fluent.SetTrigger(x => x.Count, cnt => this.ucInputCnt.Number = cnt); fluent.SetBinding(this.ucInputCnt, e => e.Number, x => x.Count); this.ucInputInterval.Number = viewModel.Interval; this.ucInputInterval.NumberChanged += (sender, e) => viewModel.Interval = (int)this.ucInputInterval.Number; fluent.SetTrigger(x => x.Interval, interval => this.ucInputInterval.Number = interval); this.radioGroupModel.SelectedIndex = viewModel.Normal ? 0 : 1; this.radioGroupModel.SelectedIndexChanged += (sender, e) => viewModel.Normal = this.radioGroupModel.SelectedIndex == 0; fluent.SetTrigger(x => x.Normal, normal => this.radioGroupModel.SelectedIndex = normal ? 0 : 1); fluent.SetBinding(this.checkEditClear, e => e.Checked, x => x.ClearMachineCount); fluent.SetBinding(this.checkEditStart, e => e.Checked, x => x.MachineImmediately); this.btnAbort.Click += (sender, e) => { viewModel.Result = DialogResult.Abort; this.Close(); }; this.btnOK.Click += (sender, e) => { this.btnOK.Focus(); viewModel.Result = DialogResult.OK; this.Close(); }; this.btnCancel.Click += (sender, e) => { viewModel.Result = DialogResult.Cancel; this.Close(); }; fluent.SetBinding(this.radioGroupModel, e => e.Enabled, x => x.Enabled); fluent.SetBinding(this.checkEditStart, e => e.Enabled, x => x.Enabled); }
public StandardDataBindingUserControl() { InitializeComponent(); #region SetUp MVVMContext mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; TextEdit editor = new TextEdit(); editor.Dock = DockStyle.Top; editor.Properties.NullValuePrompt = "Please, enter the Title here..."; editor.Properties.NullValuePromptShowForEmptyValue = true; SimpleButton commandButton = new SimpleButton(); commandButton.Dock = DockStyle.Top; commandButton.Text = "Report the Title property value"; commandButton.Parent = this; editor.Parent = this; #endregion SetUp #region #standardDataBinding // Set type of POCO-ViewModel mvvmContext.ViewModelType = typeof(ViewModel); ViewModel viewModel = mvvmContext.GetViewModel <ViewModel>(); // Data binding for the Title property (via the DataBindings collection) editor.DataBindings.Add("EditValue", viewModel, "Title", true, DataSourceUpdateMode.OnPropertyChanged); // UI binding for the Report command commandButton.Click += (s, e) => XtraMessageBox.Show(viewModel.GetTitleAsHumanReadableString()); #endregion #standardDataBinding }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MVVMContext.RegisterFlyoutMessageBoxService(); Application.Run(new Form1()); }
public void Invalidate() { if (Context == null) { return; } Context.Dispose(); Context = null; }
void OnDisposing() { var context = MVVMContext.FromControl(this); if (context != null) { context.Dispose(); } }
void OnDisposing() { MVVMContext.RegisterXtraMessageBoxService(); var context = MVVMContext.FromControl(this); if (context != null) { context.Dispose(); } }
protected MVVMContextFluentAPI <TModel> GetModelBindingManager(TModel model) { var mvvmContext = new MVVMContext(); mvvmContext.ContainerControl = this; mvvmContext.SetViewModel(typeof(TModel), model); var fluentAPI = mvvmContext.OfType <TModel>(); return(fluentAPI); }
private void InitBindings() { MVVMContext.RegisterXtraMessageBoxService(); MVVMContext.RegisterXtraDialogService(); mvvmContext1.ViewModelType = typeof(BusinessPartnerViewModel); var fluentAPI = mvvmContext1.OfType <BusinessPartnerViewModel>(); //mvvmContext1.RegisterService(new NewAgentFrm()); mvvmContext1.RegisterService(SplashScreenService.Create(splashScreenManager1)); fluentAPI.SetBinding(gridControl1, gv => gv.DataSource, x => x.Agents); fluentAPI.WithEvent <ColumnView, FocusedRowObjectChangedEventArgs>(gridView1, "FocusedRowObjectChanged") .SetBinding(x => x.SelectedAgent, args => args.Row as Agent, (gView, entity) => { gView.FocusedRowHandle = gView.FindRow(entity); if (entity != null) { gpcPush.Enabled = entity.bit_synPush; gpcQuery.Enabled = entity.bit_synQuery; gpcSync.Enabled = entity.bit_synOpen; } }); fluentAPI.SetBinding(txtAgentName, x => x.EditValue, x => x.SelectedAgent.vchar_AGname); fluentAPI.SetBinding(txtContactor, x => x.EditValue, x => x.SelectedAgent.vchar_AGLinkMan); fluentAPI.SetBinding(txtContactNum, x => x.EditValue, x => x.SelectedAgent.vchar_AGcontect); fluentAPI.SetBinding(txtAgentCode, x => x.EditValue, x => x.SelectedAgent.vchar_AGcode); fluentAPI.SetBinding(txtAgentType, x => x.EditValue, x => x.SelectedAgent.int_AGtype); fluentAPI.SetBinding(cbxOpenSyncServer, x => x.EditValue, x => x.SelectedAgent.bit_synOpen); fluentAPI.SetBinding(cbxSearchService, x => x.EditValue, x => x.SelectedAgent.bit_synQuery); fluentAPI.SetBinding(cbxOpenPushServer, x => x.EditValue, x => x.SelectedAgent.bit_synPush); fluentAPI.SetBinding(txtVerifyCode, x => x.EditValue, x => x.SelectedAgent.vchar_synVerify); fluentAPI.SetBinding(txtSearchVerifyCode, x => x.EditValue, x => x.SelectedAgent.vchar_QueryVerify); fluentAPI.SetBinding(txtPushServerVerifyCode, x => x.EditValue, x => x.SelectedAgent.vchar_PushVerify); fluentAPI.SetBinding(txtPushUser, x => x.EditValue, x => x.SelectedAgent.vchar_PushUser); fluentAPI.SetBinding(txtKeyWords, x => x.EditValue, x => x.SelectedAgent.vchar_synStopKeyWord); fluentAPI.SetBinding(txtSyncTimSpan, x => x.EditValue, x => x.SelectedAgent.int_synSpacing); fluentAPI.BindCommand(btnAdd, x => x.AddAgentInfo()); fluentAPI.BindCommand(btnDelete, x => x.DeleteSelectedAgent()); fluentAPI.BindCommand(btnSave, x => x.SaveAgentInfo()); fluentAPI.SetBinding(gpcSync, x => x.Enabled, x => x.IsGPCSync); fluentAPI.SetBinding(gpcQuery, x => x.Enabled, x => x.IsGPCQuery); fluentAPI.SetBinding(gpcPush, x => x.Enabled, x => x.IsGPCPush); fluentAPI.WithEvent <EventArgs>(txtAgentType, "SelectedIndexChanged").EventToCommand(x => x.AgentTypeChanged()); }
public PrimaryFiles() { InitializeComponent(); if (!mvvmContextPrimaryFiles.IsDesignMode) { InitializeBindings(); mvvmContextPrimaryFiles.RegisterService( FolderBrowserDialogService.Create(FolderBrowserStyle.SkinnableWide)); MVVMContext.RegisterFlyoutMessageBoxService(); } }
private void RegisterServices() { MVVMContext.RegisterXtraDialogService(); mvvmContextMain.RegisterService(new SettingsWindowService()); mvvmContextMain.RegisterService(new TextEditorFontChangeService()); mvvmContextMain.RegisterService(new ConnectionWindowService()); mvvmContextMain.RegisterService(new QueryBuilderService()); mvvmContextMain.RegisterService(new BackupViewService()); mvvmContextMain.RegisterService(App.Skins); mvvmContextMain.RegisterService(SplashScreenService.Create(splashScreenManagerMainWait)); }
public QueryPane() { InitializeComponent(); HookupEvents(); SetupGridButtons(); if (!mvvmContextQueryControl.IsDesignMode) { mvvmContextQueryControl.ViewModelSet += MvvmContextQueryControlOnViewModelSet; } MVVMContext.RegisterXtraMessageBoxService(); ApplyGridLayout(); }
public UCMannual() { InitializeComponent(); InitializeBindings(); this.Load += (sender, e) => { var viewModel = MVVMContext.FromControl(this).GetViewModel <ManualViewModel>(); var monitor = new UnitMonitor(this, () => viewModel.RaisePropertiesChanged()); monitor.Listen(); }; }
//TODO this is just plain nasty, clean it up public ConnectionWindowView() { InitializeComponent(); if (!mvvmContextConnectionWindowView.IsDesignMode) { InitializeBindings(); } MVVMContext.RegisterXtraMessageBoxService(); HackControls(); HookupEvents(); }
public ObjectExplorer() { InitializeComponent(); if (!mvvmContextObjectExplorer.IsDesignMode) { InitializeBindings(); } MVVMContext.RegisterXtraDialogService(); HookupEvents(); RegisterServices(); CreatePopUpActions(); }
public static void Init() { WindowsFormsSettings.ForceDirectXPaint(); WindowsFormsSettings.EnableFormSkins(); WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinSvgPalette.Bezier.DarkTurquoise); var fs = WindowsFormsSettings.DefaultFont.Size; WindowsFormsSettings.DefaultFont = new System.Drawing.Font("Segoe UI", fs); MVVMContext.RegisterXtraMessageBoxService(); MVVMContext.RegisterOpenFileDialogService(); MVVMContext.RegisterSaveFileDialogService(); }
private void InitBindings() { MVVMContext.RegisterMessageBoxService(); mvvmContext1.ViewModelType = typeof(LoginViewModel); var fluentAPI = mvvmContext1.OfType <LoginViewModel>(); mvvmContext1.RegisterService(SplashScreenService.Create(splashScreenManager1)); fluentAPI.SetBinding(txtUserName, t => t.EditValue, x => x.CurrentUser); var loginFrm = this; fluentAPI.WithEvent <KeyEventArgs>(txtUserName, "KeyDown").EventToCommand(x => x.KeyDown(null), x => loginFrm, e => (e.KeyCode == Keys.Enter)); fluentAPI.WithEvent <EventArgs>(btnLogin, "Click").EventToCommand(x => x.Login(null), x => loginFrm); }
public ManualViewModel() { MVVMContext.RegisterXtraMessageBoxService(); OperationEngine.Instance.OnLaserEnabled += Engine_OnLaserEnabled; OperationEngine.Instance.OnBlowingEnabled += Engine_OnBlowingEnabled; OperationEngine.Instance.OnFollowEnabled += Engine_OnFollowEnabled; Messenger.Default.Register <object>(this, "OperStatusChanged", this.OnOperStatusChanged); Messenger.Default.Register <object>(this, "SetCoordinate", x => this.SwichContext(0)); var coordinatePara = SystemContext.CoordinatePara; var p = coordinatePara.MarkSeries[0]; var color = this.colorMap[0]; Messenger.Default.Send <object>(Tuple.Create(p, color), "MarkFlagChanged"); }
private void InitializeBindings() { var context = new MVVMContext(); context.ContainerControl = this; context.ViewModelType = typeof(MachineViewModel); var viewModel = context.GetViewModel <MachineViewModel>(); var fluent = context.OfType <MachineViewModel>(); #region Command Bindings fluent.BindCommand(this.btnStart, (x, para) => x.RunOperation(para), x => "Start"); fluent.BindCommand(this.btnPause, x => x.Pause()); fluent.BindCommand(this.btnStop, x => x.StopOperation()); fluent.BindCommand(this.btnOutline, (x, para) => x.RunOperation(para), x => "Outline"); fluent.BindCommand(this.btnSimulate, (x, para) => x.RunOperation(para), x => "Simulate"); fluent.BindCommand(this.btnFastStart, (x, para) => x.RunOperation(para), x => "Fast"); fluent.BindCommand(this.btnEmpty, (x, para) => x.RunOperation(para), x => "Empty"); fluent.BindCommand(this.btnCircle, x => x.ConfigCirclePara()); fluent.BindCommand(this.btnLocate, x => x.LoacateBreakPoint()); fluent.BindCommand(this.btnBreakPointStart, (x, para) => x.RunOperation(para), x => "BreakPointStart"); fluent.BindCommand(this.btnForward, (x, para) => x.RunOperation(para), x => "Forward"); fluent.BindCommand(this.btnBackward, (x, para) => x.RunOperation(para), x => "Backward"); fluent.BindCommand(this.btnZero, x => x.MoveToZero()); #endregion #region Property Bindings fluent.SetBinding(this.checkReturn, e => e.Checked, x => x.IsReturnAfterMachine); fluent.SetBinding(this.cmbReturnPoint, e => e.SelectedIndex, x => x.ReturnPointIndex); fluent.SetBinding(this.checkReturnAfterStop, e => e.Checked, x => x.IsReturnZeroWhenStop); fluent.SetBinding(this.checkSelected, e => e.Checked, x => x.IsOnlyMachineSelected); fluent.SetBinding(this.checkSoftLimit, e => e.Checked, x => x.SoftwareLimitEnalbed); fluent.SetBinding(this.checkEdgeDetection, e => e.Checked, x => x.EdgeDetectoinEnabled); fluent.SetBinding(this.ucInputStep, e => e.Number, x => x.Step, m => double.Parse(SpeedUnitConverter.Convert(m)), r => SpeedUnitConverter.ConvertBack(r.ToString())); fluent.SetBinding(this.ucInputSpeed, e => e.Number, x => x.StepSpeed, m => double.Parse(SpeedUnitConverter.Convert(m)), r => SpeedUnitConverter.ConvertBack(r.ToString())); //this.ucInputStep.Number = viewModel.Step; //this.ucInputStep.NumberChanged += (sender, e) => viewModel.Step = this.ucInputStep.Number; //fluent.SetTrigger(x => x.Step, step => this.ucInputStep.Number = step); //this.ucInputSpeed.Number = viewModel.StepSpeed; //this.ucInputSpeed.NumberChanged += (sender, e) => viewModel.StepSpeed = this.ucInputSpeed.Number; //fluent.SetTrigger(x => x.StepSpeed, speed => this.ucInputSpeed.Number = speed); #endregion this.cmbReturnPoint.DataBindings.Add("Enabled", this.checkReturn, "Checked"); viewModel.StatusChanged += ViewModel_StatusChanged; viewModel.DisableLocateStatus += ViewModel_DisableLocateStatus; viewModel.Register("UpdateCirclePara", this.UpdateCircleConfig); }
public MachineViewModel() { MVVMContext.RegisterXtraMessageBoxService(); Messenger.Default.Register <object>(this, "ReceiveDataProvider", this.OnDataProviderReceive); Messenger.Default.Register <object>(this, "ReceiveDrawObjectsCnt", this.OnDrawObjectsCntReceive); Messenger.Default.Register <object>(this, "DataProviderChanged", this.OnDataProviderChanged); Messenger.Default.Register <bool>(this, "OnManualMovement", this.OnManualMovement); Messenger.Default.Register <object>(this, "OnOperationTrigger", this.OnOperationTrigger); Messenger.Default.Register <object>(this, "AutoSuspend", this.OnAutoSuspend); OperationEngine.Instance.OnFinishOnce += () => { Messenger.Default.Send <object>(null, "ClearMark"); Messenger.Default.Send <object>(null, "OnMachineOnce"); }; OperationEngine.Instance.OnLog += Engine_OnLog; }