/// <summary>
        ///     Called when [execute].
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        protected override void OnExecute(object parameter)
        {
            var requiredItem = parameter as IRequiredItemBase;

            if (requiredItem == null)
            {
                return;
            }

            var dialog = new FolderBrowserDialog();

            if (Directory.Exists(requiredItem.DefaultValue))
            {
                dialog.SelectedPath = requiredItem.DefaultValue;
            }

            dialog.ShowNewFolderButton = false;

            var result = FolderBrowserLauncher.ShowFolderBrowser(dialog, null);

            if (result == DialogResult.OK)
            {
                requiredItem.SelectedValue = dialog.SelectedPath;
                EventAggregator.PublishOnUIThread(new LogEntry(
                                                      "Successfully set " + requiredItem.FriendlyName + " to ", LogEntrySeverity.Info, LogEntrySource.UI,
                                                      requiredItem.SelectedValue));
            }
        }
Пример #2
0
        private void ExportButton_Click(object sender, EventArgs args)
        {
            // get an export folder
            string outputPath = Properties.Settings.Default.ExportPath;

            if (string.IsNullOrEmpty(outputPath))
            {
                outputPath = Path.GetDirectoryName(_XMLFileName);
            }

            var dialog = new FolderBrowserDialog {
                ShowNewFolderButton = true, Description = "Select export folder:", SelectedPath = outputPath
            };

            if (FolderBrowserLauncher.ShowFolderBrowser(dialog, this) != DialogResult.OK || string.IsNullOrEmpty(dialog.SelectedPath))
            {
                return;
            }

            try {
                // output the code
                _codeGen.WriteOutput(dialog.SelectedPath);

                // success
                MessageBox.Show(string.Format("The code was successfully exported to {0}.", dialog.SelectedPath));

                // persistence is not futile
                Properties.Settings.Default.ExportPath = dialog.SelectedPath;
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Exception: {0}.", e.ToString()));
            }
        }
Пример #3
0
        private void OnButtonClick(object sender, EventArgs e)
        {
            switch (((Button)sender).Name)
            {
            case "btnDirectory":
                var folderBrowser = new FolderBrowserDialog();
                folderBrowser.ShowNewFolderButton = true;
                folderBrowser.SelectedPath        = SaveMapForm.GetSavedMapsFolder();
                folderBrowser.Description         = "Locate folder containing saved fishing ground";
                DialogResult result = FolderBrowserLauncher.ShowFolderBrowser(folderBrowser);
                if (result == DialogResult.OK)
                {
                    FishingGearMapping.SaveMapFolder = folderBrowser.SelectedPath;
                    txtFolderPath.Text = FishingGearMapping.SaveMapFolder;
                }
                break;

            case "btnOk":
                if (FishingGearMapping.SaveMapFolder.Length > 0 && txtDPI.Text.Length > 0)
                {
                    switch (_parentForm.GetType().Name)
                    {
                    case "TargetAreaGearsForm":
                        var f = _parentForm as TargetAreaGearsForm;
                        var n = 0;
                        foreach (ListViewItem item in f.GearListView.Items)
                        {
                            if (item.Checked)
                            {
                                _currentGearItem = item;
                                var mehf = MapEffortHelperForm.GetInstance();
                                mehf.BatchMode            = true;
                                mehf.CombineYearsInOneMap = chkCombinedMap.Checked;
                                mehf.SetUpMapping(f.TargetArea.TargetAreaGuid, item.Tag.ToString(), item.SubItems[1].Text, f.TargetArea.TargetAreaName);
                                mehf.MapTargetAreaGearFishingGroundBatch(this);
                                n++;
                            }
                        }
                        if (n > 0)
                        {
                            MessageBox.Show($"{n} items were mapped and saved");
                        }
                        Close();
                        break;
                    }
                }
                Close();
                break;

            case "btnCancel":
                Close();
                break;
            }
        }
        private void TourPackageButton_Click(object sender, EventArgs e)
        {
            try {
                String curTourFolder = Properties.Settings.Default.ExportDirectory;
                if (myTourRow != null)
                {
                    using (FolderBrowserDialog curFolderDialog = new FolderBrowserDialog()) {
                        curFolderDialog.ShowNewFolderButton = true;
                        curFolderDialog.RootFolder          = Environment.SpecialFolder.Desktop;
                        curFolderDialog.SelectedPath        = @curTourFolder;
                        if (FolderBrowserLauncher.ShowFolderBrowser(curFolderDialog, Form.ActiveForm) == DialogResult.OK)
                        {
                            curTourFolder = curFolderDialog.SelectedPath;
                        }
                    }
                    writeTourIdentDataFile(myTourRow, curTourFolder);

                    ExportTourSummary myExportTourSummary = new ExportTourSummary();
                    myExportTourSummary.ExportData();

                    ExportData myExportData        = new ExportData();
                    String     curTourDataFileName = curTourFolder;
                    if (curTourFolder.Substring(curTourFolder.Length - 1).Equals("\\"))
                    {
                        curTourDataFileName += mySanctionNum + "TS.txt";
                    }
                    else
                    {
                        curTourDataFileName += "\\" + mySanctionNum + "TS.txt";
                    }
                    myExportData.exportTourData(mySanctionNum, curTourDataFileName);

                    Cursor.Current = Cursors.WaitCursor;
                    ArrayList curFileFilterList = getEndOfTourReportList(mySanctionNum, myTourClass);
                    ZipUtil.ZipFiles(curTourFolder, mySanctionNum + myTourClass + ".zip", curFileFilterList);
                    TourPackageButton.BeginInvoke((MethodInvoker) delegate() {
                        Application.DoEvents();
                        Cursor.Current = Cursors.Default;
                    });
                }
            } catch (Exception ex) {
                MessageBox.Show("Exception selecting and compressing selected files from specified folder " + "\n\nError: " + ex.Message);
            }
        }
Пример #5
0
        private void OnBackupChangeBackup(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
            dialog.ShowNewFolderButton = true;
            dialog.Description         = "Choose Backup folder";
            dialog.SelectedPath        = Config.Backup.FolderBackup;
            if (dialog.SelectedPath == string.Empty)
            {
                dialog.SelectedPath = lastFolderPath;
            }
            var result = FolderBrowserLauncher.ShowFolderBrowser(dialog);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                Config.Backup.FolderBackup = dialog.SelectedPath;
                textBoxBackup.Text         = dialog.SelectedPath;
            }
            lastFolderPath = dialog.SelectedPath;
        }
Пример #6
0
        private void OnBrowseTerraria(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
            dialog.ShowNewFolderButton = false;
            dialog.Description         = "Choose Terraria Content folder";
            dialog.SelectedPath        = Helpers.FixPathSafe(Config.TerrariaContentDirectory);
            if (dialog.SelectedPath == string.Empty)
            {
                dialog.SelectedPath = lastFolderPath;
            }
            var result = FolderBrowserLauncher.ShowFolderBrowser(dialog);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                Config.TerrariaContentDirectory = dialog.SelectedPath;
                textBoxTerrariaContent.Text     = dialog.SelectedPath;
            }
            lastFolderPath = dialog.SelectedPath;
        }
        private void OnButtonClick(object sender, EventArgs e)
        {
            switch (((Button)sender).Name)
            {
            case "btnCreateExtent":

                MakeGridFromPoints.MakeExtentShapeFile();

                break;

            case "btnOk":
                Close();
                break;

            case "btnGetMetadataFolder":
                var folderBrowser = new FolderBrowserDialog();
                folderBrowser.ShowNewFolderButton = true;
                if (_ERDDAPMetadataFolder == "")
                {
                    folderBrowser.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                }
                else
                {
                    folderBrowser.SelectedPath = _ERDDAPMetadataFolder;
                }
                folderBrowser.Description = "Locate folder containing ERDDAP metadata";
                DialogResult result = FolderBrowserLauncher.ShowFolderBrowser(folderBrowser);
                if (result == DialogResult.OK)
                {
                    ERDDAPMetadataFiles.MetadataFiles.Clear();
                    lvERDDAP.Visible = false;
                    lvERDDAP.Items.Clear();
                    ERDDAPMetadataFiles.MetadataDirectory = folderBrowser.SelectedPath;
                    ERDDAPMetadataFiles.ReadISO9115Metadata();
                    ERDDAPMetadataFiles.SaveMetadataDirectorySetting(folderBrowser.SelectedPath);
                    txtMetadataFolderPath.Text = folderBrowser.SelectedPath;
                    lvERDDAP.Visible           = true;
                    UpdateDataSetCount();
                }
                break;

            case "btnDownload":
                if (txtMinLat.Text.Length > 0 &&
                    txtMaxLat.Text.Length > 0 &&
                    txtMinLon.Text.Length > 0 &&
                    txtMaxLon.Text.Length > 0 &&
                    lvERDDAP.SelectedItems.Count > 0)
                {
                    ERDDAPConfigureDownloadForm edf = ERDDAPConfigureDownloadForm.GetInstance(this);
                    if (edf.Visible)
                    {
                        edf.BringToFront();
                    }
                    else
                    {
                        string identifier = lvERDDAP.SelectedItems[0].Name;
                        edf.BeginPosition    = ERDDAPMetadataFiles.MetadataFiles[identifier].BeginPosition;
                        edf.EndPosition      = ERDDAPMetadataFiles.MetadataFiles[identifier].EndPosition;
                        edf.Dimensions       = ERDDAPMetadataFiles.MetadataFiles[identifier].Dimensions;
                        edf.DataExtents      = _selectionExtent;
                        edf.GridParameters   = ERDDAPMetadataFiles.MetadataFiles[identifier].DataParameters;
                        edf.Credits          = ERDDAPMetadataFiles.MetadataFiles[identifier].Credits;
                        edf.Title            = ERDDAPMetadataFiles.MetadataFiles[identifier].DataTitle;
                        edf.DataAbstract     = ERDDAPMetadataFiles.MetadataFiles[identifier].DataAbstract;
                        edf.LegalConstraint  = ERDDAPMetadataFiles.MetadataFiles[identifier].LegalConstraints;
                        edf.GridExtents      = ERDDAPMetadataFiles.MetadataFiles[identifier].Extents;
                        edf.URL              = ERDDAPMetadataFiles.MetadataFiles[identifier].URL;
                        edf.Identifier       = identifier;
                        edf.MetadataFileName = ERDDAPMetadataFiles.MetadataFiles[identifier].MetaDataFilename;
                        edf.Show(this);
                    }
                }
                else
                {
                    MessageBox.Show("Data extents must be provided and data to download must be selected");
                }
                break;
            }
        }
Пример #8
0
        //--------------------------------
        #endregion
        //=========== HELPERS ============
        #region Helpers

        private string GetPath(string currentPath, bool input, bool extract)
        {
            switch (extract ? Config.Extract.Mode : Config.Convert.Mode)
            {
            case InputModes.Folder: {
                System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
                dialog.ShowNewFolderButton = true;
                dialog.Description         = "Choose " + (input ? "input" : "output") + " folder";
                dialog.SelectedPath        = currentPath;
                if (dialog.SelectedPath == string.Empty)
                {
                    dialog.SelectedPath = lastFolderPath;
                }
                var result = FolderBrowserLauncher.ShowFolderBrowser(dialog);
                lastFolderPath = dialog.SelectedPath;
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    return(dialog.SelectedPath);
                }
                break;
            }

            case InputModes.File: {
                FileDialog dialog;
                if (input)
                {
                    dialog = new OpenFileDialog();
                }
                else
                {
                    dialog = new SaveFileDialog();
                }
                string audioFiles = "*.wav;*.mp3;*.mp2;*.mpga;*.m4a;*.aac;*.flac;*.ogg;*.wma;*.aif;*.aiff;*.aifc";
                dialog.Filter = (extract == input ?
                                 "Xna files|*.xnb;*.xwb|" +
                                 "Xnb files|*.xnb|" +
                                 "Xwb files|*.xwb|" :
                                 "Image & Audio files (*.png;*.wav;...)|*.png;*.bmp;*.jpg;" + audioFiles + "|" +
                                 "Image files|*.png;*.bmp;*.jpg;|" +
                                 "Audio files (*.wav;*.mp3;...)|" + audioFiles + "|"
                                 ) + "All files|*.*";
                dialog.FilterIndex     = 0;
                dialog.Title           = "Choose " + (input ? "input" : "output") + " file";
                dialog.CheckFileExists = input;
                if (currentPath != string.Empty)
                {
                    try {
                        dialog.FileName = Path.GetFileName(currentPath);
                    }
                    catch { }
                    try {
                        dialog.InitialDirectory = Path.GetDirectoryName(currentPath);
                    }
                    catch {
                        dialog.InitialDirectory = lastFilePath;
                    }
                }
                else
                {
                    dialog.InitialDirectory = lastFilePath;
                }
                var result = dialog.ShowDialog(this);
                try {
                    lastFilePath = Path.GetDirectoryName(dialog.FileName);
                }
                catch { }
                if (result.HasValue && result.Value)
                {
                    return(dialog.FileName);
                }
                break;
            }
            }
            return(null);
        }
Пример #9
0
        private void ExportButton_Click(object sender, EventArgs args)
        {
            // get an export folder
            string outputPath = Properties.Settings.Default.ExportPath;

            if (string.IsNullOrEmpty(outputPath))
            {
                outputPath = Path.GetDirectoryName(_XMLFileName);
            }

            var dialog = new FolderBrowserDialog {
                ShowNewFolderButton = true, Description = "Select export folder:", SelectedPath = outputPath
            };

            if (FolderBrowserLauncher.ShowFolderBrowser(dialog, this) != DialogResult.OK || string.IsNullOrEmpty(dialog.SelectedPath))
            {
                return;
            }

            // generate output filenames
            string interfaceFile      = Path.Combine(dialog.SelectedPath, _codeGen.N2ObjC.InterfaceFile);
            string implementationFile = Path.Combine(dialog.SelectedPath, _codeGen.N2ObjC.ImplementationFile);

            try
            {
                bool ouputMonolithicInterface      = false;
                bool ouputMonolithicImplementation = false;

                // output interface
                if (ouputMonolithicInterface)
                {
                    File.WriteAllText(interfaceFile, _codeGen.N2ObjC.InterfaceOutput, Encoding.UTF8);
                }
                else
                {
                    GeneratedFileExporter.WriteAllText(Net2ObjC.OutputType.Interface, interfaceFile,
                                                       _codeGen.N2ObjC.InterfaceOutput);
                }

                // output implementation
                if (ouputMonolithicImplementation)
                {
                    File.WriteAllText(implementationFile, _codeGen.N2ObjC.ImplementationOutput, Encoding.UTF8);
                }
                else
                {
                    GeneratedFileExporter.WriteAllText(Net2ObjC.OutputType.Implementation, implementationFile,
                                                       _codeGen.N2ObjC.ImplementationOutput);
                }

                // do post flight processing
                PostflightObjC postflight = PostflightObjC.PostflightObjCForAssembly(_codeGen.N2ObjC.XMLFilePath);
                if (!postflight.Process())
                {
                    // problems
                    MessageBox.Show(string.Format("The code was exported to {0} but problems occurred during the postflight processing.", dialog.SelectedPath));
                }
                else
                {
                    // success
                    MessageBox.Show(string.Format("The code was successfully exported to {0}.", dialog.SelectedPath));
                }

                // persistence is not futile
                Properties.Settings.Default.ExportPath = dialog.SelectedPath;
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Exception: {0}.", e.ToString()));
            }
        }