//public RelayCommand AddMarkFromDeviceCommand //{ // get // { // return addMarkFromDeviceCommand ?? // (addMarkFromDeviceCommand = new RelayCommand((o) => // { // AddMarkFromDeviceCommandMethod(); // } // )); // } //} public void AddMarkCommandMethod() { Models.Mark mark = new Models.Mark(); mark.MarkNumber = CurrnetMarks.Count > 0 ? CurrnetMarks.Last().MarkNumber + 1 : 1; ViewModels.AddMarkViewModel addMarkViewModel = new AddMarkViewModel(mark); addMarkViewModel.CurrentRoute = CurrentRoute; Views.AddMarkView addMarkView = new Views.AddMarkView(addMarkViewModel); MakeLogEntry(8, null, null, "open AddMark. Start adding mark"); if ((bool)addMarkView.ShowDialog()) { Models.Mark mark_to_base = Models.Mark.GetCopyOfMark(addMarkViewModel.CurrentMark); AddEntry <Models.Mark>(mark_to_base); CurrnetMarks.Add(mark_to_base); Models.Map map = new Models.Map() { MarkId = mark_to_base.Id, CoordX = 0, CoordY = 0, DefaultHeight = 0, DefaultWidth = 0 }; AddEntry <Models.Map>(map); UpdateMapVisual(); } else { MakeLogEntry(8, null, null, "open AddMark. Cancel adding mark"); } }
public void DeleteMarkMethod(Models.Mark SelectedItem) { MakeLogEntry(8, null, null, "open AddMark. Start deleting mark"); if (DeleteEntry <Models.Mark>(SelectedItem) == MessageBoxResult.Yes) { CurrnetMarks.Remove(CurrnetMarks.FirstOrDefault(o => o.Id == SelectedItem.Id)); UpdateMapVisual(); } else { MakeLogEntry(8, null, null, "open AddMark. Cancel deleting mark"); } }
public static Models.Mark GetCopyOfMark(Models.Mark entry_to_copy) { return(new Models.Mark() { Id = entry_to_copy.Id, AddingDate = entry_to_copy.AddingDate, DeletingDate = entry_to_copy.DeletingDate, EthalonTime = entry_to_copy.EthalonTime, EthalonWindow = entry_to_copy.EthalonWindow, IsDeleted = entry_to_copy.IsDeleted, MarkNumber = entry_to_copy.MarkNumber, MarkSerial = entry_to_copy.MarkSerial, Name = entry_to_copy.Name, Route = entry_to_copy.Route, RouteId = entry_to_copy.RouteId, }); }
public void EditMarkCommandMethod(Models.Mark SelectedItem) { if (SelectedItem == null || (CurrentUser.UserRoleId != 1 && CurrentUser.UserRoleId != 2)) { return; } Models.Mark mark_to_view = Models.Mark.GetCopyOfMark(SelectedItem); ViewModels.AddMarkViewModel addMarkViewModel = new AddMarkViewModel(mark_to_view); addMarkViewModel.CurrentRoute = CurrentRoute; Views.AddMarkView addMarkView = new Views.AddMarkView(addMarkViewModel); addMarkView.Owner = CurrentMarksView; MakeLogEntry(8, null, null, "open AddMark. Start editing mark"); if ((bool)addMarkView.ShowDialog()) { Models.Mark mark_to_base = Models.Mark.GetCopyOfMark(addMarkViewModel.CurrentMark); EditEntry <Models.Mark>(mark_to_base); UpdateMapVisual(); } else { MakeLogEntry(8, null, null, "open AddMark. Cancel editing mark"); } }
public AddMarkViewModel(Models.Mark mark) { CurrentMark = mark; }
public async void MarksDataGrid_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (CurrentUser != null && (CurrentUser.UserRoleId != 1 && CurrentUser.UserRoleId != 2)) { return; } if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) { P = e.GetPosition(sender as System.Windows.Controls.DataGrid); System.Windows.Controls.DataGrid MarksDataGrid = sender as System.Windows.Controls.DataGrid; if (Row_select < 0) { Row_select = GetCurrentRowIndex(e.GetPosition, MarksDataGrid); if (rowIndex < 0) { return; } } Row_want_to = GetCurrentRowIndex(e.GetPosition, MarksDataGrid); if (Row_select >= 0 && Row_want_to >= 0 && Row_select < CurrnetMarks.Count && Row_want_to < CurrnetMarks.Count && Row_select != Row_want_to) { System.Windows.Input.Mouse.SetCursor(System.Windows.Input.Cursors.Hand); NoteTextBlock.Text = "\"" + CurrnetMarks[Row_select].Name + "\" поместить вместо \"" + CurrnetMarks[row_want_to].Name + "\""; NoteTextBlock.Background = Brushes.Black; NoteTextBlock.Foreground = Brushes.White; NoteTextBlock.FontSize = 20; NoteTextBlock.VerticalAlignment = VerticalAlignment.Top; NoteTextBlock.HorizontalAlignment = HorizontalAlignment.Left; CurrentMarksView.MainGrid.Children.Remove(NoteTextBlock); CurrentMarksView.MainGrid.Children.Add(NoteTextBlock); Grid.SetRow(NoteTextBlock, 1); NoteTextBlock.Margin = new Thickness(P.X, P.Y, 0, 0); } else { CurrentMarksView.MainGrid.Children.Remove(NoteTextBlock); System.Windows.Input.Mouse.SetCursor(System.Windows.Input.Cursors.No); } } else { System.Windows.Controls.DataGrid MarksDataGrid = sender as System.Windows.Controls.DataGrid; if ((Row_select < 0 || Row_want_to < 0) || (Row_want_to == Row_select) || (Row_want_to == MarksDataGrid.Items.Count)) { SetRowStatmentDefault(); return; } // place where need change mark number Models.Mark changedProduct = CurrnetMarks[Row_select]; CurrnetMarks.RemoveAt(Row_select); CurrnetMarks.Insert(Row_want_to, changedProduct); SetRowStatmentDefault(); await Task.Run(() => { for (int i = 0; i < CurrnetMarks.Count; i++) { CurrnetMarks[i].MarkNumber = i + 1; EditEntry <Models.Mark>(CurrnetMarks[i]); } }); } }