Ejemplo n.º 1
0
        static public void WriteLine(string prompt_str)
        {
            if (logWindow == null)
            {
                return;
            }

            if (logWindow.InvokeRequired)
            {
                LogOutInvoke invokeFunc = new LogOutInvoke(WriteLine);

                logWindow.BeginInvoke(invokeFunc, prompt_str);

                return;
            }

            prompt_list[prompt_idx] = prompt_str + "\r\n";
            prompt_idx = (prompt_idx + 1) % prompt_list.Length;

            string total_str = "";

            for (int i = 0; i < prompt_list.Length; i++)
            {
                total_str += prompt_list[(prompt_idx + i) % prompt_list.Length];
            }
            logWindow.Text = total_str;

            logWindow.Select(total_str.Length, total_str.Length);
            logWindow.ScrollToCaret();

            logWindow.Invalidate();
            logWindow.Update();

            return;
        }
 private void timerUIUpdate_Tick(object sender, System.EventArgs e)
 {
     if (needsScroll)
     {
         needsScroll = false;
         textBoxContents.Select(textBoxContents.Text.Length, 0);
         textBoxContents.ScrollToCaret();
     }
 }
Ejemplo n.º 3
0
 public override void Write(string value)
 {
     if (_textBox.IsHandleCreated)
     {
         _textBox.BeginInvoke(new ThreadStart(() =>
         {
             if (maxRowLenght > 0 && _textBox.Lines.Length > maxRowLenght)
             {
                 int strat = _textBox.GetFirstCharIndexFromLine(0); //获取第0行第一个字符的索引
                 int end   = _textBox.GetFirstCharIndexFromLine(10);
                 _textBox.Select(strat, end);                       //选择文本框中的文本范围
                 _textBox.SelectedText = "";                        //将当前选定的文本内容置为“”
                 _textBox.AppendText(value + " ");
             }
             else
             {
                 _textBox.AppendText(value + " ");
             }
         }));
     }
 }
        /*This extension method allows you to extend the textbox and select the line of text that the cursor is on*/
        public static void SelectLine(this System.Windows.Forms.TextBox source, int line, int length = 0)
        {
            string[] objTextboxLines = source.Lines;


            if (line < 1 || source.Lines.Length < line)
            {
                return;
            }

            if (length != 0)
            {
                source.Select(source.GetFirstCharIndexFromLine(line - 1), length);
            }
            else
            {
                source.Select(source.GetFirstCharIndexFromLine(line - 1), objTextboxLines[line].Length - 1);
            }

            source.ScrollToCaret();
            source.Focus();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Show help message on supported programme parameters.
        /// </summary>
        private static void ShowParametersHelp()
        {
            StringBuilder sb           = new StringBuilder();
            const int     COLCHARWIDTH = 22;

            sb.AppendLine(Strings.T("Parameter:".PadRight(COLCHARWIDTH, ' ')) + Strings.T("Description:"));
            sb.AppendLine("-?".PadRight(COLCHARWIDTH, ' ') + Strings.T("Show this parameters help window."));
            sb.AppendLine("-disabletransparency".PadRight(COLCHARWIDTH, ' ') + Strings.T("Disable transparency."));
            sb.AppendLine("-disableplugins".PadRight(COLCHARWIDTH, ' ') + Strings.T("Disable all plugins."));
            sb.AppendLine("-disablehighlighting".PadRight(COLCHARWIDTH, ' ') + Strings.T("Disable any highlighting in notes."));
            sb.AppendLine("-disablevisualstyles".PadRight(COLCHARWIDTH, ' ') + Strings.T("Disable XP visual style."));
            sb.AppendLine("-disablegpg".PadRight(COLCHARWIDTH, ' ') + Strings.T("Disable GnuPG signature checking."));
            sb.AppendLine("-forcefirstrun".PadRight(COLCHARWIDTH, ' ') + Strings.T("Force a first run."));
            sb.AppendLine("-logall".PadRight(COLCHARWIDTH, ' ') + Strings.T("Log exceptions, errors and debug messages."));
            sb.AppendLine("-lognone".PadRight(COLCHARWIDTH, ' ') + Strings.T("Don't log exceptions, errors and debug messages."));
            sb.AppendLine("-newnote".PadRight(COLCHARWIDTH, ' ') + Strings.T("Immediately open a new note after startup."));
            sb.AppendLine("-title".PadRight(COLCHARWIDTH, ' ') + Strings.T("Set title new note."));
            sb.AppendLine("-content".PadRight(COLCHARWIDTH, ' ') + Strings.T("Set content new note."));
            sb.AppendLine("-setlanguage".PadRight(COLCHARWIDTH, ' ') + Strings.T("Set the language(ISO 639-1) of the programme."));
            if (Program.CurrentOS == OS.WINDOWS)
            {
                sb.AppendLine("-suspressadminwarn".PadRight(COLCHARWIDTH, ' ') + "Supress the warning that NoteFly is running");
                sb.AppendLine(string.Empty.PadRight(COLCHARWIDTH, ' ') + Strings.T("with unnecessary administrator privilege."));
            }

            sb.AppendLine("-resetpositions".PadRight(COLCHARWIDTH, ' ') + Strings.T("Reset all positions of visual notes at startup."));
            sb.AppendLine("-resetsettings".PadRight(COLCHARWIDTH, ' ') + Strings.T("Reset all NoteFly settings to default."));
            System.Windows.Forms.TextBox tbtexthelp = new System.Windows.Forms.TextBox();
            tbtexthelp.Font      = new System.Drawing.Font("Courier New", 10); // Courier New, every character has the same width.
            tbtexthelp.Location  = new System.Drawing.Point(0, 0);
            tbtexthelp.Multiline = true;
            tbtexthelp.Dock      = System.Windows.Forms.DockStyle.Fill;
            tbtexthelp.Text      = sb.ToString();
            System.Windows.Forms.Form frmhelp = new System.Windows.Forms.Form();
            frmhelp.Width           = 600;
            frmhelp.Height          = 380;
            frmhelp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            frmhelp.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
            frmhelp.ControlBox      = true;
            frmhelp.ShowIcon        = false;
            frmhelp.Controls.Add(tbtexthelp);
            tbtexthelp.Select(0, 0);
            frmhelp.Text = string.Format(Strings.T("{0} parameters help", Program.AssemblyTitle));
            frmhelp.Show();
            frmhelp.BringToFront();
        }
Ejemplo n.º 6
0
        private void btnHighlight_Click(object sender, System.EventArgs e)
        {
            if (lstResults.SelectedItem == null)
            {
                return;
            }
            if (tokens.Count < lstResults.Items.Count)
            {
                return;
            }

            Token t     = (Token)tokens[lstResults.SelectedIndex];
            int   start = t.StartOffset();
            int   end   = t.EndOffset();

            txtOutput.Select(start, end - start);
        }
Ejemplo n.º 7
0
        public HelpDialog()
        {
            this.Width       = 510;
            this.Height      = 650;
            this.Text        = "Help";
            this.MinimumSize = new System.Drawing.Size(this.Width, this.Height);
            this.MaximumSize = new System.Drawing.Size(this.Width, this.Height);

            tbHelp            = new System.Windows.Forms.TextBox();
            tbHelp.Multiline  = true;
            tbHelp.ReadOnly   = true;
            tbHelp.WordWrap   = true;
            tbHelp.Width      = this.Width - 15;
            tbHelp.Height     = this.Height - 470;
            tbHelp.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            tbHelp.Text       =
                " Create realistic fractal trees by recursively drawing branches." + Environment.NewLine +
                " Use Recursion Depth for the number of recursion levels," + Environment.NewLine +
                " Branch Angle for the number of degrees between the branches," + Environment.NewLine +
                " Branch Length for the length of the inital branch," + Environment.NewLine +
                " Randomness for the degree of randomness in drawing branches," + Environment.NewLine +
                " End Leaves and Color to specify if there are leaves at the end of the branches," + Environment.NewLine +
                " Two Branches, Three Branches or Random Third Branch for the number of branches at each level." + Environment.NewLine +
                " You can save the settings (Depth, Length, etc) as an XML file and then open it again later." + Environment.NewLine +
                " You can save the image as a bmp, jpg, gif or png file." + Environment.NewLine +
                " Your settings are saved automatically if you don't specify an XML file, and restored when you" + Environment.NewLine +
                @"  start the program. (The settings are stored in %userprofile%\appdata\local)" + Environment.NewLine +
                @" Reset retrieves the last settings from %userprofile%\appdata\local," + Environment.NewLine +
                @" Clear Settings sets the fractal tree to the default settings and clears the settings in" + Environment.NewLine +
                @" %userprofile%\appdata\local."
            ;
            tbHelp.Select(0, 0);

            System.Windows.Forms.PictureBox pbExample = new System.Windows.Forms.PictureBox();
            pbExample.Size  = new System.Drawing.Size(418, 425);
            pbExample.Image = global::Fractal.Properties.Resources.FractalTreeScreenShot;

            pbExample.Location = new System.Drawing.Point(25, tbHelp.Height);
            pbExample.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;

            this.Controls.Add(tbHelp);
            this.Controls.Add(pbExample);
        }
Ejemplo n.º 8
0
 void ITextBoxStorage.LoadText(System.Windows.Forms.TextBox pTextBox)
 {
     pTextBox.Text = _defaultText;
     pTextBox.Select(0, 0);
 }
Ejemplo n.º 9
0
        public static void Check_Hint(
            System.Windows.Forms.TextBox textbox,
            System.Windows.Forms.RichTextBox textBox1,
            int kind,
            ref string current_suggestion,
            ref interpreter.suggestion_result suggestion_result,
            ref bool error,
            System.Drawing.Font this_Font
            )
        {
            // collapse into a single line
            if (textbox.Lines.Length > 1)
            {
                textbox.Text = textbox.Lines[0] + textbox.Lines[1];
                textbox.Select(textbox.Text.Length, 0);
            }
            suggestion_result = interpreter_pkg.suggestion(textbox.Text, kind);
            have_bold         = suggestion_result.bold_start > 0 &&
                                suggestion_result.bold_finish >= suggestion_result.bold_start;
            if (have_bold)
            {
                string[] copy = new string[suggestion_result.suggestions.Length - 1];
                for (int k = 1; k < suggestion_result.suggestions.Length; k++)
                {
                    copy[k - 1] = suggestion_result.suggestions[k];
                }
                Array.Sort(copy);
                for (int k = 1; k < suggestion_result.suggestions.Length; k++)
                {
                    suggestion_result.suggestions[k] = copy[k - 1];
                }
            }
            else
            {
                Array.Sort(suggestion_result.suggestions);
            }
            if (!Component.MONO)
            {
                textBox1.Lines = suggestion_result.suggestions;
            }
            else
            {
                textBox1.Lines = addNewlines(suggestion_result.suggestions);
            }

            textBox1.SelectAll();
            textBox1.SelectionColor = System.Drawing.Color.Black;
            // if the current suggestion is unavailable, switch to the first one
            if (suggestion_result.suggestions.Length == 0)
            {
                current_suggestion      = "";
                current_suggestion_line = -1;
                textBox1.Hide();
            }
            else
            {
                if (suggestion_result.suggestions.Length > 1)
                {
                    int loc;
                    if (current_suggestion != null)
                    {
                        try
                        {
                            loc = textBox1.Find(current_suggestion);
                        }
                        catch
                        {
                            loc = -1;
                        }
                    }
                    else
                    {
                        loc = -1;
                    }
                    if (loc < 0 && !have_bold)
                    {
                        current_suggestion      = suggestion_result.suggestions[0];
                        current_suggestion_line = 0;
                    }
                    else if (loc <= 0 && have_bold)
                    {
                        current_suggestion      = suggestion_result.suggestions[1];
                        current_suggestion_line = 1;
                    }
                    int index;
                    try
                    {
                        index = textBox1.Find(current_suggestion);
                        current_suggestion_line = textBox1.GetLineFromCharIndex(index);

                        textBox1.Select(index,
                                        current_suggestion.Length);
                    }
                    catch
                    {
                    }
                    textBox1.SelectionColor = System.Drawing.Color.Red;
                    error = false;
                    textBox1.Show();
                }
                else if (suggestion_result.suggestions.Length == 1)
                {
                    current_suggestion      = suggestion_result.suggestions[0];
                    current_suggestion_line = 0;
                    try
                    {
                        textBox1.Select(textBox1.Find(current_suggestion),
                                        current_suggestion.Length);
                        if (have_bold)
                        {
                            textBox1.SelectionColor = System.Drawing.Color.Black;
                        }
                        else
                        {
                            textBox1.SelectionColor = System.Drawing.Color.Red;
                        }
                    }
                    catch
                    {
                    }
                }
                if (have_bold)
                {
                    textBox1.Select(suggestion_result.bold_start - 1, suggestion_result.bold_finish - suggestion_result.bold_start + 1);
                    textBox1.SelectionFont = new Font(this_Font, FontStyle.Bold);
                    textBox1.Select(0, textBox1.Lines[0].Length);
                    textBox1.SelectionColor = System.Drawing.Color.Black;
                }
                error = false;
                textBox1.Show();
            }
        }
Ejemplo n.º 10
0
 public void AddLog(System.Windows.Forms.TextBox TxtBox, string Line)
 {
     TxtBox.Text += "\r\n" + Line;
     TxtBox.Select(TxtBox.Text.Length - 1, 0);
     TxtBox.ScrollToCaret();
 }
Ejemplo n.º 11
0
        public void ChangeHomeDirectory()
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.Width           = 270;
            form.Height          = 120;
            form.Text            = "Home directory";
            form.MaximizeBox     = false;
            form.MinimizeBox     = false;
            form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            System.Windows.Forms.TextBox dir    = new System.Windows.Forms.TextBox(); dir.Left = 10; dir.Top = 10; dir.Width = 230; dir.Height = 30; dir.Text = localDir; dir.Select(dir.Text.Length, 0);
            System.Windows.Forms.Button  button = new System.Windows.Forms.Button(); button.Left = 10; button.Top = 45; button.Width = 230; button.Height = 30; button.Text = "Submit";
            form.Controls.Add(dir); form.Controls.Add(button);
            form.AcceptButton = button;
            Thread thread = new Thread(new ThreadStart(() => System.Windows.Forms.Application.Run(form)));

            thread.Start();
            button.Click += (object snd, EventArgs args) =>
            {
                string oldDir = localTree.Way;
                try
                {
                    localDir = dir.Text;
                    if (localDir[localDir.Length - 1] != '\\')
                    {
                        localDir += '\\';
                    }
                    Dispatcher.Invoke(() => localTree.Way = localDir);
                    GenerateConfig("config.txt", localDir, serverDir, ip, login, password);
                    form.Close();
                }
                catch
                {
                    localTree.Way = oldDir;
                }
            };
        }