private void HandleAddData() { var msg = new NotificationMessageAction <DateTime>("请输入新增数据的日期及时间", (result) => { try { //检查是否有数据存在 if (DbContext.CheckExistData(_appInfo.CurrentApp.Id, result)) { throw new Exception("该时刻的数据已存在,无法添加"); } DataRow newRow = AppDataTable.NewRow(); newRow[PubConstant.timeColumnName] = result; AppDataTable.Rows.Add(newRow); AppDataTable.AcceptChanges(); } catch (Exception ex) { Messenger.Default.Send <Exception>(ex); } }); Messenger.Default.Send <NotificationMessageAction <DateTime> >(msg); }
private void HandleNotification(NotificationMessageAction <string> message) { //message.Execute("Success from <App.xaml>"); var dialog = ServiceLocator.Current.GetInstance <IDialogService>(); DispatcherHelper.RunAsync(() => dialog.ShowMessage(message.Notification, "Message")); }
private void HandleRenameApp(object model) { var handelModel = _selectedApp; var msg = new NotificationMessageAction <string>("请输入新的名称", (result) => { if (result != null && result.Trim().Length != 0) { try { handelModel.AppName = result.Trim(); // DbContext.UpdateObject(handelModel); DbContext.SaveChanges(); } catch (Exception ex) { Messenger.Default.Send <Exception>(ex); // DbContext.Detach(handelModel); _selectedApp = (from i in DbContext.Apps where i.Id == _selectedApp.Id select i).First(); //HandleRefreshApps(_currentModel, true); } } }); Messenger.Default.Send <NotificationMessageAction <string> >(msg); }
/// <summary> /// Initializes a new instance of the AddBookViewModel class. /// </summary> public AddBookViewModel() { Messenger.Default.Register <NotificationMessageAction <BookItem> >(this, "book", m => { _addItem = m; }); }
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); }
private void ProcessCloudFoundryProviderMessage(NotificationMessageAction <ICloudFoundryProvider> message) { if (message.Notification.Equals(Messages.GetCloudFoundryProvider)) { message.Execute(this); } }
private void ResetSettings() { var msg = new NotificationMessageAction <MessageBoxResult>(this, "Reset Settings", (r) => { if (r == MessageBoxResult.Yes) { UserSettings userSettings = new UserSettings(); File.Delete(Globals.DirectoryPath + @"/Data/config/config.xml"); userSettings.NsfwEnabled = false; userSettings.MaxSpoilerLevel = 0; ModifyUserSettings.SaveUserSettings(userSettings); var cvm = ServiceLocator.Current.GetInstance <VnCharacterViewModel>(); var ssvm = ServiceLocator.Current.GetInstance <VnScreenshotViewModel>(); var rvm = ServiceLocator.Current.GetInstance <VnReleaseViewModel>(); var mvm = ServiceLocator.Current.GetInstance <VnMainViewModel>(); mvm.BindVnDataPublic(); cvm.ClearCharacterDataCommand.Execute(null); cvm.LoadCharacterCommand.Execute(null); rvm.ClearReleaseDataCommand.Execute(null); rvm.LoadReleaseNamesCommand.Execute(null); ssvm.BindScreenshotsCommand.Execute(null); Messenger.Default.Send(new NotificationMessage("Reset Settings")); } }); Messenger.Default.Send(msg); }
private void OnMSG_CareOneConfig_SAVEDATA(NotificationMessageAction <DataOneRegistationInfo> action) { _dataInfo.Led_name = Led_name; _dataInfo.Latitude = Latitude; _dataInfo.Longitude = Longitude; action.Execute(_dataInfo); }
private void finishGame(NotificationMessageAction notificationMessageAction) { if (notificationMessageAction.Notification.Equals("win")) { dispatcherTime.Stop(); if (Time < _bestTime || _bestTime == 0) { _bestTime = Time; ApplicationData.Current.LocalSettings.Values[Name] = Time; } _dialogService.ShowMessage( "Best time " + HelpConvert.intToStringTime(_bestTime) + "\nCurrent time " + HelpConvert.intToStringTime(Time), "Puzzle Completed", "Menu", "Retry", (menu) => { if (menu) { _navigationService.GoBack(); } else { initGame(); notificationMessageAction.Execute(); // execute the callback = restart } }); } }
private void NotificationMessageBoxResultRecieved(NotificationMessageAction <MessageBoxResult> msg) { if (msg.Notification == "Reset Settings") { var result = ModernDialog.ShowMessage("Are you sure you want to reset your settings to default?", "Reset settings to default", MessageBoxButton.YesNo); msg.Execute(result); } }
private void NotificationMessageBoxResultRecieved(NotificationMessageAction <MessageBoxResult> msg) { if (msg.Notification == "Delete Vn Confirm") { var result = ModernDialog.ShowMessage("Are you SURE you want to delete this visual novel and all associated data?", "Delete Visual Novel?", MessageBoxButton.YesNo); msg.Execute(result); } }
public HttpViewModel(INavigationService navigationService) : base(navigationService) { Messenger.Default.Register <NotificationMessageAction <Book> >(this, "book", m => { _addBook = m; }); Ip = HttpHelper.GetLocalIp(); }
private void GetDirectory(NotificationMessageAction <DirectoryInfo> msg) { System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog(); if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var result = new System.IO.DirectoryInfo(folderBrowser.SelectedPath); msg.Execute(result); } }
private async void ShowConfirmation(NotificationMessageAction message) { var result = await this.ShowMessageAsync("Confirmation", message.Notification, MessageDialogStyle.AffirmativeAndNegative); if (result == MessageDialogResult.Affirmative) { await Dispatcher.BeginInvoke(new Action(message.Execute)); } }
private void OnNotificationMessageActionReceived(NotificationMessageAction <MessageBoxResult> obj) { if (obj.Sender is ViewMassMove) { switch (obj.Notification.ToString()) { case "AskForOverwrite": obj.Execute(MessageBox.Show("The preset position has been existed, overwrite ?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question)); break; } } }
public BookChapterViewModel(INavigationService navigationService) : base(navigationService) { Messenger.Default.Register <NotificationMessageAction <Book> >(this, "book", m => { _showBook = m; Book = m.Sender as Book; if (Book != null) { _loadChapter(); } }); }
private async void RenderImage(NotificationMessageAction <SoftwareBitmap> notificationMessageAction) { if (BaumCollection != null && BaumCollection.Count > 0) { if (BaumCollection.Where(x => x.IsMarked == true).Count() > 0) { SelectTree(BaumCollection.Where(x => x.IsMarked == true).First()); } //_selectedBaum = _BaumCollection.Where(x => x.IsMarked = true).First(); //RaisePropertyChanged(() => SelectedBaum); } RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(mapGrid); if (renderTargetBitmap.PixelHeight != 0 && renderTargetBitmap.PixelWidth != 0) { SoftwareBitmap softwareBitmap = new SoftwareBitmap(BitmapPixelFormat.Bgra8, renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight); softwareBitmap.DpiX = 600; softwareBitmap.DpiY = 600; softwareBitmap.CopyFromBuffer(await renderTargetBitmap.GetPixelsAsync()); notificationMessageAction.Execute(softwareBitmap); } //BitmapDecoder imagedecoder; //using (var imagestream = await Map.OpenAsync(FileAccessMode.Read)) //{ // imagedecoder = await BitmapDecoder.CreateAsync(imagestream); // CanvasDevice device = CanvasDevice.GetSharedDevice(); // CanvasRenderTarget renderTarget = new CanvasRenderTarget(device, imagedecoder.PixelWidth, imagedecoder.PixelHeight, 96); // using (var ds = renderTarget.CreateDrawingSession()) // { // ds.Clear(Colors.White); // CanvasBitmap image = await CanvasBitmap.LoadAsync(device, imagestream); // ds.DrawImage(image); // //ds.DrawText(lblName.Text, new System.Numerics.Vector2(150, 150), Colors.Black); // } // await renderTarget.SaveAsync(imagestream, CanvasBitmapFileFormat.Jpeg); // BitmapImage bitmap = new BitmapImage(); // bitmap.SetSource(imagestream); // MapR = bitmap; //} }
private void ExecuteTest <T>(object sender, object target, T argument1) { object receivedSender = null; object receivedTarget = null; string receivedNotification = null; var receivedArgument1 = default(T); var callbackExecuted1 = false; Messenger.Reset(); Messenger.Default.Register <NotificationMessageAction <T> >( this, m => { receivedSender = m.Sender; receivedTarget = m.Target; receivedNotification = m.Notification; m.Execute(argument1); }); NotificationMessageAction <T> message1 = null; Action <T> callback1 = p => { callbackExecuted1 = true; receivedArgument1 = p; }; if (sender == null) { message1 = new NotificationMessageAction <T>(DummyNotification1, callback1); } else { if (target == null) { message1 = new NotificationMessageAction <T>(sender, DummyNotification1, callback1); } else { message1 = new NotificationMessageAction <T>(sender, target, DummyNotification1, callback1); } } Messenger.Default.Send(message1); Assert.AreEqual(sender, receivedSender); Assert.AreEqual(target, receivedTarget); Assert.AreEqual(DummyNotification1, receivedNotification); Assert.IsTrue(callbackExecuted1); Assert.AreEqual(argument1, receivedArgument1); }
/// <summary> /// 打开添加用户窗口 /// </summary> private void OpenAddUserView() { var msg = new NotificationMessageAction <bool>("OpenAddUserViewNotification", async result => { if (result) { var userListViewModel = await GetAllUserAsync(); UserList = new ObservableCollection <UserDto>(userListViewModel.Users); } }); Messenger.Default.Send(msg, "OpenAddUserView"); }
/// <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; } }); }
/// <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(); }); }
private void GetInputDate(NotificationMessageAction <DateTime> msg) { object[] vals = new object[] { msg.Notification, null }; var win = new InputDateWindow(vals); win.Owner = this; win.WindowStartupLocation = WindowStartupLocation.CenterOwner; win.ShowDialog(); if (vals[1] != null) { msg.Execute(vals[1]); } }
private void DeleteCommandExec() { NotificationMessageAction <MessageBoxResult> msg = new NotificationMessageAction <MessageBoxResult>("", (ret) => { if (ret == MessageBoxResult.OK) { lst.Remove(SelectedMPSYPItem); new MPSYPItemRepository().Delete(SelectedMPSYPItem); RaisePropertyChanged("ICMOFeedingView"); } } ); Messenger.Default.Send <NotificationMessageAction <MessageBoxResult> >(msg); }
private void HandleNotificationMessage(NotificationMessageAction <CollectionLibrary> message) { //check if it has a same id from sender var x = (ItemModel)message.Sender; CollectionLibrary checkitem; try { checkitem = ItemItemSource.Where(i => i.Itemproperty.Item_Id == x.Item_Id).First(); message.Execute(checkitem); } catch (Exception) { checkitem = null; } }
private void ProcessMessage(NotificationMessageAction message) { switch (message.Notification) { case "LoadArmy": //TODO: show dialog to load army break; case "CreateNewArmy": CreateNewArmy(); break; default: break; } }
private void GetInput(NotificationMessageAction <string> msg) { string[] vals = new string[] { msg.Notification, null }; var win = new InputWindow(vals); win.Owner = this; win.WindowStartupLocation = WindowStartupLocation.CenterOwner; win.ShowDialog(); if (vals[1] != null) { msg.Execute(vals[1]); } // msg.Execute(MessageBox.Show("选择", "问题", MessageBoxButton.YesNo, MessageBoxImage.Question).ToString()); }
private void HandleChoosePath(object obj) { var msg = new NotificationMessageAction <System.IO.DirectoryInfo>("请选择要导入文件的路径", (result) => { try { Dir = result; HandleInfo = "导入目录: " + Dir.FullName; } catch (Exception ex) { Messenger.Default.Send <Exception>(ex); } }); Messenger.Default.Send <NotificationMessageAction <System.IO.DirectoryInfo> >(msg); }
/// <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(); }); }
/// <summary> /// Initializes a new instance of the EmailViewModel class. /// </summary> public EmailViewModel() { Messenger.Default.Register <NotificationMessageAction <EmailItem> >(this, "rule", m => { _callBack = m; if (m.Sender == null) { return; } var item = m.Sender as EmailItem; Email = item.Email; Params = item.Value; }); Messenger.Default.Register <NotificationMessageAction>(this, "close", m => { _close = m; }); }
private void HandleAttachApp(ProjectPartViewModel model) { var msg = new NotificationMessageAction <List <string> >("请将需要关联的测点名称粘贴到下面的列表中", (result) => { try { DbContext.UpdateAppsProjectByNames(_currentModel.ProjectPartID, result); //refresh current HandleRefreshApps(_currentModel, true); } catch (Exception ex) { Messenger.Default.Send <Exception>(ex); } }); Messenger.Default.Send <NotificationMessageAction <List <string> > >(msg); }