/// <summary> /// Invoked on every mouse click, touch screen tap, or equivalent interaction when this /// page is active and occupies the entire window. Used to detect browser-style next and /// previous mouse button clicks to navigate between pages. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="e">Event data describing the conditions that led to the event.</param> private void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs e) { PointerPointProperties properties = e.CurrentPoint.Properties; // Ignore button chords with the left, right, and middle buttons if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || properties.IsMiddleButtonPressed) { return; } // If back or foward are pressed (but not both) navigate appropriately bool backPressed = properties.IsXButton1Pressed; bool forwardPressed = properties.IsXButton2Pressed; if (backPressed ^ forwardPressed) { e.Handled = true; if (backPressed) { GoBackCommand.Execute(null); } if (forwardPressed) { GoForwardCommand.Execute(null); } } }
/// <summary> /// Supprimer une note /// </summary> public void DeleteNote() { DataServiceNote dsNote = new DataServiceNote(); dsNote.DeleteNote(Note); GoBackCommand.Execute(null); }
private void ShowBackStep() { if (CurrentPage >= 1) { CurrentPage -= 1; } if (CurrentPage == 0) // Back to previ view. { GoBackCommand.Execute(); } else if (CurrentPage == 1) { View.PanToPage(CurrentPage); HightlightStep(true, false, false, false); } else if (CurrentPage == 2) { View.PanToPage(CurrentPage); HightlightStep(true, true, false, false); } else if (CurrentPage == 3) { View.PanToPage(CurrentPage); HightlightStep(true, true, true, false); } }
private void CoreWindowOnPointerPressed(CoreWindow sender, PointerEventArgs args) { var properties = args.CurrentPoint.Properties; if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || properties.IsMiddleButtonPressed) { return; } var backPressed = properties.IsXButton1Pressed; var forwardPressed = properties.IsXButton2Pressed; if (backPressed ^ forwardPressed) { args.Handled = true; if (backPressed) { GoBackCommand.Execute(null); } if (forwardPressed) { GoForwardCommand.Execute(null); } } }
/// <summary> /// 当此页处于活动状态并占用整个窗口时,在每次鼠标单击、触摸屏点击 /// 或执行等效交互时调用。 用于检测浏览器样式下一页和 /// 上一步鼠标按钮单击以在页之间导航。 /// </summary> /// <param name="sender">触发事件的实例。</param> /// <param name="e">描述导致事件的条件的事件数据。</param> private void CoreWindow_PointerPressed(Windows.UI.Core.CoreWindow sender, PointerEventArgs e) { PointerPointProperties properties = e.CurrentPoint.Properties; // 忽略与鼠标左键、右键和中键的键关联 if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || properties.IsMiddleButtonPressed) { return; } // 如果按下后退或前进(但不是同时),则进行相应导航 bool backPressed = properties.IsXButton1Pressed; bool forwardPressed = properties.IsXButton2Pressed; if (backPressed ^ forwardPressed) { e.Handled = true; if (backPressed) { GoBackCommand.Execute(null); } if (forwardPressed) { GoForwardCommand.Execute(null); } } }
/// <summary> /// Invoked on every keystroke, including system keys such as Alt key combinations, when /// this page is active and occupies the entire window. Used to detect keyboard navigation /// between pages even when the page itself doesn't have focus. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="e">Event data describing the conditions that led to the event.</param> private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e) { VirtualKey virtualKey = e.VirtualKey; // Only investigate further when Left, Right, or the dedicated Previous or Next keys // are pressed if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || e.EventType == CoreAcceleratorKeyEventType.KeyDown) && (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || (int)virtualKey == 166 || (int)virtualKey == 167)) { CoreWindow coreWindow = Window.Current.CoreWindow; CoreVirtualKeyStates downState = CoreVirtualKeyStates.Down; bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState; bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState; bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState; bool noModifiers = !menuKey && !controlKey && !shiftKey; bool onlyAlt = menuKey && !controlKey && !shiftKey; if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt)) { // When the previous key or Alt+Left are pressed navigate back e.Handled = true; GoBackCommand.Execute(null); } else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt)) { // When the next key or Alt+Right are pressed navigate forward e.Handled = true; GoForwardCommand.Execute(null); } } }
protected virtual void OnBackRequested(object sender, BackRequestedEventArgs e) { if (GoBackCommand.CanExecute(null)) { e.Handled = true; GoBackCommand.Execute(null); } }
/// <summary> /// Invoked when the hardware back button is pressed. For Windows Phone only. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="e">Event data describing the conditions that led to the event.</param> protected virtual void HardwareButtonsBackPressed(object sender, BackPressedEventArgs e) { if (GoBackCommand.CanExecute(null)) { e.Handled = true; GoBackCommand.Execute(null); } }
/// <summary> /// Invoked when the hardware back button is pressed. For Windows Phone only. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="e">Event data describing the conditions that led to the event.</param> private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e) { if (GoBackCommand.CanExecute(null)) { e.Handled = true; GoBackCommand.Execute(null); } }
//private void Frame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) //{ // DeregisterPageEvents(); // RefreshPage(); // RegisterPageEvents(); //} private void App_BackRequested(object sender, Windows.UI.Core.BackRequestedEventArgs e) { if (GoBackCommand.CanExecute(null)) { e.Handled = true; GoBackCommand.Execute(null); } }//
private async void SaveDetailsAsync() { IsLoading = true; // Show a progress dialog. var progressDialog = _dialogService.ShowProgress("Please wait...", "The details are being saved to your Office 365 tenant."); if (IsExisting) { // Calculate address (range). const int startRow = 2; var endRow = 2 + (_configService.DataFile.PropertyTable.Rows.Length - 1); var address = $"{Constants.DataFilePropertyTableColumnStart}{startRow}:" + $"{Constants.DataFilePropertyTableColumnEnd}{endRow}"; // Update the table row. await _graphService.UpdateGroupTableRowsAsync(_configService.AppGroup, _configService.DataFile.DriveItem, Constants.DataFileDataSheet, address, _configService.DataFile.PropertyTable.Rows.Cast <TableRowModel>().ToArray()); } else { // Create property group. var mailNickname = new string(_streetName.ToCharArray() .Where(char.IsLetterOrDigit) .ToArray()) .ToLower(); var propertyGroup = await _graphService.AddGroupAsync(GroupModel.CreateUnified( StreetName, Details.Description, mailNickname)); // Add the current user as a member of the app group. await _graphService.AddGroupUserAsync(propertyGroup, _configService.User); // We need the file storage to be ready in order to place any files. // Wait for it to be configured. await _graphService.WaitForGroupDriveAsync(propertyGroup); // Add details to data file. Details.Id = propertyGroup.Mail; await _graphService.AddGroupTableRowAsync(_configService.AppGroup, _configService.DataFile.DriveItem, Constants.DataFilePropertyTable, Details); // Add group and details to local config. _configService.Groups.Add(propertyGroup); _configService.DataFile.PropertyTable.AddRow(Details); } // Close the progress dialog. progressDialog.Close(); IsLoading = false; GoBackCommand.Execute(null); }
private async Task SaveTask() { if (Model.IsValid) { TaskDao dao = _taskMapper.Convert(Model); var obj = await _taskAPiService.SaveToDoItemAsync(dao); GoBackCommand.Execute(); } }
public IncomingRequestViewModel(IUnityContainer container) : base(container) { _messageService = container.Resolve <IMessageService>(); _fileManagerService = container.Resolve <IFileManagerService>(); InstructRequestCommand = new DelegateLogCommand( () => { Item.IsActual = true; Item.InstructionDate = DateTime.Now; //сохраняем запрос SaveCommand.Execute(null); //закрываем запрос GoBackCommand.Execute(null); }, () => Item.IsValid && Item.IsChanged && Item.Performers.Any()); RequestIsNotActualCommand = new DelegateLogCommand( () => { var dr = _messageService.ShowYesNoMessageDialog("Подтверждение", "Вы уверены, что запрос не актуален?", defaultYes: true); if (dr != MessageDialogResult.Yes) { return; } Item.IsActual = false; Item.Performers.Clear(); //сохраняем запрос if (Item.IsChanged) { SaveCommand.Execute(null); } //закрываем запрос GoBackCommand.Execute(null); }, () => Item.IsValid); OpenFolderCommand = new DelegateLogCommand( () => { if (string.IsNullOrEmpty(GlobalAppProperties.Actual.IncomingRequestsPath)) { _messageService.ShowOkMessageDialog("Информация", "Путь к хранилищу приложений не назначен"); return; } var path = _fileManagerService.GetPath(Item.Model.Document); Process.Start($"\"{path}\""); }); }
private async Task SaveCustomerAsync() { try { if (!WasModified) { GoBackCommand.Execute(null); return; } if (!Pages.Any(p => IsValid(p))) { ErrorMessage = "Unable to save customer"; return; } ErrorMessage = ""; Customer = Pages[0].Customer; Customer.Address = Pages[1].Address; Customer.Contact = Pages[2].Contact; Customer.Pool = Pages[3].Pool; Position?position = await Customer.Address.FullAddress.GetPositionAsync(); if (position.HasValue) { Customer.Latitude = position.Value.Latitude; Customer.Longitude = position.Value.Longitude; } var customerController = new CustomerController(); await customerController.ModifyWithChildrenAsync(Customer); OnPropertyChanged("Progress"); OnPropertyChanged("Percent"); Pages[3].NotifyPropertyChanged("ShowAddEquipment"); WasModified = false; ErrorMessage = "Save Customer Success"; OriginalCustomer = JsonConvert.SerializeObject(Customer, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }); } catch (Exception e) { Debug.WriteLine(e); ErrorMessage = $"Error: {e.Message}"; } }
/// <summary> /// Handle XButton events. /// </summary> private void OnCoreWindowPointerReleased(CoreWindow sender, PointerEventArgs args) { if (args.CurrentPoint.Properties.PointerUpdateKind == Windows.UI.Input.PointerUpdateKind.XButton1Released) { var popups = VisualTreeHelper.GetOpenPopups(Window.Current); if (popups.Count != 0) { return; } args.Handled = true; GoBackCommand.Execute(null); } else if (args.CurrentPoint.Properties.PointerUpdateKind == Windows.UI.Input.PointerUpdateKind.XButton2Released) { var popups = VisualTreeHelper.GetOpenPopups(Window.Current); if (popups.Count != 0) { return; } args.Handled = true; GoForwardCommand.Execute(null); } }
private void DispatcherOnAcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args) { var virtualKey = args.VirtualKey; var acceptedEventTypes = new[] { CoreAcceleratorKeyEventType.SystemKeyDown, CoreAcceleratorKeyEventType.KeyDown }; var acceptedVirtualKeys = new[] { (int)VirtualKey.Left, (int)VirtualKey.Right, 166, 167 }; if (acceptedEventTypes.Contains(args.EventType) && acceptedVirtualKeys.Contains((int)virtualKey)) { var coreWindow = Window.Current.CoreWindow; var downState = CoreVirtualKeyStates.Down; var menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState; var controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState; var shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState; var noModifiers = !menuKey && !controlKey && !shiftKey; var onlyAlt = menuKey && !controlKey && !shiftKey; if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt)) { // When the next key or Alt+Left are pressed navigate back args.Handled = true; GoBackCommand.Execute(null); } else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt)) { // When the next key or Alt+Right are pressed navigate forward args.Handled = true; GoForwardCommand.Execute(null); } } }
/// <summary> /// 当此页处于活动状态并占用整个窗口时,在每次 /// 击键(包括系统键,如 Alt 组合键)时调用。 用于检测页之间的键盘 /// 导航(即使在页本身没有焦点时)。 /// </summary> /// <param name="sender">触发事件的实例。</param> /// <param name="e">描述导致事件的条件的事件数据。</param> private void CoreDispatcher_AcceleratorKeyActivated(Windows.UI.Core.CoreDispatcher sender, AcceleratorKeyEventArgs e) { var virtualKey = e.VirtualKey; // 仅当按向左、向右或专用上一页或下一页键时才进一步 // 调查 if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || e.EventType == CoreAcceleratorKeyEventType.KeyDown) && (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || (int)virtualKey == 166 || (int)virtualKey == 167)) { CoreWindow coreWindow = Window.Current.CoreWindow; var downState = CoreVirtualKeyStates.Down; bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState; bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState; bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState; bool noModifiers = !menuKey && !controlKey && !shiftKey; bool onlyAlt = menuKey && !controlKey && !shiftKey; if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt)) { // 在按上一页键或 Alt+向左键时向后导航 e.Handled = true; GoBackCommand.Execute(null); } else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt)) { // 在按下一页键或 Alt+向右键时向前导航 e.Handled = true; GoForwardCommand.Execute(null); } } }
public CreateTaskPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, ITaskService taskAPiService) : base(navigationService, eventAggregator) { _taskAPiService = taskAPiService; _saveTaskCommand = new DelegateCommand(async() => await SaveTask(), CanSaveExecuted); _goBackCommand = new DelegateCommand(async() => { await NavigationService.GoBackAsync(); }); _deleteTaskCommand = new DelegateCommand(async() => { var result = await Application.Current.MainPage.DisplayAlert( "Delete Task", "Delete the selected task?", "Yes", "No"); if (result) { await _taskAPiService.DeleteToDoItemAsync(Model.ID.ToString()); GoBackCommand.Execute(); } }, () => { return(Model != null && Model.IsValid); }); _resetTaskCommand = new DelegateCommand(async() => { var obj = await _taskAPiService.FindByIdAsync(Model.ID.ToString()); if (obj == null) { Model.Name = string.Empty; Model.Description = string.Empty; Model.Start = DateTime.Now; Model.End = DateTime.Now.AddDays(30); } else { Model = _taskMapper.Convert(obj); } }, () => { return(Model != null); }); }
public OrderViewModel(IUnityContainer container) : base(container) { //сохранить заказ SaveOrderCommand = new DelegateLogCommand( () => { if (UnitOfWork.SaveChanges().OperationCompletedSuccessfully) { Item.AcceptChanges(); _unitsWrappers.AcceptChanges(); var changed = _unitsWrappers.ModifiedItems.ToList(); if (changed.Any()) { Container.Resolve <IEventAggregator>().GetEvent <AfterSaveOrderItemsEvent>().Publish(changed.Select(salesUnitOrderItem => salesUnitOrderItem.Model)); } } SaveOrderCommand.RaiseCanExecuteChanged(); }, () => { //юниты валидны var unitsIsValid = _unitsWrappers != null && _unitsWrappers.IsValid; if (!unitsIsValid) { return(false); } //заказ валиден var orderIsValid = Item != null && Item.IsValid && GroupsInOrder.Any(); if (!orderIsValid) { return(false); } //если нет плановых дат производства if (GroupsInOrder.SelectMany(x => x.Units).Any(x => x.EndProductionPlanDate == null)) { return(false); } //если нет позиций заказа if (GroupsInOrder.SelectMany(x => x.Units).Any(x => string.IsNullOrEmpty(x.OrderPosition))) { return(false); } //что-то изменилось return(_unitsWrappers.IsChanged || Item.IsChanged); }); RemoveOrderCommand = new DelegateLogCommand( () => { var dr = Container.Resolve <IMessageService>().ShowYesNoMessageDialog("Удаление", "Вы уверены, что хотите удалить этот заказ?"); if (dr != MessageDialogResult.Yes) { return; } var order = Item.Model; _unitsWrappers.ForEach(x => x.RejectChanges()); foreach (var groupInOrder in GroupsInOrder) { groupInOrder.EndProductionPlanDate = null; groupInOrder.SignalToStartProductionDone = null; groupInOrder.Order = null; groupInOrder.Units.ForEach(x => x.OrderPosition = string.Empty); } _unitsWrappers.ForEach(salesUnitOrderItem => salesUnitOrderItem.AcceptChanges()); if (UnitOfWork.RemoveEntity(order).OperationCompletedSuccessfully) { Container.Resolve <IEventAggregator>().GetEvent <AfterRemoveOrderEvent>().Publish(order); GoBackCommand.Execute(null); } }); AddGroupCommand = new DelegateLogCommand(AddGroupCommand_Execute, () => GroupsPotential.SelectedItem != null); RemoveGroupCommand = new DelegateLogCommand(RemoveGroupCommand_Execute, () => GroupsInOrder.SelectedItem != null); ShowProductStructureCommand = new DelegateLogCommand( () => { var salesUnit = GroupsPotential.SelectedUnit?.Model ?? GroupsPotential.SelectedGroup.Unit; var productStructureViewModel = new ProductStructureViewModel(salesUnit); Container.Resolve <IDialogService>().Show(productStructureViewModel, "Структура продукта"); }, () => GroupsPotential.SelectedItem != null); }