void OnProgramExeTextChanged(object sender, RoutedEventArgs args) { SDCCProgram prog = GetCurrentProgram(); if (prog != null) { prog.ExecutablePath = programExeTextBox.Text; } }
void ExistingProgComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { var programs = CApplicationSettings.Instance.GetAllDCCProgramsDefined(); SDCCProgram prog = null; string sSelected = (existingProgComboBox.SelectedItem as ComboBoxItem).Content as string; if (programs.TryGetValue(sSelected, out prog)) { nameTextBox.Text = prog.Name; execTextBox.Text = prog.ExecutablePath; } }
void OnRemoveFileClicked(object sender, RoutedEventArgs args) { SDCCProgram currentProgram = GetCurrentProgram(); string selectedItemName = (startupFileListView.SelectedItem as ListViewItem).Content as string; if (currentProgram.StartupFiles.ContainsKey(selectedItemName)) { currentProgram.StartupFiles.Remove(selectedItemName); } UpdateListViews(); }
void OnRemoveProgramClicked(object sender, RoutedEventArgs args) { SDCCProgram prog = GetCurrentProgram(); if (prog != null) { CDCCDefinition def = GetCurrentDefinition(); if (def != null) { def.Programs.Remove(prog.Name); UpdateListViews(); } } }
private bool ApplyCurrentSettings() { if (!ValidateDefs()) { CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.DCCDefChangesNotSaved); return(false); } if (GetCurrentProgram() != null) { if (File.Exists(programExeTextBox.Text)) { SDCCProgram pro = GetCurrentProgram(); pro.ExecutablePath = programExeTextBox.Text; } else { CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.CommonPathDoesntExist + " (" + programExeTextBox.Text + ")"); } if (GetCurrentStartupFile() != null) { if (File.Exists(startupFileTextBox.Text)) { SStartupFile file = GetCurrentStartupFile(); file.SetFilePath(startupFileTextBox.Text); file.Copy = (bool)copyFileCheckbox.IsChecked; file.LaunchWithProgram = (bool)launchWithProgCheckbox.IsChecked; } else { CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.CommonPathDoesntExist + " (" + startupFileTextBox.Text + ")"); } } UpdateListViews(); } ApplyAllChanges(); return(true); }
int AddFileEntryCallback(TextBox box, System.Windows.Forms.DialogResult res) { if (GetCurrentProgram() != null) { SDCCProgram prog = GetCurrentProgram(); if (prog.StartupFiles.ContainsKey(box.Text)) { CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.DCCDefDuplicateEntry + " " + box.Text); return(0); } SStartupFile newFile = new SStartupFile(box.Text, ""); prog.StartupFiles.Add(newFile.Name, newFile); RefreshFilesListView(); } return(0); }
bool AddProgramEntryCallback(TextBox box, System.Windows.Forms.DialogResult res) { if (GetCurrentDefinition() != null) { CDCCDefinition def = GetCurrentDefinition(); if (def.Programs.ContainsKey(box.Text)) { CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.DCCDefDuplicateEntry + " " + box.Text); return(false); } SDCCProgram prog = new SDCCProgram(); prog.Name = box.Text; def.Programs.Add(prog.Name, prog); UpdateListViews(); } return(true); }
void OnAddNewProgramClicked(object sender, RoutedEventArgs args) { //CUserInteractionUtils.AskUserToEnterString(Properties.Resources.DCCDefEnterProgName, AddProgramEntryCallback); var grid = new Grid(); for (int i = 0; i < 5; i++) { var rowDef = new RowDefinition(); rowDef.Height = new GridLength(12, GridUnitType.Star); grid.RowDefinitions.Add(rowDef); } // Label var label = new Label(); label.Content = "Either enter name or choose existing"; // LOCALIZE label.SetValue(Grid.RowProperty, 0); grid.Children.Add(label); // Combobox var comboBox = new ComboBox(); comboBox.SetValue(Grid.RowProperty, 1); // items in combobox var progs = CApplicationSettings.Instance.GetAllDCCProgramsDefined(); foreach (var prog in progs.Keys) { var item = new ComboBoxItem(); item.Content = prog; comboBox.Items.Add(item); } grid.Children.Add(comboBox); // Name label label = new Label(); label.Content = "Name"; // LOCALIZE label.SetValue(Grid.RowProperty, 2); grid.Children.Add(label); // text box var textBox = new TextBox(); textBox.Text = "New Program"; textBox.SetValue(Grid.RowProperty, 3); grid.Children.Add(textBox); // Ok Cancel var okCancGrid = new Grid(); okCancGrid.SetValue(Grid.RowProperty, 4); var colDef = new ColumnDefinition(); colDef.Width = new GridLength(50, GridUnitType.Star); okCancGrid.ColumnDefinitions.Add(colDef); colDef = new ColumnDefinition(); colDef.Width = new GridLength(50, GridUnitType.Star); okCancGrid.ColumnDefinitions.Add(colDef); var okBtn = new Button(); okBtn.Content = Properties.Resources.CommonOK; okBtn.SetValue(Grid.ColumnProperty, 0); okCancGrid.Children.Add(okBtn); var cancButton = new Button(); cancButton.Content = Properties.Resources.CommonCancel; cancButton.SetValue(Grid.ColumnProperty, 1); okCancGrid.Children.Add(cancButton); grid.Children.Add(okCancGrid); var window = new Window(); window.SizeToContent = SizeToContent.WidthAndHeight; window.Content = grid; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.Title = "Add new program"; // LOCALIZE comboBox.SelectionChanged += delegate { textBox.IsEnabled = false; }; okBtn.Click += delegate { // If there's a wrong entry, keep the window open bool bCloseWindow = false; if (comboBox.SelectedIndex != -1) { var programs = CApplicationSettings.Instance.GetAllDCCProgramsDefined(); string sSelected = (comboBox.SelectedItem as ComboBoxItem).Content as string; var curDef = GetCurrentDefinition(); if (curDef == null) { return; } if (!curDef.Programs.ContainsKey(sSelected)) { SDCCProgram prog = null; if (programs.TryGetValue(sSelected, out prog)) { curDef.Programs.Add(prog.Name, prog); UpdateDataGrid(); UpdateListViews(); bCloseWindow = true; } } else { CUserInteractionUtils.ShowErrorMessageBox(Properties.Resources.DCCDefDuplicateEntry + " " + sSelected); } } else { if (textBox.Text.Length > 0) { bCloseWindow = AddProgramEntryCallback(textBox, System.Windows.Forms.DialogResult.OK); } else { CUserInteractionUtils.ShowErrorMessageBox("Please enter a name or choose an existing program from the dropdown!"); // LOCALIZE } } if (bCloseWindow) { window.Close(); } else { comboBox.SelectedIndex = -1; textBox.IsEnabled = true; } }; cancButton.Click += delegate { window.Close(); }; window.ShowDialog(); }
void OnBrowseDirClicked(object sender, RoutedEventArgs e) { // TODO: Remimplement System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog(); // Error checking can be omitted since there are only valid entries to begin with ComboBoxItem item = (ComboBoxItem)dccProgramDropdown.SelectedItem; string progName = (string)item.Content; CDCCDefinition prog = CApplicationSettings.Instance.GetDCCProgram(progName); if (prog != null) { string filter = ""; int j = 0; foreach (string key in prog.Programs.Keys) { SDCCProgram program = prog.GetProgram(key); int i = 0; foreach (string fileKey in program.StartupFiles.Keys) { SStartupFile file = program.GetFile(fileKey); if (i == 0) { filter += program.Name + " Files|"; } filter += "*." + file.Extension; if (i < program.StartupFiles.Count - 1) { filter += ";"; } ++i; } // TODO: What if there are two progs but only one startup? if (j < prog.Programs.Count - 1) { filter += "|"; } ++j; } dialog.Filter = filter; } dialog.InitialDirectory = (string)CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString(); System.Windows.Forms.DialogResult res = dialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.Cancel) { if (saveFileTextBox.Text != CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString()) { return; } string sRootPath = (string)CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString(); string sGameFolder = (string)CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString(); sGameFolder = sGameFolder == null ? "" : sGameFolder; SetDesiredSavePath(sGameFolder + "\\Objects\\"); } else { SetDesiredSavePath(dialog.FileName); } }