private void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e) { TextBoxWithButton tb = e.Source as TextBoxWithButton; if (tb != null) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = tb.Text; ofd.Filter = e.Parameter?.ToString(); if (ofd.ShowDialog() == true) { tb.Text = ofd.FileName; } } }
public NewProjectWindow() { Title = "New project"; Padding = new Padding(8); MinimumSize = new Size(512, 160); Resizable = false; Content = new StackLayout() { Style = "vertical", Spacing = 8, Items = { new StackLayoutItem(propertiesPanel = new PropertiesListBase()) { Expand = true }, new StackLayoutItem(new StackLayout() { Style = "horizontal", Spacing = 8, Padding = new Padding(0, 8, 0, 0), Items = { null, (confirmButton = new Button(OnConfirm) { Text = "OK", Image = Resources.GetIcon("CheckGreen.ico", 16) }), (cancelButton = new Button(OnCancel) { Text = "Cancel", Image = Resources.GetIcon("CloseRed.ico", 16) }) } }) { Expand = false } } }; folderDialog = new SelectFolderDialog() { Title = "Project folder", //Directory = EtoEnvironment.GetFolderPath(EtoSpecialFolder.Documents) }; propertiesPanel.AddRow("Project name", nameBox = new TextBox()); propertiesPanel.AddRow("Description", descriptionBox = new TextBox()); propertiesPanel.AddRow("Folder", folderBox = new TextBoxWithButton() { ControlEnabled = false }); propertiesPanel.CompleteRows(); AbortButton = cancelButton; DefaultButton = confirmButton; folderBox.ButtonClick += SelectFolder; }
void test() { TextBoxWithButton textBoxWithButton = new TextBoxWithButton(); }
public SettingsWindow() { #region Main Layout Init Title = "Settings"; Padding = new Padding(8); MinimumSize = new Size(512, 386); Content = new StackLayout() { Style = "vertical", Items = { new StackLayoutItem(tabs = new TabControl()) { Expand = true }, new StackLayoutItem(new StackLayout() { Style = "horizontal", Spacing = 8, Padding = new Padding(0, 8, 0, 0), Items = { null, (DefaultButton = new Button(OnConfirm) { Text = "OK", Image = Resources.GetIcon("CheckGreen.ico", 16) }), (AbortButton = new Button(OnCancel) { Text = "Cancel", Image = Resources.GetIcon("CloseRed.ico", 16) }) } }) { Expand = false } } }; #endregion #region Tab Initialization #region General tabs.Pages.Add(new TabPage() { Text = "General", Content = new Scrollable() { Content = new StackLayout() { Style = "vertical", Spacing = 4, Items = { (generalOpenLastProject = new CheckBox() { Text = "Open most recent project on startup" }) } } } }); #endregion #region Campaign Preview Mode tabs.Pages.Add(new TabPage() { Text = "In-game campaign preview", Content = new Scrollable() { Content = new StackLayout() { Style = "vertical", Spacing = 4, Items = { (previewModeInfoLabel = new Label() { Text = "The preview mode requires the AdventureMaker mod to be installed.", TextColor = Colors.Blue }), "Select the method that will be used to run the game:", (previewModeRunMethod = new RadioButtonList() { Style = "no-padding", Orientation = Orientation.Vertical, Spacing = new Size(0, 2), Items = { "Use steam:// links (if you own the game on steam)", "Open game executable (for drm-free distance players)", } }), (previewModeRunExecutable = new TextBoxWithButton()), (previewModeEnableRemoteConsole = new CheckBox() { Text = "Intercept log messages from the game (using named memory pipes)", }) } } } }); #endregion #endregion previewModeRunExecutable.ButtonClick += () => { using OpenFileDialog dialog = new OpenFileDialog() { Title = "Select the Distance game executable", Filters = { Constants.DIALOG_FILTER_ANY } }; if (dialog.ShowDialog(this) == DialogResult.Ok) { previewModeRunExecutable.Text = dialog.FileName; } }; previewModeRunMethod.SelectedIndexChanged += (sender, e) => previewModeRunExecutable.Enabled = previewModeRunMethod.SelectedIndex == 1; previewModeInfoLabel.Font = new Font(previewModeInfoLabel.Font.Family, previewModeInfoLabel.Font.Size, FontStyle.Bold); }