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


C# Microsoft.Win32.OpenFileDialog.OpenFile方法代码示例

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


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

示例1: MenuItem_Open_Click

        private void MenuItem_Open_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.DefaultExt = ".hex";
            ofd.Filter = "HEX Files (*.hex)|*.hex|All Files (*.*)|*.*";
            Nullable<bool> selected = ofd.ShowDialog();

            if(selected==true)
            {
                //lstISA.Items.Clear();
                lstHex.Items.Clear();
                string fname = ofd.FileName;
                StreamReader sr = new StreamReader(ofd.OpenFile());
                while(!sr.EndOfStream)
                    lstHex.Items.Add(sr.ReadLine());
                pic = new PIC(fname);
                ISA = pic.decompile();
                lstISA.ItemsSource = ISA;
                //foreach (var x in ISA)
                //{
                //    lstISA.Items.Add(x);
                //}
                mnuRun.IsEnabled = true;
                CLK.Interval = pic.getclkInterval()/2;
                CLK.Elapsed += CLK_Elapsed;
                CLK.AutoReset = true;
                lblStatus.DataContext = pic.getCurrent();
            }
        }
开发者ID:eliasv,项目名称:PicSim,代码行数:29,代码来源:MainWindow.xaml.cs

示例2: Open

		// http://msdn.microsoft.com/en-us/library/system.windows.controls.openfiledialog(VS.95).aspx
		// http://msdn.microsoft.com/en-us/library/microsoft.win32.openfiledialog.aspx
		// http://blog.everythingflex.com/2008/10/01/filereferencesave-in-flash-player-10/
		
		// at 2009.06.05 silverlight cannot use save file dialog

		// Only one file browsing session may be performed at a time.

		public void Open(Action<MemoryStream> handler)
		{
			1.AtDelay(
				delegate
				{
					var s = new Microsoft.Win32.OpenFileDialog();

					if (s.ShowDialog() ?? false)
					{
						var m = new MemoryStream();

						using (var r = s.OpenFile())
						{
							var buffer = new byte[r.Length];

							r.Read(buffer, 0, buffer.Length);

							m.Write(buffer, 0, buffer.Length);
						}

						handler(m);
					}
				}
			);
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:33,代码来源:FileDialog.cs

示例3: SelectGameFile

        public string SelectGameFile(out byte[] filedata)
        {
            String fName = null;
            byte[] buffer = null;
            Dispatcher.Invoke(new Action(delegate
            {
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                ofd.Title = "Open a Z-Code file";
                ofd.DefaultExt = ".dat";

                ofd.Filter = CreateFilterList(
                 "Most IF Files (*.zblorb;*.dat;*.z?;*.blorb)|*.zblorb;*.dat;*.z?;*.blorb",
                 "Infocom Blorb File (*.zblorb)|*.zblorb",
                 "Infocom Games (*.dat)|*.dat",
                 "Z-Code Files (*.z?)|*.z?",
                 "Blorb File (*.blorb)|*.blorb");

                if (ofd.ShowDialog(_parent) == true)
                {
                    fName = ofd.FileName;
                    var s = ofd.OpenFile();
                    buffer = new byte[s.Length];
                    s.Read(buffer, 0, buffer.Length);
                    s.Close();
                }

            }));
            filedata = buffer;
            return fName;
        }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:30,代码来源:AbsoluteScreen.xaml.cs

示例4: bOpenFileDialog_Click

        private void bOpenFileDialog_Click(object sender, RoutedEventArgs e)
        {
            Stream checkStream = null;
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();

            openFileDialog.Multiselect = false;
            //openFileDialog.InitialDirectory = "c:\\";
            //if you want filter only .txt file
            //dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            //if you want filter all files
            openFileDialog.Filter = "All Files | *.*";
            if ((bool)openFileDialog.ShowDialog())
            {
                try
                {
                    if ((checkStream = openFileDialog.OpenFile()) != null)
                    {
                        //MyImage.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
                        filePath.Text = openFileDialog.FileName;
                        filePathString = openFileDialog.FileName;

                    }
                }
                catch (Exception ex)
                {
                   System.Windows.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
            else
            {
                   System.Windows.MessageBox.Show("Problem occured, try again later");
            }
        }
开发者ID:rohalchandrakar2007,项目名称:TestRepository,代码行数:33,代码来源:MainWindow.xaml.cs

示例5: OnClick

        protected override void OnClick()
        {
            Stream checkStream = null;
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Multiselect = false;
            if (mTransit != null)
                openFileDialog.InitialDirectory = mTransit.DuongDanHinh;
            else
                openFileDialog.InitialDirectory = "c:\\";

            openFileDialog.Filter = "All Image Files | *.*";
            if ((bool)openFileDialog.ShowDialog())
            {
                if ((checkStream = openFileDialog.OpenFile()) != null)
                {

                    Stream fs = File.OpenRead(openFileDialog.FileName);
                    BitmapImage mBitmapImage = new BitmapImage();
                    mBitmapImage.BeginInit();
                    mBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                    mBitmapImage.StreamSource = fs;
                    mBitmapImage.EndInit();
                    //this.ImageBitmap = Utilities.ImageHandler.BitmapImageCopy(mBitmapImage);                    
                    //this.ImageBitmap = Utilities.ImageHandler.ImageToByte(mBitmapImage);
                    System.IO.FileInfo file = new FileInfo(openFileDialog.FileName);
                    if (mTransit != null)
                        mTransit.DuongDanHinh = file.Directory.FullName; ;
                    this.Image = mBitmapImage;
                    this.ImageBitmap = mBitmapImage;

                    if (_OnBitmapImageChanged != null)
                    {
                        _OnBitmapImageChanged(this);
                    }
                }
            }
            base.OnClick();
        }
开发者ID:MisterTobi,项目名称:restaurant-cafe,代码行数:38,代码来源:POSButtonImage.cs

示例6: LoadFile

        public void LoadFile()
        {
            Stream myStream = null;
            Int16 val;
            UInt32 time_offset;
            //Int16[] channel = new Int16[NUM_CHANNELS];
            Double time_calc;
            int pos = 0;
            string packet_display = "";

            Int32 buffer_loc = 0;

            Double SampleCount = 0;

            // Show the dialog and get result.
            Microsoft.Win32.OpenFileDialog openFileDialog1 = new Microsoft.Win32.OpenFileDialog();

            bool? result = openFileDialog1.ShowDialog();
            if (result == true) // Test result.
            {
                if ((myStream = openFileDialog1.OpenFile()) != null)
                {

                    foreach (GraphingData data in GraphData)
                    {
                        data.Channel_AllData.Collection.Clear();
                    }

                    //textBox1.AppendText(openFileDialog1.FileName + " Opened Successfully! File Size: " + myStream.Length + "\r\n"); // <-- For debugging use only.
                    //myStream.Length
                    byte[] buffer = new byte[myStream.Length];
                    // buffer_loc += 32 * NUM_PACKETS;
                    while (buffer_loc < myStream.Length)
                    {
                        //myStream.Read(buffer,
                        myStream.Read(buffer, 0, NUM_PACKETS);
                        byte[] packet = new byte[32];

                        while (pos < NUM_PACKETS)
                        {
                            // packet_display = "";
                            Array.Copy(buffer, pos, packet, 0, 32);
                            /*for (int i = 0; i < 32; i++)
                            {
                                packet[i] = buffer[i + pos];

                                //textBox1.AppendText(packet[i].ToString("X") + " ");
                                //packet_display += packet[i].ToString("X") + " ";

                            }*/

                            val = BitConverter.ToInt16(packet, 0);
                            time_offset = BitConverter.ToUInt32(packet, 2);
                            time_calc = time_offset * .00000002;

                            if (SampleCount == 0)
                            {
                                time_from_start = time_calc;
                                prev_time_calc = time_calc;
                            }
                            else if (time_calc < prev_time_calc)
                            {
                                time_from_start += (4294967296 * .00000002 - prev_time_calc) + time_calc;
                                prev_time_calc = time_calc;
                            }
                            else
                            {
                                time_from_start += time_calc - prev_time_calc;
                                prev_time_calc = time_calc;
                            }

                            //textBox1.AppendText("\r\n\r\nTimeOffset: " + time_calc.ToString("00.000000"));
                            // packet_display += "\r\nTimeOffset: " + time_calc.ToString("00.000000");

                            for (int i = 0; i < ChannelsToGraph; i++)
                            {
                                Int16 raw_voltage = BitConverter.ToInt16(packet, 7 + i * 3);
                                //textBox1.AppendText("\tChannel" + i.ToString() + ": " + (channel[i] / 32768.0 * 5.0).ToString("0.000") + "V\t");
                                // packet_display += "\tChannel" + i.ToString() + ": " + (channel[i] / 32768.0 * 5.0).ToString("0.000") + "V\t";
                                if (raw_voltage == 0) { raw_voltage = 1; }
                                Point p1 = new Point(time_from_start, raw_voltage / 32768.0 * 10.0);
                                GraphData[i].Channel_AllData.Collection.Add(p1);
                            }
                            //textBox1.AppendText(packet_display + "\r\n\r\n");

                            //Point p1 = new Point(time_from_start, channel[0] / 32768.0 * 5.0);
                            //Point p1 = new Point(SampleCount, channel[0] / 32768.0 * 5.0);
                            //Point p1 = new Point(SampleCount, SampleCount);
                            //Channel1_Data.AppendAsync(Dispatcher, p1);
                            //Channel1_Data.Channel_AllData.Collection.Add(p1);
                            //Channel1_Data.Collection.Add(p1);
                            // Thread.Sleep(5);

                            pos += 32;
                            SampleCount++;

                            //plotter.Viewport.FitToView();
                        }
                        buffer_loc += NUM_PACKETS;
                        pos = 0;
//.........这里部分代码省略.........
开发者ID:KyleBatzer,项目名称:Thesis,代码行数:101,代码来源:Graphing.cs

示例7: LoadFileAction

        private void LoadFileAction()
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".c--";
            dlg.Filter = @"C-- programs (.c--)|*.c--|All files|*.*";

            if (dlg.ShowDialog() == true)
            {
                _lastUsedFileName = dlg.FileName;
                Title = TITLE + " " + Path.GetFileName(_lastUsedFileName);
                using (var reader = new StreamReader(dlg.OpenFile()))
                {
                    Code = new TextDocument(reader.ReadToEnd());
                }
            }
        }
开发者ID:nmenshov,项目名称:Iron-C--,代码行数:16,代码来源:MainViewModel.cs

示例8: LoadStructure_Menu_Click

        private void LoadStructure_Menu_Click(object sender, RoutedEventArgs e)
        {
            Stream dicomfile = null;

            Microsoft.Win32.OpenFileDialog opendicom = new Microsoft.Win32.OpenFileDialog();
            opendicom.Multiselect = true;
            if (opendicom.ShowDialog() != false)
            {
                if (opendicom.FileNames.GetLength(0) > 1)
                {
                    string h = ""; string t = "";
                    foreach (string s in opendicom.FileNames)
                    {
                        System.IO.FileInfo f = new FileInfo(s);
                        if (f.Extension == ".h")
                            h = s;
                        if (f.Extension == ".txt")
                            t = s;
                    }
                    SS = new StructureSet(h, t);

                }
                else
                {
                    dicomfile = opendicom.OpenFile();
                    //TM = new DICOMRT(opendicom.FileName, 0);
                }

                if (SS.f_structurearray != null)
                {
                    slider2.Minimum = 0;
                    slider2.Maximum = SS.f_structurearray.GetLength(0);
                    tabControl1.SelectedIndex = 1;
                }
                AddStructureLoadedToListBox();
                Plan_btn.IsEnabled = true;
            }
        }
开发者ID:ngowdar,项目名称:TomosurgeryAlpha,代码行数:38,代码来源:MainWindow.xaml.cs

示例9: LoadConfigExecute

		private void LoadConfigExecute(object sender)
		{
			var fileDialog = new OpenFileDialog();
			fileDialog.Multiselect = false;
			fileDialog.CheckFileExists = true;
			fileDialog.DefaultExt = "*.msConfigStore";
			fileDialog.Filter = "ConfigFile (*.msConfigStore)|*.msConfigStore";
			var result = fileDialog.ShowDialog();
			if (result.HasValue && result.Value == true && File.Exists(fileDialog.FileName))
			{
				this.Tables.Clear();
				this.Views.Clear();
				this.StoredProcs.Clear();

				var binFormatter = new BinaryFormatter();
				ConfigStore options;
				try
				{
					using (var fs = fileDialog.OpenFile())
					{
						options = (ConfigStore)binFormatter.Deserialize(fs);
					}
				}
				catch (Exception)
				{
					Status = "File is an in invalid format";
					return;
				}

				var version = typeof(SharedMethods).Assembly.GetName().Version;
				if (new Version(options.Version) != version)
				{
					var messageBoxResult = MessageBox.Show(App.Current.MainWindow,
						"Warning Version missmatch",
						string.Format("The current Entity Creator version ({0}) is not equals the version ({1}) you have provided.",
							version, options.Version),
						MessageBoxButton.OKCancel);

					if(messageBoxResult == MessageBoxResult.Cancel)
						return;
				}

				foreach (var option in options.Tables)
				{
					var itemExisits = this.Tables.FirstOrDefault(s => s.Info.TableName == option.Info.TableName);
					if (itemExisits != null)
					{
						this.Tables.Remove(itemExisits);
					}

					this.Tables.Add(new TableInfoViewModel(option, this));
				}
				foreach (var option in options.Views)
				{
					this.Views.Add(new TableInfoViewModel(option, this));
				}
				foreach (var option in options.StoredPrcInfoModels)
				{
					this.StoredProcs.Add(option);
				}

				if (options.SourceConnectionString != null)
				{
					this.ConnectionString = options.SourceConnectionString;
					this.CreateEntrys(this.ConnectionString, "", string.Empty);
				}

				this.GenerateConstructor = options.GenerateConstructor;
				this.GenerateForgeinKeyDeclarations = options.GenerateForgeinKeyDeclarations;
				this.GenerateCompilerHeader = options.GenerateCompilerHeader;
				this.GenerateConfigMethod = options.GenerateConfigMethod;
				this.Namespace = options.Namespace;
				this.TargetDir = options.TargetDir;
				this.SelectedTable = Tables.FirstOrDefault();
			}
		}
开发者ID:JPVenson,项目名称:DataAccess,代码行数:76,代码来源:SqlEntityCreatorViewModel.cs

示例10: ObtenerBytex

        private byte[] ObtenerBytex()
        {
            System.IO.Stream stream;
            Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog();
            openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            openDialog.Filter = "Pictures(*.jpg;*.jpeg;*.gif;*.png;*.bmp)|*.jpg;*.jpeg;*.gif;*.png;*.bmp| All Files (*.*)|*.*";
            openDialog.FilterIndex = 1;
            openDialog.Multiselect = false;
            byte[] imageData = null;

            if (openDialog.ShowDialog() == true)
            {
                try
                {
                    if ((stream = openDialog.OpenFile()) != null)
                    {
                        arcOri = openDialog.FileName;
                        ext = System.IO.Path.GetExtension(arcOri);
                        using (stream)
                        {
                            imageData = new byte[stream.Length];
                            stream.Read(imageData, 0, (int)stream.Length);
                        }
                        return imageData;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: No se puede subir la imagen " + ex.Message);
                    imageData = null;
                }
            }
            return imageData;
        }
开发者ID:amarodev,项目名称:PantallasCC,代码行数:34,代码来源:WDoc.xaml.cs

示例11: importPB_Click

        private void importPB_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog o = new Microsoft.Win32.OpenFileDialog();
            if (o.ShowDialog()==true)
            {
                System.IO.Stream myStream = o.OpenFile();
                byte[] bt = new byte[myStream.Length];
                myStream.Read(bt,0,(int)myStream.Length);

                var item = datagrid1.SelectedItem as EmployeeInfo;
                var q = from t in context.EmployeeInfo
                        where t.EmployeeNo == item.EmployeeNo
                        select t;
                try
                {
                    var q1 = q.FirstOrDefault();
                    if (q1!=null)
                    {
                        q1.photo = bt;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                   
                }
            }
        }
开发者ID:978823884,项目名称:HBNews,代码行数:28,代码来源:EmployeeBase.xaml.cs

示例12: MenuItem_Click

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog temp = new Microsoft.Win32.OpenFileDialog();
            Stream myStream = null;

            List<Tuple<string, int>> resultat = new List<Tuple<string, int>>();

            temp.Filter = "CSV files (*.csv)|*.csv";
            Nullable<bool> result = temp.ShowDialog();
            if (result == true)
            {
                try
                {
                    if ((myStream = temp.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            StreamReader sr = new StreamReader(myStream);
                            String s = sr.ReadLine();
                            String[] temps;
                            while (s != null)
                            {
                                temps = s.Split(';');
                                resultat.Add(new Tuple<string, int>(temps[0], int.Parse(temps[1])));
                                s = sr.ReadLine();
                            }
                            sr.Close();
                        }
                    }
                    myStream.Close();

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message + "\n" + ex.TargetSite + "\n" + ex.StackTrace + "\n" + ex.HelpLink);
                }
                worker.RunWorkerAsync(resultat);
            }
        }
开发者ID:TigerSCR,项目名称:TigerAppWPF,代码行数:39,代码来源:MainWindow.xaml.cs

示例13: Execute

            public void Execute(object parameter)
            {
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                ofd.ValidateNames = true;
                ofd.Multiselect = false;
                if (ofd.ShowDialog() != true) return;

                using (System.IO.Stream s = ofd.OpenFile()) {
                    List<Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair> list = new List<Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair>();
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(list.GetType());
                    list = (List<Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair>)xs.Deserialize(s);

                    var rules = Settings.Current.ProxySettings.Rules;
                    list.ForEach(kv => rules[kv.Key] = kv.Value);

                    ((IProxySettings)Settings.Current.ProxySettings).CompiledRules = null;
                    vm.RaisePropertyChanged(nameof(vm.Rules));
                }
            }
开发者ID:c933103,项目名称:KanColleViewer,代码行数:21,代码来源:ProxyRulesViewModel.cs

示例14: _btnOpen_Click

 void _btnOpen_Click(object sender, RoutedEventArgs e)
 {
     var dlg = new Microsoft.Win32.OpenFileDialog();
     dlg.Filter = "Excel Workbook (*.xlsx)|*.xlsx";
     if (dlg.ShowDialog().Value)
     {
         try
         {
             using (var s = dlg.OpenFile())
             {
                 _flex.Load(s);
             }
         }
         catch (Exception x)
         {
             var msg = "Error opening file: \r\n\r\n" + x.Message;
             MessageBox.Show(msg, "Error", MessageBoxButton.OK);
         }
     }
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:20,代码来源:MainWindow.xaml.cs

示例15: OpenTeamWithFileDialog

        public static TeamViewModel OpenTeamWithFileDialog()
        {
            //hack: duplicated code don't have time to organize right now.
              Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
              dlg.InitialDirectory = Properties.Resources.InitialDirectory;
              dlg.Multiselect = false;
              var result = dlg.ShowDialog();
              if (result == null || result == false)
            return null;

              var stream = dlg.OpenFile();
              stream.Position = 0;

              var team = Team.LoadFromFile(stream);
              stream.Close();
              team.FileNameFullPath = dlg.FileName;
              team.Text = dlg.SafeFileName;

              var teamVM = Services.Container.GetExportedValue<TeamViewModel>();
              teamVM.Team = team;

              return teamVM;
        }
开发者ID:bill-mybiz,项目名称:NeroUtils,代码行数:23,代码来源:Team.cs


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