Esempio n. 1
0
 private static void ClearBox(TextBoxBase textBoxBase)
 {
     if (textBoxBase.Text.Equals("Last"))
     {
         textBoxBase.Clear();
     }
     else if (textBoxBase.Text.Equals("Middle"))
     {
         textBoxBase.Clear();
     }
     else if (textBoxBase.Text.Equals("First"))
     {
         textBoxBase.Clear();
     }
 }
        public static void LimpiarForm(Control Objeto)
        {
            foreach (Control Item in Objeto.Controls)
            {
                if (Item is Control)
                {
                    Control ObjConatiner = (Control)Item;

                    foreach (Control editable in ObjConatiner.Controls)
                    {
                        if (editable is TextBoxBase)
                        {
                            TextBoxBase objText = (TextBoxBase)editable;
                            objText.Clear();
                        }
                        if (editable is ListControl)
                        {
                            ListControl objListControl = (ListControl)editable;
                            objListControl.SelectedIndex = 0;
                        }
                        if (editable is ButtonBase)
                        {
                            ButtonBase buttonBase = (ButtonBase)editable;
                            buttonBase.Refresh();
                        }
                    } //End foreach editable
                }
            }         //End foreach of object
        }             //End Method LimpiarForm
Esempio n. 3
0
        public async Task Load(string name, TextBoxBase textBox)
        {
            using (var connection = new SQLiteConnection(_connectionString))
            {
                await connection.OpenAsync();

                string query = $"SELECT distinct {_valueColumnName} " +
                               $"from {_tableName} " +
                               $"where {_nameColumnName} = @name";

                using (var command = new SQLiteCommand(query, connection))
                {
                    command.Parameters.Add(new SQLiteParameter("@name", name));

                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        textBox.Clear();

                        if (reader.HasRows)
                        {
                            await reader.ReadAsync(); // read only the first row

                            string temp = await Task.Run(() => _valueEncoding.GetString((byte[])reader[_valueColumnName]));

                            textBox.AppendText(temp);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public async Task Load(string path, TextBoxBase into)
        {
            into.Clear();

            using (var fileStream = new StreamReader(path, true))
            {
                StringBuilder builder = new StringBuilder(3000);
                int           i       = 0;

                while (!fileStream.EndOfStream)
                {
                    builder.Append(await fileStream.ReadLineAsync() + Environment.NewLine);
                    i++;

                    if (i > 50)
                    {
                        into.AppendText(builder.ToString());
                        i = 0;
                        builder.Clear();
                    }
                }

                into.AppendText(builder.ToString());
            }
        }
Esempio n. 5
0
        public TextBoxScriptLogger(TextBoxBase box)
        {
            _box = box;

            if (box != null)
            {
                box.Clear();
            }
        }
Esempio n. 6
0
        public override void ShowErrors(params string[] errors)
        {
            if (_box == null)
            {
                throw new NullReferenceException("_box is not set!");
            }

            _box.Clear();
            _box.Lines = errors;
        }
Esempio n. 7
0
 private static void ClearAddressBox(TextBoxBase textBoxBase)
 {
     if (textBoxBase.Text.Equals("No."))
     {
         textBoxBase.Clear();
     }
     else if (textBoxBase.Text.Equals("Street Name"))
     {
         textBoxBase.Clear();
     }
     else if (textBoxBase.Text.Equals("Brgy"))
     {
         textBoxBase.Clear();
     }
     else if (textBoxBase.Text.Equals("City"))
     {
         textBoxBase.Clear();
     }
 }
Esempio n. 8
0
 public void Clear()
 {
     if (isFc)
     {
         fc.Clear();
     }
     else
     {
         tb.Clear();
     }
 }
Esempio n. 9
0
 public static void Clear(Control control)
 {
     foreach (Control item in control.Controls)
     {
         if (item.HasChildren)
         {
             Clear(item);
         }
         if (item is TextBoxBase)
         {
             TextBoxBase Item = (TextBoxBase)item;
             Item.Clear();
         }
     }
 }
Esempio n. 10
0
        public override void Clear()
        {
            base.Clear();

            lock (_textBox)
            {
                if (_textBox.InvokeRequired)
                {
                    _textBox.BeginInvoke(new Action(_textBox.Clear));
                }
                else
                {
                    _textBox.Clear();
                }
            }
        }
Esempio n. 11
0
        public static void LoadText(TextBoxBase sourceRichEdit, string fileName, bool excludeEmptyLines)
        {
            if (sourceRichEdit == null)
            {
                throw new NolmeArgumentNullException();
            }

            sourceRichEdit.Clear();

            //Win32RichEditUtility.BeginUpdate (sourceRichEdit);
            if (File.Exists(fileName))
            {
                string [] aszAllLines = FileUtility.ReadAllLines(fileName, excludeEmptyLines, true);
                string    szBuffer    = String.Concat(aszAllLines);
                sourceRichEdit.AppendText(szBuffer);
            }
            //Win32RichEditUtility.EndUpdate (sourceRichEdit);
        }
Esempio n. 12
0
        public static void LoadText(TextBoxBase sourceRichEdit, string [] lineArray)
        {
            if (sourceRichEdit == null)
            {
                throw new NolmeArgumentNullException();
            }
            if (lineArray == null)
            {
                throw new NolmeArgumentNullException();
            }

            sourceRichEdit.Clear();

            for (int i = 0; i < lineArray.Length; i++)
            {
                sourceRichEdit.AppendText(lineArray[i]);
                sourceRichEdit.AppendText(StringUtility.CreateLinefeedString());
            }
        }
Esempio n. 13
0
        public static void Clear(Control control)
        {
            foreach (Control item in control.Controls)
            {
                if (item.HasChildren)
                {
                    Clear(item);
                }

                if (item is TextBoxBase)
                {
                    TextBoxBase txt = (TextBoxBase)item;
                    txt.Clear();
                }
                else if (item is ComboBox)
                {
                    ComboBox cmb = (ComboBox)item;
                    cmb.SelectedIndex = -1;
                }
            }
        }
Esempio n. 14
0
        public static void LoadText(TextBoxBase sourceRichEdit, ArrayList arrayList)
        {
            if (sourceRichEdit == null)
            {
                throw new NolmeArgumentNullException();
            }
            if (arrayList == null)
            {
                throw new NolmeArgumentNullException();
            }

            sourceRichEdit.Clear();

            //Win32RichEditUtility.BeginUpdate (sourceRichEdit);
            for (int i = 0; i < arrayList.Count; i++)
            {
                sourceRichEdit.AppendText(arrayList[i].ToString());
                sourceRichEdit.AppendText(StringUtility.CreateLinefeedString());
                //Win32RichEditUtility.AddTextLine (sourceRichEdit, arrayList[i].ToString (), Color.Black, 8, false, false, false, false);
            }
            //Win32RichEditUtility.EndUpdate (sourceRichEdit);
        }
Esempio n. 15
0
        public static void LoadText(TextBoxBase sourceRichEdit, Stream stream)
        {
            if (sourceRichEdit == null)
            {
                throw new NolmeArgumentNullException();
            }
            if (stream == null)
            {
                throw new NolmeArgumentNullException();
            }

            byte [] aBytes;
            sourceRichEdit.Clear();

            aBytes = new byte [stream.Length + 1];
            stream.Read(aBytes, 0, (int)stream.Length);

            ASCIIEncoding oObj     = new ASCIIEncoding();
            string        szBuffer = oObj.GetString(aBytes, 0, aBytes.GetLength(0));

            sourceRichEdit.AppendText(szBuffer);
        }
Esempio n. 16
0
        public static void ProcessTextContextMenu(TextBoxBase textbox, object sender)
        {
            var tsmi = sender as ToolStripMenuItem;

            if (tsmi == null)
            {
                return;
            }

            var cmd = tsmi.Tag as string;

            var text = string.Empty;

            try
            {
                if (cmd == FormStringKeys.STR_MENU_ITEM_COPY_ALL.ToString())
                {
                    if (textbox.Text != "")
                    {
                        Clipboard.SetText(textbox.Text);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_COPY.ToString())
                {
                    if (textbox.SelectedText != "")
                    {
                        Clipboard.SetText(textbox.SelectedText);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_CUT.ToString())
                {
                    if (textbox.SelectedText != "")
                    {
                        textbox.Cut();
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_PASTE.ToString())
                {
                    if (Clipboard.ContainsText())
                    {
                        //TODO no RTF
                        textbox.Paste();
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SELECT_ALL.ToString())
                {
                    textbox.Focus();
                    textbox.SelectAll();
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_CLEAR.ToString())
                {
                    textbox.Clear();
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_DELETE.ToString())
                {
                    if (textbox.SelectionLength > 0)
                    {
                        var oldStart = textbox.SelectionStart;
                        textbox.Text           = textbox.Text.Remove(textbox.SelectionStart, textbox.SelectionLength);
                        textbox.SelectionStart = oldStart;
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SAVE.ToString())
                {
                    var sfd = new SaveFileDialog();
                    sfd.Filter = ResxManager.GetResourceString(FormStringKeys.STR_TEXT_SAVE_FILTER);
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        File.WriteAllText(sfd.FileName, textbox.Text);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_WORDWRAP.ToString())
                {
                    textbox.WordWrap = !tsmi.Checked;
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SEND_TO_SOURCE.ToString())
                {
                    //TODO STR_MENUITEM_SEND_TO_SOURCE
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_UNDO.ToString())
                {
                    if (textbox.CanUndo)
                    {
                        textbox.Undo();
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_COPY_AS_REGEX.ToString())
                {
                    text = textbox.SelectedText;
                    if (text != string.Empty)
                    {
                        IRegexAnalyst ra = new RegexAnalyst();
                        text = ra.ToSimpleRegexString(text);
                        Clipboard.SetText(text);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_TO_REGEX_FORMAT.ToString())
                {
                    text = textbox.SelectedText;

                    if (text == string.Empty)
                    {
                        text = textbox.Text;
                    }

                    if (text != string.Empty)
                    {
                        IRegexAnalyst ra = new RegexAnalyst();
                        text = ra.ToSimpleRegexString(text);

                        if (textbox.SelectedText.Length > 0)
                        {
                            if (text != textbox.SelectedText)
                            {
                                //TODO it can be undo,but affect the clipboard
                                Clipboard.SetText(text);
                                textbox.Paste();
                                Clipboard.Clear();
                            }
                        }
                        else
                        {
                            if (text != textbox.Text)
                            {
                                //TODO it can be undo,but affect the clipboard
                                Clipboard.SetText(text);
                                textbox.SelectAll();
                                textbox.Paste();
                                Clipboard.Clear();
                            }
                        }
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SELECTION_ONLY.ToString())
                {
                    tsmi.Checked = !tsmi.Checked;
                    //textbox.HideSelection = !tsmi.Checked;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 17
0
 protected override void ClearScreen()
 {
     _logControl.Clear();
 }
Esempio n. 18
0
        public TextBoxScriptLogger(TextBoxBase box)
        {
            _box = box;

            box?.Clear();
        }
Esempio n. 19
0
        private void HexDump(TextBoxBase box, IReadOnlyList <byte> bytes, int size)
        {
            if (bytes == null)
            {
                return;
            }

            var       bytesLength  = size;
            const int bytesPerLine = 16;

            var hexChars = "0123456789ABCDEF".ToCharArray();

            var firstHexColumn = 8 + 3;                  // 8 characters for the address + 3 spaces

            var firstCharColumn = firstHexColumn
                                  + bytesPerLine * 3       // - 2 digit for the hexadecimal value and 1 space
                                  + (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
                                  + 2;                     // 2 spaces

            var lineLength = firstCharColumn
                             + bytesPerLine                // - characters to show the ascii value
                             + Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)

            var line          = (new string(' ', lineLength - 2) + Environment.NewLine).ToCharArray();
            var expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
            var result        = new StringBuilder(expectedLines * lineLength);

            box.Clear();

            for (var i = 0; i < bytesLength; i += bytesPerLine)
            {
                line[0] = hexChars[(i >> 28) & 0xF];
                line[1] = hexChars[(i >> 24) & 0xF];
                line[2] = hexChars[(i >> 20) & 0xF];
                line[3] = hexChars[(i >> 16) & 0xF];
                line[4] = hexChars[(i >> 12) & 0xF];
                line[5] = hexChars[(i >> 8) & 0xF];
                line[6] = hexChars[(i >> 4) & 0xF];
                line[7] = hexChars[(i >> 0) & 0xF];

                var hexColumn  = firstHexColumn;
                var charColumn = firstCharColumn;

                for (var j = 0; j < bytesPerLine; j++)
                {
                    if (j > 0 && (j & 7) == 0)
                    {
                        hexColumn++;
                    }
                    if (i + j >= bytesLength)
                    {
                        line[hexColumn]     = ' ';
                        line[hexColumn + 1] = ' ';
                        line[charColumn]    = ' ';
                    }
                    else
                    {
                        var b = bytes[i + j];
                        line[hexColumn]     = hexChars[(b >> 4) & 0xF];
                        line[hexColumn + 1] = hexChars[b & 0xF];
                        line[charColumn]    = (b < 32 ? '·' : (char)b);
                    }
                    hexColumn += 3;
                    charColumn++;
                }
                result.Append(line);
            }
            box.Text = result.ToString();
        }
Esempio n. 20
0
 private void ReflectFromGridToCommandLine()
 {
     textBox.Clear();
     textBox.Text           = commandLoaded.CommandLine;
     textBox.SelectionStart = textBox.Text.Length;
 }
Esempio n. 21
0
 /// <summary>
 /// Clear both the TextBox and the buffer.
 /// </summary>
 public void Clear()
 {
     textBox.Clear();
     sb = null;
 }