Example #1
0
        private Pen GenerateWirePen(PointF a, PointF b, bool asel, bool bsel, GH_WireType wiretype, Color color, GH_Canvas canvas)
        {
            switch (wiretype)
            {
            case GH_WireType.generic:
                return(GenerateWirePen_Static_Generic(a, b, asel, bsel, Empty: false, color));

            case GH_WireType.@null:
                return(GenerateWirePen_Static_Generic(a, b, asel, bsel, Empty: true, color));

            case GH_WireType.faint:
                return(GenerateWirePen_Static_Faint(color));

            case GH_WireType.item:
                return(GenerateWirePen_Static_Item(a, b, asel, bsel, Empty: false, color));

            case GH_WireType.list:
                return(GenerateWirePen_Static_List(a, b, asel, bsel, Empty: false, color, canvas));

            case GH_WireType.tree:
                return(GenerateWirePen_Static_Tree(a, b, asel, bsel, Empty: false, color, canvas));

            case GH_WireType.dynamic:
                return(GenerateWirePen_Dynamic(0, color));

            case GH_WireType.dynamicAlternative1:
                return(GenerateWirePen_Dynamic(1, color));

            case GH_WireType.wireless:
                return(GenerateWirePen_WireLess(a, b, asel, bsel, empty: false, color));

            default:
                return(null);
            }
        }
Example #2
0
        public void DrawConnection(PointF pointA, PointF pointB, GH_WireDirection directionA, GH_WireDirection directionB, bool selectedA, bool selectedB, GH_WireType type, Color colorinput, GH_Canvas canvas, Graphics graphics)
        {
            if (ConnectionVisible(pointA, pointB, canvas))
            {
                Color color = colorinput;
                if (selectedA || selectedB)
                {
                    color.SolidenColor(Owner.SelectWireSolid);
                }

                GraphicsPath graphicsPath = new GraphicsPath();
                switch (Owner.WireType)
                {
                case 0:
                    graphicsPath = GH_Painter.ConnectionPath(pointA, pointB, directionA, directionB);
                    break;

                case 1:
                    float moveMent = (pointA.X - pointB.X) * (float)Owner.PolywireParam;
                    moveMent = Math.Max(moveMent, 20);
                    PointF C = new PointF(pointA.X - moveMent, pointA.Y);
                    PointF D = new PointF(pointB.X + moveMent, pointB.Y);
                    graphicsPath.AddLine(pointA, C);
                    graphicsPath.AddLine(C, D);
                    graphicsPath.AddLine(D, pointB);
                    graphicsPath.Reverse();
                    break;

                case 2:
                    graphicsPath.AddLine(pointA, pointB);
                    graphicsPath.Reverse();
                    break;

                default:
                    graphicsPath = GH_Painter.ConnectionPath(pointA, pointB, directionA, directionB);
                    break;
                }

                if (graphicsPath == null)
                {
                    graphicsPath = new GraphicsPath();
                    graphicsPath.AddLine(pointA, pointB);
                }

                Pen pen = GenerateWirePen(pointA, pointB, selectedA, selectedB, type, color, canvas);

                if (selectedA || selectedB)
                {
                    pen.Width += (float)Owner.SelectWireThickness;
                }

                if (pen == null)
                {
                    pen = new Pen(Color.Black);
                }
                try
                {
                    graphics.DrawPath(pen, graphicsPath);
                }
                catch (Exception ex)
                {
                    ProjectData.SetProjectError(ex);
                    Exception ex2 = ex;
                    Tracing.Assert(new Guid("{72303320-11AD-484e-BE32-8BDAA7377BE0}"), "Connection could not be drawn:" + Environment.NewLine + ex2.Message + Environment.NewLine + Environment.NewLine + $"A: ({pointA.X}, {pointA.Y})" + Environment.NewLine + $"B: ({pointB.X}, {pointB.Y})" + Environment.NewLine + $"A_Dir: {directionA}" + Environment.NewLine + $"B_Dir: {directionB}" + Environment.NewLine + $"A_Selected: {selectedA}" + Environment.NewLine + $"B_Selected: {selectedB}" + Environment.NewLine + $"Type: {type}");
                    ProjectData.ClearProjectError();
                }
                graphicsPath.Dispose();
                pen.Dispose();
            }
        }
Example #3
0
        protected void NewRenderIncomingWires(IGH_Param param, GH_Canvas canvas, Graphics graphics)
        {
            IEnumerable <IGH_Param> sources = param.Sources;
            GH_ParamWireDisplay     style   = param.WireDisplay;

            if (!param.Attributes.HasInputGrip)
            {
                return;
            }
            bool flag = false;

            if (param.Attributes.Selected)
            {
                flag = true;
            }
            else if (style != 0)
            {
                foreach (IGH_Param source in sources)
                {
                    if (source.Attributes.GetTopLevel.Selected)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            else
            {
                flag = true;
            }

            int count = sources.Count();

            if (count != ParamProxies.Count)
            {
                UpdateParamProxy();
            }
            if (flag)
            {
                if (CentralSettings.CanvasFancyWires)
                {
                    for (int i = 0; i < count; i++)
                    {
                        GH_WireType type = GH_Painter.DetermineWireType(sources.ElementAt(i).VolatileData);
                        DrawConnection(param.Attributes.InputGrip, sources.ElementAt(i).Attributes.OutputGrip, GH_WireDirection.left, GH_WireDirection.right, param.Attributes.Selected, sources.ElementAt(i).Attributes.Selected, type, ParamProxies[i].ShowColor, canvas, graphics);
                    }
                    return;
                }
                for (int i = 0; i < count; i++)
                {
                    DrawConnection(param.Attributes.InputGrip, sources.ElementAt(i).Attributes.OutputGrip, GH_WireDirection.left, GH_WireDirection.right, param.Attributes.Selected, sources.ElementAt(i).Attributes.Selected, GH_WireType.generic, ParamProxies[i].ShowColor, canvas, graphics);
                }
                return;
            }
            switch (style)
            {
            case GH_ParamWireDisplay.faint:
                for (int i = 0; i < count; i++)
                {
                    DrawConnection(param.Attributes.InputGrip, sources.ElementAt(i).Attributes.OutputGrip, GH_WireDirection.left, GH_WireDirection.right, param.Attributes.Selected, sources.ElementAt(i).Attributes.Selected, GH_WireType.faint, ParamProxies[i].ShowColor, canvas, graphics);
                }
                break;

            case GH_ParamWireDisplay.hidden:
            {
                break;
            }
            }
        }