private void btnLoad_Click(object sender, RoutedEventArgs e) { var dlg = new OpenFileDialog <FileFormat.FileOpenDlg>(); dlg.Filter = "样品光谱|*.spc"; dlg.Multiselect = true; dlg.Title = "Open File"; dlg.FileDlgStartLocation = AddonWindowLocation.Right; dlg.FileDlgDefaultViewMode = NativeMethods.FolderViewMode.Tiles; dlg.FileDlgOkCaption = "&Open"; dlg.FileDlgEnableOkBtn = true; dlg.SetPlaces(new object[] { (int)Places.History, (int)Places.MyComputer, (int)Places.Desktop, (int)Places.MyDocuments, (int)Places.Favorites }); if ((bool)dlg.ShowDialog() == true) { foreach (string file in dlg.FileNames) { DrugInfo newDrug = Common.CommonMethod.ReadDrugInfo(file); if (newDrug == null) { newDrug = new DrugInfo(); newDrug.filename = file; newDrug.fileData = new SpecFileFormatDouble(); newDrug.fileData.ReadFile(newDrug.filename); newDrug.identResult = EnumIdentResult.UNKNOWN; } dataList.Add(newDrug); } } }
private void OpenFile(object sender, RoutedEventArgs e) { OpenFileDialog <ArchiveDialog> ofd = new OpenFileDialog <ArchiveDialog> { FileDlgStartLocation = AddonWindowLocation.Bottom, InitialDirectory = new System.Windows.Forms.OpenFileDialog().InitialDirectory, FileDlgOkCaption = "&Открыть" }; ofd.SetPlaces(new object[] { @"c:\", (int)Places.MyComputer, (int)Places.Favorites, (int)Places.All_Users_MyVideo, (int)Places.MyVideos }); if (ofd.ShowDialog() == true) { var tab = new ArchiveTab(ofd.FileName, ofd.ChildWnd.Key); tab.LoadDataWin += LoadData; tab.CloseTab += CloseTab; tab.TabIndex = Archives.Items.Count; Archives.Items.Add(tab); Archives.SelectedIndex = tab.TabIndex; tab.Initialize(); } }
private void button1_Click(object sender, EventArgs e) { if (sender.Equals(_btnSelect)) { using (MyOpenFileDialogControl openDialog = new MyOpenFileDialogControl()) { if (openDialog.ShowDialog(this) == DialogResult.OK) { lblFilePath.Text = openDialog.MSDialog.FileName; } } } else if (sender.Equals(_btnSave)) { using (MySaveDialogControl saveDialog = new MySaveDialogControl(lblFilePath.Text, this)) { if (saveDialog.ShowDialog(this) == DialogResult.OK) { lblFilePath.Text = saveDialog.MSDialog.FileName; } } } else if (sender.Equals(this._btnExtension)) { using (MyOpenFileDialogControl openDialogCtrl = new MyOpenFileDialogControl()) { openDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); OpenFileDialog openDialog = new OpenFileDialog(); openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openDialog.AddExtension = true; openDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif"; openDialog.FilterIndex = 2; openDialog.CheckFileExists = true; openDialog.DefaultExt = "jpg"; openDialog.FileName = "Select Picture"; openDialog.DereferenceLinks = true; //openDialog.ShowHelp = true; if (Environment.OSVersion.Version.Major < 6) { openDialog.SetPlaces(new object[] { @"c:\", (int)Places.MyComputer, (int)Places.Favorites, (int)Places.Printers, (int)Places.Fonts }); } if (openDialog.ShowDialog(openDialogCtrl, this) == DialogResult.OK) { lblFilePath.Text = openDialog.FileName; } } } else if (sender.Equals(_btnSaveExt)) { using (SaveFileDialog saveDialog = new SaveFileDialog()) { MySaveDialogControl saveDialogCtrl = new MySaveDialogControl(lblFilePath.Text, this); saveDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); saveDialog.AddExtension = true; saveDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif"; saveDialog.FilterIndex = 2; saveDialog.CheckFileExists = true; saveDialog.DefaultExt = "jpg"; saveDialog.FileName = "Change Picture"; saveDialog.DereferenceLinks = true; //saveDialog.ShowHelp = true; if (Environment.OSVersion.Version.Major < 6) { saveDialog.SetPlaces(new object[] { (int)Places.Desktop, (int)Places.Printers, (int)Places.Favorites, (int)Places.Programs, (int)Places.Fonts, }); } if (saveDialog.ShowDialog(saveDialogCtrl, this) == DialogResult.OK) { lblFilePath.Text = saveDialog.FileName; } } } else if (sender.Equals(_btnExit)) { this.Close(); } System.GC.Collect(); GC.WaitForPendingFinalizers(); }