当前位置: 首页>>代码示例>>C#>>正文


C# System.Windows.Forms.OpenFileDialog.ShowDialog方法代码示例

本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.OpenFileDialog.ShowDialog方法的具体用法?C# System.Windows.Forms.OpenFileDialog.ShowDialog怎么用?C# System.Windows.Forms.OpenFileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.OpenFileDialog的用法示例。


在下文中一共展示了System.Windows.Forms.OpenFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChangePictureButton_Click

 private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (track != null)
         {
             var dialog = new System.Windows.Forms.OpenFileDialog();
             dialog.Filter = "Image Files (*.jpg,*.jpeg,*.png,*.gif)|*.jpg;*.jpeg;*.png;*.gif|All Files (*.*)|*.*";
             if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 if (track.Path.EndsWith(".mp3"))
                 {
                     tagController.AddPicture(track, dialog.FileName);
                 }
                 else
                 {
                     track.ImagePath = dialog.FileName;
                     trackController.Save(track);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("MediaPropertyView.ChangePictureButton_Click", ex);
         MessageBox.Show("There was an error trying to add a picture to this track.\n\n" + ex.Message, "Could Not Add Picture To Track");
     }
 }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:28,代码来源:MediaPropertyView.xaml.cs

示例2: GetProperyField

 public override FrameworkElement GetProperyField()
 {
     var pan = new DockPanel();
     t = (new TextBox());
     try
     {
         t.Text = GetVaueAsType<ImageSource>().ToString();
     }
     catch { }//Null value
     t.TextChanged += delegate(object sender, TextChangedEventArgs e) { SetString(t.Text); };
     var btn = new Button();
     btn.Content = "...";
     btn.Click += delegate
     {
         var fpd = new System.Windows.Forms.OpenFileDialog();
         fpd.Filter = "Images|*.jpg;*.jpeg;*.png;*.gif;*.tif;*.bmp";
         if (fpd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             t.Text = fpd.FileName;
         }
     };
     DockPanel.SetDock(btn, Dock.Right);
     pan.Children.Add(btn);
     pan.Children.Add(t);
     return pan;
 }
开发者ID:byteit101,项目名称:ZomB-Dashboard-System,代码行数:26,代码来源:ImageSourceDesigner.cs

示例3: AddFilm

        public void AddFilm()
        {
            var ofd = new System.Windows.Forms.OpenFileDialog
                          {

                          };
            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            var fileInfo = new FileInfo(ofd.FileName);
            var closeableTabItem = new CloseableTabItem
                                       {
                                           Header = fileInfo.Name,
                                           HorizontalAlignment = HorizontalAlignment.Stretch,
                                           VerticalAlignment = VerticalAlignment.Stretch,
                                           Content = new FilmEditor(ofd.FileName)
                                       };

            if ((string) closeableTabItem.Header == "swag") return;

            foreach (var tabb in homeTabControl.Items.Cast<TabItem>().Where(tabb => tabb.Header == closeableTabItem.Header))
            {
                homeTabControl.SelectedItem = tabb;
                return;
            }
            homeTabControl.Items.Add(closeableTabItem);
            homeTabControl.SelectedItem = closeableTabItem;
        }
开发者ID:0xdeafcafe,项目名称:vintage,代码行数:27,代码来源:Home.xaml.cs

示例4: UploadNewAvatar

        private async void UploadNewAvatar(object sender, MouseButtonEventArgs e)
        {
            var dialog = new System.Windows.Forms.OpenFileDialog
                             {
                                 DefaultExt = ".png",
                                 InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(),
                                 Title = "Select a new avatar",
                                 Filter = "Image files | *.png; *.jpg; *.bmp"
                             };
            dialog.ShowDialog();

            var mimeType = "image/";

            if (String.IsNullOrEmpty(dialog.FileName)) return;
            if (dialog.SafeFileName == null) return;

            if (dialog.SafeFileName.EndsWith(".png")) mimeType += "png";
            else if (dialog.SafeFileName.ToLower().EndsWith(".jpg")) mimeType += "jpg";
            else if (dialog.SafeFileName.EndsWith(".bmp")) mimeType += "bmp";
            else
            {
                dialog.Dispose();
                App.Connection.NotificationController.Notification.Notify("That's not a supported file type! Please try again.");
                return;
            }

            await App.Connection.SessionController.CurrentSession.UploadAvatar(
                new FileStream(dialog.FileName, FileMode.Open), mimeType);
            dialog.Dispose();
            
        }
开发者ID:Conji,项目名称:Cloudsdale-Win7,代码行数:31,代码来源:Settings.xaml.cs

示例5: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            var dialog = new System.Windows.Forms.OpenFileDialog();

            dialog.Filter = "Map file|*.js";

            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                Environment.Exit(0);
            }

            map = new Map(this);
            map.setMapFolder(dialog.FileName.Replace(dialog.SafeFileName, ""));
            map.LoadMap(dialog.SafeFileName);

            //shows the windows.forms layout design
            new Layout(map).Show();

            //allows the mouse to show over the game
            this.IsMouseVisible = true;
            base.Initialize();
        }
开发者ID:Daminvar,项目名称:Euphor,代码行数:32,代码来源:Game1.cs

示例6: AddProjectClick

        private void AddProjectClick(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Filter = "C# Project files (*.csproj)|*.csproj|VS Project files (*.vcproj)|*.vcproj|Android Project (*.project)|*.project";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                var newProject = ProjectManager.AddSyncedProject(openFileDialog.FileName);

                // If newProject is null, then no project was added
                if (newProject != null)
                {
                    ViewModel.Refresh();
                }
                else
                {
                    GlueGui.ShowMessageBox("The selected project is already a synced project.");
                }

                GluxCommands.Self.SaveGlux();

                ProjectManager.SaveProjects();

            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:26,代码来源:SyncedProjectsControl.xaml.cs

示例7: CreateContent

        public UIElement CreateContent(string fileName)
        {
            Grid grid_main = new Grid();
            grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) });
            grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            m_textBox_fileName = new TextBox();
            m_textBox_fileName.TextChanged += (sender, args) => { FileName = m_textBox_fileName.Text; };
            m_textBox_fileName.Text = fileName;
            grid_main.SetGridRowColumn(m_textBox_fileName, 0, 0);

            Button button_openFile = new Button() { Content = "Select file ..." };
            button_openFile.Click += (x, y) =>
                {
                    System.Windows.Forms.OpenFileDialog openFileDialog =
                        new System.Windows.Forms.OpenFileDialog()
                        {
                            CheckFileExists = false,
                            CheckPathExists = true
                        };
                    if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        m_textBox_fileName.Text = openFileDialog.FileName;
                };
            grid_main.SetGridRowColumn(button_openFile, 0, 1);

            return grid_main;
        }
开发者ID:ianeller-romey,项目名称:GinTub_TLATEOTH,代码行数:27,代码来源:Window_SelectFile.cs

示例8: Action

 public override bool Action(string action)
 {
     bool result = base.Action(action);
     if (result)
     {
         if (action == ACTION_IMPORT)
         {
             using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
             {
                 dlg.FileName = "";
                 dlg.Filter = "*.gcc|*.gcc|*.*|*.*";
                 if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     _errormessage = "";
                     _filename = dlg.FileName;
                     _importMissing = System.Windows.Forms.MessageBox.Show(string.Concat(Utils.LanguageSupport.Instance.GetTranslation(STR_IMPORTMISSING),"?"), Utils.LanguageSupport.Instance.GetTranslation(ACTION_IMPORT), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes;
                     PerformImport();
                     if (!string.IsNullOrEmpty(_errormessage))
                     {
                         System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                     }
                 }
             }
         }
     }
     return result;
 }
开发者ID:RH-Code,项目名称:GAPP,代码行数:27,代码来源:Import.cs

示例9: LoadBenchmark

        public void LoadBenchmark()
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.ShowDialog();
            string pathToLoad = dialog.FileName;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Benchmark));
                FileStream filestream = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read, FileShare.Read);

                Benchmark benchmark = (Benchmark)serializer.Deserialize(filestream);
                filestream.Close();

                // before setting benchmark, clear the screen
                // clear screen
                global.Verschnittoptimierung.display.Invalidate();

                global.benchmark = benchmark;

                // also create a basic solution
                SolutionManagement solutionManagement = new SolutionManagement();
                solutionManagement.CreateBasicSolution(global, global.benchmark);

                // show benchmark
                Show show = new Show(global);
                show.ShowBenchmark(global.benchmark);

                System.Windows.Forms.MessageBox.Show("Benchmark was loaded successfully.");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Benchmark could not be loaded. Please make sure to select the correct file path.");
            }
        }
开发者ID:Norman2357,项目名称:Verschnittoptimierung,代码行数:35,代码来源:SaveAndLoad.cs

示例10: Browse_Click

        private void Browse_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Multiselect = true;

            ofd.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"; //Should change the limit of data type

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string[] filePath = ofd.FileNames;
                string[] safeFilePath = ofd.SafeFileNames;

                for (int i = 0; i < safeFilePath.Length; i++)
                {
                    BitmapImage myBitmapImage = new BitmapImage();
                    myBitmapImage.BeginInit();
                    myBitmapImage.UriSource = new Uri(@filePath[i]);
                    myBitmapImage.EndInit();

                    //set image source
                    image1.Source = myBitmapImage;
                    title_tag.Text = safeFilePath[i];
                }

            }
        }
开发者ID:huylu,项目名称:brownuniversitylads,代码行数:26,代码来源:small_window.xaml.cs

示例11: bLearn_Click

        private async void bLearn_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.CheckFileExists = true;
            dialog.CheckPathExists = true;
            dialog.Multiselect = true;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dialog.FileNames.Length >= 2)
                {
                    string mimeType = getMimeType();
                    var infoOne = new FileInfo(dialog.FileNames[0]);
                    var infoTwo = new FileInfo(dialog.FileNames[1]);
                    var fileType = MimeDetective.LearnMimeType(infoOne, infoTwo, mimeType);
                    if (fileType != null)
                    {
                        //Detective.types.Add(fileType);
                        await animateLearnSuccess();
                    }
                    else
                        await animateLearnFailure();
                }
            }
            else
                await animateLearnFailure();
        }
开发者ID:vpanuccio,项目名称:Mime-Detective,代码行数:27,代码来源:MainWindow.xaml.cs

示例12: OnClickFindBtn2

        private void OnClickFindBtn2(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox2.Text = ofd.SafeFileName;

                try
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(ofd.OpenFile());
                    string content = sr.ReadToEnd();
                    sr.Close();

                    selectTextBeforeValue.Text = content;
                    content = System.Text.RegularExpressions.Regex.Replace(content, "a", "QQQ");

                    System.IO.StreamWriter writer = new System.IO.StreamWriter(ofd.FileName);
                    writer.Write(content);
                    writer.Close();

                    sr = new System.IO.StreamReader(ofd.OpenFile());
                    content = sr.ReadToEnd();
                    sr.Close();

                    selectTextAfterValue.Text = content;
                }
                catch(Exception ex)
                {
                    Console.WriteLine("=-=-=-=Exception : " + ex);
                }
            }
        }
开发者ID:hrSung,项目名称:ModernUITestProject,代码行数:34,代码来源:Home.xaml.cs

示例13: btnSelectHex_Click

        private void btnSelectHex_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openHexFileDialog = new System.Windows.Forms.OpenFileDialog();
            openHexFileDialog.Filter = "Hex Files (.hex)|*.hex";
            openHexFileDialog.FilterIndex = 1;

            openHexFileDialog.Multiselect = false;

            openHexFileDialog.ShowDialog();

            if (openHexFileDialog.FileName != "")
            {
                HexFileName = openHexFileDialog.FileName;
                if (ConnectedToBootloader == true)
                {
                    string s = "Upload: " + System.IO.Path.GetFileNameWithoutExtension(HexFileName);
                    Console.WriteLine(s);
                }
                else
                {
                    Console.WriteLine("You must select to connect to the bootloader");
                }

                btnUploadHex.IsEnabled = false;
                FileSelected = true;
            }
        }
开发者ID:TechJect,项目名称:DragonFly_SDK,代码行数:27,代码来源:Bootloader.xaml.cs

示例14: btn_filedb_Click

 private void btn_filedb_Click(object sender, RoutedEventArgs e)
 {
     string path = System.Environment.CurrentDirectory + "\\filepath.txt";
     string filepath_db = System.Environment.CurrentDirectory + "\\bd4.mdf";
     FileInfo fi1;
     if (System.IO.File.Exists(path))//проверка на существование файла настроек
     {
         fi1 = new FileInfo(path);
         using (StreamReader sr = fi1.OpenText())
         {
             string s = sr.ReadLine();
             if (System.IO.File.Exists(s))//проверка на путь в нем
             {
                 filepath_db = s;
             }
         }
     }
     if (!System.IO.File.Exists(filepath_db))
     {
         filepath_db = @"C:\";
     }
     System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
     dialog.InitialDirectory = filepath_db;
     dialog.Filter = "DB File |*.mdf";
     if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         filepath_db = dialog.FileName;
     }
     else filepath_db = System.Environment.CurrentDirectory + "\\bd4.mdf";
     fi1 = new FileInfo(path);
     using (StreamWriter sr = fi1.CreateText())
     {
         sr.WriteLine(filepath_db);
     }
 }
开发者ID:Kirk7by,项目名称:mandarin,代码行数:35,代码来源:MandarinForm.xaml.cs

示例15: PrepareInsertFromDatabase

 public override bool PrepareInsertFromDatabase()
 {
     bool result = false;
     using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
     {
         if (string.Compare(PluginSettings.Instance.ActiveDataFile, dlg.FileName, true) != 0)
         {
             if (string.IsNullOrEmpty(_lastInsertFromFolder))
             {
                 _lastInsertFromFolder = System.IO.Path.GetDirectoryName(PluginSettings.Instance.ActiveDataFile);
             }
             dlg.InitialDirectory = _lastInsertFromFolder;
             dlg.Filter = "*.gpp|*.gpp";
             dlg.FileName = "";
             if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 if (string.Compare(PluginSettings.Instance.ActiveDataFile, dlg.FileName, true) != 0)
                 {
                     _selectedInsertFromFilename = dlg.FileName;
                     result = true;
                 }
             }
         }
     }
     return result;
 }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:26,代码来源:InsertFrom.cs


注:本文中的System.Windows.Forms.OpenFileDialog.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。