コード例 #1
0
        /// <summary>
        /// Uploads an application to the online database (as background thread).
        /// </summary>
        /// <param name="argument">The ApplicationJob which is to be uploaded</param>
        private static void ShareOnline(object argument)
        {
            ApplicationJob job = argument as ApplicationJob;

            if (job == null)
            {
                return;
            }

            try
            {
                IGeGeekRpc proxy = XmlRpcProxyGen.Create <IGeGeekRpc>();
                proxy.Timeout = 10000;

                proxy.SaveApplication(job.GetXmlWithoutGlobalVariables(), Settings.GetValue("AuthorGuid") as string);
            }
            catch (XmlRpcFaultException ex)
            {
                LogDialog.Log("Could not submit '" + job.Name + "' to the online database: " + ex.FaultString);
            }
            catch (Exception)
            {
                // No internet, server down, whatever. We don't have to care.
            }
        }
コード例 #2
0
        /// <summary>
        /// Automatically fills the application name text box based on the
        /// FileHippo ID (to be used as background procress).
        /// </summary>
        private void AutoFillApplicationName(object fileHippoId)
        {
            string appName = string.Empty;

            try
            {
                appName = ExternalServices.FileHippoAppName(fileHippoId as string);

                if (string.IsNullOrEmpty(appName))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                // Ignore any errors, since optional process in background
                LogDialog.Log("FileHippo application name could not be determined", ex);
                return;
            }
            finally
            {
                // Make sure that form does still exist
                if (this.Visible)
                {
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        // Reset cursor
                        Cursor = Cursors.Default;
                        // Only fill the application name if it is still empty
                        if (string.IsNullOrEmpty(txtApplicationName.Text))
                        {
                            txtApplicationName.Text = appName;
                        }
                    });
                }
            }
        }
コード例 #3
0
        private void bLoad_Click(object sender, EventArgs e)
        {
            // Load URL contents and show a wait cursor in the meantime
            this.Cursor = Cursors.WaitCursor;

            try
            {
                using (WebClient client = new WebClient(this.UserAgent))
                {
                    string expandedUrl = null;
                    string postData    = null;

                    // Note: The Text property might modify the text value
                    using (ProgressDialog dialog = new ProgressDialog("Loading URL", "Please wait while the content is being downloaded..."))
                    {
                        dialog.OnDoWork = delegate
                        {
                            expandedUrl = this.CurrentVariable.ExpandedUrl;
                            if (dialog.Cancelled)
                            {
                                return(false);
                            }
                            client.SetPostData(this.CurrentVariable);
                            postData = client.PostData;
                            this.CurrentVariable.TempContent = client.DownloadString(new Uri(expandedUrl));
                            return(true);
                        };
                        dialog.OnCancel = delegate {
                            dialog.Cancel();
                        };
                        dialog.ShowDialog(this);

                        // Did an error occur?
                        if (!dialog.Cancelled && dialog.Error != null)
                        {
                            LogDialog.Log("Failed loading URL", dialog.Error);

                            // Check whether or not the URL is valid and show an error message if necessary
                            if (dialog.Error is ArgumentNullException || string.IsNullOrEmpty(expandedUrl))
                            {
                                MessageBox.Show(this, "The URL you entered is empty and cannot be loaded.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else if (dialog.Error is UriFormatException)
                            {
                                MessageBox.Show(this, "The specified URL '" + expandedUrl + "' is not valid.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                MessageBox.Show(this, "The contents of the URL can not be loaded: " + dialog.Error.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }

                    this.rtfContent.Text = this.CurrentVariable.TempContent;
                    // For Regex: Go to match after thread finish
                    this.gotoMatch = true;
                    this.UpdateRegexMatches();
                    // For Start/End: Go to match now
                    this.RefreshRtfFormatting();

                    this.GoToMatch();

                    // Show page preview if desired
                    if (this.cmnuBrowser.Checked)
                    {
                        this.PreviewDialog.ShowPreview(this, expandedUrl, postData);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "An error occured when loading the URL: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #4
0
ファイル: LogDialog.cs プロジェクト: jf3000/furry-waffle
 private LogDialog()
 {
     this.InitializeComponent();
     m_Instance = this;
     this.txtLog.ContextMenu = this.contextMenu;
 }