Пример #1
0
 private void OnBrowseForFilePath(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.FileDialog filePathBrowser = (Microsoft.Win32.FileDialog)Resources["mFilePathBrowser"];
     filePathBrowser.InitialDirectory = mFilePathBox.Text;
     filePathBrowser.FileName         = "[Filename will be ignored]";
     if (filePathBrowser.ShowDialog(this).GetValueOrDefault())
     {
         mFilePathBox.Text = System.IO.Path.GetDirectoryName(filePathBrowser.FileName);
     }
 }
        private void btnFileDlg_Click(object sender, RoutedEventArgs e)
        {
            resetGUI(true);
            fileDlg = new Microsoft.Win32.OpenFileDialog();

            fileDlg.InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Rocket League\TAGame\Demos\");
            fileDlg.Filter = "RL-Replay Files (*.replay)|*.replay";
            if(fileDlg.ShowDialog() == true) {
                txtBoxFileName.Text = System.IO.Path.GetFileName(fileDlg.FileName);
                lblCreatedAt.Content = File.GetLastWriteTime(fileDlg.FileName).ToString();
            }
        }
Пример #3
0
        private void resetGUI(bool resetAll)
        {
            lblSaved.Content = "";

            if (resetAll)
            {
                txtBoxFileName.Text  = "";
                txtBoxJSON.Text      = "";
                lblCreatedAt.Content = "";
                fileDlg = null;
            }
        }
Пример #4
0
        private void btnFileDlg_Click(object sender, RoutedEventArgs e)
        {
            resetGUI(true);
            fileDlg = new Microsoft.Win32.OpenFileDialog();

            fileDlg.InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Rocket League\TAGame\Demos\");
            fileDlg.Filter           = "RL-Replay Files (*.replay)|*.replay";
            if (fileDlg.ShowDialog() == true)
            {
                txtBoxFileName.Text  = System.IO.Path.GetFileName(fileDlg.FileName);
                lblCreatedAt.Content = File.GetLastWriteTime(fileDlg.FileName).ToString();
            }
        }
Пример #5
0
 public void PokazSaveDialog(string fileFilter)
 {
     fileDialog        = new Microsoft.Win32.SaveFileDialog();
     fileDialog.Filter = fileFilter;
     if (fileDialog.ShowDialog() == true)
     {
         List <string> adresyMailowe = new List <string>();
         foreach (var adres in ViewModels.Adres.ListaAdresow)
         {
             adresyMailowe.Add((adres.AdresMailowy).ToString());
             System.IO.File.WriteAllLines(fileDialog.FileName, adresyMailowe.ToArray());
         }
     }
 }
Пример #6
0
        private static string GetFileDialog(string initialDirectory = null, string fileName = null,
                                            string defaultExt       = null, string filter   = null, bool isOpenFile = true)
        {
            Microsoft.Win32.FileDialog dlg = isOpenFile
                ? new Microsoft.Win32.OpenFileDialog() as Microsoft.Win32.FileDialog
                : new Microsoft.Win32.SaveFileDialog() as Microsoft.Win32.FileDialog
            ;

            dlg.InitialDirectory = initialDirectory ?? CaminhoPadrao.GetPathSubPasta();
            dlg.FileName         = fileName ?? "Arquivo";                // Default file name
            dlg.DefaultExt       = defaultExt ?? ".txt";                 // Default file extension
            dlg.Filter           = filter ?? "Arquivo TXT (.txt)|*.txt"; // Filter files by extension

            return(dlg.ShowDialog() ?? false ? dlg.FileName : null);
        }
Пример #7
0
        /// <summary>
        /// Displays given dialog and returns its result as a <c>string</c>.
        /// </summary>
        /// <param name="dialog">The dialog to show.</param>
        /// <param name="filter">File type filter string.</param>
        /// <returns>Path to selected file, or <c>null</c> if no file was selected.</returns>
        private static string ShowDialog(FileDialog dialog, string filter)
        {
            string fileName = null;

            dialog.Filter           = filter;
            dialog.RestoreDirectory = true;

            bool?result = dialog.ShowDialog();

            if (result == true)
            {
                fileName = dialog.FileName;
            }

            return(fileName);
        }
Пример #8
0
 public void PokazOpenDialog(string fileFilter)
 {
     fileDialog        = new Microsoft.Win32.OpenFileDialog(); //utworzenie instancji klasy OpenFileDialog
     fileDialog.Filter = fileFilter;
     if (fileDialog.ShowDialog() == true)
     {
         string     tekst      = "";
         FileStream fileStream = new FileStream(fileDialog.FileName,
                                                FileMode.Open);
         StreamReader streamReader = new StreamReader(fileStream, Encoding.Default);
         while ((tekst = streamReader.ReadLine()) != null)
         {
             ViewModels.Adres.ListaAdresow.Add(new AdresViewModel(tekst, true, false, true));
         }
         fileStream.Close();
     }
 }
Пример #9
0
        public void ZalacznikOpenDialog()
        {
            fileDialog = new Microsoft.Win32.OpenFileDialog(); //utworzenie instancji klasy OpenFileDialog
            if (fileDialog.ShowDialog() == true)
            {
                string nazwa = "";
                string adres = "";

                FileStream fileStream = new FileStream(fileDialog.FileName,
                                                       FileMode.Open);
                StreamReader streamReader = new StreamReader(fileStream, Encoding.Default);
                nazwa = fileDialog.SafeFileName; ///do zmiany
                adres = fileDialog.FileName;

                ViewModels.MainViewModel.ListaZalacznikow.Add(new ZalacznikViewModel(nazwa, adres));
                fileStream.Close();
            }
        }
Пример #10
0
    /// <summary>
    /// Open this file dialog on top of all other windows
    /// </summary>
    /// <param name="fileDialog"></param>
    /// <returns></returns>
    public static bool?Show(Microsoft.Win32.FileDialog fileDialog)
    {
        Window win = new Window();

        win.ResizeMode  = System.Windows.ResizeMode.NoResize;
        win.WindowStyle = System.Windows.WindowStyle.None;
        win.Topmost     = true;
        win.Visibility  = System.Windows.Visibility.Hidden;
        win.Content     = fileDialog;
        bool?result = false;

        win.Loaded += (s, e) =>
        {
            result = fileDialog.ShowDialog();
        };
        win.ShowDialog();
        return(result);
    }
        private void resetGUI(bool resetAll)
        {
            lblSaved.Content = "";

            if(resetAll) {
                txtBoxFileName.Text = "";
                txtBoxJSON.Text = "";
                lblCreatedAt.Content = "";
                fileDlg = null;
            }
        }
Пример #12
0
        static public string GetFileName(this Microsoft.Win32.FileDialog dialog)
        {
            bool?result = dialog.ShowDialog();

            return(result.HasValue && result.Value ? dialog.FileName : (string)null);
        }
Пример #13
0
 private static void AssignCommonFileDialogProps(Microsoft.Win32.FileDialog dlg)
 {
     dlg.DefaultExt = "*.droppy";
     dlg.Filter     = "Droppy Configuration Files (*.droppy)|*.droppy";
 }
 FileDialogResult IUIServiceWpf.ShowFileDialog(Microsoft.Win32.FileDialog dialog)
 {
     return(GetService <IUIServiceWpf>().ShowFileDialog(dialog));
 }