ShowDialog() public méthode

public ShowDialog ( ) : bool?
Résultat bool?
 private void OpenClick(object sender, RoutedEventArgs e)
 {
     OpenFileDialog openDialog = new OpenFileDialog();
     openDialog.Filter = "clients.json|clients.json"; //http://www.wpf-tutorial.com/dialogs/the-openfiledialog/
     openDialog.ShowDialog();
     string ClientFile = openDialog.FileName;
     openDialog.Filter = "workers.json|workers.json";
     openDialog.ShowDialog();
     string WorkerFile = openDialog.FileName;
     if (ClientFile == "" || WorkerFile == "") { MessageBox.Show("Select both files!"); return; }
     try
     {
         Clients.RemoveAll(t => t.Name == t.Name);
         Clients.AddRange(JsonConvert.DeserializeObject<List<Person>>(File.ReadAllText(ClientFile)));
         ClientData.Items.Refresh();
         ClientGrid.IsEnabled = true;
         Workers.RemoveAll(t => 1 == 1);
         Workers.AddRange(JsonConvert.DeserializeObject<List<Person>>(File.ReadAllText(WorkerFile)));
         WorkerData.Items.Refresh();
         WorkerGrid.IsEnabled = true;
     }
     catch (Exception exc)
     {
         MessageBox.Show("Something went wrong! " + exc.Message);
     }
 }
		private void ImportImageButtonClick(object sender, RoutedEventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
#if WPF
			openFileDialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp";
#else
			openFileDialog.Filter = "Image Files (*.png, *.jpg)|*.png;*.jpg";
#endif
			bool? dialogResult = openFileDialog.ShowDialog();
			if (dialogResult.HasValue && dialogResult.Value == true)
			{
				Image image = new Image();
#if WPF
				image.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
#else
					using (var fileOpenRead = openFileDialog.File.OpenRead())
					{
						BitmapImage bitmap = new BitmapImage();
						bitmap.SetSource(fileOpenRead);
						image.Source = bitmap;
					}
#endif
				Viewbox viewBox = new Viewbox() { Stretch = Stretch.Fill, Margin = new Thickness(-4) };
				viewBox.Child = image;
				RadDiagramShape imageShape = new RadDiagramShape()
				{
					Content = viewBox
				};
				this.diagram.Items.Add(imageShape);
			}
		}
        private void Button3_Click(object sender, RoutedEventArgs eArgs)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            if (dlg.ShowDialog() != true)
                return;

            var txtLines = System.IO.File.ReadAllLines(dlg.FileName);
            var pts = new ObservableCollection<NehPoint>();

            var idexFile = Path.ChangeExtension(dlg.FileName, ".idx");
            using (var idexStream = new FileStream(idexFile, FileMode.Create))
            {
                using (var gsiWriter = new IDEXFileWriter(idexStream))
                {
                    foreach (var ln in txtLines)
                    {
                        if (!string.IsNullOrEmpty(ln.Trim())) {
                        var pt = new NehPoint(ln);
                        gsiWriter.AddPoint(pt.Id, pt.E, pt.N, pt.H, null);
                        pts.Add(pt);
                        }
                    }
                }
            }
            PtsGrid.ItemsSource = pts;
            MessageBox.Show("Saved to: \r\n" + idexFile);
        }
Exemple #4
0
        /// <summary>
        /// Initializes the gamePath if not specefied defines new one
        /// </summary>
        private void InitGamePath()
        {
            if (AppSettings.getPropertyValue<string>("GamePath").Length > 2 || Directory.Exists(AppSettings.getPropertyValue<string>("GamePath")) == false)
            {
                RegistryKey regKey = Registry.CurrentUser;
                regKey = regKey.OpenSubKey(@"Software\Valve\Steam");

                if (regKey != null && regKey.GetValue("SteamPath") != null && Directory.Exists(regKey.GetValue("SteamPath").ToString().Replace("/", "\\") + "\\steamapps\\common\\Arma 3"))
                {
                    AppSettings.setProperty("GamePath", regKey.GetValue("SteamPath").ToString().Replace("/", "\\") + "\\steamapps\\common\\Arma 3");
                    AppSettings.SaveAsync();
                    return;
                }
                else
                    if (MessageBox.Show("Unable to locate \"arma3.exe\"!" + Environment.NewLine + "Do you want so specify it?", "Installation not found!", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                    {
                        OpenFileDialog ofd = new OpenFileDialog();
                        ofd.Filter = "Arma 3|arma3.exe";

                        if (ofd.ShowDialog() == true)
                        {
                            AppSettings.setProperty("GamePath", ofd.FileName.Replace("\\" + ofd.FileName.Split('\\')[ofd.FileName.Split('\\').Length - 1], ""));
                            AppSettings.SaveAsync();
                        }
                        else
                            Environment.Exit(1223);
                    }
                    else
                        Environment.Exit(1223);
            }
        }
        /// <summary>
        /// Get the nodes from the selected text file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnNodefileSel_OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            //openFileDialog.InitialDirectory = citiesIn.filepath;
            if (openFileDialog.ShowDialog() == true)
            {
                txtboxNodefile.Text = @"...\" + openFileDialog.SafeFileName;
                citiesIn.filepath = openFileDialog.FileName;
            }

            // set the value of the combobox
            nodelist = citiesIn.GetCitieses();
            maxNumofCities = nodelist.Count;
            List<string> citynames = nodelist.Select(cityNode => cityNode.city).ToList();
            comboboxStartCity.ItemsSource = citynames;
            comboboxStartCity.SelectedIndex = 0;
            lboxManualSelectNodes.ItemsSource = citynames;

            if (RandomNodeSelect.IsChecked == true)
                lboxManualSelectNodes.IsEnabled = false;
            else
                lboxManualSelectNodes.IsEnabled = true;

            // draw the circles
            _drawlines(citylisttodraw);
        }
Exemple #6
0
        public void LoadImage()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Bitmap Image (.bmp)|*.bmp|PNG Image (.png)|*.png|JPEG Image (.jpeg)|*.jpeg|JPG Image (.jpg)|*.jpg";

            bool? result = ofd.ShowDialog();

            string fileName = "";
            if (result != null)
                fileName = ofd.FileName;

            if (fileName == "")
                return;

            canvas.Children.Clear();
            BitmapImage image;
            using (FileStream stream = new FileStream(fileName, FileMode.Open))
            {
                stream.Position = 0;
                image = new BitmapImage();
                image.BeginInit();
                image.StreamSource = stream;
                image.CacheOption = BitmapCacheOption.OnLoad;
                image.EndInit();
            }
            canvas.Background = new ImageBrush(image);
        }
		private void btnRun_Click(object sender, RoutedEventArgs e)
		{
			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Filter = "Programs|*.exe|All files|*.*";
			dlg.DefaultExt = ".exe";
			if (!(dlg.ShowDialog() ?? false))
				return;
			string path = dlg.FileName;

			// remove UI before disposing profiler
			//this.timeLine.ValuesList.Clear();
			if (this.provider != null)
				this.provider.Close();

			if (this.profiler != null)
				this.profiler.Dispose();
			
			string pathToDb = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(Profiler.Controller.Profiler).Assembly.Location), "output.sdps");
			if (File.Exists(pathToDb))
				File.Delete(pathToDb);
			
			this.database = new TempFileDatabase();
			
			this.profiler = new Profiler.Controller.Profiler(path, database.GetWriter(), new ProfilerOptions());
			profiler.RegisterFailed += delegate { MessageBox.Show("register failed"); };
			profiler.DeregisterFailed += delegate { MessageBox.Show("deregister failed"); };

			this.profiler.OutputUpdated += profiler_OutputUpdated;
			this.profiler.SessionEnded += profiler_SessionEnded;

			this.profiler.Start();

			this.btnRun.IsEnabled = false;
			this.btnStop.IsEnabled = true;
		}
        // �����Ϳ��� �̺�Ʈ �ڵ鷯 (���� IO�κ�)
        // ������ ������� ���̴� Deserialize�� Serialize �κ�
        void OpenOnExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            OpenFileDialog dlg = new OpenFileDialog();    // ���Ͽ��� ���̾�α� ��ü ����
            dlg.Filter = strFilter;                                   // ǥ�õǴ� �������� ���� (�������ĺκ�)
            Person pers;                                            // PersonŬ���� ��ü ����

            if ((bool)dlg.ShowDialog(this))                      // ���Ͽ��� ���̾�αװ� ����������?
            {
                try
                {
                    // �����̸� ���ڿ��� �д� ��Ʈ�� ���� ��ü ����
                    StreamReader reader = new StreamReader(dlg.FileName);
                    // ��Ʈ������ ��ü�� �籸�� �ؼ� Person ��ü�� ����
                    pers = (Person) xml.Deserialize(reader);
                    reader.Close();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("������ �����ھ�� ��  _�� : " + exc.Message,
                                    Title, MessageBoxButton.OK,  MessageBoxImage.Exclamation);
                    return;
                }
                // DataContext�� ��Ұ� ���ε��� ���Ǵ� ������ �ҽ��� ���� ���� �� ��� ��
                // ���ε��� ��Ÿ Ư���� �θ� ��ҷκ��� ��� �� �� �ֵ��� �ϴ� ����.
                pnlPerson.DataContext = pers;
            }
        }
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog openfiledialog = new OpenFileDialog();
     openfiledialog.ShowDialog();
     //if(openfiledialog.FileOk)
        // System.IO.Stream fileStream = openfiledialog.FileOk;
 }
        //导入“1300000	"北京市"	"联通"”文本格式数据
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "文本文件|*.txt";
            if (ofd.ShowDialog() == false)
            {
                return;
            }

            string[] lines = File.ReadLines(ofd.FileName, Encoding.Default).ToArray();

            for (int i = 1; i < lines.Count(); i++)
            {
                string line = lines[i];
                string[] str = line.Split('\t');
                string startTeLNum = str[0];
                string city = str[1];
                city = city.Trim('"');
                string telType = str[2];
                telType = telType.Trim('"');
                SqlHelper.ExecuteQuery(@"Insert into T_TelNum(StartTelNum,TelType,TelArea) 
                    values(@StartTelNum,@TelType,@TelArea)",
                    new SqlParameter("@StartTelNum", startTeLNum),
                new SqlParameter("@TelType", telType),
                new SqlParameter("@TelArea", city));
            }
            MessageBox.Show("导入成功!"+lines.Count()+"条数据");
        }
        //导入“张三|123”文本格式数据
        private void btn_insert_Click(object sender, RoutedEventArgs e)
        {
            //打开文本
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "文本文件|*.txt";
            if (ofd.ShowDialog() != true)
            {
                return;
            }
            string filename = ofd.FileName;

            //把文件一次读取到string集合中
            IEnumerable<string> lines = File.ReadLines(filename, Encoding.Default);

            foreach (string line in lines)
            {
                string[] segs = line.Split('|', ' ');
                string name = segs[0];
                string age = segs[1];
                SqlHelper.ExecuteQuery("insert into custome(Name,Age)values(@Name,@Age)",
                    new SqlParameter("@Name", name),
                    new SqlParameter("@Age", Convert.ToInt32(age)));
            }
            MessageBox.Show("导入成功" + lines.Count() + "条数据!");
        }
Exemple #12
0
        private void EjectButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog { Title = "Select an audio file (wma, mp3, ...etc.) or video file..." };
            if (dialog.ShowDialog() == true)
            {
                lock (lockAudio)
                {
                    if (audioPlayer != null)
                    {
                        audioPlayer.Close();
                        audioPlayer = null;
                    }

                    if (fileStream != null)
                    {
                        fileStream.Close();
                    }

                    // Ask the user for a video or audio file to play
                    fileStream = new NativeFileStream(dialog.FileName, NativeFileMode.Open, NativeFileAccess.Read);

                    audioPlayer = new AudioPlayer(xaudio2, fileStream);

                    FilePathTextBox.Text = dialog.FileName;
                    SoundProgressBar.Maximum = audioPlayer.Duration.TotalSeconds;
                    SoundProgressBar.Value = 0;

                    // Auto-play
                    audioPlayer.Play();
                }
            }
        }
        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == true)
                SetPreviewImage(dialog.FileName);
        }
        private async void btnChooseFile_Click(object sender, RoutedEventArgs e)
        {
            SelectExistingRamlOption();
            FileDialog fd = new OpenFileDialog();
            fd.DefaultExt = ".raml;*.rml";
            fd.Filter = "RAML files |*.raml;*.rml";

            var opened = fd.ShowDialog();

            if (opened != true)
            {
                return;
            }

            RamlTempFilePath = fd.FileName;
            RamlOriginalSource = fd.FileName;

            var title = Path.GetFileName(fd.FileName);

            
            var preview = new RamlPreview(ServiceProvider, action, RamlTempFilePath, RamlOriginalSource, title, isContractUseCase);
            
            StartProgress();
            preview.FromFile();
            StopProgress();

            var dialogResult = preview.ShowDialog();
            if(dialogResult == true)
                Close();
        }
Exemple #15
0
        /**
         * <summary>Zeigt OpenFileDialog an</summary>
         *
         * <remarks>Beate, 09.10.2013.</remarks>
         */
        private static string OpenFile()
        {
            string[] allfiles = { };
            string filename = string.Empty;
            string path = string.Empty;
            List<string> filenameOnly = new List<string>();
            OpenFileDialog inputDlg = new OpenFileDialog();
            inputDlg.Multiselect = true;
            inputDlg.InitialDirectory = @"";
            inputDlg.Filter = "Xmascup Competitor Dateien|Competitor*.xml";

            if (inputDlg.ShowDialog().Value)
            {
                allfiles = inputDlg.FileNames;
                foreach (string s in allfiles)
                {
                    filename = System.IO.Path.GetFileName(s);
                    path = System.IO.Path.GetDirectoryName(s);
                    filenameOnly.Add(filename);

                }

                MessageBox.Show("Eingabe: " + filename,
                    "Xmascup Dateiauswahl");
                return allfiles[0].ToString();
            }
            else
            {
                MessageBox.Show("Keine Datei ausgewählt !!",
                     "Xmascup Dateiauswahl");
                return "keine Auswahl getroffen";
            }
        }
        private void MenuEtude_Click(object sender, RoutedEventArgs e)
        {
            //Configuration de la boite de dialogue ouvrir fichier
            OpenFileDialog open = new OpenFileDialog();
            open.FileName = "Document";
            open.DefaultExt = ".xls; .xlsx"; //Extention de fichier par default
            open.Filter = "Excel document (.xls; .xlsx) | *.xls; *.xlsx"; //Filtre les fichier par extention

            //Afficher la boite de dialogue
            Nullable<bool> result = open.ShowDialog();

            //Traitement d'ouverture de fichier
            if (result == true)
            {
                _filePath = open.FileName;
                
               //DonneesFichierExcelView donneesfichierexcel = new DonneesFichierExcelView(filePath);
                donneesFichierExcel = new DonneesFichierExcelView(_filePath);
                GridMilieu.Children.Clear();
                GridMilieu.Children.Add(donneesFichierExcel);
                MenuHaut.IsEnabled = true;
                MenuHautAfficheDonnees.IsEnabled = false;
                MenuHautParametre.IsEnabled = true;
                MenuHautAnalyse.IsEnabled = true;
                MenuHautImpression.IsEnabled = false;
            }
        }
 private void SetMode()
 {
     if(IsFileSelector)
     {
         ButtonText = "\uF15C";
         ButtonCommand = new RelayCommand(() => 
         {
             var dlg = new OpenFileDialog();
             if (dlg.ShowDialog() == true)
             {
                 ConfigItemValue = dlg.FileName;
             }
         }, true);
     }
     else
     {
         ButtonText = "\uF07C";
         ButtonCommand = new RelayCommand(() =>
         {
             var dlg = new System.Windows.Forms.FolderBrowserDialog();
             dlg.ShowNewFolderButton = true;
             dlg.ShowDialog();
             if (!String.IsNullOrEmpty(dlg.SelectedPath))
             {
                 ConfigItemValue = dlg.SelectedPath;
             }
         }, true);
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Multiselect = false;
            fileDialog.ShowDialog();
            if (fileDialog.FileName == string.Empty)
            {
                return;
            }

            var titleDialog = new ImageTitleDialogBox();
            titleDialog.Owner = this;
            var result = titleDialog.ShowDialog();
            if (result != true)
            {
                return;
            }

            var newImage = new ImageViewModel()
            {
                Title = titleDialog.tbImageTitle.Text,
                Source = fileDialog.FileName
            };

            var viewModel = (ImageGalleryViewModel)DataContext;
            if (viewModel.CurrentAlbum.AddImage.CanExecute(null))
            {
                viewModel.CurrentAlbum.AddImage.Execute(newImage);
            }
        }
Exemple #19
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            // 画像を開く
            var dialog = new OpenFileDialog();
            dialog.Filter = "画像|*.jpg;*.jpeg;*.png;*.bmp";
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            // ファイルをメモリにコピー
            var ms = new MemoryStream();
            using (var s = new FileStream(dialog.FileName, FileMode.Open))
            {
                s.CopyTo(ms);
            }
            // ストリームの位置をリセット
            ms.Seek(0, SeekOrigin.Begin);
            // ストリームをもとにBitmapImageを作成
            var bmp = new BitmapImage();
            bmp.BeginInit();
            bmp.StreamSource = ms;
            bmp.EndInit();
            // BitmapImageをSourceに指定して画面に表示する
            this.image.Source = bmp;
        }
 private void OpenDDL_Click(object sender, RoutedEventArgs e)
 {
   OpenFileDialog dialog = null;
   try
   {
     dialog = new OpenFileDialog();
     dialog.CheckFileExists = true;
     dialog.CheckPathExists = true;
     dialog.Filter = "MigraDoc DDL (*.mdddl)|*.mdddl|All Files (*.*)|*.*";
     dialog.FilterIndex = 1;
     dialog.InitialDirectory = System.IO.Path.Combine(GetProgramDirectory(), "..\\..");
     //dialog.RestoreDirectory = true;
     if (dialog.ShowDialog() == true)
     {
       Document document = DdlReader.DocumentFromFile(dialog.FileName);
       string ddl = DdlWriter.WriteToString(document);
       preview.Ddl = ddl;
     }
   }
   catch (Exception ex)
   {
     MessageBox.Show(ex.Message, Title);
     preview.Ddl = null; // TODO has no effect
   }
   finally
   {
     //if (dialog != null)
     //  dialog.Dispose();
   }
   //UpdateStatusBar();
 }
        private void OpenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (asm != null && asm.Strings.Any(s => s.IsDirty))
            {
                if (MessageBox.Show("You have unsaved changes. Really open a new file?", Title, MessageBoxButton.YesNo) == MessageBoxResult.No)
                    return;
            }

            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != true)
                return;

            try
            {
                using (var f = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read))
                {
                    DataContext = asm = CompiledAssembly.Load(f);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Could not open file: {ex}");
            }
        }
Exemple #22
0
        internal async Task Load_File(CancellationToken cancellation, IProgress<Tuple<string, int>> currentTaskAndPercentComplete)
        {
            if (UnsavedChangesPresent && !_window.Confirm_Discard_Changes()) return;

            var dialog = new OpenFileDialog
            {
                DefaultExt = DataFileExt,
                Filter = DataFileFilter
            };
            if (dialog.ShowDialog() ?? false)
            {
                FileList = await FileAccess.LoadInfo(dialog.FileName, cancellation, currentTaskAndPercentComplete);
                if (cancellation.IsCancellationRequested)
                {
                    return;
                }

                UnsavedChangesPresent = false;
                if (FileList.Any())
                {
                    FileIndex = 0;
                    RectangleIndex = 0;
                    RectangleHasFocus = false;
                    await _window.Canvas.LoadImage(this, FileIndex);
                    _window.Canvas.LoadRectangles(this, FileIndex);
                }
            }
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog dlg = new OpenFileDialog();
     dlg.FileOk += Dlg_FileOk;
     dlg.Filter = "*.jpg|*.jpg";
     dlg.ShowDialog();
 }
        public void CustomButtonClick()
        {
            var openDialog = new OpenFileDialog
              {
            CheckFileExists = true,
            Filter = "Sitecore Package or ZIP Archive (*.zip)|*.zip",
            Title = "Choose Package",
            Multiselect = true
              };
              if (openDialog.ShowDialog(Window.GetWindow(this)) == true)
              {
            foreach (string path in openDialog.FileNames)
            {
              var fileName = Path.GetFileName(path);

              if (string.IsNullOrEmpty(fileName))
              {
            continue;
              }

              FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(ApplicationManager.ConfigurationPackagesFolder, fileName));

              var products = this.checkBoxItems.Where(item => !item.Name.Equals(fileName, StringComparison.OrdinalIgnoreCase)).ToList();
              products.Add(new ProductInCheckbox(Product.GetFilePackageProduct(Path.Combine(ApplicationManager.ConfigurationPackagesFolder, fileName))));
              this.checkBoxItems = new ObservableCollection<ProductInCheckbox>(products);
              this.unfilteredCheckBoxItems = new ObservableCollection<ProductInCheckbox>(products);
              this.filePackages.ItemsSource = this.checkBoxItems;

              this.SelectAddedPackage(fileName);
            }
              }
        }
Exemple #25
0
        private void AddImageMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                InitialDirectory = @"C:\Users\Dmitry\Pictures",
                FilterIndex = 2,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() != null)
            {
                try
                {
                    var image = new BitmapImage(new Uri(openFileDialog.FileName));
                    if(_height == 0)
                    {
                        _height = image.PixelHeight;
                        _width = image.PixelWidth;
                        _pixelsNumber = _width*_height;
                    }
                    _standardImages.Add(image);
                    _standardImageVectors.Add(GetImageVector(BitmapConverter.BitmapImage2Bitmap(image)));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
      private void SelectFile(object sender, RoutedEventArgs e)
      {
         SoundItem soundItem = DataContext as SoundItem;
         if (soundItem == null)
            return;

         string oldPath = soundItem.FilePath;

         // Open a dialog to have the user pick a file.
         // NOTE: I made a default filter for WAV files but for all I know the
         // SoundPlayer class will play others.  I added the "All files" filter
         // for this situation.
         OpenFileDialog ofd = new OpenFileDialog();
         ofd.Title = "Select .wav file";
         ofd.Filter = "WAV files (*.wav)|*.wav|All files (*.*)|*.*";
         ofd.Multiselect = false;
         
         DirectoryInfo di = SoundController.GetSoundProfileDirectory();
         ofd.InitialDirectory = di.FullName;

         bool? result = ofd.ShowDialog();

         // If the user canceled or otherwise exited, do nothing.
         if (result == null || result == false)
            return;

         // Set the new path and submit it for loading.
         soundItem.FilePath = ofd.FileName;
         if (soundItem.Submit() != Status.Success)
         {
            soundItem.FilePath = oldPath;
         }
      }
Exemple #27
0
        private void OpenFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                InitialDirectory = @"C:\Users\Dmitry\Pictures",
                FilterIndex = 2,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() != null)
            {
                try
                {
                    _sourceImage = new BitmapImage(new Uri(openFileDialog.FileName));
                    _noisedImage = _sourceImage;
                    SourceImage.Source = _sourceImage;
                    _width = _sourceImage.PixelWidth;
                    _height = _sourceImage.PixelHeight;
                    _pixelsNumber = _width * _height;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
        private void btnPopupLoadFile_Click(object sender, RoutedEventArgs e)
        {
            var fileDialog = new OpenFileDialog { Multiselect = false };
            var ftoload = fileDialog.ShowDialog(this);
            if (ftoload.Value)
            {
                try
                {
                    var tabs = JObject.Parse(File.ReadAllText(fileDialog.FileName))["tabs"] as JArray;

                    List<StashBookmark> tabb = new List<StashBookmark>();

                    foreach (JObject tab in tabs)
                    {
                        string name = tab["n"].Value<string>();
                        int index = tab["i"].Value<int>();
                        var c = tab["colour"].Value<JObject>();
                        var color = Color.FromArgb(0xFF, c["r"].Value<byte>(), c["g"].Value<byte>(), c["b"].Value<byte>());
                        StashBookmark sb = new StashBookmark(name, index, color);
                        tabb.Add(sb);
                    }

                    Tabs = tabb;
                    cbTabs.SelectedIndex = 0;

                }
                catch (Exception ex)
                {
                    Popup.Error(L10n.Message("An error occurred while attempting to load stash data."), ex.Message);
                }
            }
        }
        private void open_button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            openFileDialog1.Filter = @"Evennote File(*.note)|*.note";

            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == true)
            {
                Note temp = Evennote.OpenNoteFromFile(openFileDialog1.FileName);

                titleTextBox.Text = temp.Title;

                using (MemoryStream mem = new MemoryStream())
                {
                    TextRange range = new TextRange(temp.Text.ContentStart,
                        temp.Text.ContentEnd);
                    range.Save(mem, DataFormats.XamlPackage);
                    mem.Position = 0;

                    TextRange kange = new TextRange(richTextBox.Document.ContentStart,
                        richTextBox.Document.ContentEnd);
                    kange.Load(mem, DataFormats.XamlPackage);
                }
            }
        }
        private void Add()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.DefaultExt = ".dll";
            ofd.Filter = "*.dll|*.dll";

            if (ofd.ShowDialog() == true)
            {
                var types =
                    App.Pyrite.ModulesControl.RegisterChecker(ofd.FileName).Value.ToList().Union(
                        App.Pyrite.ModulesControl.RegisterAction(ofd.FileName).Value.ToList()
                        );
                if (types.Count() == 0)
                {
                    System.Windows.MessageBox.Show("Ни одного типа не зарегистрировано");
                }
                else
                {
                    var str = "Зарегистрированы следующие типы: ";
                    foreach (var typeName in types.Select(x => x.Name))
                    {
                        str += "\r\n" + typeName;
                    }
                    System.Windows.MessageBox.Show(str);
                }
            }

            Refresh();

            lvDlls.SelectedItem = ofd.FileName;

            App.Pyrite.CommitChanges();
        }
Exemple #31
0
        /// <summary>
        ///
        /// </summary>
        private void PerformImport(string _scope, GraphDataFormatBase format)
        {
            string importData = string.Empty;

            System.Windows.Controls.OpenFileDialog openFileDialog = new System.Windows.Controls.OpenFileDialog();

            openFileDialog.Filter      = string.Format("{0} (*.{1}) | *.{1}", format.Description, format.Extension);
            openFileDialog.FilterIndex = 1;
            openFileDialog.Multiselect = false;

            bool?dialogResult = openFileDialog.ShowDialog();

            if (dialogResult == true)
            {
                // Open the file and read it into our variable
                importData = openFileDialog.File.OpenText().ReadToEnd();

                //TODO:  ADD ERROR TRAPPING HERE
                if (!string.IsNullOrEmpty(importData))
                {
                    ImportData(importData, _scope, format);
                }
            }
        }