BEurtle.ParseParameters.FillInDefaults C# (CSharp) Метод

FillInDefaults() публичный Метод

public FillInDefaults ( IWin32Window hwnd ) : void
hwnd IWin32Window
Результат void
        public void FillInDefaults(IWin32Window hwnd)
        {
            if (BEPath.Length == 0)
            {
                // Try the embedded copy first, then python
                string mylocation;
                using (RegistryKey r=Registry.ClassesRoot.OpenSubKey(@"CLSID\{233C8C6B-00AC-4E21-89FD-A66A9C10CEDB}\InprocServer32"))
                    mylocation=r.GetValue("CodeBase").ToString().Substring(8);
                mylocation=Path.GetDirectoryName(mylocation);
                while(mylocation.Length>0 && !Directory.Exists(mylocation+@"\dist"))
                    mylocation = Path.GetDirectoryName(mylocation);
                if (mylocation.Length > 0)
                {
                    if (File.Exists(mylocation + @"\dist\be.exe"))
                        BEPath = mylocation + @"\dist\be.exe";
                }
                // Still haven't found a BE, so try python
                if(BEPath.Length==0)
                {
                    try
                    {
                        RegistryKey r = Registry.ClassesRoot.OpenSubKey(@"Python.File\shell\open\command");
                        string pythonexe = r.GetValue("").ToString();
                        r.Close();
                        pythonexe = pythonexe.Substring(1, pythonexe.IndexOf('"', 1) - 1);
                        BEPath = Path.GetDirectoryName(pythonexe) + "\\Scripts\\be.bat";
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(hwnd, "Failed to find a copy of BE and failed to read what executes Python files. Is Python installed?\nError was: " + ex.Message);
                    }
                }
            }
            if (DefaultAuthor.Length == 0)
            {
                if (plugin.VCSAuthor != null && plugin.VCSAuthor.Length > 0)
                {
                    DefaultAuthor = plugin.VCSAuthor;
                }
                else
                {
                    StringBuilder fullname_ = new StringBuilder(1024);
                    string fullname, login, machine;
                    uint l = (uint)fullname_.Capacity;
                    int code = Win32.GetUserNameEx((int)Win32.EXTENDED_NAME_FORMAT.NameDisplay, fullname_, ref l);
                    fullname = fullname_.ToString();
                    if (fullname == "") fullname = "<set full name in user account settings>";
                    login = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split('\\')[1];
                    machine = System.Net.Dns.GetHostEntry("").HostName;
                    DefaultAuthor = "\"" + fullname + "\" <" + login + "@" + machine + ">";
                }
            }
            if (DumpHTMLPath.Length == 0)
                DumpHTMLPath = "BEBugsAsHTML";
        }

Usage Example

Пример #1
0
        private void OptionsDialog_Shown(object sender, EventArgs e)
        {
            try
            {
                initialising = true;
                DefaultAuthorChanged = false;
                BoxDefaultAuthor.Text = "";
                BoxDefaultAuthor.ForeColor = Color.FromArgb(0, 0, 0);
                DumpHTMLPathChanged = false;
                BoxDumpHTMLPath.Text = "";
                BoxDumpHTMLPath.ForeColor = Color.FromArgb(0, 0, 0);
                if (parameters != null)
                {
                    ParseParameters parsed = new ParseParameters(plugin, this, parameters, false);
                    if (parsed.DefaultAuthor.Length > 0)
                        DefaultAuthorChanged = true;
                    else
                        BoxDefaultAuthor.ForeColor = Color.FromArgb(192, 192, 192);
                    if (parsed.DumpHTMLPath.Length > 0)
                        DumpHTMLPathChanged = true;
                    else
                        BoxDumpHTMLPath.ForeColor = Color.FromArgb(192, 192, 192);
                    parsed.FillInDefaults(this);

                    BEPath = parsed.BEPath;
                    BoxDefaultAuthor.Text = parsed.DefaultAuthor;
                    CheckDumpHTML.Checked = parsed.DumpHTML;
                    BoxDumpHTMLPath.Text = parsed.DumpHTMLPath;
                    CheckAddCommitAsComment.Checked = parsed.AddCommitAsComment;
                    CheckFilterOutClosedIssues.Checked = parsed.FilterOutClosedIssues;
                    CheckBEXMLCache.Checked = parsed.CacheBEXML;
                    switch(parsed.ShowCommentCount)
                    {
                        case ShowCommentCountType.DontShow:
                            CheckShowCommentCount.CheckState = CheckState.Unchecked;
                            break;
                        case ShowCommentCountType.ShowEasy:
                            CheckShowCommentCount.CheckState = CheckState.Indeterminate;
                            break;
                        case ShowCommentCountType.ShowAll:
                            CheckShowCommentCount.CheckState = CheckState.Checked;
                            break;
                    }
                    CheckUseBEXML.Checked = parsed.UseBEXML;
                }
                else
                {
                    this.Text = "About BEurtle";
                    OptionsGroupBox.Enabled = false;
                    ButtonReset.Visible = false;
                    ButtonCancel.Visible = false;
                }
            }
            finally
            {
                initialising = false;
            }
        }