/// <summary> /// Whenever the View is unloaded, we want to cancel any edit operation /// that is in progress. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserControl_Unloaded(object sender, RoutedEventArgs e) { logger.Debug("UserControl unloading."); if (IsInEditMode) { logger.Debug("IsInEditMode is true during unload. Canceling edit."); ((IEditableCollectionView)_departmentsView).CancelEdit(); DepartmentsDataGrid.CancelEdit(); IsInEditMode = false; } }
private void DepartmentsDataGrid_DragDrop(object sender, DragEventArgs e) { Point clientPoint = DepartmentsDataGrid.PointToClient(new Point(e.X, e.Y)); if (e.Effect == DragDropEffects.Move) { //int DepartmentID = (int)e.Data.GetData(typeof(int)); var hittest = DepartmentsDataGrid.HitTest(clientPoint.X, clientPoint.Y); if (hittest.ColumnIndex != -1 && hittest.RowIndex != -1) { AdminFunctionsEdit.ChangeDepartment(CurrentFunctionID, Convert.ToInt32(DepartmentsDataGrid.Rows[hittest.RowIndex].Cells["DepartmentID"].Value)); AdminFunctionsEdit.Save(); InfiniumTips.ShowTip(this, 50, 85, "Обязанность перенесена в отдел \"" + DepartmentsDataGrid.Rows[hittest.RowIndex].Cells["DepartmentName"].Value.ToString() + "\"", 1700); } } }
/// <summary> /// The constructor for the DepartmentsView. Wires up all the necessary /// objects and events needed by this View. /// </summary> /// <param name="presenter"></param> /// <param name="eventAggregator"></param> /// <param name="configurationService"></param> public DepartmentsView(DepartmentsPresenter presenter, IEventAggregator eventAggregator, IConfigurationService configurationService) : this() { _presenter = presenter; _presenter.View = this; _eventAggregator = eventAggregator; _configurationService = configurationService; logger.Debug("Subscribing to ShellRefreshRequestedEvent."); ShellRefreshRequestedEvent shellRefreshRequestedEvent = _eventAggregator.GetEvent <ShellRefreshRequestedEvent>(); shellRefreshRequestedEvent.Subscribe(OnShellRefreshRequested, ThreadOption.UIThread); // Hook into the CanExecuteEvent of the DataGrid so that we can look for // when user tries to Delete DepartmentsDataGrid.AddHandler(CommandManager.CanExecuteEvent, new CanExecuteRoutedEventHandler(OnCanExecuteRoutedEventHandler), true); }