Example #1
0
        private void buttonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            CommonOpenFileDialog openfiledialog = new CommonOpenFileDialog();

            openfiledialog.FoldersOnly = true;
            openfiledialog.CheckPathExists = true;
            openfiledialog.Title = "Select Theme Directory";

            CommonFileDialogResult result = openfiledialog.ShowDialog();
            if (result.Canceled == true)
                return;

            buttonEdit1.Text = openfiledialog.FileName;
        }
Example #2
0
        private void OpenLibraryButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                CommonOpenFileDialog pickLocationDialog = new CommonOpenFileDialog();
                pickLocationDialog.Title = "Pick a library";
                pickLocationDialog.ForceFileSystem = false;
                pickLocationDialog.FoldersOnly = true;
                pickLocationDialog.MultiSelect = false;

                CommonFileDialogResult result = pickLocationDialog.ShowDialog();
                if (result.Canceled)
                    return;

                _libraryManager.OpenShellLibrary(pickLocationDialog.FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        /// <summary>
        /// "Open File Dialog Customization 2" button click event handler.
        /// </summary>
        /// 
        /// <param name="sender">object</param>
        /// <param name="e">RoutedEventArgs</param>
        /// 
        private void OpenFileDialogCustomizationXamlClicked(object sender, RoutedEventArgs e)
        {
            openFileDialog = FindOpenFileDialog("simpleOFD");

            // Name access to Xaml resource control work-around.
            
            /*
             * Resources can also be referenced by code from within the 
             * collection, but be aware that resources created in XAML will 
             * definitely not be accessible until after Loaded is raised by 
             * the element that declares the dictionary. In fact, resources 
             * are parsed asynchronously and not even the Loaded event is an 
             * assurance that you can reference a XAML defined resource. For 
             * this reason you should generally only access XAML defined 
             * resources as part of run-time code, or through other XAML 
             * techniques such as styles or resource extension references for 
             * attribute values.
             */

            int forIdx = 0;
            int controlIndex = -1;
            int numberOfControls = openFileDialog.Controls.Count;
            CommonFileDialogControl cfdc = null;

            // find the control you want to initialize
            for (forIdx = 0; forIdx < numberOfControls; forIdx++)
            {
                cfdc = openFileDialog.Controls[forIdx];

                // un-comment the .Equals test if looking for a specific
                // control.
                if (cfdc is CommonFileDialogTextBox /*&& 
                    cfdc.Name.Equals("textName", StringComparison.InvariantCulture)*/)
                {
                    // save the index of the CommonFileDialogTextBox (or 
                    // otherwise perform what ever other operation is deemed
                    // necessary / useful here).
                    controlIndex = forIdx;
                    break;
                }
            }

            // init the control's text
            cfdc.Text = "enter text here.";

            CommonFileDialogResult result = openFileDialog.ShowDialog();

            if (!result.Canceled)
            {
                MessageBox.Show("File Selected: " + openFileDialog.FileName,
                    "Open File Dialog Customization 2 Result" );
            }

        }
Example #4
0
        private void OpenFileDialogCustomizationClicked(object sender, RoutedEventArgs e)
        {
            CommonOpenFileDialog openDialog = new CommonOpenFileDialog();
            ApplyCommonSettings(openDialog);
            
            // set the 'allow multi-select' flag
            openDialog.MultiSelect = true;

            AddCustomControls(openDialog);
            CommonFileDialogResult result = openDialog.ShowDialog();
            if (!result.Canceled)
            {
                StringBuilder output = new StringBuilder("Files selected: ");
                foreach (string file in openDialog.FileNames)
                {
                    output.Append(file);
                    output.Append(Environment.NewLine);
                }
                TaskDialog.Show(output.ToString(), "Files Chosen", "Files Chosen");
            }
        }
Example #5
0
 private void OpenVistaFileDialogClicked(object sender, RoutedEventArgs e)
 {
     CommonOpenFileDialog openDialog = new CommonOpenFileDialog();
     ApplyCommonSettings(openDialog);
     CommonFileDialogResult result = openDialog.ShowDialog();
     if (!result.Canceled)
     {
         StringBuilder output = new StringBuilder("Files selected: ");
         foreach (string file in openDialog.FileNames)
         {
             output.Append(file);
             output.Append(Environment.NewLine);
         }
         TaskDialog.Show(output.ToString(), "Files Chosen", "Files Chosen");
     }
 }
Example #6
0
 private void SaveTrack() {
     if (_fileName == null) {
         var saveDialog = new CommonOpenFileDialog("Save Track");
         saveDialog.Title = "Save Track";
         saveDialog.InitialDirectory = TrackDir;
         saveDialog.Filters.Add(new CommonFileDialogFilter("Track XML Files", "xml"));
         var result = saveDialog.ShowDialog();
         if (result.Canceled || saveDialog.FileNames.Count == 0) return;
         _fileName = saveDialog.FileNames.First();
         if (!_fileName.EndsWith(".xml")) _fileName += ".xml";
     }
     TrackXml.Save(_fileName);
 }
Example #7
0
 private void HandleKeyboardInput(InputState input) {
     if (input.IsNewKeyPress(Keys.S)) {
         SaveTrack();
     } else if (input.IsNewKeyPress(Keys.L)) {
         var openDialog = new CommonOpenFileDialog("Load Track");
         openDialog.Title = "Load Track";
         openDialog.InitialDirectory = TrackDir;
         openDialog.Filters.Add(new CommonFileDialogFilter("Track XML Files", "xml"));
         var result = openDialog.ShowDialog();
         if (!result.Canceled && openDialog.FileNames.Count > 0) {
             LoadTrack(openDialog.FileNames.First());
         }
     } 
 }
Example #8
0
        private void OpenVistaFileDialogClicked(object sender, RoutedEventArgs e)
        {
            CommonOpenFileDialog openDialog = new CommonOpenFileDialog();
            openDialog.Title = "My Open File Dialog";
            openDialog.Opening += new EventHandler(openDialog_Opening);
            openDialog.Multiselect = true;

            CommonFileDialogResult result = openDialog.ShowDialog();
            if (!result.Canceled)
            {
                StringBuilder output = new StringBuilder("Files selected: ");
                foreach (string file in openDialog.FileNames)
                {
                    output.Append(file);
                    output.Append(Environment.NewLine);
                }
                TaskDialog.Show(output.ToString(), "Files Chosen", "Files Chosen");
            }
        }