Beispiel #1
0
        public ArcIconShape(graphElement a, ArcShape arcShape, GraphGUI gd)
            : base(a, gd, arcShape.Tag, maxOpacity, radiusMultiplier, radiusAddition, arcShape.Controller)
        {
            this.arcShape      = arcShape;
            this.arcShape.icon = this;

            var dt      = (DataTemplate)Application.Current.Resources["NodeIconShape"];
            var penData = (Shape)dt.LoadContent();

            defaultBrush     = penData.Stroke;
            defaultThickness = penData.StrokeThickness;
            defaultDashStyle = new DashStyle(penData.StrokeDashArray, 0);

            dt      = (DataTemplate)Application.Current.Resources["SelectedArcPen"];
            penData = (Shape)dt.LoadContent();

            selectedBrush           = penData.Stroke;
            selectedBufferThickness = penData.StrokeThickness;
            selectedDashStyle       = new DashStyle(penData.StrokeDashArray, 0);


            /* bind the thickness property s.t. the iconArc shows up thick enough. */
            var binding = new Binding
            {
                Source = arcShape,
                Path   = new PropertyPath(Shape.StrokeThicknessProperty),
                Mode   = BindingMode.OneWay
            };

            SetBinding(StrokeThicknessProperty, binding);
        }
Beispiel #2
0
        public ShapeBank(GraphGUI gd)
        {
            this.gd = gd;
            var binding = new Binding
            {
                Source = gd,
                Mode   = BindingMode.OneWay,
                Path   = new PropertyPath(OpacityProperty)
            };

            BindingOperations.SetBinding(this, OpacityProperty, binding);
        }
        public HyperArcIconShape(graphElement h, HyperArcShape hyperArcShape, GraphGUI gd)
            : base(h, gd, hyperArcShape.Tag, maxOpacity, radiusMultiplier, radiusAddition, hyperArcShape.Controller)
        {
            this.hyperArcShape      = hyperArcShape;
            this.hyperArcShape.icon = this;
            this.Center             = hyperArcShape.Center;

            var dt            = (DataTemplate)Application.Current.Resources["HyperArcIconShape"];
            var templateShape = (Shape)dt.LoadContent();

            defaultBrush     = templateShape.Stroke;
            defaultThickness = templateShape.StrokeThickness;
            defaultDashStyle = new DashStyle(templateShape.StrokeDashArray, 0.0);

            templateGeometry = (PathGeometry)((Path)templateShape).Data;
            var iconPts = new List <Point>(((PolyLineSegment)templateGeometry.Figures[0].Segments[0]).Points);

            iconPts.Insert(0, templateGeometry.Figures[0].StartPoint);
            var midpoint = new Point(iconPts.Average(n => n.X), iconPts.Average(n => n.Y));

            Radius         = defaultRadius = (from p in iconPts select(new Point(p.X, p.Y) - midpoint).Length).Max();
            angleBtwPoints = 2 * Math.PI / iconPts.Count;

            dt = (DataTemplate)Application.Current.Resources["SelectedArcPen"];
            var penData = (Shape)dt.LoadContent();

            selectedBrush           = penData.Stroke;
            selectedBufferThickness = penData.StrokeThickness;
            selectedDashStyle       = new DashStyle(penData.StrokeDashArray, 0);
            selectedEffect          = penData.Effect;

            var binding = new Binding
            {
                Source    = this,
                Converter = new SelectedHyperArcEffectConverter(selectedEffect),
                Mode      = BindingMode.OneWay,
                Path      = new PropertyPath(SelectedProperty)
            };

            hyperArcShape.SetBinding(EffectProperty, binding);

            binding = new Binding
            {
                Source = hyperArcShape,
                Mode   = BindingMode.OneWay,
                Path   = new PropertyPath(HyperArcShape.NodeCentersProperty)
            };
            SetBinding(NodeCentersProperty, binding);
        }
        public NullNodeIconShape(Point pt, graphElement e, bool attachedToHead, GraphGUI gd)
            : base(e, gd, "", maxOpacity, radiusMultiplier, radiusAddition, null)
        {
            Center         = pt;
            AttachedToHead = attachedToHead;

            var dt           = (DataTemplate)Application.Current.Resources["NodeIconShapeNull"];
            var nullNodeIcon = (Shape)dt.LoadContent();

            Radius           = defaultRadius = nullNodeIcon.Width / 2;
            defaultBrush     = nullNodeIcon.Stroke;
            defaultDashStyle = new DashStyle(nullNodeIcon.StrokeDashArray, 0.0);
            defaultThickness = nullNodeIcon.StrokeThickness;
            Width            = Height = 0.0;
        }
Beispiel #5
0
 public NodeIconBank(GraphGUI gd) : base(gd)
 {
 }
Beispiel #6
0
 public HyperArcIconBank(GraphGUI gd) : base(gd)
 {
 }
Beispiel #7
0
 public ArcIconBank(GraphGUI gd) : base(gd)
 {
 }
Beispiel #8
0
 public SelectionClass(GraphGUI gd)
     : this()
 {
     this.gd = gd;
 }
Beispiel #9
0
        protected IconShape(graphElement e, GraphGUI gd, object textDisplayData,
                            double maxOpacity, double radiusMultiplier, double radiusAddition, object arcController)
        {
            GraphElement = e;
            if (textDisplayData == null)
            {
                textDisplayData = "";
            }
            else
            {
                textDisplayData = textDisplayData.ToString().Split(new[] { ':' })[0];
            }
            var    tDDataList = StringCollectionConverter.Convert(textDisplayData.ToString());
            double result;

            if ((tDDataList.Count > 1) && (double.TryParse(tDDataList[1], out result)))
            {
                DisplayTextDistance = result;
            }
            else
            {
                DisplayTextDistance = double.NaN;
            }
            if ((tDDataList.Count > 2) && (double.TryParse(tDDataList[2], out result)))
            {
                DisplayTextPosition = result;
            }
            else
            {
                DisplayTextPosition = double.NaN;
            }
            if ((tDDataList.Count > 3) && (double.TryParse(tDDataList[3], out result)))
            {
                FontSize = result;
            }
            else
            {
                FontSize = double.NaN;
            }

            var binding = new Binding
            {
                Source = gd,
                Mode   = BindingMode.OneWay,
                Path   = new PropertyPath(GraphGUI.ScaleFactorProperty)
            };

            SetBinding(ScaleFactorProperty, binding);
            binding = new Binding
            {
                Converter = new IconOpacityConverter(this, maxOpacity, radiusMultiplier, radiusAddition),
                Source    = gd,
                Mode      = BindingMode.OneWay,
                Path      = new PropertyPath(GraphGUI.MouseLocationProperty)
            };
            SetBinding(StrokeOpacityProperty, binding);

            /* whether or not to show the text depends on various parameters */
            var multiBinding = new MultiBinding
            {
                Converter          = new DisplayTextConverter(),
                Mode               = BindingMode.OneWay,
                ConverterParameter = GraphElement
            };

            {
                binding = new Binding {
                    Source = this, Path = new PropertyPath(ShowNameProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = this, Path = new PropertyPath(ShowLabelsProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = this, Path = new PropertyPath(FontSizeProperty)
                };
                multiBinding.Bindings.Add(binding);
            }
            SetBinding(DisplayTextProperty, multiBinding);

            /* where is text to be shown? */
            multiBinding = new MultiBinding
            {
                Converter          = new PositionTextConverter(),
                ConverterParameter = arcController,
                Mode = BindingMode.OneWay
            };
            {
                binding = new Binding {
                    Source = this, Path = new PropertyPath(DisplayTextDistanceProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = this, Path = new PropertyPath(DisplayTextPositionProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = this, Path = new PropertyPath(DisplayTextProperty)
                };
                multiBinding.Bindings.Add(binding);
            }
            SetBinding(TextPointProperty, multiBinding);
        }
Beispiel #10
0
 protected IconBank(GraphGUI gd)
 {
     this.gd = gd;
 }
Beispiel #11
0
        public NodeIconShape(graphElement n, Shape displayShape, GraphGUI gd)
            : base(n, gd, displayShape.Tag, maxOpacity, radiusMultiplier, radiusAddition, null)
        {
            nodeShape = displayShape;
            var dt       = (DataTemplate)Application.Current.Resources["NodeIconShape"];
            var nodeIcon = (Shape)dt.LoadContent();

            Radius           = defaultRadius = nodeIcon.Width / 2;
            defaultBrush     = nodeIcon.Stroke;
            defaultThickness = nodeIcon.StrokeThickness;

            var multiBinding = new MultiBinding
            {
                Converter          = new NodeIconTransformConverter(),
                ConverterParameter = new[] { defaultRadius + defaultThickness / 2, ScaleReduction },
                Mode = BindingMode.OneWay
            };

            {
                var binding = new Binding {
                    Source = nodeShape, Path = new PropertyPath(RenderTransformProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = nodeShape, Path = new PropertyPath(WidthProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = nodeShape, Path = new PropertyPath(HeightProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = gd, Path = new PropertyPath(GraphGUI.ScaleFactorProperty)
                };
                multiBinding.Bindings.Add(binding);
            }
            SetBinding(RenderTransformProperty, multiBinding);

            multiBinding = new MultiBinding {
                Converter = new NodeIconCenterConverter()
            };
            {
                var binding = new Binding {
                    Source = nodeShape, Path = new PropertyPath(RenderTransformProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = nodeShape, Path = new PropertyPath(WidthProperty)
                };
                multiBinding.Bindings.Add(binding);

                binding = new Binding {
                    Source = nodeShape, Path = new PropertyPath(HeightProperty)
                };
                multiBinding.Bindings.Add(binding);
            }
            SetBinding(CenterProperty, multiBinding);
        }