private void OnTextChanged(object sender, EventArgs e) { var textBox = (System.Windows.Controls.TextBox)sender; FilePath = textBox.Text; FileSelected?.Invoke(this, EventArgs.Empty); }
public FileSelectionControl() { _viewModel = new ViewModel.FileSelection(this); _viewModel.FileSelected += (fn) => FileSelected?.Invoke(fn); _viewModel.DatabaseSelected += () => DatabaseSelected?.Invoke(); InitializeComponent(); }
private void ButtonSelectFile_Click(object sender, RoutedEventArgs e) { bool?result = dialog.ShowDialog(); if (result.HasValue && result.Value) { FileSelected?.Invoke(); } }
/// <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); } }
private void Files_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!SelectedItem.HasValue) { return; } FileSelected?.Invoke(this, new FileSelectedEventArgs(SelectedItem.Value)); }
private void CleanData() { Members = new ObservableCollection <YoungMember>(); MemberSelected = new YoungMember(); IdentityFile = new FileSelected(); RegisterFile = new FileSelected(); ErrorMinorSelected = string.Empty; ErrorIdentityFile = string.Empty; ErrorRegisterFile = string.Empty; }
private void OnFileSelected(int index) { string path = files[index]; if (FileSelected != null) { FileSelected.Invoke(path); } PlayerPrefs.SetString("currentDirectory", currentDirectory); }
public void FileButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Multiselect = false }; if (openFileDialog.ShowDialog() == true) { FileSelected?.Invoke(openFileDialog.FileName); } }
protected override void OnExecute(object parameter) { var openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Filter = "Apk Files (.apk)|*.apk"; Nullable <bool> result = openFileDialog.ShowDialog(); if (result == true) { FileSelected.Invoke(this, new FileSelectedEventArgs(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 SetDialogWithoutPreviousData() { bool?result = dialog.ShowDialog(); if (result.HasValue && result.Value) { FileSelected?.Invoke(); } else { Application.Current.Shutdown(); } }
private void btn_chooseWorld_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); ofd.DefaultExt = ".sav"; ofd.Filter = "Gnomoria Save Games (.sav)|*.sav"; ofd.InitialDirectory = dir; if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { FileSelected.TryRaise(this, ofd.FileName, TreatAll, AprilFool); } }
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 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; } }
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 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); }
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 RunFile() { if (currentFile != null) { if ((bool)currentFile["Invalid"]) { MessageBox.Show(string.Format(((string)FindResource("IllegalName")).Replace("\\n", "\r\r"), (string)currentFile["Name"]), "ioSender", MessageBoxButton.OK, MessageBoxImage.Error); } else { 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; } } }
public async Task <FileRequest> AddFile(string serviceDate, string serviceNumber) { FileSelected file = await SelectFile(); FileRequest requestFile = new FileRequest(); try { requestFile = new FileRequest { ServiceMiddlewareId = serviceNumber, ServiceDate = serviceDate, FileName = file.Name, FileContentType = MimeType(file.Extension), FileData = file.File }; } catch (Exception e) { ServiceLocator.Current.GetInstance <IExceptionService>().RegisterException(e); } return(requestFile); }
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(); } }
/// <summary> /// Initializes a new instance of the <see cref="ChooseFileMessage"/> class. /// </summary> /// <param name="callback">The callback when files are selected.</param> public ChooseFileMessage(FileSelected callback) : this(null, null, callback) { }
public void OnFileChosen(string fileSelectionPath) { FileSelected?.Invoke(fileSelectionPath); }
private async void List_SelectionChanged(object sender, SelectionChangedEventArgs e) { _cancelGetDetails.Cancel(false); _cancelGetDetails.Dispose(); _cancelGetDetails = new CancellationTokenSource(); if (_list.SelectedItem is DriveItem driveItem && driveItem.File != null) { try { SelectedFile = driveItem; FileSize = driveItem.Size ?? 0; LastModified = driveItem.LastModifiedDateTime?.LocalDateTime.ToString() ?? string.Empty; if (FileSelected != null) { FileSelected.Invoke(this, new FileSelectedEventArgs(driveItem)); } ThumbnailImageSource = null; VisualStateManager.GoToState(this, NavStatesFileReadonly, false); GraphServiceClient graphClient = await GraphServiceHelper.GetGraphServiceClientAsync(); if (graphClient != null) { Task <IDriveItemPermissionsCollectionPage> taskPermissions = graphClient.Drives[_driveId].Items[driveItem.Id].Permissions.Request().GetAsync(_cancelGetDetails.Token); IDriveItemPermissionsCollectionPage permissions = await taskPermissions; if (!taskPermissions.IsCanceled) { foreach (Permission permission in permissions) { if (permission.Roles.Contains("write") || permission.Roles.Contains("owner")) { VisualStateManager.GoToState(this, NavStatesFileEdit, false); break; } } Task <IDriveItemThumbnailsCollectionPage> taskThumbnails = graphClient.Drives[_driveId].Items[driveItem.Id].Thumbnails.Request().GetAsync(_cancelGetDetails.Token); IDriveItemThumbnailsCollectionPage thumbnails = await taskThumbnails; if (!taskThumbnails.IsCanceled) { ThumbnailSet thumbnailsSet = thumbnails.FirstOrDefault(); if (thumbnailsSet != null) { Thumbnail thumbnail = thumbnailsSet.Large; if (thumbnail.Url.Contains("inputFormat=svg")) { SvgImageSource source = new SvgImageSource(); using (Stream inputStream = await graphClient.Drives[_driveId].Items[driveItem.Id].Content.Request().GetAsync()) { SvgImageSourceLoadStatus status = await source.SetSourceAsync(inputStream.AsRandomAccessStream()); if (status == SvgImageSourceLoadStatus.Success) { ThumbnailImageSource = source; } } } else { ThumbnailImageSource = new BitmapImage(new Uri(thumbnail.Url)); } } } IsDetailPaneVisible = true; ShowDetailsPane(); } } } catch (Exception exception) { MessageDialog messageDialog = new MessageDialog(exception.Message); await messageDialog.ShowAsync(); } }
/// <summary> /// Initializes a new instance of the <see cref="ChooseFileMessage"/> class. /// </summary> /// <param name="sender">The message's original sender.</param> /// <param name="target">The message's intended target.</param> /// <param name="callback">The callback when files are selected.</param> public ChooseFileMessage(object sender, object target, FileSelected callback) : base(sender, target) { _callback = callback; }
/// <summary> /// Initializes a new instance of the <see cref="ChooseFileMessage"/> class. /// </summary> /// <param name="sender">The message's original sender.</param> /// <param name="callback">The callback when files are selected.</param> public ChooseFileMessage(object sender, FileSelected callback) : this(sender, null, callback) { }
public async Task <FileSelected> SelectFile() { FileSelected requestFile = new FileSelected(); try { if (await permissionService.CheckPermissions(Plugin.Permissions.Abstractions.Permission.Photos)) { var option = await dialogService.ShowListActionsAsync(null, AppResources.Cancel, null, AppResources.SelectedPhotoGalery, AppResources.PickDocument); if (option == AppResources.SelectedPhotoGalery) { var photo = await SelectedPhotoAsync(); if (photo != null) { string ex = Path.GetExtension(photo.Path); if (ex.Equals(".png", StringComparison.InvariantCultureIgnoreCase) || ex.Equals(".jpg", StringComparison.InvariantCultureIgnoreCase) || ex.Equals("jpeg", StringComparison.InvariantCultureIgnoreCase)) { if (await ValidateFile(new FileInfo(photo.Path).Length)) { requestFile = new FileSelected { Name = Path.GetFileName(photo.Path), Extension = ex, File = Convert.ToBase64String(File.ReadAllBytes(photo.Path)) }; } } else { await dialogService.ShowMessage("", "Formato de archivo no soportado"); } } } else if (option == AppResources.PickDocument) { FileData fileData = await CrossFilePicker.Current.PickFile(); await Task.WhenAll(Task.Delay(200)); if (fileData != null) { string ex = Path.GetExtension(fileData.FileName); if (ex.Equals(".pdf", StringComparison.InvariantCultureIgnoreCase)) { if (await ValidateFile(fileData.DataArray.Length)) { requestFile = new FileSelected { Name = fileData.FileName, Extension = ex, File = Convert.ToBase64String(fileData.DataArray) }; } } else { await dialogService.ShowMessage("", "Formato de archivo no soportado"); } } } } } catch (Exception e) { ServiceLocator.Current.GetInstance <IExceptionService>().RegisterException(e); } return(requestFile); }
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { provider.ReleaseStorage(); provider.ReleaseStream(); try { if (provider.ProviderItem.CanRead) { IAsyncResult asyncResult = null; if (provider.ProviderItem.IsFolder) { FolderSelected selectedDelegate = new FolderSelected(br.CurrentViewPlugin.FolderSelected); asyncResult = br.CurrentViewPlugin.ViewControl.BeginInvoke(selectedDelegate, provider, provider.ProviderItem); } else { FileSelected selectedDelegate = new FileSelected(br.CurrentViewPlugin.FileSelected); asyncResult = br.CurrentViewPlugin.ViewControl.BeginInvoke(selectedDelegate, provider, provider.ProviderItem); } asyncResult.AsyncWaitHandle.WaitOne(); } else br.CurrentViewPlugin.Reset(); } catch (Exception) { } }
private void OnFileSelected(FileInfo fileInfo) { FileSelected?.Invoke(fileInfo); }
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; } }