Exemplo n.º 1
0
        private void TrackBarItem_Scroll(object sender, EventArgs e)
        {
            TrackBar  bar  = sender as TrackBar;
            FloatItem item = bar.Tag as FloatItem;

            if (item != null)
            {
                item.Value = bar.Value * item.Increment;
                string controlName = item.CategoryName + "_" + item.UIName + "_" + "textFloat";
                if (bar.Parent.Controls[controlName] != null)
                {
                    bar.Parent.Controls[controlName].Text = item.ValueString;
                }
            }
        }
Exemplo n.º 2
0
        private void AddFloatItemControl(BaseItem item, Panel panelItem)
        {
            Label labelItem = new Label();

            labelItem.AutoSize    = true;
            labelItem.ForeColor   = Color.Black;
            labelItem.Location    = new Point(m_NameLocationX, 3);
            labelItem.MaximumSize = new Size(m_ValueLocationX - m_NameLocationX, 20);
            labelItem.Name        = item.CategoryName + "_" + item.UIName + "_" + "label";
            labelItem.Text        = item.UIName;

            TextBox textItem = new TextBox();

            textItem.Location = new Point(m_ValueLocationX, 1);
            textItem.Size     = new Size(50, m_ItemHeight - 1);
            textItem.Name     = item.CategoryName + "_" + item.UIName + "_" + "textFloat";
            textItem.Text     = item.ValueString;
            textItem.ReadOnly = true;

            FloatItem floatItem    = item as FloatItem;
            TrackBar  trackBarItem = new TrackBar();

            trackBarItem.Location      = new Point(m_ValueLocationX + 51, 1);
            trackBarItem.Size          = new Size(this.Width - m_ValueLocationX - 51 - 2, m_ItemHeight - 1);
            trackBarItem.Name          = item.CategoryName + "_" + item.UIName + "_" + "trackBarFloat";
            trackBarItem.Maximum       = (int)(floatItem.Maximum / floatItem.Increment);
            trackBarItem.Minimum       = (int)(floatItem.Minimum / floatItem.Increment);
            trackBarItem.LargeChange   = 1;
            trackBarItem.SmallChange   = 1;
            trackBarItem.TickFrequency = 1;
            trackBarItem.TickStyle     = TickStyle.None;
            trackBarItem.Value         = (int)(floatItem.Value / floatItem.Increment);
            trackBarItem.Cursor        = Cursors.Hand;
            trackBarItem.Scroll       += TrackBarItem_Scroll;
            trackBarItem.Tag           = floatItem;

            panelItem.Controls.Add(labelItem);
            panelItem.Controls.Add(textItem);
            panelItem.Controls.Add(trackBarItem);
        }