Exemplo n.º 1
0
        public override GH_ObjectResponse RespondToMouseUp(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                GH_Component comp = Owner as GH_Component;
                if (drag)
                {
                    // if drag was true then we release it here:
                    scrollStartY += deltaY;
                    deltaY        = 0;
                    drag          = false;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Release);
                }

                System.Drawing.RectangleF rec = BorderBound;
                if (rec.Contains(e.CanvasLocation))
                {
                    unfolded = !unfolded;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }

                if (unfolded)
                {
                    System.Drawing.RectangleF rec3 = dropdownBound;
                    if (rec3.Contains(e.CanvasLocation))
                    {
                        for (int i = 0; i < dropdownlist.Count; i++)
                        {
                            System.Drawing.RectangleF rec4 = dropdownBounds[i];
                            if (rec4.Contains(e.CanvasLocation))
                            {
                                comp.RecordUndoEvent("Selected " + dropdownlist[i]);
                                displayText = dropdownlist[i]; //change what user sees to selected item
                                action(dropdownlist[i]);       // send selected item back to component
                                unfolded = !unfolded;          // close dropdown
                                comp.ExpireSolution(true);
                                return(GH_ObjectResponse.Handled);
                            }
                        }
                    }
                    else
                    {
                        unfolded = !unfolded;
                        comp.ExpireSolution(true);
                        return(GH_ObjectResponse.Handled);
                    }
                }
            }
            return(base.RespondToMouseUp(sender, e));
        }
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                GH_Component comp = Owner as GH_Component;

                if (xTxtBounds.Contains(e.CanvasLocation) | xBounds.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle X");
                    x = !x;
                    update(x, y, z, xx, yy, zz);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (yTxtBounds.Contains(e.CanvasLocation) | yBounds.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle Y");
                    y = !y;
                    update(x, y, z, xx, yy, zz);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (zTxtBounds.Contains(e.CanvasLocation) | zBounds.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle Z");
                    z = !z;
                    update(x, y, z, xx, yy, zz);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (xxTxtBounds.Contains(e.CanvasLocation) | xxBounds.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle XX");
                    xx = !xx;
                    update(x, y, z, xx, yy, zz);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (yyTxtBounds.Contains(e.CanvasLocation) | yyBounds.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle YY");
                    yy = !yy;
                    update(x, y, z, xx, yy, zz);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (zzTxtBounds.Contains(e.CanvasLocation) | zzBounds.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle ZZ");
                    zz = !zz;
                    update(x, y, z, xx, yy, zz);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemplo n.º 3
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                for (int i = 0; i < dropdownlists.Count; i++)
                {
                    System.Drawing.RectangleF rec = BorderBound[i];
                    GH_Component comp             = Owner as GH_Component;
                    if (rec.Contains(e.CanvasLocation))
                    {
                        unfolded[i] = !unfolded[i];
                        comp.ExpireSolution(true);
                        return(GH_ObjectResponse.Handled);
                    }

                    if (unfolded[i])
                    {
                        System.Drawing.RectangleF rec2 = dropdownBound[i];
                        if (rec2.Contains(e.CanvasLocation))
                        {
                            for (int j = 0; j < dropdownBounds[i].Count; j++)
                            {
                                System.Drawing.RectangleF rec3 = dropdownBounds[i][j];
                                if (rec3.Contains(e.CanvasLocation))
                                {
                                    if (displayTexts[i] != dropdownlists[i][j])
                                    {
                                        // record an undo event so that user can ctrl + z
                                        comp.RecordUndoEvent("Selected " + dropdownlists[i][j]);

                                        // change the displayed text on canvas
                                        displayTexts[i] = dropdownlists[i][j];

                                        // if initial texts exists then change all dropdowns below this one to the initial description
                                        if (initialTxts != null)
                                        {
                                            for (int k = i + 1; k < dropdownlists.Count; k++)
                                            {
                                                displayTexts[k] = initialTxts[k];
                                            }
                                        }

                                        // send the selected item back to component (i = dropdownlist index, j = selected item in that list)
                                        action(i, j);

                                        // close the dropdown
                                        unfolded[i] = !unfolded[i];

                                        // recalculate component
                                        comp.ExpireSolution(true);
                                    }
                                    else
                                    {
                                        unfolded[i] = !unfolded[i];
                                        comp.ExpireSolution(true);
                                    }
                                    return(GH_ObjectResponse.Handled);
                                }
                            }
                        }
                        else
                        {
                            unfolded[i] = !unfolded[i];
                            comp.ExpireSolution(true);
                            return(GH_ObjectResponse.Handled);
                        }
                    }
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemplo n.º 4
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                for (int i = 0; i < dropdownlists.Count; i++)
                {
                    System.Drawing.RectangleF rec = BorderBound[i];
                    GH_Component comp             = Owner as GH_Component;
                    if (rec.Contains(e.CanvasLocation))
                    {
                        unfolded[i] = !unfolded[i];
                        comp.ExpireSolution(true);
                        return(GH_ObjectResponse.Handled);
                    }

                    if (unfolded[i])
                    {
                        System.Drawing.RectangleF rec2 = dropdownBound[i];
                        if (rec2.Contains(e.CanvasLocation))
                        {
                            for (int j = 0; j < dropdownBounds[i].Count; j++)
                            {
                                System.Drawing.RectangleF rec3 = dropdownBounds[i][j];
                                if (rec3.Contains(e.CanvasLocation))
                                {
                                    if (displayTexts[i] != dropdownlists[i][j])
                                    {
                                        // record an undo event so that user can ctrl + z
                                        comp.RecordUndoEvent("Selected " + dropdownlists[i][j]);

                                        // change the displayed text on canvas
                                        displayTexts[i] = dropdownlists[i][j];

                                        // if initial texts exists then change all dropdowns below this one to the initial description
                                        if (initialTxts != null)
                                        {
                                            for (int k = i + 1; k < dropdownlists.Count; k++)
                                            {
                                                displayTexts[k] = initialTxts[k];
                                            }
                                        }

                                        // send the selected item back to component (i = dropdownlist index, j = selected item in that list)
                                        action(i, j, isTapered, isHollow, isElliptical, isGeneral, isB2B);

                                        // close the dropdown
                                        unfolded[i] = !unfolded[i];

                                        // recalculate component
                                        comp.ExpireSolution(true);
                                    }
                                    else
                                    {
                                        unfolded[i] = !unfolded[i];
                                        comp.ExpireSolution(true);
                                    }
                                    return(GH_ObjectResponse.Handled);
                                }
                            }
                        }
                        else
                        {
                            unfolded[i] = !unfolded[i];
                            comp.ExpireSolution(true);
                            return(GH_ObjectResponse.Handled);
                        }
                    }
                }

                if (displayTexts[0] == "Standard")
                {
                    GH_Component comp = Owner as GH_Component;

                    if (taperBounds.Contains(e.CanvasLocation) || taperTxtBounds.Contains(e.CanvasLocation))
                    {
                        comp.RecordUndoEvent("Toggle Taper");
                        isTapered = !isTapered;
                        action(-1, -1, isTapered, isHollow, isElliptical, isGeneral, isB2B);
                        return(GH_ObjectResponse.Handled);
                    }

                    if (hollowBounds.Contains(e.CanvasLocation) || hollowTxtBounds.Contains(e.CanvasLocation))
                    {
                        comp.RecordUndoEvent("Toggle Hollow");
                        isHollow = !isHollow;
                        action(-1, -1, isTapered, isHollow, isElliptical, isGeneral, isB2B);
                        return(GH_ObjectResponse.Handled);
                    }

                    if (ellipBounds.Contains(e.CanvasLocation) || ellipTxtBounds.Contains(e.CanvasLocation))
                    {
                        comp.RecordUndoEvent("Toggle Elliptical");
                        isElliptical = !isElliptical;
                        action(-1, -1, isTapered, isHollow, isElliptical, isGeneral, isB2B);
                        return(GH_ObjectResponse.Handled);
                    }

                    if (genBounds.Contains(e.CanvasLocation) || genTxtBounds.Contains(e.CanvasLocation))
                    {
                        comp.RecordUndoEvent("Toggle General");
                        isGeneral = !isGeneral;
                        action(-1, -1, isTapered, isHollow, isElliptical, isGeneral, isB2B);
                        return(GH_ObjectResponse.Handled);
                    }

                    if (b2bBounds.Contains(e.CanvasLocation) || b2bTxtBounds.Contains(e.CanvasLocation))
                    {
                        comp.RecordUndoEvent("Toggle BackToBack");
                        isB2B = !isB2B;
                        action(-1, -1, isTapered, isHollow, isElliptical, isGeneral, isB2B);
                        return(GH_ObjectResponse.Handled);
                    }
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemplo n.º 5
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                GH_Component comp = Owner as GH_Component;

                if (xTxtBounds1.Contains(e.CanvasLocation) | xBounds1.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle X1");
                    x1 = !x1;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (yTxtBounds1.Contains(e.CanvasLocation) | yBounds1.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle Y1");
                    y1 = !y1;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (zTxtBounds1.Contains(e.CanvasLocation) | zBounds1.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle Z1");
                    z1 = !z1;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (xxTxtBounds1.Contains(e.CanvasLocation) | xxBounds1.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle XX1");
                    xx1 = !xx1;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (yyTxtBounds1.Contains(e.CanvasLocation) | yyBounds1.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle YY1");
                    yy1 = !yy1;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (zzTxtBounds1.Contains(e.CanvasLocation) | zzBounds1.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle ZZ1");
                    zz1 = !zz1;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }

                if (xTxtBounds2.Contains(e.CanvasLocation) | xBounds2.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle X2");
                    x2 = !x2;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (yTxtBounds2.Contains(e.CanvasLocation) | yBounds2.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle Y2");
                    y2 = !y2;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (zTxtBounds2.Contains(e.CanvasLocation) | zBounds2.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle Z2");
                    z2 = !z2;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (xxTxtBounds2.Contains(e.CanvasLocation) | xxBounds2.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle XX2");
                    xx2 = !xx2;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (yyTxtBounds2.Contains(e.CanvasLocation) | yyBounds2.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle YY2");
                    yy2 = !yy2;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
                if (zzTxtBounds2.Contains(e.CanvasLocation) | zzBounds2.Contains(e.CanvasLocation))
                {
                    comp.RecordUndoEvent("Toggle ZZ2");
                    zz2 = !zz2;
                    update(x1, y1, z1, xx1, yy1, zz1, x2, y2, z2, xx2, yy2, zz2);
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }