private void btnMessage_Comment_Browse_Click(object sender, RoutedEventArgs e) { try { ClGlobul.CommentMessagesList.Clear(); txtCommentMessage.IsReadOnly = true; Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { txtCommentMessage.Text = dlg.FileName.ToString(); } try { ClGlobul.CommentMessagesList = GlobusFileHelper.ReadFile(txtCommentMessage.Text.Trim()); } catch (Exception ex) { GlobusLogHelper.log.Info(" Please Select File "); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error :" + ex.StackTrace); } }
// Get the recipe xml file public void Load() { // Show file dialog Microsoft.Win32.OpenFileDialog LoadRecipeDialog = new Microsoft.Win32.OpenFileDialog(); LoadRecipeDialog.DefaultExt = ".xml"; Nullable<bool> result = LoadRecipeDialog.ShowDialog(); if (result == true) { // Open document string filename = LoadRecipeDialog.FileName; string ext = System.IO.Path.GetExtension(filename); // Check if file is of type xml if (ext != ".xml") { MessageBox.Show("Invalid file type selected. \n Please open a xml recipe file"); LoadRecipeDialog.ShowDialog(); } else { ParseRecipeFile(filename); } } }
private void btLoad_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.FileOk += dialog_FileOk; dialog.ShowDialog(); }
private void ChoosePackageDialog() { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".AGT"; // Default file extension dlg.Filter = "Agent Package (.agt)|*.agt"; // Filter files by extension // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document PackageSource = dlg.FileName; ICSharpCode.SharpZipLib.Zip.FastZip fz = new FastZip(); var root = System.IO.Path.Combine(System.IO.Path.GetTempPath(), (Guid.NewGuid().ToString())); fz.ExtractZip(PackageSource, root, FastZip.Overwrite.Always, null, null, null, true); PackageFile = System.IO.Path.Combine(root, "package.json"); if (System.IO.File.Exists(PackageFile)) { var cnt = System.IO.File.ReadAllText(PackageFile); Contents = cnt; } } }
//<< -------------------------- >>// private void btnBrowse_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".jpg"; dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document string filename = dlg.FileName; lblFilename.Content = filename; imgCategoryImage.Source = new BitmapImage(new Uri(filename)); } }
private void BT_AddImage_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".jpeg"; dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; Nullable<bool> result = dialog.ShowDialog(); if (result == true) { CB_Images.Items.Add(dialog.FileName.ToString()); IMG_SelectedImage.Source = CloneImage(dialog.FileName.ToString()); imageSource.Add(dialog.FileName.ToString()); imageCaptions.Add(""); if( (CB_Images.Items.Count-1) == 0 ) { CB_Images.SelectedIndex = 0; } else { CB_Images.SelectedIndex = CB_Images.Items.Count - 1; } } }
private void OnCommand() { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); //dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".jws"; // Default file extension dlg.Filter = "Jade Workspace files (.jws)|*.jws"; // Filter files by extension dlg.CheckFileExists = true; dlg.CheckPathExists = true; // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; try { JadeData.Workspace.IWorkspace workspace = JadeData.Persistence.Workspace.Reader.Read(filename); _viewModel.Workspace = new JadeControls.Workspace.ViewModel.Workspace(workspace); } catch (System.Exception e) { } } }
private void menuItemFileOpen_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog openXmlFileDialog = new Microsoft.Win32.OpenFileDialog(); openXmlFileDialog.DefaultExt = "xml"; openXmlFileDialog.Filter = "XML(.xml)|*.xml"; //show dialog Nullable<bool> result = openXmlFileDialog.ShowDialog(); //wait the result if (result == true && openXmlFileDialog.FileName != "") { try { //http://blog.csdn.net/zengjibing/archive/2009/01/16/3797837.aspx XmlDocument answerXmlSource = new XmlDocument(); answerXmlSource.Load(openXmlFileDialog.FileName); XmlDataProvider answerXmlprovider = this.FindResource("answerXmlDoc") as XmlDataProvider; answerXmlprovider.Document = answerXmlSource; answerXmlprovider.XPath = "/ArrayOfQuestion/Question"; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
void AddDependency(object pSender, RoutedEventArgs pEvents) { var lDialog = new Microsoft.Win32.OpenFileDialog() { Title = "Choose dependency Assembly", CheckFileExists = true, Filter = "Assemblies|*.dll;*.exe;*.winmd|All Files|*.*", Multiselect = true }; if (lDialog.ShowDialog() == true) { foreach (string lName in lDialog.FileNames) { // Check if the dependency is already on the list. var lSameLib = ( from ListViewItem lItem in DependencyList.Items where lItem.Content.Equals(lName) select lItem); if (lSameLib.Count() == 0) { ListViewItem lEntry = new ListViewItem(); lEntry.Content = lName; DependencyList.Items.Add(lEntry); } } } }
public FindFileDialogue(string filter) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension switch (filter) { case "csv": dlg.DefaultExt = ".csv"; dlg.Filter = "CSV Files (*.csv)|*.csv|All Files |*.*"; break; } // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document string filename = dlg.FileName; LocationOfFile = filename; } }
public static IronPythonEngine.Types.Set Load() { try { var openFileDialog = new Microsoft.Win32.OpenFileDialog(); var set = new IronPythonEngine.Types.Set(10); openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { using (var stream = System.IO.File.OpenText(openFileDialog.FileName)) { string line; while ((line = stream.ReadLine()) != null) { var d = Convert.ToDouble(line); set.Add(d); } } return set; } } catch (Exception ex) { MainWindow.ErrorDialog(ex.Message); } return new IronPythonEngine.Types.Set(0); }
private void ex1FileBrowseButton_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog(); fileDialog.Filter = "Python Script Files(*.py)|*.py|All Files (*.*)|*.*"; fileDialog.ShowDialog(); if ((fileDialog.FileName != "") && (fileDialog.CheckFileExists == true)) ex1FileAddTextBox.Text = fileDialog.FileName; }
private void settingsDirAddBrowseButton_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog(); fileDialog.Filter = "Python Script Files(*.py)|*.py|All Files (*.*)|*.*"; fileDialog.ShowDialog(); if ((fileDialog.FileName != "") && (fileDialog.CheckFileExists == true)) settingsDirAddTextBox.Text = new FileInfo(fileDialog.FileName).Directory.FullName; }
private void OpenForeignDB(object sender, RoutedEventArgs e) { var DbFile = new Microsoft.Win32.OpenFileDialog() { Filter = "DataBase Files (*.db)|*.db" }; var result = DbFile.ShowDialog(); if ((bool)result) { var file = DbFile.FileName; ForeignDB = new DbHandle(new SQLIteClient("", "", "", @file)); ForeignColection = new CookingBookDataCollection(ForeignDB); ForeignColection.GetAll(); ForeignDbListViev.ItemsSource = ForeignColection.ListOfRecipes; CollectionView ForeignRecipeViev = (CollectionView)CollectionViewSource.GetDefaultView(ForeignDbListViev.ItemsSource); ForeignRecipeViev.Filter = (item => (String.IsNullOrEmpty(ForeignRecipeFilterText.Text) ? true : ((item as Recipe).Name.IndexOf(ForeignRecipeFilterText.Text, StringComparison.OrdinalIgnoreCase) >= 0))); OpenedName.Text = @DbFile.SafeFileName; } else { MessageBox.Show("dsfgds"); } }
private void btn_AccountCreation_BrowseAccountFile_Click(object sender, RoutedEventArgs e) { try { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { GlobalDeclaration.objAccountCreation.QueueOfProxy.Clear(); txt_AccountCreation_LoadAccountFilePath.Text = dlg.FileName.ToString(); List<string> tempList= Globussoft.GlobusFileHelper.ReadFiletoStringList(dlg.FileName); foreach(string item in tempList) { GlobalDeclaration.objAccountCreation.QueueOfProxy.Enqueue(item); } } GlobusLogHelper.log.Info(" [ " + GlobalDeclaration.objAccountCreation.QueueOfProxy.Count + " ] Proxy Uploaded"); lbl_AccountCreation_Report_NoOfAccountLoaded.Dispatcher.Invoke(new Action(() => { lbl_AccountCreation_Report_NoOfAccountLoaded.Content = GlobalDeclaration.objAccountCreation.QueueOfProxy.Count.ToString(); })); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }
private void OpenFolderOrFile(object sender, ExecutedRoutedEventArgs e) { var dialog = new Microsoft.Win32.OpenFileDialog { CheckFileExists = true, CheckPathExists = true, Multiselect = false }; if (lastAddedPath != null) { dialog.FileName = lastAddedPath; } var ret = dialog.ShowDialog(this); if (ret.HasValue && ret.Value) { lastAddedPath = dialog.FileName; string filename = null; if (File.Exists(lastAddedPath)) { filename = lastAddedPath; lastAddedPath = Path.GetDirectoryName(lastAddedPath); } DirectoryController.Scan(lastAddedPath); DirectoryController.SelectFile(filename); ShowFile(); } }
public void UpdateThumbnail(object sender, EventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = ""; // Default file name dlg.DefaultExt = ".png"; // Default file extension dlg.Filter = "Image Files(*.PNG;*.JPG;*.BMP;*.GIF)|*.PNG;*.JPG;*.BMP;*.GIF|All files (*.*)|*.*"; Nullable<bool> result = dlg.ShowDialog(); if (true == result) { if (null != dlg.FileName && 0 < dlg.FileName.Length && File.Exists(dlg.FileName)) { // loadimage try { // fetch via URL Uri imageUri = new Uri(dlg.FileName); BitmapDecoder bmd = BitmapDecoder.Create(imageUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); // reset width ThumbnailImage.Width = double.NaN; // set the source _thumbnailImage.Source = bmd.Frames[0]; _isDefault = false; } catch (Exception) { /* noop */ } } } }
public string[] GetFileOpenPath(string title, string filter) { if (VistaOpenFileDialog.IsVistaFileDialogSupported) { VistaOpenFileDialog openFileDialog = new VistaOpenFileDialog(); openFileDialog.Title = title; openFileDialog.CheckFileExists = true; openFileDialog.RestoreDirectory = true; openFileDialog.Multiselect = true; openFileDialog.Filter = filter; if (openFileDialog.ShowDialog() == true) return openFileDialog.FileNames; } else { Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.Title = title; ofd.CheckFileExists = true; ofd.RestoreDirectory = true; ofd.Multiselect = true; ofd.Filter = filter; if (ofd.ShowDialog() == true) return ofd.FileNames; } return null; }
private void openList_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Filter = "mp3 files (*.mp3)|*.mp3"; dlg.DefaultExt = "mp3"; dlg.Title = "Browse MP3 Files"; dlg.Multiselect = true; if(player.IsInit){ // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); if (result == true) { List<String> paths = new List<string>(); foreach (String file in dlg.FileNames) { paths.Add(file); char[] st = {'\\'}; String[] name = file.Split(st); //MessageBox.Show(name[name.Length - 1]); listBox1.Items.Add(name[name.Length - 1]); } listBox1.Tag = paths; } } }
private void btnPinUrls_Like_Browse_Click(object sender, RoutedEventArgs e) { try { txtLikePinUrl.IsReadOnly = true; ClGlobul.lstAddToBoardUserNames.Clear(); Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.DefaultExt = ".txt"; ofd.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = ofd.ShowDialog(); if (result == true) { txtLikePinUrl.Text = ofd.FileName.ToString(); Thread ReadLargeFileThread = new Thread(ReadLargeLikePinUrlsFile); ReadLargeFileThread.Start(ofd.FileName); ClGlobul.lstAddToBoardUserNames = GlobusFileHelper.ReadFile(txtLikePinUrl.Text.Trim()); GlobusLogHelper.log.Info(" => [ " + ClGlobul.lstAddToBoardUserNames.Count + " Pin Urls Uploaded ]"); } } catch (Exception ex) { GlobusLogHelper.log.Info("Error :" + ex.StackTrace); } }
//public RelayCommand _browseButtonCommand; public void brows() { //MessageBox.Show(show); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".png"; //dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; dlg.Filter = "EXCEL Files (*.xls)|*.xls|EXCEL Files (*.xlsx)|*.xlsx"; // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document filePath = dlg.FileName; MainViewModel.staticFilePath = filePath; //return fileName; } else { filePath = null; MainViewModel.staticFilePath = filePath; //return fileName; } }
private void btn_MentionUsers_BrowseMessage_Click(object sender, RoutedEventArgs e) { try { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { this.Dispatcher.Invoke(new Action(delegate { txt_MentionUser_LoadMessage_MessageFilePath.Text = dlg.FileName; })); List<string> tmpList = Globussoft.GlobusFileHelper.ReadFiletoStringList(dlg.FileName); GlobalDeclration.objMentionUser.listOfMessageToComment = tmpList.Distinct().ToList(); GlobusLogHelper.log.Info(tmpList.Count + " Urls Uploaded "); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error ==> " + ex.Message); } }
private void BrowseWaitingListButton_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); if (!string.IsNullOrEmpty(WaitingListFileTextBox.Text)) { string dir = System.IO.Path.GetDirectoryName(WaitingListFileTextBox.Text); if (Directory.Exists(dir)) { dlg.InitialDirectory = dir; } } // Set filter for file extension and default file extension dlg.DefaultExt = ".csv"; dlg.Filter = "CSV Files (*.csv)|*.csv"; // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { WaitingListFileTextBox.Text = dlg.FileName; } }
private void btnOpenFile_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; switch (btn.Tag.ToString()) { case "OpenFile": //添加显示的图片。 Microsoft.Win32.OpenFileDialog file = new Microsoft.Win32.OpenFileDialog(); file.Filter = "*.jpg|*.jpg|*.bmp|*.bmp|*.gif|*.gif|*.png|*.png"; file.ShowDialog(); this.ImgInfo.Source = new BitmapImage(new Uri(file.FileName)); break; case "InitImage": //图片重置大小。 ScaleTransform scale = this.Scroll.GetTransFormGroup().Children[0] as ScaleTransform; scale.ScaleX = 1; scale.ScaleY = 1; break; case "OcrKnow": //调用一个exe程序的方面实现。 this.Execute(this.ImgInfo.Source.ToString()); break; case "SaveText": this.SaveText(); break; case "RotateTransform": //图片旋转90度的。 this.Scroll.DoImageRotate(); break; case "AboutBox": MessageBox.Show("AboutBox"); break; } }
private void loadDocumentBtn_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".png"; dlg.Filter = "Image documents (.png)|*.png"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { ocrData.clearData(); filePath = dlg.FileName; sourcePathTxtBox.Text = filePath; BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri(filePath); bi.EndInit(); sourceImage.Stretch = Stretch.Uniform; sourceImage.Source = bi; ocrData.filename = Regex.Match(filePath, @".*\\([^\\]+$)").Groups[1].Value; ocrData.created = File.GetCreationTime(filePath); processBtn.IsEnabled = true; } }
private void Button_Click_1(object sender, RoutedEventArgs e) { var ofd = new Microsoft.Win32.OpenFileDialog(); var result = ofd.ShowDialog(); if (result == false) return; nombreArchivo.Text = ofd.FileName; }
private void Button_Click_1(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".png"; // Display OpenFileDialog by calling ShowDialog method if (dlg.ShowDialog() == true) { StatusLabel.Content = "Uploading image..."; new Thread(delegate() { try { String url = ImageAPI.imgur.imgur.UploadImage(dlg.FileName); Dispatcher.Invoke(new Action(() => { MessageTextBox.Text += "\r\n" + url; StatusLabel.Content = "画像を投稿しました"; })); } catch(Exception ex) { Dispatcher.Invoke(new Action(() => { StatusLabel.Content = ex.Message; })); } }).Start(); } }
public static string AskForImageFilePathViaDialog() { //BitmapImage returnImage = null; dynamic op = new Microsoft.Win32.OpenFileDialog(); op.Title = "画像を選択してください。"; op.Filter = "|*.jpg;*.jpeg;*.png;*.bmp;.gif|" + "JPEG形式 (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "PNG形式 (*.png)|*.png|" + "GIF形式(*.gif)|*.gif|" + "BMP形式(*.bmp)|*.bmp"; //"全ての形式|*.*|"; //初期位置は前のを覚えていればそれを、なければマイドキュメント //Dim previousPath = LocalSettings.ReadSetting(Constants.PreviousOpenFilePath) //If previousPath IsNot Nothing Then // op.InitialDirectory = previousPath //Else // op.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) //End If //FilterIndexは1から始まる //op.FilterIndex = 1; if (op.ShowDialog() == true) { return op.FileName; //Dim rawImage = New RawImage(op.FileName) //returnImage = rawImage.CreateBitmapImage() //ファイルパスは覚えておく //LocalSettings.AddUpdateAppSettings(Constants.PreviousOpenFilePath, op.FileName) } return null; }
private void cc_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog(); d.Filter = "JPEG Image (*.JPG)|*.JPG"; bool? result = d.ShowDialog(this); if (result == true) { System.IO.FileInfo fi = new System.IO.FileInfo(d.FileName); //fi.CopyTo("..\\..\\Resources\\"+fi.Name,true); XmlDataProvider xdp = this.Resources["BookData"] as XmlDataProvider; System.Xml.XmlElement xe = (System.Xml.XmlElement)(e.Source as System.Windows.Controls.ContentControl).Content; if (xe["Image"] != null) { xe["Image"].InnerText = fi.FullName; //System.Xml.XmlTextWriter xr = new System.Xml.XmlTextWriter(new System.IO.FileStream(@"C:\a.txt", System.IO.FileMode.OpenOrCreate), Encoding.Unicode); //xe.WriteTo(xr); //xr.Close(); } else { System.Xml.XPath.XPathNavigator navigator = xe.CreateNavigator(); navigator.AppendChildElement(null, "Image", null, fi.FullName); this.listBox.Items.Refresh(); } } }
private void ExecutedOpenCommand(object sender, ExecutedRoutedEventArgs e) { try { var fd = new Microsoft.Win32.OpenFileDialog(); if (_main.IsChanged) { if (!UnsavedChanges()) { if (!(fd?.ShowDialog() ?? false)) { return; } _main = new V5MainCollection(); _main.Load(fd.FileName); DataContext = _main; } } if (!(fd?.ShowDialog() ?? false)) { return; } _main = new V5MainCollection(); _main.Load(fd.FileName); DataContext = _main; } catch (Exception) { MessageBox.Show("Error"); } finally { ErrorMsg(); } }
private void ButtonAddElement(object sender, RoutedEventArgs e) { try { var dlg = new Microsoft.Win32.OpenFileDialog(); var result = dlg?.ShowDialog(); _main.AddFromFile(dlg.FileName); } catch (Exception) { MessageBox.Show("Add error"); } finally { ErrorMsg(); } }
/// <summary> /// Shows the new setup control and updates with the results. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">Event arguments that contains the event data.</param> private void buttonBrowse_Click(object sender, RoutedEventArgs e) { IFCExportConfiguration configuration = GetSelectedConfiguration(); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".txt"; dlg.Filter = Properties.Resources.UserDefinedParameterSets + @"|*.txt"; if (configuration != null && !string.IsNullOrWhiteSpace(configuration.ExportUserDefinedPsetsFileName)) { string pathName = System.IO.Path.GetDirectoryName(configuration.ExportUserDefinedPsetsFileName); if (Directory.Exists(pathName)) { dlg.InitialDirectory = pathName; } if (File.Exists(configuration.ExportUserDefinedPsetsFileName)) { string fileName = System.IO.Path.GetFileName(configuration.ExportUserDefinedPsetsFileName); dlg.FileName = fileName; } } // Display OpenFileDialog by calling ShowDialog method bool?result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result.HasValue && result.Value) { string filename = dlg.FileName; userDefinedPropertySetFileName.Text = filename; if (configuration != null) { configuration.ExportUserDefinedPsetsFileName = filename; } } }
/// <summary> /// Подпрограмма задания пути доступа к НЕХ-файлу /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textPath_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { // Директория содержащая НЕХ-файлы var path = AppDomain.CurrentDomain.BaseDirectory + App.TaskManager.ConfigProgram.PathHexFiles; if (!Directory.Exists(path)) { return; } // Создание диалогового окна var open_file = new OpenFileDialog { RestoreDirectory = true, InitialDirectory = path, Filter = @"HEX files (*.mot,*.s19 )|*.mot;*.s19|" + @"All files (*.*)|*.*" }; // Настройка диалогового окна if (open_file.ShowDialog() == false) { return; } // Путь доступа к выбранному НЕХ-файлу var file_name = open_file.FileName; // Директория выбранного НЕХ-файла var dir_name = Path.GetDirectoryName(file_name) + "\\"; // Сравнение директории выбранного файла с директорией по умолчанию if (string.Equals(dir_name, path, StringComparison.CurrentCultureIgnoreCase)) { // Директории совпадают // Указываем только имя НЕХ-файла file_name = Path.GetFileName(file_name); } // Сохранение пути к НЕХ-файлу TextPath.Text = file_name; }
public void ChooseSpreadsheet() { _statusBar.StatusText = "Please Choose a Spreadsheet."; //clear out cache, in case they're opening a new spreadsheet. _rowList = new List <SpreadSheetRow>(); _totalsBar.NumberScans = 0; _totalsBar.TotalFound = 0; _totalsBar.TotalRows = 0; Scans = new List <string>(); //Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".xlsx"; dlg.Filter = "XLSX Files (*.xlsx)|*.xlsx"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); Console.WriteLine(""); // Get the selected file name and display in a TextBox if (result == true) { // Open document XlsFileName = dlg.FileName; Dialogs.ShowLongOperationDialog(new Action(() => { LoadSpreadsheetExecute(); }), "Loading..."); SpreadSheetGrid.ItemsSource = _rowList; _totalsBar.TotalRows = _rowList.Count; _statusBar.StatusText = "Waiting for you to Scan..."; } }
private void buttonFilterLoad_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Filter = Properties.Resources.FilterWWAFilterFiles; dlg.ValidateNames = true; var result = dlg.ShowDialog(); if (result != true) { return; } var filters = WWAudioFilterCore.AudioFilterCore.LoadFiltersFromFile(dlg.FileName); if (filters == null) { return; } mFilters = filters; Update(); }
private void CoverImage_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) //Change the book cover picture { var image = (Image)sender; var openFileDialog = new OpenFileDialog { Filter = "Images|*.png; *.jpg; *.gif; *.tif; *.bmp" }; if (openFileDialog.ShowDialog() != true) { return; } var cover = new BitmapImage(); cover.BeginInit(); cover.CreateOptions = BitmapCreateOptions.PreservePixelFormat | BitmapCreateOptions.IgnoreColorProfile; cover.CacheOption = BitmapCacheOption.OnLoad; cover.StreamSource = openFileDialog.OpenFile(); cover.EndInit(); image.Source = cover; BookInfoSet("Cover", File.ReadAllBytes(openFileDialog.FileName)); }
private void buttonBrowser_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = "Html files (*.html)|*.html|All files (*.*)|*.*", Multiselect = true }; var dialogResult = openFileDialog.ShowDialog(); if (dialogResult == true) { listhtmlFile.Clear(); grvHtmlFile.DataContext = null; foreach (string file in openFileDialog.FileNames) { ItemHtmlSelect item = new ItemHtmlSelect(file, "Uncheck"); listhtmlFile.Add(item); } pgbRunning.Maximum = openFileDialog.FileNames.Length; pgbRunning.Minimum = 0; grvHtmlFile.DataContext = listhtmlFile; } }
private void Button_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog chooseLocalFile = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension chooseLocalFile.DefaultExt = ".png"; chooseLocalFile.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = chooseLocalFile.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document filename = chooseLocalFile.FileName; Pathfile.Text = filename; } }
private void OnSelectFiles(object param) { var dialog = new Microsoft.Win32.OpenFileDialog() { CheckFileExists = true, InitialDirectory = SelectedFolder, Multiselect = true }; if (dialog.ShowDialog().GetValueOrDefault()) { SelectedFolder = Path.GetDirectoryName(dialog.FileNames[0]); Files.Clear(); foreach (var file in dialog.FileNames) { var fileInfo = new FileInfo(file); Files.Add(new Model.File() { Name = Path.GetFileName(file), FullFilePath = file, SizeInBytes = fileInfo.Length, RelativeToFolder = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar, }); } } }
private void ChooseDocFile_Click(object sender, RoutedEventArgs e) { try { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Filter = "Расписание докторов (*.xlsx) | *.xlsx"; bool?result = dlg.ShowDialog(); pathToDocTimetable = dlg.FileName; if (result == true) { docsTimetableData = docRetriever.RetrieveDoctorsTimetableInformation(pathToDocTimetable, Message); } Message.Foreground = Brushes.Black; Message.Text = "Расписание врачей добавлено."; /* * //var docFileName = @"C:\Users\Daniel3\Desktop\TimetableUniter\TestResources\DoctorsTimetableExample.xlsx"; * var assistantFileName = @"C:\Users\Daniel3\Desktop\TimetableUniter\TestResources\Assistant'sTimetableExample.xlsx"; * var assistantFileName2 = @"C:\Users\Daniel3\Desktop\TimetableUniter\TestResources\Assistant'sTimetableExample2.xlsx"; * * // TODO: Make for loop foreach file * var assistantsTimetableDataList = new List<string>(); * assistantsTimetableDataList.Add(assistantRetriever.RetrieveAssistantsTimetableInformation(assistantFileName, Message)); * assistantsTimetableDataList.Add(assistantRetriever.RetrieveAssistantsTimetableInformation(assistantFileName2, Message)); */ } catch (Exception ex) { Message.Foreground = Brushes.Red; Message.Text = ex.Message; } }
private void Button_Click_2(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.OpenFileDialog { DefaultExt = "*.dll", CheckFileExists = true, CheckPathExists = true, Multiselect = false, RestoreDirectory = true, DereferenceLinks = true, Title = "Please select a DLL that Implements IServerCrypto", Filter = "Crypto Files *.dll|*.dll" }; if (dlg.ShowDialog() == true) { crypto = null; status[3] = false; try { using (var cat = new AggregateCatalog()) { cat.Catalogs.Add(new DirectoryCatalog(Path.GetDirectoryName(dlg.FileName), Path.GetFileName(dlg.FileName))); var loader = new CompositionContainer(cat); loader.ComposeParts(this); } cryptoPath = dlg.FileName; status[3] = true; (sender as Button).Content = Path.GetFileName(dlg.FileName); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error Loading Crypto"); return; } finally { ShowStatus(); } } }
/// <summary> /// Prompts a dialog to select one or more BCF files to open /// </summary> /// <returns></returns> public static IEnumerable <BcfFile> OpenBcfDialog() { try { var openFileDialog1 = new Microsoft.Win32.OpenFileDialog(); openFileDialog1.Filter = "BIM Collaboration Format (*.bcfzip)|*.bcfzip"; openFileDialog1.DefaultExt = ".bcfzip"; openFileDialog1.Multiselect = true; openFileDialog1.RestoreDirectory = true; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; var result = openFileDialog1.ShowDialog(); // Show the dialog. if (result == true) // Test result. { return(openFileDialog1.FileNames.Select(OpenBcfFile).ToList()); } } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1); } return(null); }
private void btnAddPicture_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".png"; dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result.HasValue && result == true) { // Open document string filename = dlg.FileName; MessageBox.Show("This function is not implemented yet!"); } }
/// <summary> /// Open a dialog to upload a file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uploadClick(object sender, RoutedEventArgs e) { Button s = (Button)sender; //Open a file dialog to be able to pick a file to be uploaded Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); //Set the default extension and the allowed file types to pick from the dialog dlg.DefaultExt = "*.docx"; dlg.Filter = "DOCX Files (*.docx)|*.docx|PDF Files (*.pdf)|*.pdf"; //Show the dialog box and if a file gets selected put it into a string Nullable <bool> result = dlg.ShowDialog(); if (result == true) { //Check what file is being uploaded if (s == uploadContract) { //Get the file extension and display the file that was chosen contractExt = System.IO.Path.GetExtension(dlg.FileName); contractFilePath = dlg.FileName; int lastSlash = contractFilePath.LastIndexOf('\\'); uploadedContract.Text = contractFilePath.Remove(0, lastSlash + 1); uploadedDocument = File.ReadAllBytes(contractFilePath); } else { tribalExt = System.IO.Path.GetExtension(dlg.FileName); tribalFilePath = dlg.FileName; int lastSlash = tribalFilePath.LastIndexOf('\\'); uploadedTribal.Text = tribalFilePath.Remove(0, lastSlash + 1); tribalCoverSheet = File.ReadAllBytes(tribalFilePath); } } }
private void Workspace_AskSavePathWorkspace(object sender, WorkspacePathEventArgs e) { if (e.IsSave) { Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); dialog.Filter = string.Format("MiniMaster (*{0})|*{0}", Workspace.FILEENDING); var result = dialog.ShowDialog(); if (result ?? false) { e.Path = dialog.FileName; } } else { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.Filter = string.Format("MiniMaster (*{0})|*{0}", Workspace.FILEENDING); dialog.CheckFileExists = true; var result = dialog.ShowDialog(); if (result ?? false) { e.Path = dialog.FileName; } } }
public void photoChooseExecute(Object parameter) { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.Filter = "图像文件|*.jpg;*.png;*.jpeg"; if (dialog.ShowDialog() == true) { // 根据文件名在本地读取文件,存为字节文件,调用上传服务上传文件转换为图片并返回 // 在服务器端的存储位置(http链接),存储到数据库中;获取数据库中路径,赋给Photo预览 Photo = dialog.FileName; Image image = Image.FromFile(dialog.FileName); try { string imgString = Utils.ImgToByteArray(image); ServiceProxy.ServiceTestClient client = new ServiceProxy.ServiceTestClient("WSHttpBinding_IServiceTest"); string imgName = client.PicUpload(imgString); this.Information.Photo = imgName; } catch (Exception e) { System.Windows.MessageBox.Show("上传错误,请联系管理员!"); } } }
private void PathToPhotoUser_Click(object sender, RoutedEventArgs e) { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = ""; // Default file name dlg.DefaultExt = ".jpg"; // Default file extension dlg.Filter = "Файлы фотографий|*.jpg;*.png;*.ico"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; InputPathPhotoUser.Text = filename; StackSucc.Visibility = Visibility.Visible; MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(); mainWindowViewModel.PathUserPhoto = filename; ImagePhotoUser.ImageSource = new BitmapImage(new Uri(filename)); } }
VugraphLin NowyTrening() { Microsoft.Win32.OpenFileDialog lin = new Microsoft.Win32.OpenFileDialog(); lin.Title = "Zaladuj lina z vugrapha"; lin.ShowDialog(); VugraphLin vugraph_ = new VugraphLin(); FileStream plik1 = File.OpenRead(lin.FileName); StreamReader reader = new StreamReader(plik1); string calosc = ""; while (!reader.EndOfStream) { calosc += reader.ReadLine(); } reader.Close(); plik1.Close(); vugraph_.ReadLinVugraph(calosc); return(vugraph_); }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var api = ApiService.Get(); var key = await api.Users.GetUploadAvatarUrl(); var webClient = new WebClient(); var pathUrlUpload = "http://" + api.Address + $"/api/users.uploadPhoto/{key}"; Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.Filter = "Изрбражения (*.png, *.jpg) | *.png;*.jpg"; dialog.FilterIndex = 2; var result = dialog.ShowDialog(); if (result == true) { // Open document string patchFile = dialog.FileName; var a = await webClient.UploadFileTaskAsync(pathUrlUpload, patchFile); MessageBox.Show("ready", "ready"); } }
private void buttonDisplay_Click(object sender, RoutedEventArgs e) { try { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Filter = "XPS files |*.xps|Word files |*.doc;*.docx|Text files |*.txt;*.log"; openFileDialog.InitialDirectory = Environment.CurrentDirectory; Nullable <bool> result = openFileDialog.ShowDialog(); if (result == true) { string fileName = openFileDialog.FileName; string extention = System.IO.Path.GetExtension(fileName); switch (extention.ToLower()) { case ".xps": ShowXpsDocument(fileName); break; case ".txt": ShowTextDocument(fileName); break; case ".log": ShowLogDocument(fileName); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnSelectFiles_Click(object sender, RoutedEventArgs e) { // Open multiselect file dialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog { Filter = "Text documents (.txt)|*.txt", InitialDirectory = @"\\ICAL8000\Users\Public\Documents\Calmetrix\CalCommander 2\Export", Multiselect = true }; Nullable <bool> result = dlg.ShowDialog(); // If files selected, add filename only to list box if (result == true) { Filenames = dlg.FileNames; foreach (string filename in Filenames) { string file = Path.GetFileNameWithoutExtension(filename); ListCalFiles.Items.Add(file); } } }
private void Importer_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Pokemons"; dlg.DefaultExt = ".xml"; dlg.Filter = "XML documents |*.xml"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { String filename = dlg.FileName; XmlSerializer serializer = new XmlSerializer(typeof(List <Pokemon>)); using (var stream = File.OpenRead(filename)) { var item = (List <Pokemon>)(serializer.Deserialize(stream)); BManager.getPokemon().Clear(); BManager.getPokemon().AddRange(item); } ListViewPokemon.ItemsSource = null; ListViewPokemon.ItemsSource = BManager.getPokemon(); } }
private void SelectButton_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog { Multiselect = true, DefaultExt = ".xlsx", Filter = "Excel and Word Files (*.xslx,*.docx)|*.xlsx;*.docx|Excel Files (*.xslx)|*.xlsx|Word Files (*.docx)|*.docx|*.*|*.*", CheckFileExists = true }; bool?result = dlg.ShowDialog(); if (result == true) { try { UnprotectFiles(dlg.FileNames); } catch (Exception x) { MessageBox.Show(x.Message, "Error Processing Files", MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// 打开图像文件选择对话框 /// <param name="title">对话框标题</param> /// </summary> //-------------------------------------------------------------------------- //修改历史: //日期 修改人 修改 //2010-8-2 qizhenguo 创建代码 //-------------------------------------------------------------------------- public static List <string> OpenFileSelectDialog(string title) { // 类型过滤字符串,是否可以多选及对话框标题设置 string imageFilter = "图片文件(*.jpg,*.jpeg,*.gif,*.bmp,*.tif,*.png)|*.jpg;*.jpeg;*.gif;*.bmp;*.tif;*.png"; Microsoft.Win32.OpenFileDialog dialogOpenFile = new Microsoft.Win32.OpenFileDialog(); dialogOpenFile.Multiselect = true; dialogOpenFile.Filter = imageFilter; dialogOpenFile.Title = title; //打开对话框 bool isOpened = (bool)dialogOpenFile.ShowDialog(); if (!isOpened) { return(null); } //获取选择文件名称列表并返回 string[] strNames = dialogOpenFile.FileNames; List <string> selImgNames = strNames.ToList(); return(selImgNames); }
private void btnImage_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Title = "Select Vehicle Image"; dlg.Filter = "Images (*.JPG;*.JPEG;*.PNG) | *.JPG;*.JPEG;*.PNG"; Nullable <bool> result = dlg.ShowDialog(); try { if (result == true) { sourceFile = dlg.FileName; fileName = sourceFile.Substring(sourceFile.LastIndexOf('\\')); } destinationFile = imageDirectory + fileName; if (!File.Exists(destinationFile)) { File.Copy(sourceFile, destinationFile); } tbxImagePath.Text = ""; tbxImagePath.Text = fileName.Replace("\\", "").ToString(); } catch (IOException ioe) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ioe.Message); } catch (Exception fe) { MessageBox.Show("Error: Image needed for vehicle. Original Error: " + fe.Message); } }
// ---------------------------------------------------------- // Opening Videos/Images // ---------------------------------------------------------- // Some utilities for opening images/videos and directories private List <string> openMediaDialog(bool images) { string[] image_files = new string[0]; Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => { var d = new Microsoft.Win32.OpenFileDialog(); d.Multiselect = true; if (images) { d.Filter = "Image files|*.jpg;*.jpeg;*.bmp;*.png;*.gif"; } else { d.Filter = "Video files|*.avi;*.wmv;*.mov;*.mpg;*.mpeg;*.mp4"; } if (d.ShowDialog(this) == true) { image_files = d.FileNames; } })); List <string> img_files_list = new List <string>(image_files); return(img_files_list); }
private CertificateFile OpenFileDialog() { var dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".pem"; dialog.Filter = "PEM Files (*.pem)|*.pem|PFX Files (*.pfx)|*.pfx|Pkcs12 Files (*.p12)|*.p12"; dialog.CheckPathExists = true; dialog.CheckFileExists = true; var result = dialog.ShowDialog(); if (result ?? false) { return(new CertificateFile() { Path = dialog.FileName, FileName = System.IO.Path.GetFileName(dialog.FileName), Extention = System.IO.Path.GetExtension(dialog.FileName), Content = File.ReadAllBytes(dialog.FileName) }); } return(null); }
//Загрузка данных private void Load_BtnClick(object sender, RoutedEventArgs e) { OpenFileDialog openFileDlg = new OpenFileDialog(); openFileDlg.Filter = "CSV documents (.csv)|*.csv"; Nullable <bool> result = openFileDlg.ShowDialog(); if (result == true) { xes.Clear(); string filename = openFileDlg.FileName; XYGrid.ItemsSource = null; xes = File.ReadAllLines(filename).Select(v => XY.FromCsv(v)).ToList(); if (SwitchFunc.IsChecked == false) { xylist.Clear(); foreach (XY xy in xes) { xylist.Add(xy); } XYGrid.ItemsSource = xylist; } else { xylist1.Clear(); foreach (XY xy in xes) { xylist1.Add(xy); } XYGrid.ItemsSource = xylist1; } Reverse(); Work = false; } }
private void OnChooseImageClick(object sender, RoutedEventArgs e) { var fileDialog = new Microsoft.Win32.OpenFileDialog(); fileDialog.DefaultExt = ".png"; fileDialog.Filter = "Images (*.png,*.jpg, *.jpeg)|*.png;*.jpg;*.jpeg"; bool?success = fileDialog.ShowDialog(); if (success.Value) { image = new Uri(fileDialog.FileName); var loadedPreview = new BitmapImage(); loadedPreview.BeginInit(); loadedPreview.UriSource = image; loadedPreview.CacheOption = BitmapCacheOption.OnLoad; loadedPreview.EndInit(); WidthTextBox.Text = loadedPreview.PixelWidth.ToString(); HeightTextBox.Text = loadedPreview.PixelHeight.ToString(); PreviewImage.Source = loadedPreview; } }
public PowerPointControl() { // OpenFileDialog Instanz erzeugen Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Dateiendungs-Filter setzen dlg.DefaultExt = ".pptx"; dlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*"; // OpenFileDialog anzeigen Nullable<bool> result = dlg.ShowDialog(); // PowerPoint Instanz erzeugen oPPT = new Microsoft.Office.Interop.PowerPoint.Application(); // PowerPoint anzeigen oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; objPresSet = oPPT.Presentations; // Wenn der Benutzer im OpenFileDialog eine Datei ausgewählt + auf OK geklickt hat if (result == true) { // Ausgewählte Datei (Präsentation) öffnen objPres = objPresSet.Open(dlg.FileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue); // Präsentationsansicht öffnen objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse; System.Diagnostics.Debug.WriteLine(objPres.SlideShowSettings.ShowWithAnimation); objPres.SlideShowSettings.Run(); oSlideShowView = objPres.SlideShowWindow.View; } }