Example #1
0
 private void RemParam(System.Windows.Forms.TextBox textBox, ListBox listBox, int index)
 {
     if (string.IsNullOrWhiteSpace(textBox.Text) == false && string.IsNullOrEmpty(textBox.Text) == false)
     {
         listBox.Items.Insert(index, textBox.Text);
         textBox.ResetText();
     }
 }
Example #2
0
 /*************
 * AUX METHODS*
 **************/
 private void DisplayRegion(char[,] map, TextBox display)
 {
     display.ResetText();
       for (int r = 0; r <= 14; r++)
       {
     for (int c = 0; c <= 14; c++)
     {
       if (map[r, c] == '#')
     area++;
       display.Text += map[r, c].ToString();
     }
     display.AppendText("\n");
       }
 }
Example #3
0
        private int AddParamGetIndex(System.Windows.Forms.TextBox textBox, ListBox listBox, int index)
        {
            if (string.IsNullOrWhiteSpace(textBox.Text) == false && string.IsNullOrEmpty(textBox.Text) == false)
            {
                listBox.Items.Insert(index, textBox.Text);
                textBox.ResetText();
            }
            int newindex = listBox.SelectedIndex;

            textBox.Text = listBox.GetItemText(listBox.SelectedItem);
            listBox.Items.Remove(textBox.Text);

            return(newindex);
        }
        public void ResetAllControlsInPanel(ErrorProvider ep, System.Windows.Forms.GroupBox currentPanel)
        {
            System.Windows.Forms.Control ctrl = currentPanel.GetNextControl(currentPanel, true);

            while (ctrl != null)
            {
                System.Type ctrlType = ctrl.GetType();
                if (ctrlType == typeof(System.Windows.Forms.TextBox))
                {
                    System.Windows.Forms.TextBox currentTextBox = ctrl as System.Windows.Forms.TextBox;
                    currentTextBox.ResetText();
                    ep.SetError(currentTextBox, string.Empty);
                }
                else if (ctrlType == typeof(System.Windows.Forms.ComboBox))
                {
                    System.Windows.Forms.ComboBox currentComboBox = ctrl as System.Windows.Forms.ComboBox;
                    if (currentComboBox.Items.Count > 0)
                    {
                        currentComboBox.SelectedIndex = 0;
                    }
                    ep.SetError(currentComboBox, string.Empty);
                }
                else if (ctrlType == typeof(System.Windows.Forms.ListBox))
                {
                    System.Windows.Forms.ListBox currentListBox = ctrl as System.Windows.Forms.ListBox;
                    if (currentListBox.Items.Count > 0)
                    {
                        currentListBox.SelectedIndex = 0;
                    }
                    ep.SetError(currentListBox, string.Empty);
                }
                else if (ctrlType == typeof(System.Windows.Forms.CheckBox))
                {
                    System.Windows.Forms.CheckBox currentCheckBox = ctrl as System.Windows.Forms.CheckBox;
                    currentCheckBox.Checked = false;
                    ep.SetError(currentCheckBox, string.Empty);
                }
                else if (ctrlType == typeof(System.Windows.Forms.CheckedListBox))
                {
                    System.Windows.Forms.CheckedListBox currentCheckBox = ctrl as System.Windows.Forms.CheckedListBox;
                    ep.SetError(currentCheckBox, string.Empty);
                }
                ctrl = currentPanel.GetNextControl(ctrl, true);
            }
        }
        public void ResetAllControlsInPanel(System.Windows.Forms.Panel currentPanel)
        {
            System.Windows.Forms.Control ctrl = currentPanel.GetNextControl(currentPanel, true);

            while (ctrl != null)
            {
                System.Type ctrlType = ctrl.GetType();
                if (ctrlType == typeof(System.Windows.Forms.TextBox))
                {
                    System.Windows.Forms.TextBox currentTextBox = ctrl as System.Windows.Forms.TextBox;
                    currentTextBox.ResetText();
                }
                else if (ctrlType == typeof(System.Windows.Forms.ComboBox))
                {
                    System.Windows.Forms.ComboBox currentComboBox = ctrl as System.Windows.Forms.ComboBox;
                    if (currentComboBox.Items.Count > 0)
                    {
                        currentComboBox.SelectedIndex = 0;
                    }
                }
                else if (ctrlType == typeof(System.Windows.Forms.ListBox))
                {
                    System.Windows.Forms.ListBox currentListBox = ctrl as System.Windows.Forms.ListBox;
                    if (currentListBox.Items.Count > 0)
                    {
                        currentListBox.SelectedIndex = 0;
                    }
                }
                else if (ctrlType == typeof(System.Windows.Forms.CheckBox))
                {
                    System.Windows.Forms.CheckBox currentCheckBox = ctrl as System.Windows.Forms.CheckBox;
                    currentCheckBox.Checked = false;
                }
                ctrl = currentPanel.GetNextControl(ctrl, true);
            }
        }
Example #6
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            byte bit, and;

            byte[] donusum = new byte[8];         //0-255 arasý girilen sayýmýzýn bitler ayýrdýðýmýz zaman aktaracaðýmýz dizi
            if (textBox1.Text == "")
            {
                MessageBox.Show("Sayý girmeniz gerekiyor");
                return;
            }
            long degeregec = Convert.ToInt64(textBox1.Text);

            if (degeregec > 255)
            {
                MessageBox.Show("0-255 arasý veri giriniz");
                if (textBox1.CanFocus)
                {
                    textBox1.Focus();
                }
                return;
            }
            byte deger = Convert.ToByte(textBox1.Text);

            for (byte k = 8; k >= 1; k--)
            {
                and = 1;
                for (int l = 1; l <= k - 1; l++)
                {
                    and *= 2;
                }
                bit            = (byte)((deger & and) >> k - 1);
                donusum[k - 1] = bit;
            }

            if (donusum[7] == 1)
            {
                sekiz.Image = yanýk.Image;
            }
            else if (donusum[7] == 0)
            {
                sekiz.Image = sonuk.Image;
            }
            if (donusum[6] == 1)
            {
                yedi.Image = yanýk.Image;
            }
            else if (donusum[6] == 0)
            {
                yedi.Image = sonuk.Image;
            }
            if (donusum[5] == 1)
            {
                altý.Image = yanýk.Image;
            }
            else if (donusum[5] == 0)
            {
                altý.Image = sonuk.Image;
            }
            if (donusum[4] == 1)
            {
                bes.Image = yanýk.Image;
            }
            else if (donusum[4] == 0)
            {
                bes.Image = sonuk.Image;
            }
            if (donusum[3] == 1)
            {
                dort.Image = yanýk.Image;
            }
            else if (donusum[3] == 0)
            {
                dort.Image = sonuk.Image;
            }
            if (donusum[2] == 1)
            {
                uc.Image = yanýk.Image;
            }
            else if (donusum[2] == 0)
            {
                uc.Image = sonuk.Image;
            }
            if (donusum[1] == 1)
            {
                iki.Image = yanýk.Image;
            }
            else if (donusum[1] == 0)
            {
                iki.Image = sonuk.Image;
            }
            if (donusum[0] == 1)
            {
                bir.Image = yanýk.Image;
            }
            else
            {
                bir.Image = sonuk.Image;
            }
            try
            {
                gonder.verigonder(888, deger);
                label1.Text = "Veri baþarýyla gönderildi";
                textBox1.ResetText();
            }
            catch (Exception hata)
            {
                string error = hata.Message;
                MessageBox.Show("Veri gönderilirken hata oluþtu", "hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #7
0
        /// <summary>
        /// Defines the row view section of the form.
        /// </summary>
        private void _CreateRowView()
        {
            _rows_LayoutPanel.SuspendLayout();
            int column = 0;
            TextBox relationTextBox = null;

            foreach (DataColumn dc in _dataTable.Columns)
            {
                column++;

                new Label
                {
                    Text = dc.ColumnName,
                    Parent = _rows_LayoutPanel,
                    AutoSize = true,
                    Dock = DockStyle.Fill
                };

                column++;

                if (dc.ExtendedProperties.ContainsKey(ExcelFile.ColumnTypeKeys.IsBool) && (bool)dc.ExtendedProperties[ExcelFile.ColumnTypeKeys.IsBool])
                {
                    CheckBox checkBox = new CheckBox
                    {
                        Parent = _rows_LayoutPanel,
                        AutoSize = true,
                        Dock = DockStyle.Fill,
                        Name = dc.ColumnName,
                        CheckAlign = ContentAlignment.MiddleLeft
                    };

                    checkBox.CheckedChanged += _RowView_CheckBox_ItemCheck;
                    _specialControls.Add(dc.ColumnName, checkBox);
                }
                else if (dc.ExtendedProperties.ContainsKey(ExcelFile.ColumnTypeKeys.IsBitmask) && (bool)dc.ExtendedProperties[ExcelFile.ColumnTypeKeys.IsBitmask])
                {
                    CheckedListBox checkedListBox = new CheckedListBox
                    {
                        Parent = _rows_LayoutPanel,
                        AutoSize = true,
                        Dock = DockStyle.Fill,
                        MultiColumn = false,
                        Name = dc.ColumnName
                    };

                    checkedListBox.ItemCheck += _RowView_CheckedListBox_ItemCheck;
                    _specialControls.Add(dc.ColumnName, checkedListBox);

                    OutputAttribute attribute = ExcelFile.GetExcelAttribute(_dataFile.DataType.GetField(dc.ColumnName));

                    // Populate the checklist by either a enum or (less commonly) table indices
                    if (!String.IsNullOrEmpty(attribute.TableStringId))
                    {
                        // TODO: should perhaps use object delegator here, it might be faster
                        // so far its only its runtime is only 1n so doesnt really matter.
                        //
                        DataTable dataTable = _fileManager.GetDataTable(attribute.TableStringId);
                        foreach (DataRow row in dataTable.Rows)
                        {
                            checkedListBox.Items.Add(row[2], false);
                        }
                    }
                    else
                    {
                        Type cellType = dc.DataType;
                        foreach (Enum type in Enum.GetValues(cellType))
                        {
                            checkedListBox.Items.Add(type, false);
                        }
                    }
                }
                else if (dc.ExtendedProperties.ContainsKey(ExcelFile.ColumnTypeKeys.IsEnum) && (bool)dc.ExtendedProperties[ExcelFile.ColumnTypeKeys.IsEnum])
                {
                    ComboBox comboBox = new ComboBox
                    {
                        Parent = _rows_LayoutPanel,
                        Dock = DockStyle.Fill,
                        Name = dc.ColumnName
                    };

                    // todo: consider lookomg into overloaded FindString or FindExactString methods and check (change) the startIndex parameter
                    Binding comboBoxBinding = comboBox.DataBindings.Add("SelectedIndex", _dataTable, dc.ColumnName, true);
                    comboBoxBinding.Format += _ComboBoxFormat;
                    comboBox.SelectedIndexChanged += _RowView_ComboList_ItemChange;

                    // need order as VALUE order - Enum.GetValues provides sorted as UNSIGNED values e.g. {0, 1, 2, 3, -3, -2, -1} instead of {-3, -2, -1, 0, 1, 2, 3}
                    List<Enum> enumValues = Enum.GetValues(dc.DataType).Cast<Enum>().ToList();
                    enumValues.Sort(); // List sort works as SIGNED
                    comboBox.Items.AddRange(enumValues.ToArray());
                    comboBox.Tag = Math.Abs(Convert.ToInt32(enumValues.Min())); // we need a minimum value to get our base offset
                }
                else
                {
                    TextBox textBox = new TextBox
                    {
                        Text = String.Empty,
                        Parent = _rows_LayoutPanel,
                        AutoSize = true,
                        Dock = DockStyle.Fill,
                        Name = dc.ColumnName
                    };
                    textBox.DataBindings.Add("Text", _dataTable, dc.ColumnName);

                    if ((dc.ExtendedProperties.ContainsKey(ExcelFile.ColumnTypeKeys.IsRelationGenerated) && (bool)dc.ExtendedProperties[ExcelFile.ColumnTypeKeys.IsRelationGenerated]) || column == 0)
                    {
                        textBox.ReadOnly = true;
                        if (relationTextBox != null)
                        {
                            relationTextBox.TextChanged += (sender, e) => textBox.ResetText();
                        }
                    }

                    if ((dc.ExtendedProperties.ContainsKey(ExcelFile.ColumnTypeKeys.IsStringIndex) && (bool)dc.ExtendedProperties[ExcelFile.ColumnTypeKeys.IsStringIndex]) ||
                        (dc.ExtendedProperties.ContainsKey(ExcelFile.ColumnTypeKeys.IsStringOffset) && (bool)dc.ExtendedProperties[ExcelFile.ColumnTypeKeys.IsStringOffset]))
                    {
                        relationTextBox = textBox;
                    }
                    else
                    {
                        relationTextBox = null;
                    }
                }
            }

            new Label
            {
                Text = String.Empty,
                Parent = _rows_LayoutPanel,
                AutoSize = true,
                Dock = DockStyle.Fill
            };
            _rows_LayoutPanel.ResumeLayout();
            _rows_LayoutPanel.Width += 10;

            // fixes mouse scroll wheel
            // todo: this is dodgy and causes focused elements within the layoutpanel to lose focus (e.g. a text box) - rather anoying
            _rows_LayoutPanel.Click += (sender, e) => _rows_LayoutPanel.Focus();
            _rows_LayoutPanel.MouseEnter += (sender, e) => _rows_LayoutPanel.Focus();
        }
Example #8
0
        public static void SetAllMentionToTextBox(TextBox tb, ListViewItem item, ref TwitterModelClass tmc)
        {
            TwitterStatus status = (TwitterStatus)item.Tag;
            tb.Tag = item;
            tb.ResetText();

            List<string> screenNameList = new List<string>();
            screenNameList.Add(status.User.ScreenName);

            foreach (TwitterMention tm in status.Entities.Mentions)
            {
                screenNameList.Add(tm.ScreenName);
            }

            string MySName = tmc.MySName;
            screenNameList.RemoveAll((s => s == MySName));

            foreach (string sname in screenNameList)
            {
                tb.Text = tb.Text + "@" + sname + " ";
            }
            tb.Focus();
            tb.Select(tb.TextLength, 0);
        }