Exemplo n.º 1
0
 /// <summary>
 /// 4个滑块的构造函数
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="leftValue"></param>
 /// <param name="rightValue"></param>
 /// <param name="isLargeValueOK"></param>
 /// <param name="slideCount"></param>
 public DoubleEditorRangeForm(string unit, double min, double max, double leftValue, double rightValue, double leftValue1, double rightValue1, bool isLargeValueOK, int slideCount = 4)
 {
     InitializeComponent();
     Unit         = unit;
     this.min     = min;
     this.max     = max;
     blockList    = new List <SlideBlock>();
     left         = new SlideBlock(leftValue, min, max, width, unit);
     right        = new SlideBlock(rightValue, min, max, width, unit);
     left1        = new SlideBlock(leftValue1, min, max, width, unit);
     right1       = new SlideBlock(rightValue1, min, max, width, unit);
     left.right   = right;
     left.Left    = null;
     right.Left   = left;
     right.right  = left1;
     left1.Left   = right;
     left1.right  = right1;
     right1.Left  = left1;
     right1.right = null;
     blockList.Add(left);
     blockList.Add(right);
     blockList.Add(left1);
     blockList.Add(right1);
     this.isLargeValueOK = isLargeValueOK;
     initControls();
     RefreshControls();
 }
Exemplo n.º 2
0
 private void pbColor_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         double            xPos   = e.Location.X;
         List <SlideBlock> sbList = blockList?.FindAll((p) => p.IsMouseOn(xPos));
         if (sbList.Count == 1)
         {
             curSlideBlock = sbList.First();
         }
         else if (sbList.Count >= 2)
         {
             if (sbList.FindAll(p => p.Value == min).Count > 0)
             {
                 curSlideBlock = sbList.Last();
             }
             else if (sbList.FindAll(p => p.Value == max).Count > 0)
             {
                 curSlideBlock = sbList.First();
             }
             else
             {
                 curSlideBlock = sbList.First();
             }
         }
         mouseDownCalculateLoc = e.Location.X;
     }
 }
Exemplo n.º 3
0
        public override void RefreshRect(Graphics e)
        {
            if (blockList?.Count == 4)
            {
                SlideBlock left       = blockList.Find((p) => p.Left == null);
                double     leftLevel  = left.DrawXLocation;
                double     rightLevel = left.right.DrawXLocation;

                double leftLevel1  = left.right.right.DrawXLocation;
                double rightLevel1 = left.right.right.right.DrawXLocation;

                if (isLargeValueOK)
                {
                    e.FillRectangle(OkBrush, new Rectangle(0, 0, (int)leftLevel, (int)height));
                    e.FillRectangle(warnBrush, new Rectangle((int)leftLevel, 0, (int)(rightLevel - leftLevel), (int)height));
                    e.FillRectangle(ngBrush, new Rectangle((int)rightLevel, 0, (int)(leftLevel1 - rightLevel), (int)height));
                    e.FillRectangle(warnBrush, new Rectangle((int)leftLevel1, 0, (int)(rightLevel1 - leftLevel1), (int)height));
                    e.FillRectangle(OkBrush, new Rectangle((int)rightLevel1, 0, (int)(width - rightLevel1), (int)height));
                }
                else
                {
                    e.FillRectangle(ngBrush, new Rectangle(0, 0, (int)leftLevel, (int)height));
                    e.FillRectangle(warnBrush, new Rectangle((int)leftLevel, 0, (int)(rightLevel - leftLevel), (int)height));
                    e.FillRectangle(OkBrush, new Rectangle((int)rightLevel, 0, (int)(leftLevel1 - rightLevel), (int)height));
                    e.FillRectangle(warnBrush, new Rectangle((int)leftLevel1, 0, (int)(rightLevel1 - leftLevel1), (int)height));
                    e.FillRectangle(ngBrush, new Rectangle((int)rightLevel1, 0, (int)(width - rightLevel1), (int)height));
                }
            }
        }
Exemplo n.º 4
0
 public SlideBlock(double value, double minLevel, double MaxLevel, double parentWidth, string lbUnit, SlideBlock left = null, SlideBlock right = null)
 {
     this.ParentWidth = parentWidth;
     this.value       = value;
     this.minLevel    = minLevel;
     this.maxLevel    = MaxLevel;
     this.lbUnit      = lbUnit;
     this.Left        = left;
     this.right       = right;
 }
Exemplo n.º 5
0
 private void pbColor_MouseUp(object sender, MouseEventArgs e)
 {
     lastSlideBlock = curSlideBlock;
     curSlideBlock  = null;
 }