private void NotificationMessageActionHandler(NotificationMessageAction<MessageBoxResult> m)
 {
     if (m.Notification == Messages.Messages.SETTINGSIP_SAVE)
     {
         var result = MessageBox.Show("Do you want to save the settings?", "Save settings?", MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
         m.Execute(result);
     }
 }
        public void Initializes(NotificationMessageAction<ObservableCollection<DataGradItemInfo>> nsa)
        {
            _nsaEdit = nsa;
            ImportDataGradItemInfoList = (ObservableCollection<DataGradItemInfo>)nsa.Target;
            ScanBoardConfigManager_VM vm = (ScanBoardConfigManager_VM)nsa.Sender;
            ObservableCollection<DataGradItemInfo> oldData = vm.DataGradItemInfoList;

            for (int i = 0; i < ImportDataGradItemInfoList.Count; i++)
            {
                string msgAdd = "";
                CommonStaticMethod.GetLanguageString("添加", "Lang_ScanBoardConfigManager_Add", out msgAdd);

                string msgNoAdd = "";
                CommonStaticMethod.GetLanguageString("不添加", "Lang_ScanBoardConfigManager_NoAdd", out msgNoAdd);

                string msgRePlace = "";
                CommonStaticMethod.GetLanguageString("替换", "Lang_ScanBoardConfigManager_Replace", out msgRePlace);


                if (oldData.Count <= 0)
                {
                    ImportDataGradItemInfoList[i].DataHandleWay = HandleWay.Add;
                    ImportDataGradItemInfoList[i].ComBoxDataContext.Clear();
                    ImportDataGradItemInfoList[i].DataHandelSatate = DataSatate.Operability;
                    ImportDataGradItemInfoList[i].ComBoxDataContext.Add(new HandleWayInfo() { DisplayName = msgAdd, EnumValue = HandleWay.Add });
                    ImportDataGradItemInfoList[i].ComBoxDataContext.Add(new HandleWayInfo() { DisplayName = msgNoAdd, EnumValue = HandleWay.NoAdd });
                }
                else
                {
                    for (int j = 0; j < oldData.Count; j++)
                    {
                        if (oldData[j].ScanBoardName == ImportDataGradItemInfoList[i].ScanBoardName)
                        {
                            ImportDataGradItemInfoList[i].ComBoxDataContext.Clear();
                            ImportDataGradItemInfoList[i].DataHandleWay = HandleWay.Replace;
                            ImportDataGradItemInfoList[i].DataHandelSatate = DataSatate.ExistFile;
                            ImportDataGradItemInfoList[i].ComBoxDataContext.Add(new HandleWayInfo() { DisplayName = msgRePlace, EnumValue = HandleWay.Replace });
                            ImportDataGradItemInfoList[i].ComBoxDataContext.Add(new HandleWayInfo() { DisplayName = msgNoAdd, EnumValue = HandleWay.NoAdd });
                            break;
                        }
                        else
                        {
                            ImportDataGradItemInfoList[i].ComBoxDataContext.Clear();
                            ImportDataGradItemInfoList[i].DataHandleWay = HandleWay.Add;
                            ImportDataGradItemInfoList[i].DataHandelSatate = DataSatate.Operability;
                            ImportDataGradItemInfoList[i].ComBoxDataContext.Add(new HandleWayInfo() { DisplayName = msgAdd, EnumValue = HandleWay.Add });
                            ImportDataGradItemInfoList[i].ComBoxDataContext.Add(new HandleWayInfo() { DisplayName = msgNoAdd, EnumValue = HandleWay.NoAdd });
                        }
                    }
                }

                if (ImportDataGradItemInfoList != null &&
                    ImportDataGradItemInfoList.Count > 0)
                {
                    SelectedValue = ImportDataGradItemInfoList[0];
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the AddViewModel class.
 /// </summary>
 public AddViewModel()
 {
     Messenger.Default.Register<NotificationMessageAction<PasswordItem>>(this, "add", m =>
     {
         _addItem = m;
         if (m.Sender == null) return;
         _item = (PasswordItem)m.Sender;
     });
 }
 private void ShowExportWindow(NotificationMessageAction<ObservableCollection<DataGradItemInfo>> msg)
 {
     if (msg.Notification == MsgToken.MSG_EXPORTCONFIGFOLE)
     {
         Window_ExportCfgFile exportCfgFileWin = new Window_ExportCfgFile();
         exportCfgFileWin.Initializes(msg);
         exportCfgFileWin.Owner = this;
         exportCfgFileWin.ShowDialog();
     }
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the ReadViewModel class.
 /// </summary>
 public ReadViewModel()
 {
     Messenger.Default.Register<NotificationMessageAction<int>>(this, "readViewer", m =>
     {
         _readViewer = m;
     });
     Messenger.Default.Register<NotificationMessageAction<BookItem>>(this, "read", m =>
     {
         _readItem = m;
         _book = (BookItem) m.Sender;
         _loading();
     });
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the AddWebViewModel class.
 /// </summary>
 public AddWebViewModel()
 {
     Messenger.Default.Register<NotificationMessageAction<WebsiteItem>>(this, "web", m =>
     {
         _addItem = m;
         if (m.Sender != null)
         {
             WebsiteItem item = (WebsiteItem)m.Sender;
             Name = item.Name;
             Url = item.Url;
         }
     });
 }
        public Window_ChangedSenderType(NotificationMessageAction<SenderConfigInfo> info)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            _vm = (Window_ChangedSenderType_VM)FindResource("Window_ChangedSenderType_VMDataSource");
            DataContext = _vm;
            _vm.SenderConfigInfoNsa = info;

            Messenger.Default.Register<string>(this, MsgToken.MSG_SHOWCHANGEDSENDETTYPE_CLOSE, msg =>
            {
                this.Close();
            });
        }
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel()
 {
     Messenger.Default.Register<NotificationMessageAction>(this, "main", m => _closeView = m);
     var result = new LoginView().ShowDialog();
     if (true != result)
     {
         Task.Factory.StartNew(() =>
         {
             Thread.Sleep(500);
             _closeView.Execute();
         });
         return;
     }
     ViewVisibility = Visibility.Visible;
     GetPassword();
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the SystemViewModel class.
 /// </summary>
 public SystemViewModel()
 {
     Messenger.Default.Register<NotificationMessageAction>(this, "system", m =>
     {
         _system = m;
     });
     _loadFont();
     Task.Factory.StartNew(() =>
     {
         DatabaseHelper.Open();
         SystemHelper.Open();
         Background = SystemHelper.Get("Background");
         FontFamily = new FontFamily(SystemHelper.Get("FontFamily", "宋体"));
         FontSize = SystemHelper.GetInt("FontSize");
         FontWeight = SystemHelper.GetInt("FontWeight");
         Foreground = SystemHelper.Get("Foreground");
         DatabaseHelper.Close();
     });
 }
 private void ShowMsgBox(NotificationMessageAction<ButtonClickType> msg)
 {
     if (msg.Notification == MsgToken.MSG_DELETEMSG_MSGBOX)
     {
         NotificationMessageAction<ButtonClickType> msgs = msg;
          ButtonClickType butType= (ButtonClickType)msg.Sender;
         if (MessageBox.Show(msg.Target.ToString(), "", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK)
         {
             butType = ButtonClickType.Ok;
         }
         else
         {
             butType = ButtonClickType.Cancel;
         }
         if (msgs != null)
         {
             msgs.Execute(butType);
         }
     }
 }
Пример #11
0
        private void WindowOperation_MessageReceived(NotificationMessageAction msg)
        {
            if(msg.Notification == "OpenDebugTool")
            {
                debugTool = new DebugTool();
                msg.Execute();
                debugTool.Show();
            }

            if (msg.Notification == "OpenConnectionSetup")
            {
                ConnectionSetupWindow = new ConnectionSetup();
                msg.Execute();
                ConnectionSetupWindow.ShowDialog();
            }

            if (msg.Notification == "OpenHardwareSetup")
            {
                HardwareSetupWindow = new HardwareSetup();
                msg.Execute();
                HardwareSetupWindow.ShowDialog();
            }

            if(msg.Notification == "CloseHardwareSettings")
            {
                if(HardwareSetupWindow != null)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                    new System.Action(() => { HardwareSetupWindow.Close(); }));
                }
            }

            if(msg.Notification == "CloseConnectionSetup")
            {
                if(ConnectionSetupWindow != null)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                    new System.Action(() => { ConnectionSetupWindow.Close(); }));
                }
            }
        }
Пример #12
0
        public static ICommand Bind(this ICommand command, System.Windows.Controls.Control ctrl)
        {
            CommandBinding binding = new CommandBinding();
            binding.Command = command;

            binding.Executed += new ExecutedRoutedEventHandler((sender, e) =>
            {
                var message = new NotificationMessage<ExecutedRoutedEventArgs>(sender, e, "Execute");
                Messenger.Default.Send(message, command);
            });

            binding.CanExecute += new CanExecuteRoutedEventHandler((sender, e) =>
            {
                var message = new NotificationMessageAction<bool>(sender, "CanExecute", b =>
                {
                    e.CanExecute = (b) ? b : e.CanExecute;
                });
                Messenger.Default.Send(message, command);
            });

            ctrl.CommandBindings.Add(binding);

            return command;
        }
Пример #13
0
 private void HandleNotificationMessage(NotificationMessageAction<string> message)
 {
     // Execute a callback to send a reply to the sender.
     message.Execute("Success! (from App.xaml.cs)");
 }
Пример #14
0
 private void OnCmdWizardProject()
 {
     //保存当前工程
     string msg = "";
     CommonStaticMethod.GetLanguageString("是否保存?", "Lang_SmartLCT_VM_IsSave", out msg);
     MessageBoxResult result = ShowQuestionMessage(msg, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
     if (result == MessageBoxResult.Yes)
     {
         //SaveSysConfigFile(MyConfigurationData.ProjectLocationPath + "\\" + MyConfigurationData.ProjectName + ".xml");
         OnOtherSaveSysConfigFile();
     }
     else if (result == MessageBoxResult.Cancel)
     {
         return;
     }
     //发送新建工程的消息,并返回新建的信息
     ConfigurationData data = new ConfigurationData();
     data.OperateType = OperateScreenType.UpdateScreen;
     NotificationMessageAction<ConfigurationData> nsa =
     new NotificationMessageAction<ConfigurationData>(this, data, MsgToken.MSG_SHOWGUIDETWO, NewProjectCallBack);
     Messenger.Default.Send(nsa, MsgToken.MSG_SHOWGUIDETWO);
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the AddBookViewModel class.
 /// </summary>
 public AddBookViewModel()
 {
     Messenger.Default.Register<NotificationMessageAction<BookItem>>(this, "book", m =>
     {
         _addItem = m;
     });
 }
 public void Initializes(NotificationMessageAction<string> nsa)
 {
     DisplayTestMsg = nsa.Notification;
 }
 private void OnFastSegmentation()
 {
     NotificationMessageAction<FastSegmentParam> nsa =
         new NotificationMessageAction<FastSegmentParam>(this, _fastSementParam, MsgToken.MSG_SHOWFASTSEGMENTATION, SetSegmentationNotifycationCallBack);
     Messenger.Default.Send(nsa, MsgToken.MSG_SHOWFASTSEGMENTATION);
 }
 public void Initializes(NotificationMessageAction<ObservableCollection<DataGradItemInfo>> nsa)
 {
     _window_ExportCfgFile_VM.Initializes(nsa);
 }
 private void OpenImportConfigFile()
 {
     if (OpenFile.IsCheckedOK)
     {
         ObservableCollection<DataGradItemInfo> data = GetFileDataList();
         //ObservableCollection<DataGradItemInfo> data = new ObservableCollection<DataGradItemInfo>();
         //DataGradItemInfo ta = new DataGradItemInfo();
         //ta.ScanBoardSize = "50*80";
         //data.Add(ta);
         if (data.Count <= 0)
         {
             return;
         }
         NotificationMessageAction<ObservableCollection<DataGradItemInfo>> nsa =
                 new NotificationMessageAction<ObservableCollection<DataGradItemInfo>>(this, data, MsgToken.MSG_IMPORTCONFIGFOLE, ImportCfgFileNotifycationCallBack);
         Messenger.Default.Send(nsa, MsgToken.MSG_IMPORTCONFIGFOLE);
     }
 }
        private void OnCustomReceiveSize()
        {
            if (SelectedScannerConfigInfo == null)
            {
                return;
            }
            if (SelectedScannerConfigInfo.ScanBdSizeType == ScannerSizeType.Custom)
            {
                CustomReceiveResult info = new CustomReceiveResult();
                info.Width = 64;
                info.Height = 64;
                NotificationMessageAction<CustomReceiveResult> nsa =
                new NotificationMessageAction<CustomReceiveResult>(this, info, MsgToken.MSG_SHOWSETCUSTOMRECEIVESIZE, SetCustomReceiveNotifycationCallBack);
                Messenger.Default.Send(nsa, MsgToken.MSG_SHOWSETCUSTOMRECEIVESIZE);

            }
        }
Пример #21
0
 public static void Send(NotificationMessageAction<FileInfo> message)
 {
     Messenger.Default.Send(message, MessageTypes.OpenFile);
 }
Пример #22
0
 public static void Send(NotificationMessageAction<WriteableBitmap> message)
 {
     Messenger.Default.Send(message, MessageTypes.GetCharts);
 }
Пример #23
0
 private void OnCmdChangeReceiveSize()
 {
     CustomReceiveResult info = new CustomReceiveResult();
     info.Height = (int)_selectedElementCollection[0].Height;
     info.Width = (int)_selectedElementCollection[0].Width;
     NotificationMessageAction<CustomReceiveResult> nsa =
     new NotificationMessageAction<CustomReceiveResult>(this, info, MsgToken.MSG_SHOWSETCUSTOMRECEIVESIZE, SetChangeReceiveCallBack);
     Messenger.Default.Send(nsa, MsgToken.MSG_SHOWSETCUSTOMRECEIVESIZE);
 }
Пример #24
0
 private void OnAddReceive(NotificationMessageAction<AddReceiveInfo> info)
 {
     if (info.Notification == MsgToken.MSG_ADDRECEIVE)
     {
         _addReceiveCallback = info;
         _addReceiveInfo = (AddReceiveInfo)info.Target;
         SelectedElementChangedHandle(MouseState.None);
     }
 }
 private void ShowMessageBoxExit(CancelEventArgs e)
 {
     if(_IPs.IsChanged == true)
     {
     var msg = new NotificationMessageAction<MessageBoxResult>(this, Messages.Messages.SETTINGSIP_SAVE, (r) =>
     {
         if (r == MessageBoxResult.Yes)
         {
             // do stuff
             e.Cancel = true;
             SettingsSave();
         }
     });
     _log.Debug("Sending message to View to SaveSettingsIp Dialog");
     Messenger.Default.Send(msg);
     }
 }
 private void OpenExportConfigFile()
 {
     ObservableCollection<DataGradItemInfo> data = GetSelectedDataList();
     if (data.Count <= 0)
     {
         return;
     }
     NotificationMessageAction<ObservableCollection<DataGradItemInfo>> nsa =
             new NotificationMessageAction<ObservableCollection<DataGradItemInfo>>(this, data, MsgToken.MSG_EXPORTCONFIGFOLE, ExportCfgFileNotifycationCallBack);
     Messenger.Default.Send(nsa, MsgToken.MSG_EXPORTCONFIGFOLE);
 }
Пример #27
0
 private void ProcessCloudFoundryProviderMessage(NotificationMessageAction<ICloudFoundryProvider> message)
 {
     if (message.Notification.Equals(Messages.GetCloudFoundryProvider))
     {
         message.Execute(this);
     }
 }
Пример #28
0
    private void OnMouseDoubleClickWithSenderType()
    {
        if (SelectedSenderConfigInfo == null)
        {
            return;
        }
        if (CurrentSenderConfigInfo == SelectedSenderConfigInfo)
        {
            return;
        }
        NotificationMessageAction<SenderConfigInfo> nsa =
 new NotificationMessageAction<SenderConfigInfo>(SelectedSenderConfigInfo, "", MsgToken.MSG_ISMODIFYSENDERTYPE, SetChangedSenderTypeCallBack);
        Messenger.Default.Send(nsa, MsgToken.MSG_ISMODIFYSENDERTYPE);
        _isCompleteChangeSenderType = true;
    }
Пример #29
0
 private void HandleNotificationMessage(NotificationMessageAction<string> message)
 {
     message.Execute("Success (from App.xaml.cs)!");
 }
Пример #30
0
 private void handleNotificationMessage(NotificationMessageAction<string> message)
 {
     message.Execute("Le message est arrivé dans le App.xaml.cs");
 }