public FileSelectionControl() { _viewModel = new ViewModel.FileSelection(this); _viewModel.FileSelected += (fn) => FileSelected?.Invoke(fn); _viewModel.DatabaseSelected += () => DatabaseSelected?.Invoke(); InitializeComponent(); }
private void OnTextChanged(object sender, EventArgs e) { var textBox = (System.Windows.Controls.TextBox)sender; FilePath = textBox.Text; FileSelected?.Invoke(this, EventArgs.Empty); }
private void ButtonSelectFile_Click(object sender, RoutedEventArgs e) { bool?result = dialog.ShowDialog(); if (result.HasValue && result.Value) { FileSelected?.Invoke(); } }
private void Files_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!SelectedItem.HasValue) { return; } FileSelected?.Invoke(this, new FileSelectedEventArgs(SelectedItem.Value)); }
/// <summary> /// Вызов события смены выбранного для скачивания файла /// с передачей имени радиокнопки /// </summary> /// <param name="s"></param> /// <param name="e"></param> private void OnCheckedChanged(object s, EventArgs e) { var rb = s as RadioButton; if (rb.Checked) { FileSelected?.Invoke(null, rb.Name); } }
public void FileButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Multiselect = false }; if (openFileDialog.ShowDialog() == true) { FileSelected?.Invoke(openFileDialog.FileName); } }
/// <summary> /// method called when a button is pressed. Changes the selected item in the list and /// updates the selected variable /// </summary> /// <param name="button">Button that was just pressed</param> public void ChildClickHandler(UIComponent clickedChild) { if (selectedChild is Button) { selectedChild.Selected = false; } if (clickedChild is Button) { selectedChild = (Button)clickedChild; selectedChild.Selected = true; } FileSelected?.Invoke(this); }
private void ButtonClick(object sender, EventArgs e) { DialogResult dr = _dialog.ShowDialog(); if (dr == DialogResult.OK) { _textBox.Text = _dialog.FileName; if (FileSelected != null) { FileSelected.Invoke(sender, e); } } }
private void SetDialogWithoutPreviousData() { bool?result = dialog.ShowDialog(); if (result.HasValue && result.Value) { FileSelected?.Invoke(); } else { Application.Current.Shutdown(); } }
private void DownloadRun_Click(object sender, RoutedEventArgs e) { if (currentFile != null && MessageBox.Show(string.Format((string)FindResource("DownloandRun"), (string)currentFile["Name"]), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes) { var model = DataContext as GrblViewModel; using (new UIUtils.WaitCursor()) { bool?res = null; CancellationToken cancellationToken = new CancellationToken(); Comms.com.PurgeQueue(); model.SuspendProcessing = true; model.Message = string.Format((string)FindResource("Downloading"), (string)currentFile["Name"]); GCode.File.AddBlock((string)currentFile["Name"], CNC.Core.Action.New); new Thread(() => { res = WaitFor.AckResponse <string>( cancellationToken, response => AddBlock(response), a => model.OnResponseReceived += a, a => model.OnResponseReceived -= a, 400, () => Comms.com.WriteCommand(GrblConstants.CMD_SDCARD_DUMP + (string)currentFile["Name"])); }).Start(); while (res == null) { EventUtils.DoEvents(); } model.SuspendProcessing = false; GCode.File.AddBlock(string.Empty, CNC.Core.Action.End); } model.Message = string.Empty; if (Rewind) { Comms.com.WriteCommand(GrblConstants.CMD_SDCARD_REWIND); } FileSelected?.Invoke("SDCard:" + (string)currentFile["Name"], Rewind); Comms.com.WriteCommand(GrblConstants.CMD_SDCARD_RUN + (string)currentFile["Name"]); Rewind = false; } }
private void HandleLoadButton(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(Model.FilePath)) { return; } var options = new ParsingOptions { DiscardUpdateFields = Model.DiscardUpdateFields, DiscardUnknownEntities = Model.DiscardUnknownEntities }; FileSelected?.Invoke(Model.FilePath, options); }
void fileTree_NodeMouseDoubleClick(object sender, TreeEventArgs e) { if (FileSelected != null) { FileNode fileNode = e.Node as FileNode; if (fileNode != null) { if (resourceProvider.exists(fileNode.FilePath)) { FileSelected.Invoke(this, fileNode.FilePath); } } } }
private void OnFileSelected(int index) { string path = _filesItem[index]; if (FileSelected != null) { FileSelected.Invoke(path); } _currentFile = Path.GetFileName(path); _inputFieldFile.text = _currentFile; Destroy(_instance); }
public void FileDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length == 1) { FileSelected?.Invoke(files.First()); } else { MessageBox.Show("Перетащите один файл"); } } }
private void dgrSDCard_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (currentFile != null) { if ((bool)currentFile["Invalid"]) { MessageBox.Show(string.Format("File: \"{0}\"\r\r!,?,~ and SPACE is not supported in filenames, please rename.", (string)currentFile["Name"]), "Unsupported characters in filename", MessageBoxButton.OK, MessageBoxImage.Error); } else { FileSelected?.Invoke("SDCard:" + (string)currentFile["Name"]); Comms.com.WriteCommand(GrblConstants.CMD_SDCARD_RUN + (string)currentFile["Name"]); } } }
private void Browse_OnClick(object sender, RoutedEventArgs e) { var openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = false; openFileDialog.AddExtension = true; openFileDialog.DefaultExt = "wav"; openFileDialog.Filter = "Waveform | *.wav"; var dialogResult = openFileDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { var selectedFilename = openFileDialog.FileName; SelectedFilename = selectedFilename; FileSelected?.Invoke(this, new FileSelectEventArgs(selectedFilename)); } }
private void HookKeyDown(object sender, RawKeyEventArgs args) { Key key = args.Key; if (!_open) { if (key == _openKey) { ShowPlayer(); } return; } if (key == Key.Escape) { HidePlayer(); return; } if ((int)args.Key < 44 || (int)args.Key > 69) { // Not inside ABC range return; } if (_currentFolder.SubCategories != null && _currentFolder.SubCategories.ContainsKey(key)) { FolderEntry entry = _currentFolder.SubCategories[key]; _currentFolder = entry; if (!string.IsNullOrEmpty(_currentFolder.Path)) { _currentPath = Path.Combine(_currentPath, _currentFolder.Path); } RefreshView(); return; } else if (_currentFolder.Entries != null && _currentFolder.Entries.ContainsKey(key)) { FileSelected?.Invoke(Path.Combine(_currentPath, _currentFolder.Entries[key].File)); HidePlayer(); } }
private void Browse(object sender, RoutedEventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.DefaultExt = "txt"; dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; dlg.Multiselect = false; DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK) { FilePath = dlg.FileName; BindingExpression be = GetBindingExpression(FilePathProperty); if (be != null) { be.UpdateSource(); } FileSelected?.Invoke(this, EventArgs.Empty); } } }
private void SetFileDialog() { dialog.Filter = "Файлы php | *.php"; if (File.Exists(Data.FILE)) { try { string[] data = File.ReadAllLines(Data.FILE); if (data.Length != 1) { throw new FileFormatException(); } string file = data[0]; if (!File.Exists(file)) { throw new FileNotFoundException(); } if (Path.GetExtension(file) != ".php") { throw new FileFormatException(); } dialog.InitialDirectory = Path.GetDirectoryName(file); dialog.FileName = file; } catch (Exception) { SetDialogWithoutPreviousData(); return; } FileSelected?.Invoke(); } else { SetDialogWithoutPreviousData(); } }
protected override void OnClick(EventArgs e) { base.OnClick(e); FileSelected?.Invoke(Filename); }
private void OnFileSelected(FileInfo fileInfo) { FileSelected?.Invoke(fileInfo); }
protected void OnFileSelected(FileMenuArgs args) => FileSelected?.Invoke(this, args);
private void cmdFile_Click(object sender, RoutedEventArgs e) { Models.CalendarFile aFile = (Models.CalendarFile)((Button)sender).Tag; FileSelected?.Invoke(aFile); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { switch (SelectionType) { case SelectionTypeEnum.File: OpenFileDialog ofp = new OpenFileDialog(); ofp.InitialDirectory = Settings.Instance.ProjectLocation; ofp.DefaultExt = "shader"; ofp.Filter = "Voxel.Net Shader file (*.shader)|*.shader"; ofp.Multiselect = false; if (ofp.ShowDialog().GetValueOrDefault(false)) { if (ShouldBeInProject) { if (ofp.FileName.StartsWith(Settings.Instance.ProjectLocation)) { FileName = ofp.FileName; FileSelected?.Invoke(this, ofp.FileName); } else { MessageBox.Show( "You must select a file that is in the Project Directory (see Project Preferences)", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { FileName = ofp.FileName; FileSelected?.Invoke(this, ofp.FileName); } } break; case SelectionTypeEnum.Folder: FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.SelectedPath = FileName; if (fbd.ShowDialog() == DialogResult.OK) { if (ShouldBeInProject) { if (fbd.SelectedPath.StartsWith(Settings.Instance.ProjectLocation)) { FileName = fbd.SelectedPath; FileSelected?.Invoke(this, fbd.SelectedPath); } else { MessageBox.Show( "You must select a folder that is in the Project Directory (see Project Preferences)", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { FileName = fbd.SelectedPath; FileSelected?.Invoke(this, fbd.SelectedPath); } } break; } }
private void FileItem_Click(object sender, EventArgs e) { FileSelected?.Invoke(this, (sender as ToolStripMenuItem).Tag as FileInfo); }