public MainWindow()
        {
            InitializeComponent();
            openFolderDialog = new FolderBrowserDialog();
            openFolderDialog.Description = "Podaj katalog z przykładami";
            openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "*JPEG|*.jpg|Wszystkie pliki|*.*";
            openFileDialog.Title = "Podaj plik przeznaczony do rozponania";

            ojIterations = 10;
            iterationsText.Text = ojIterations.ToString();
            printLineDelegate = printByDispatcher;
            saveImagesDelegate = saveImages;
            createLearningExamplesDelegate = createLearningExamples;
            getFilesDelegate = getFiles;
            setExamplesDelegate = setExamples;
            OnStateChange = stateChange;
            OnReductionFinished = reductionFinished;
            OnReductionStarted = reductionStarted;
            files = null;
            learnButton.IsEnabled = false;
            compareButton.IsEnabled = false;
            outputDimension = 7;
            dimensionText.Text = outputDimension.ToString();

            dataBaseFileName = "C:\\database.db";
            dataBasePathText.Text = dataBaseFileName;
            getDataBaseFileNameDelegate += DBFN;

            examplesHeight = 0;
            examplesWidth = 0;
        }
Example #2
0
        //导入“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()+"条数据");
        }
Example #3
0
        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();
        }
        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 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;
         }
      }
        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);
            }
              }
        }
Example #7
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 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();
 }
Example #9
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog dlg = new OpenFileDialog();
     dlg.FileOk += Dlg_FileOk;
     dlg.Filter = "*.jpg|*.jpg";
     dlg.ShowDialog();
 }
		private void AddCellButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// Create an instance of the open file dialog box.
			OpenFileDialog openFileDialog1 = new OpenFileDialog();

			// Set filter options and filter index.
			openFileDialog1.DefaultExt = ".000";
			openFileDialog1.Filter = "S57 Cells (.000)|*.000";
			openFileDialog1.Multiselect = true;

			// Call the ShowDialog method to show the dialog box.
			bool? userClickedOK = openFileDialog1.ShowDialog();

			// Process input if the user clicked OK.
			if (userClickedOK == true)
			{
				foreach (string fileName in openFileDialog1.FileNames)
				{
					var hydroLayer = new HydrographicS57Layer() 
					{ 
						Path = fileName,
						ID = Path.GetFileNameWithoutExtension(fileName)
					};
					_hydrographicGroupLayer.ChildLayers.Add(hydroLayer);
					s57CellList.SelectedItem = hydroLayer;
				}
			}
		}
        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}");
            }
        }
Example #12
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 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);
     }
 }
Example #14
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 button1_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog openfiledialog = new OpenFileDialog();
     openfiledialog.ShowDialog();
     //if(openfiledialog.FileOk)
        // System.IO.Stream fileStream = openfiledialog.FileOk;
 }
        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);
            }
        }
Example #17
0
		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;
		}
Example #18
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);
                }
            }
        }
Example #19
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);
        }
Example #20
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);
                }
            }
        }
        /// <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);
        }
Example #22
0
        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);
                }
            }
        }
Example #23
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);
            }
        }
Example #24
0
        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 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);
        }
Example #26
0
        public string _ouvrir(typeFichier tf)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (tf == typeFichier.musique)
            {
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
                ofd.Filter = "mp3 files (*.mp3)|*.mp3";
                ofd.FilterIndex = 2;
                ofd.RestoreDirectory = true;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (ofd.OpenFile() != null)
                    {
                        try
                        {
                            Lecteur = new Audio(ofd.FileName, false);

                        }
                        catch (Exception esx)
                        {
                            MessageBox.Show("Fichier non reconnu." + esx.HResult);
                            return null;
                        }

                        return ofd.FileName;

                    }
                }
                return null;
            }
            else if (tf == typeFichier.image)
            {
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                ofd.Filter = "JPG (*.jpg)|*.jpg";
                ofd.FilterIndex = 2;
                ofd.RestoreDirectory = true;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        if (ofd.OpenFile() != null)// On attribue le chemin du fichier à lire au
                        {

                            return ofd.FileName;

                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                        return null;
                    }
                }
                return null;

            }
            return null;
        }
		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);
			}
		}
        // �����Ϳ��� �̺�Ʈ �ڵ鷯 (���� 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;
            }
        }
Example #29
0
        protected override void mergeTiffToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = imageFolder;
            openFileDialog1.Title = Properties.Resources.Select + " Input Images";
            openFileDialog1.Filter = "Image Files (*.tif;*.tiff)|*.tif;*.tiff|Image Files (*.bmp)|*.bmp|Image Files (*.jpg;*.jpeg)|*.jpg;*.jpeg|Image Files (*.png)|*.png|All Image Files|*.tif;*.tiff;*.bmp;*.jpg;*.jpeg;*.png";
            openFileDialog1.FilterIndex = filterIndex;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.Multiselect = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                filterIndex = openFileDialog1.FilterIndex;
                imageFolder = Path.GetDirectoryName(openFileDialog1.FileName);
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                saveFileDialog1.InitialDirectory = imageFolder;
                saveFileDialog1.Title = Properties.Resources.Save + " Multi-page TIFF Image";
                saveFileDialog1.Filter = "Image Files (*.tif;*.tiff)|*.tif;*.tiff";
                saveFileDialog1.RestoreDirectory = true;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    File.Delete(saveFileDialog1.FileName);

                    ImageIOHelper.MergeTiff(openFileDialog1.FileNames, saveFileDialog1.FileName);
                    MessageBox.Show(this, Properties.Resources.Mergecompleted + Path.GetFileName(saveFileDialog1.FileName) + Properties.Resources.created, strProgName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #30
0
        //导入“张三|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() + "条数据!");
        }