public void Edit() { Window addEditWindow = new AddEditWindow(); addEditWindow.DataContext = new AddEditViewModel(SelectedUser, addEditWindow, false, MyUsers, true); addEditWindow.ShowDialog(); }
private void ConnectTo() { try { AddEditWindow addEditWindow = new AddEditWindow(); if (addEditWindow.model.ReturnCommand?.ToLower() == "ok") { if (client.IsConnected) { client.Disconnect(); } var customConfig = addEditWindow.model.SelectedItem; if (customConfig == null || !customConfig.CanTryConnect) { return; } client = new FluentFTP.FtpClient(customConfig.HostName, int.Parse(customConfig.Port), customConfig.UserName, customConfig.Password); client.Connect(); ListCombine(customConfig.RemoteFolder ?? ""); StatusText = "Connected"; } } catch (Exception exc) { ToolsLib.Tools.ExceptionLogAndShow(exc, "ConnectTo"); } }
private void OnButtonClick(object sender, RoutedEventArgs e) { switch (((Button)sender).Name) { case "buttonClose": Close(); break; case "buttonDelete": BSCEntities.SamplingViewModel.DeleteRecordFromRepo(_sampling.RowID); if (BSCEntities.SamplingViewModel.EditedEntity != null && BSCEntities.SamplingViewModel.EditedEntity.EditAction == EditAction.Delete) { RefreshGridSource(); } break; case "buttonEdit": AddEditWindow aew = new AddEditWindow("Sampling", false, _sampling.RowID); aew.ShowDialog(); if (!aew.Cancelled) { RefreshGridSource(); } break; } }
public void Edit() { var addEditWindow = new AddEditWindow("Edit Mod", SelectedModName); addEditWindow.addEditViewModel.RefreshMainResourcesAction = new Action(RefreshMainResources); addEditWindow.ShowDialog(); }
public void Add() { User user = new User(); Window addEditWindow = new AddEditWindow(); addEditWindow.DataContext = new AddEditViewModel(user, addEditWindow, true, MyUsers, true); addEditWindow.ShowDialog(); }
private void AddClientBtn_Click(object sender, RoutedEventArgs e) { AddEditWindow addEdit = new AddEditWindow(); this.Hide(); addEdit.ShowDialog(); listUser.ItemsSource = Context.Client.ToList(); this.Show(); }
/// <summary> /// Assigns the main page to the controller /// </summary> /// <param name="main"></param> public void assignMainPage(MainPage main) { mainPage = main; addEditWindow = new AddEditWindow(main); optionsPanelController = new OptionsPanel_Controller(main); alarmListPanelController = new AlarmListPanel_Controller(main); CrawlAudioFiles(); }
private void EditImplementation(object obj) { IsControlEnabled = false; AddEditWindow window = new AddEditWindow(_selectedPerson); window.ShowDialog(); IsControlEnabled = true; Persons = new ObservableCollection <Person>(StationManager.DataStorage.PersonsList); }
private void Button_Click(object sender, RoutedEventArgs e) { AddEditWindow aew; switch (((Button)sender).Name) { case "btnClose": Close(); break; case "btnEdit": aew = new AddEditWindow(isNew: false, f: _fisher, ((FisherGPS)gridAssignedGPS.SelectedItem).RowID); aew.ShowDialog(); if (!aew.Cancelled) { //gridAssignedGPS.Items.Refresh(); RefreshGridSource(); EnableAddButton(); } break; case "btnDelete": FisherGPS fg = (FisherGPS)gridAssignedGPS.SelectedItem; if (BSCEntities.FisherGPSViewModel.CanDeleteEntity(fg)) { Entities.BSCEntities.FisherGPSViewModel.DeleteRecordFromRepo(fg.RowID); RefreshGridSource(); } else { System.Windows.MessageBox.Show($"Cannot delete selected item because it is used in the sampling table", "Cannot delete", MessageBoxButton.OK, MessageBoxImage.Information); } //gridAssignedGPS.Items.Refresh(); break; case "btnAdd": aew = new AddEditWindow(isNew: true, f: _fisher, null); aew.ShowDialog(); if (!aew.Cancelled) { //gridAssignedGPS.ItemsSource = BSCEntities.FisherGPSViewModel.GetFisherGPSByFisher(_fisher); //gridAssignedGPS.Items.Refresh(); RefreshGridSource(); EnableAddButton(); } break; } }
private void AddConfig() { try { AddEditWindow addEditWindow = new AddEditWindow(); if ((addEditWindow?.model?.ReturnCommand?.ToLower() ?? "cancel") == "ok") { Configs.Add(addEditWindow.model.SelectedItem); StatusText = addEditWindow.model.SelectedItem.HostName + " added to config list."; } } catch (Exception exc) { ToolsLib.Tools.ExceptionLogAndShow(exc, "addconfig()"); } }
public bool EditNumberTranslation(NumberTranslation numberTranslation) { var addEditWindow = new AddEditWindow(); var addEditWindowViewModel = new AddEditWindowViewModel(numberTranslation); addEditWindow.DataContext = addEditWindowViewModel; if (addEditWindow.ShowDialog() == false) { return(false); } numberTranslation.Id = addEditWindowViewModel.NumberTranslation.Id; numberTranslation.FromNumber = addEditWindowViewModel.NumberTranslation.FromNumber; numberTranslation.ToNumber = addEditWindowViewModel.NumberTranslation.ToNumber; numberTranslation.Description = addEditWindowViewModel.NumberTranslation.Description; return(true); }
public NumberTranslation AddNumberTranslation() { var addEditWindow = new AddEditWindow(); var addEditWindowViewModel = new AddEditWindowViewModel(); addEditWindow.DataContext = addEditWindowViewModel; if (addEditWindow.ShowDialog() == false) { return(null); } var numberTranslation = new NumberTranslation(); numberTranslation.Id = addEditWindowViewModel.NumberTranslation.Id; numberTranslation.FromNumber = addEditWindowViewModel.NumberTranslation.FromNumber; numberTranslation.ToNumber = addEditWindowViewModel.NumberTranslation.ToNumber; numberTranslation.Description = addEditWindowViewModel.NumberTranslation.Description; return(numberTranslation); }
private void EditConfig() { if (ConfigData == null) { StatusText = "Select config for edit."; return; } try { AddEditWindow addEditWindow = new AddEditWindow(ConfigData); if ((addEditWindow?.model?.ReturnCommand?.ToLower() ?? "calncel") == "ok") { ConfigData.FromOtherItem(addEditWindow.model.SelectedItem); StatusText = "To use changes please reconnect."; } } catch (Exception exc) { ToolsLib.Tools.ExceptionLogAndShow(exc, "EditConfig()"); } }
private void OnButton_Click(object sender, RoutedEventArgs e) { string buttonName = ((Button)sender).Name; switch (buttonName) { case "buttonSubGrid1": switch (_entityType) { case "LandingSite": case "Gear": case "Fisher": SamplingHistoryWindow shw = new SamplingHistoryWindow(_entityType); shw.Owner = this; shw.ShowDialog(); break; case "GPS": GPSStatusWindow gsw = new GPSStatusWindow("gps_history"); gsw.Owner = this; gsw.Show(); break; } break; case "buttonSubGrid": switch (_entityType) { case "Fisher": FisherAndGPS fg = (FisherAndGPS)gridData.SelectedItem; FisherGPSWindow fgw = new FisherGPSWindow(fisher: fg.Fisher, readOnly: false, parentWindow: this); //FisherGPSWindow fgw = new FisherGPSWindow((Fisher)gridData.SelectedItem); fgw.ShowDialog(); if (!fgw.Cancelled && RefreshDataGridNeeded) { refreshDataGrid(); } break; case "GPS": GPSStatusWindow gsw = new GPSStatusWindow("assignment"); gsw.Owner = this; gsw.Show(); break; } //buttonSubGrid.IsEnabled = false; break; case "buttonAdd": AddEditWindow aew = new AddEditWindow(_entityType, true); aew.ShowDialog(); if (!aew.Cancelled) { refreshDataGrid(); } break; case "buttonEdit": aew = new AddEditWindow(_entityType, false, _entityID); aew.ShowDialog(); if (!aew.Cancelled) { refreshDataGrid(); } break; case "buttonDelete": string msgCannotDelete = ""; bool deleteSuccess = false; switch (_entityType) { case "Gear": if (BSCEntities.GearViewModel.CanDeleteEntity(Gear)) { BSCEntities.GearViewModel.DeleteRecordFromRepo(Gear.GearName); deleteSuccess = true; } else { msgCannotDelete = $"Cannot delete the gear '{Gear.GearName}' because it is already used by the database"; } break; case "Fisher": if (Entities.BSCEntities.FisherViewModel.CanDeleteEntity(Fisher)) { Entities.BSCEntities.FisherViewModel.DeleteRecordFromRepo(_entityID); deleteSuccess = true; } else { msgCannotDelete = $"Cannot delete the fisher '{Fisher.FisherName}' because it is already used by the database"; } break; case "LandingSite": if (BSCEntities.LandingSiteViewModel.CanDeleteEntity(LandingSite)) { Entities.BSCEntities.LandingSiteViewModel.DeleteRecordFromRepo(LandingSite.LandingSiteID); } else { msgCannotDelete = $"Cannot delete the GPS '{LandingSite.ToString()}' because it is already used by the database"; } break; case "GPS": if (Entities.BSCEntities.GPSViewModel.CanDeleteEntity(GPS)) { Entities.BSCEntities.GPSViewModel.DeleteRecordFromRepo(_entityID); deleteSuccess = true; } else { msgCannotDelete = $"Cannot delete the GPS '{GPS.ToString()}' because it is already used by the database"; } break; case "ProjectSetting": if (Entities.BSCEntities.ProjectSettingViewModel.CanDeleteEntity(ProjectSetting)) { Entities.BSCEntities.ProjectSettingViewModel.DeleteRecordFromRepo(ProjectSetting.ProjectID); deleteSuccess = true; } else { msgCannotDelete = $"Cannot delete the project '{ProjectSetting.ProjectName}' because it is already used by the database"; } break; } if (deleteSuccess) { //gridData.Items.Refresh(); refreshDataGrid(); } else { if (msgCannotDelete.Length > 0) { MessageBox.Show(msgCannotDelete, "Validation error", MessageBoxButton.OK, MessageBoxImage.Information); } } break; } }
private void InitCommands() { AddCommand = new DelegateCommand(() => { AddEditWindow aer = new AddEditWindow(); IRepositoryItem result = aer.Show(null); if (result != null) { if (SelectedItem != null) { result.Parent = SelectedItem; SelectedItem.Items.Add(result); } else { result.Parent = null; RepositoryItems.Add(result); } App.Log.Log(String.Format("В репозиторий добавлен элемент <{0}>", result)); OnPropertyChanged("IsEmptyList"); Save(); } }); RemoveCommand = new DelegateCommand(() => { if (SelectedItem == null) { return; } if (App.ShowQuestion("Вы действительно хотите удалить запись с именем '" + SelectedItem.Title + "'?") == System.Windows.MessageBoxResult.Yes) { IRepositoryItem parent = SelectedItem.Parent; if (parent != null) { parent.Items.Remove(SelectedItem); } else { RepositoryItems.Remove(SelectedItem); } App.Log.Log(String.Format("Из репозитория удалён элемент <{0}>", SelectedItem)); Save(); } }, (param) => { return(SelectedItem != null); }); EditCommand = new DelegateCommand(() => { if (SelectedItem == null) { throw new InvalidOperationException("EditCommand - SelectedItem == null"); } App.Log.Log(String.Format("Попытка изменения элемента репозитория: <{0}>", SelectedItem)); AddEditWindow aer = new AddEditWindow(); aer.Owner = App.Current.MainWindow; IRepositoryItem result = aer.Show(SelectedItem.Clone()); if (result != null) { IRepositoryItem parent = SelectedItem.Parent; if (parent != null) { int index = parent.Items.IndexOf(SelectedItem); if (index > 0) { parent.Items[index] = result; } SelectedItem = result; } else { SelectedItem = result; } App.Log.Log(String.Format("Изменённый элемент репозитория: <{0}>", result)); Save(); } }, (param) => { return(SelectedItem != null); }); LoadCommand = new DelegateCommand(() => { if (SelectedItem == null) { throw new InvalidOperationException("EditCommand - SelectedItem == null"); } if (SelectedItem.Type == RepositoryItemType.Group) { throw new ArgumentException("Выбрана не запись, а группа!"); } SqlViewModel = (SelectedItem as RepositoryItem).SqlViewModel; FuncSqlViewModelSelected?.Invoke(this, new SelectFuncSqlViewModelEventArgs(SelectedItem.Title, SqlViewModel)); App.Log.Log(String.Format("Выбран элемент репозитория: <{0}>", SelectedItem)); }, (param) => { return(SelectedItem is RepositoryItem); }); ImportCommand = new DelegateCommand(() => { if (RepositoryItems != null && RepositoryItems.Count > 0) { if (App.ShowQuestion("Очистить список перед импортом'?") == System.Windows.MessageBoxResult.Yes) { RepositoryItems.Clear(); } } Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.AddExtension = true; ofd.CheckFileExists = true; ofd.Filter = String.Format("Файл списка запросов (*{0})|*{0}", RequestsRepository.REPOSITORY_FILE_EXTENSION); ofd.FilterIndex = 0; bool?show = ofd.ShowDialog(Application.Current.MainWindow); if (show != null && show.HasValue && show.Value == true) { App.Log.Log("Попытка импорта списка запросов из файла '" + ofd.FileName + "'"); bool success = true; IList <IRepositoryItem> list = Common.RepositoryCommon.BaseDeserializer <List <IRepositoryItem> > .GzJsonDeSerialize( ofd.FileName, (e) => { success = false; App.ToLogException(e); App.ShowError(String.Format("Не удалось импортировать список запросов.\n\t{0}", e.Message), "ОШИБКА"); }); if (list != null) { var notImported = new List <IRepositoryItem>(); foreach (var item in list) { if (_repository.AddRepositoryItem(item) == false) { notImported.Add(item); } } int toImportCount = GetRequestsCountInList(list); int notImportedCount = GetRequestsCountInList(notImported); int allCount = GetRequestsCountInList(RepositoryItems); string message = String.Format("Завершён. Импортировано {0} запросов из списка. Не удалось импортировать {1} запросов. Всего сейчас в списке {2} запросов.", toImportCount - notImportedCount, notImportedCount, allCount); App.Log.Log(message); App.ShowInfo(message, "ИМПОРТ"); } else if (success) { string message = "Ничего не импортировано. Файл пуст!"; App.Log.Log(message); App.ShowInfo(message, "ИМПОРТ"); } } }); ExportCommand = new DelegateCommand(() => { Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog(); ofd.AddExtension = true; ofd.Filter = String.Format("Файл списка запросов (*{0})|*{0}", RequestsRepository.REPOSITORY_FILE_EXTENSION); ofd.FilterIndex = 0; bool?show = ofd.ShowDialog(Application.Current.MainWindow); if (show != null && show.HasValue && show.Value == true) { App.Log.Log("Попытка экспорта списка запросов в файл '" + ofd.FileName + "'"); bool success = true; Common.RepositoryCommon.BaseDeserializer <List <IRepositoryItem> > .GzJsonSerialize( RepositoryItems.ToList(), ofd.FileName, (e) => { success = false; App.ToLogException(e); App.ShowError(String.Format("Не удалось экспортировать список запросов.\n\t{0}", e.Message), "ОШИБКА"); }); if (success) { string message = String.Format("Экспортировано {0} запросов.", RepositoryItems.Count); App.Log.Log(message); App.ShowInfo(message, "ЭКСПОРТ"); } } }, (param) => { if (RepositoryItems == null) { return(false); } else { return(RepositoryItems.Count != 0); } }); }