Example #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);
            }
        }
Example #2
0
        public void UpdateHoverControls()
        {
            return;

            // todo -> redo these in pure GL.. windows controls interfere too much with the drawing resulting in glitches.

            if (SelectedInstance != null)
            {
                GerberInstance GI = SelectedInstance as GerberInstance;
                if (GI == null)
                {
                    RotateLeftHover.Visible  = false;
                    RotateRightHover.Visible = false;
                }
                else
                {
                    RotateLeftHover.Visible  = true;
                    RotateRightHover.Visible = true;
                    var TL = MMToMouse(GI.BoundingBox.TopLeft);
                    var BR = MMToMouse(GI.BoundingBox.BottomRight);
                    int W  = RotateLeftHover.Width;
                    int H  = RotateLeftHover.Height;

                    RotateLeftHover.Top   = Math.Max(0, Math.Min(glControl1.Height - H, (int)(TL.Y - RotateLeftHover.Height)));
                    RotateLeftHover.Left  = Math.Max(0, Math.Min(glControl1.Width - W, (int)(TL.X - RotateLeftHover.Width)));
                    RotateRightHover.Top  = Math.Max(0, Math.Min(glControl1.Height - H, (int)(TL.Y - RotateLeftHover.Height)));
                    RotateRightHover.Left = Math.Max(0, Math.Min(glControl1.Width - W, (int)(BR.X + 1)));
                }
            }
            else
            {
                RotateLeftHover.Visible  = false;
                RotateRightHover.Visible = false;
            }
        }
Example #3
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);
     }
 }
        public void UpdateBoxes(GerberPanelize newTarget)
        {
            TargetInstance = newTarget;
            this.Visible   = true;

            if (TargetInstance == null || TargetInstance.SelectedInstance == null)
            {
                panel1.Enabled = false; return;
            }
            else
            {
                panel1.Enabled = true;
            }
            newTarget.SuspendRedraw = true;
            double x   = TargetInstance.SelectedInstance.Center.X;
            double y   = TargetInstance.SelectedInstance.Center.Y;
            double r   = TargetInstance.SelectedInstance.Angle;
            double rad = 0;

            radiusbox.Enabled = false;
            Bigger.Enabled    = false;
            Smaller.Enabled   = false;

            if (TargetInstance.SelectedInstance.GetType() == typeof(BreakTab))
            {
                BreakTab BT = TargetInstance.SelectedInstance as BreakTab;
                NameLabel.Text    = "Break tab";
                Bigger.Enabled    = true;
                Smaller.Enabled   = true;
                rad               = BT.Radius;
                radiusbox.Enabled = true;
            }

            if (TargetInstance.SelectedInstance.GetType() == typeof(GerberInstance))
            {
                GerberInstance GI = TargetInstance.SelectedInstance as GerberInstance;
                NameLabel.Text = Path.GetFileName(Path.GetDirectoryName(GI.GerberPath));
            }

            xbox.Value              = (decimal)x;
            ybox.Value              = (decimal)y;
            rbox.Value              = (decimal)r;
            radiusbox.Value         = (decimal)rad;
            Initializing            = false;
            newTarget.SuspendRedraw = false;
        }
Example #5
0
        void UpdateInstance()
        {
            if (Initializing)
            {
                return;
            }

            if (TargetInstance == null)
            {
                return;
            }

            if (TargetInstance.SelectedInstance == null)
            {
                return;
            }

            TargetInstance.SelectedInstance.Center.X = (float)xbox.Value;
            TargetInstance.SelectedInstance.Center.Y = (float)ybox.Value;
            TargetInstance.SelectedInstance.Angle    = (float)rbox.Value;

            if (TargetInstance.SelectedInstance.GetType() == typeof(BreakTab))
            {
                BreakTab BT = TargetInstance.SelectedInstance as BreakTab;
                BT.Radius = (float)radiusbox.Value;
            }
            else if (TargetInstance.SelectedInstance.GetType() == typeof(GerberInstance))

            {
                GerberInstance GI = TargetInstance.SelectedInstance as GerberInstance;
                GI.RebuildTransformed(TargetInstance.ThePanel.GerberOutlines[GI.GerberPath], TargetInstance.ThePanel.TheSet.ExtraTabDrillDistance);
            }

            TargetInstance.UpdateHoverControls();
            TargetInstance.Redraw(true);
        }