コード例 #1
0
        private void OnChangeOutputPath(object sender, EventArgs e)
        {
            // fixme - should probably move this functionality into ICloudInterface
            string path = ViewBase.AskUserForFileName("Choose a folder", Utility.FileDialog.FileActionType.SelectFolder, "");

            ApsimNG.Cloud.Azure.AzureSettings.Default.OutputDir = path;
            ApsimNG.Cloud.Azure.AzureSettings.Default.Save();
            view.DownloadPath = path;
        }
コード例 #2
0
        /// <summary>
        /// Called when user clicks on a file name.
        /// Does creation of the dialog belong here, or in the view?
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnFileBrowseClick(object sender, GridCellsChangedArgs e)
        {
            string fileName = ViewBase.AskUserForFileName("Select file path", string.Empty, Gtk.FileChooserAction.Open, e.ChangedCells[0].Value.ToString());

            if (fileName != null && fileName != e.ChangedCells[0].Value.ToString())
            {
                e.ChangedCells[0].Value = fileName;
                this.OnCellValueChanged(sender, e);
                this.PopulateGrid(this.model);
            }
        }
コード例 #3
0
 private void BtnBrowse_Clicked(object sender, EventArgs e)
 {
     try
     {
         string fileName = ViewBase.AskUserForFileName("Choose a location for saving the weather file", Utility.FileDialog.FileActionType.Save, "APSIM Weather file (*.met)|*.met", entryFilePath.Text);
         if (!String.IsNullOrEmpty(fileName))
         {
             entryFilePath.Text = fileName;
         }
     }
     catch (Exception err)
     {
         ShowMessage(MessageType.Error, err.Message, "Error");
     }
 }
コード例 #4
0
        /// <summary>
        /// User has clicked download.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private async void OnDownloadClicked(object sender, EventArgs e)
        {
            // Ask user for download path.
            string path = ViewBase.AskUserForFileName("Choose a download folder",
                                                      Utility.FileDialog.FileActionType.SelectFolder,
                                                      "",
                                                      ApsimNG.Cloud.Azure.AzureSettings.Default.OutputDir);

            if (!string.IsNullOrEmpty(path))
            {
                ApsimNG.Cloud.Azure.AzureSettings.Default.OutputDir = path;
                ApsimNG.Cloud.Azure.AzureSettings.Default.Save();

                presenter.ShowWaitCursor(true);

                try
                {
                    foreach (int listViewIndex in jobListView.SelectedIndicies)
                    {
                        var jobListIndex = ConvertListViewIndexToJobIndex(listViewIndex);

                        DownloadOptions options = new DownloadOptions()
                        {
                            Name  = jobList[jobListIndex].DisplayName,
                            Path  = ApsimNG.Cloud.Azure.AzureSettings.Default.OutputDir,
                            JobID = Guid.Parse(jobList[jobListIndex].Id)
                        };

                        await cloudInterface.DownloadResultsAsync(options, cancelToken.Token, p => { });

                        if (cancelToken.IsCancellationRequested)
                        {
                            return;
                        }
                    }
                    presenter.ShowMessage($"Results were successfully downloaded to {ApsimNG.Cloud.Azure.AzureSettings.Default.OutputDir}", Simulation.MessageType.Information);
                }
                catch (Exception err)
                {
                    presenter.ShowError(err);
                }
                finally
                {
                    presenter.ShowWaitCursor(false);
                }
            }
        }
コード例 #5
0
        /// <summary>User has clicked the browse button.</summary>
        private void OnBrowseButtonClicked(object sender, EventArgs e)
        {
            string newValue;

            if (apsimTypeToRunCombobox.SelectedValue == "A directory")
            {
                newValue = ViewBase.AskUserForFileName("Select the APSIM directory",
                                                       Utility.FileDialog.FileActionType.SelectFolder,
                                                       directoryEdit.Text);
            }
            else
            {
                newValue = ViewBase.AskUserForFileName("Please select a zipped file",
                                                       Utility.FileDialog.FileActionType.Open,
                                                       "Zip file (*.zip) | *.zip");
            }
            if (!string.IsNullOrEmpty(newValue))
            {
                directoryEdit.Text = newValue;
            }
        }