Beispiel #1
0
 public void ClearLines()
 {
     wheelCount = 0;
     ShortCuttingLines.Clear();
     LongCuttingLines.Clear();
     LinesPanel.ClearVisuals(); //清理面板
 }
Beispiel #2
0
        public void Reload()
        {
            if (map != null)
            {
                SuspendLayout();
                LinesPanel.SuspendLayout();
                items.Clear();
                LinesPanel.Controls.Clear();

                foreach (List <string> remaps in map.ControlMaps)
                {
                    DraggableTBLine line = new DraggableTBLine();
                    foreach (string remap in remaps)
                    {
                        line.AddItem(remap);
                    }
                    line.Content.ControlAdded   += new ControlEventHandler(Line_ControlAdded);
                    line.Content.ControlRemoved += new ControlEventHandler(line_ControlRemoved);
                    items.Add(line);
                    LinesPanel.Controls.Add(line);
                    line.Dock = DockStyle.Top;
                    line.BringToFront();
                }

                CreateEmptyLine();

                ResumeLayout();
                LinesPanel.ResumeLayout();
            }
        }
Beispiel #3
0
        public bool AddLongLine(double offset, Brush brsh)
        {
            DrawingVisual drawingVisual = new DrawingVisual();
            Point         start_point   = new Point();
            Point         end_point     = new Point();
            //参数设置和验证
            double height = offset / shortsied * canvas_Height;

            if (height < 0 || height > (offset_h + canvas_Height))
            {
                return(false);
            }
            start_point.X = offset_w;
            start_point.Y = offset_h + height;
            end_point.X   = offset_w + canvas_Width;
            end_point.Y   = offset_h + height;
            Pen pen = new Pen(brsh, 1);

            using (DrawingContext dc = drawingVisual.RenderOpen())
            {
                dc.DrawLine(pen, start_point, end_point);
            }
            //添加
            if (LinesPanel.AddLongVisual(drawingVisual))
            {
                LineItem item = new LineItem(drawingVisual, LineStatus.Wait, LineAction.Unselected, LineLength.LongLine, brsh, start_point, end_point);
                if (LongCuttingLines.Count == 0)
                {
                    LongCuttingLines.Add(item);
                }
                else
                {
                    int  index = 0;
                    bool flag  = false;
                    for (; index < LongCuttingLines.Count;)
                    {
                        if (LongCuttingLines[index].StartPoint.X < start_point.X)
                        {
                            index++;
                        }
                        else
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag || (index == LongCuttingLines.Count))
                    {
                        LongCuttingLines.Insert(index, item);
                    }
                }
                return(true);
            }
            return(false);
        }
Beispiel #4
0
 public void DeleteLine(LineLength length, int index)
 {
     if (length == LineLength.ShortLine)
     {
         if (index < 0 || ShortCuttingLines.Count <= 0 || ShortCuttingLines.Count <= index)
         {
             return;
         }
         ShortCuttingLines.RemoveAt(index);
         LinesPanel.DeleteVisual(index);
     }
     else
     {
         if (index < 0 || LongCuttingLines.Count <= 0 || LongCuttingLines.Count <= index)
         {
             return;
         }
         LongCuttingLines.RemoveAt(index);
         LinesPanel.DeleteVisual(ShortCuttingLines.Count + index);
     }
 }