示例#1
0
        public void glControl1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                Point DropPointPre = glControl1.PointToClient(new Point(e.X, e.Y));
                var   DropPoint    = MouseToMM(new PointD(DropPointPre.X, DropPointPre.Y));


                string[] D = e.Data.GetData(DataFormats.FileDrop) as string[];
                foreach (string S in D)
                {
                    if (Directory.Exists(S) || (File.Exists(S) && (Path.GetExtension(S).ToLower() == ".zip" || Path.GetExtension(S).ToLower() == "zip")))
                    {
                        Console.WriteLine("Adding dropped folder: {0}", S);
                        var R = ThePanel.AddGerberFolder(S);
                        foreach (var s in R)
                        {
                            GerberInstance GI = new GerberInstance()
                            {
                                GerberPath = s
                            };
                            GI.Center = DropPoint;
                            ThePanel.TheSet.Instances.Add(GI);
                            SelectedInstance = GI;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Dropped item {0} is not a folder! ignoring!", S);
                    }
                }
                TV.BuildTree(this, ThePanel.TheSet);
                Redraw(true, true);
            }
        }
示例#2
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SelectedInstance = null;
     HoverShape       = null;
     ThePanel         = new GerberPanel();
     TV.BuildTree(this, ThePanel.TheSet);
     Redraw(true);
 }
示例#3
0
        internal void SetSelectedInstance(AngledThing gerberInstance)
        {
            SelectedInstance = gerberInstance;

            UpdateHoverControls();

            ID.UpdateBoxes(this);
            Redraw(false);
        }
示例#4
0
 private void addGerberFolderToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         var R = ThePanel.AddGerberFolder(folderBrowserDialog1.SelectedPath);
         foreach (var s in R)
         {
             GerberInstance GI = new GerberInstance() { GerberPath = s };
             ThePanel.TheSet.Instances.Add(GI);
             SelectedInstance = GI;
         }
         TV.BuildTree(this, ThePanel.TheSet);
         Redraw(true);
     }
 }
示例#5
0
        internal void RemoveInstance(AngledThing angledThing)
        {
            if (SelectedInstance == angledThing)
            {
                SetSelectedInstance(null);
            }

            if (HoverShape == angledThing)
            {
                HoverShape = null;
            }

            ThePanel.RemoveInstance(angledThing);
            TV.BuildTree(this, ThePanel.TheSet);
            Redraw(true);
        }
示例#6
0
        private void DoMouseDown(MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                SelectedInstance = ThePanel.FindOutlineUnderPoint(MouseToMM(new PointD(e.X, e.Y)));
                if (SelectedInstance != null)
                {
                    MouseCapture   = true;
                    DragStartCoord = new PointD(e.X, e.Y);
                    DragInstanceOriginalPosition = new PointD(SelectedInstance.Center);
                }

                SetSelectedInstance(SelectedInstance);
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                SelectedInstance = ThePanel.FindOutlineUnderPoint(MouseToMM(new PointD(e.X, e.Y)));

                ContextStartCoord = new PointD(e.X, e.Y);

                if (SelectedInstance != null)
                {
                    contextMenuStrip2.Show(this, e.Location);
                }
                else
                {
                    addInstanceToolStripMenuItem.DropDownItems.Clear();
                    foreach (var a in ThePanel.TheSet.LoadedOutlines)
                    {
                        addInstanceToolStripMenuItem.DropDownItems.Add(a, null, addinstance);
                    }

                    addGridOfInstancesToolStripMenuItem.DropDownItems.Clear();
                    foreach (var a in ThePanel.TheSet.LoadedOutlines)
                    {
                        addGridOfInstancesToolStripMenuItem.DropDownItems.Add(a, null, addgridofinstances);
                    }

                    contextMenuStrip1.Show(this, e.Location);
                }

                SetSelectedInstance(SelectedInstance);
            }
        }
示例#7
0
 private void DoMouseMove(MouseEventArgs e)
 {
     LastMouseMove = new PointD(e.X, e.Y);
     if (MouseCapture && SelectedInstance != null)
     {
         PointD Delta = new PointD(e.X, e.Y) - DragStartCoord;
         Delta.X /= Zoom;
         Delta.Y /= -Zoom;
         SelectedInstance.Center = Snap(DragInstanceOriginalPosition + Delta).ToF();
         //       SelectedInstance.Center.Y = (float)(DragInstanceOriginalPosition.Y + Delta.Y);
         Redraw(false);
     }
     else
     {
         var newHoverShape = ThePanel.FindOutlineUnderPoint(MouseToMM(new PointD(e.X, e.Y)));
         if (newHoverShape != HoverShape)
         {
             HoverShape = newHoverShape;
             Redraw(false);
         }
     }
 }
示例#8
0
 public InstanceTreeNode(AngledThing GI)
     : base("instance")
 {
     TargetInstance = GI;
     Text           = ToString();
 }