Exemple #1
0
        /// <summary>
        /// Dynamically compute the desired angle of an element along a segment of the route.
        /// </summary>
        /// <param name="elt">the <c>UIElement</c> being rotated</param>
        /// <param name="orient">the <see cref="LabelOrientation"/> declared for the element</param>
        /// <param name="angle">the angle of the segment of the route where the element is attached</param>
        /// <returns>the intended angle for the element</returns>
        /// <remarks>
        /// This method is not called unless the <see cref="GetOrientation"/> attached property value is
        /// not <see cref="LabelOrientation.None"/>.
        /// </remarks>
        protected virtual double ComputeAngle(UIElement elt, LabelOrientation orient, double angle)
        {
            double a;

            switch (orient)
            {
            default:
            case LabelOrientation.None: a = 0; break;

            case LabelOrientation.Along: a = angle; break;

            case LabelOrientation.Plus90: a = angle + 90; break;

            case LabelOrientation.Minus90: a = angle - 90; break;

            case LabelOrientation.Opposite: a = angle + 180; break;

            case LabelOrientation.Upright: // like Along
                a = Geo.NormalizeAngle(angle);
                if (a > 90 && a < 270)
                {
                    a -= 180;               // make sure never upside-down
                }
                break;

            case LabelOrientation.Plus90Upright: // like Plus90
                a = Geo.NormalizeAngle(angle + 90);
                if (a > 90 && a < 270)
                {
                    a -= 180;               // make sure never upside-down
                }
                break;

            case LabelOrientation.Minus90Upright: // like Minus90
                a = Geo.NormalizeAngle(angle - 90);
                if (a > 90 && a < 270)
                {
                    a -= 180;               // make sure never upside-down
                }
                break;

            case LabelOrientation.Upright45: // like Along
                a = Geo.NormalizeAngle(angle);
                if (a > 45 && a < 135)
                {
                    return(0);              // make sure never angled too much
                }
                if (a > 225 && a < 315)
                {
                    return(0);
                }
                if (a > 90 && a < 270)
                {
                    a -= 180;               // make sure never upside-down
                }
                break;
            }
            return(Geo.NormalizeAngle(a));
        }
Exemple #2
0
 public Barcode()
 {
     Symbology       = Symbologies.CODE128;
     IncludeText     = true;
     Alignment       = AlignmentPositions.CENTER;
     TextOrientation = LabelOrientation.BOTTOMCENTER;
     Text            = "000000000000";
 }
Exemple #3
0
 /// <summary>
 /// Creates a new instance of the AxisPresenter class.
 /// </summary>
 /// <param name="cpation">The caption of this axis.</param>
 /// <param name="labelOrientation">The orientation of labels for this axis.</param>
 /// <param name="isCategorical">Indicates if this axis consists of categorical values (instead of numerical ones).</param>
 /// <param name="tickintevall">The intervall between 0 and 1 between ticks of this axis. Unused for categorical values.</param>
 /// <param name="labelTickIntervall">The intervall where labels are shown a the axis ticks. 1 means every tick, 2 means every second tick, and so on.</param>
 /// <param name="decimalPlaces">The number of decimal places shown for the labels of this axis. Unused for categorical values.</param>
 public AxisPresenter(string cpation, LabelOrientation labelOrientation, bool isCategorical, float tickintevall, int labelTickIntervall, int decimalPlaces)
 {
     _caption            = Caption;
     _labelOrientation   = LabelOrientation;
     _isCategorical      = isCategorical;
     _tickIntervall      = tickintevall;
     _labelTickIntervall = labelTickIntervall;
     _decimalPlaces      = decimalPlaces;
 }
Exemple #4
0
        /// <summary>
        /// Adds a <c>bodyPr</c> node (Body Properties) to the node of type <c>txPr</c> (Text properties) specified. Not supported in <c>EPPlus</c> library.
        /// </summary>
        /// <param name="textPropertiesNode"><c>txPr</c> node (Text properties).</param>
        /// <param name="orientation">A <see cref="KnownLabelOrientation" /> value from model.</param>
        /// <param name="documentHelper">Target xml document helper.</param>
        /// <remarks>
        /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_bodyPr-2.html">http://www.schemacentral.com/sc/ooxml/e-a_bodyPr-2.html</a>
        /// </remarks>
        private static void AddBodyPropertiesNode(this XmlNode textPropertiesNode, LabelOrientation orientation, IXmlHelper documentHelper)
        {
            var rotAttr = documentHelper.CreateAttribute("rot");

            rotAttr.Value = orientation.ToAngle().ToString(CultureInfo.InvariantCulture);

            var vertAttr = documentHelper.CreateAttribute("vert");

            vertAttr.Value = orientation == LabelOrientation.Vertical ? "wordArtVert" : "horz";

            var bodyPropertiesNode = documentHelper.CreateOrDefaultAndAppendElementToNode(textPropertiesNode, "a", "bodyPr");

            bodyPropertiesNode.Attributes.Append(rotAttr);
            bodyPropertiesNode.Attributes.Append(vertAttr);
        }
Exemple #5
0
        public LabelBehaviour CreateLabel(string text, Vector3 pos, LabelOrientation labelOrientation,
                                          LabelBehaviour labelComponent = null)
        {
            if (labelComponent == null)
            {
                var labelGo = LabelSystemFactory.InstantiateLabel();
                labelComponent = labelGo.GetComponent <LabelBehaviour>();
            }

            labelComponent.Text = text;

            labelComponent.Orientation = labelOrientation;

            labelComponent.transform.SetParent(LabelRoot);
            labelComponent.transform.localPosition = pos;
            labelComponent.transform.localRotation = Quaternion.identity;

            LabelViews.Add(labelComponent);

            return(labelComponent);
        }
        /// <summary>
        /// Converter for <see cref="LabelOrientation"/> enumeration type to angle degree.
        /// </summary>
        /// <param name="orientation">Orientation style from model.</param>
        /// <returns>
        /// Orientation as angle in degrees.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException">The value specified is outside the range of valid values.</exception>
        public static float ToAngle(this LabelOrientation orientation)
        {
            SentinelHelper.IsEnumValid(orientation);

            switch (orientation)
            {
            case LabelOrientation.Upward:
                return(-5400000);

            case LabelOrientation.Downward:
                return(5400000);

            case LabelOrientation.Vertical:
                return(0);

            case LabelOrientation.Horizontal:
                return(0);

            default:
                return(0);
            }
        }
Exemple #7
0
        /// <summary>
        /// Arrange the child elements of this panel and of any label nodes.
        /// </summary>
        /// <param name="finalSize"></param>
        /// <returns></returns>
        /// <remarks>
        /// This positions each child element based on the attached property values of
        /// <see cref="GetIndex"/>, <see cref="GetFraction"/>, <see cref="GetAlignment"/>,
        /// and <see cref="GetOrientation"/>.
        /// This also positions any <see cref="Link.LabelNode"/>,
        /// using the <see cref="LinkPanel"/> attached properties on the node's <see cref="Part.VisualElement"/>,
        /// even though such a node is not within the visual tree of this panel.
        /// If the label node is a <see cref="Group"/>, this will instead position all of the
        /// group's <see cref="Group.MemberNodes"/>.
        /// </remarks>
        protected override Size ArrangeOverride(Size finalSize)
        {
            Part part = Diagram.FindAncestor <Part>(this);

            if (part == null)
            {
                return(new Size());
            }

            Link link = part as Link;

            if (link == null)
            {
                Adornment node = part as Adornment;
                if (node != null)
                {
                    link = node.AdornedPart as Link;
                }
            }

            if (link != null)
            {
                //Diagram.Debug(" LinkPanelA- " + (link.Data != null ? link.Data.ToString() : ""));

                Shape         stroke      = this.Path; // may be null
                Route         route       = link.Route;
                Rect          routeBounds = route.RouteBounds;
                IList <Point> pts         = (List <Point>)route.Points;
                int           nPoints     = pts.Count;
                int           childidx    = 0;
                if (stroke != null)
                {
                    if (childidx < childrenBounds.Count)
                    {
                        stroke.Arrange(childrenBounds[childidx++]);
                    }
                }
                foreach (UIElement e in this.Children)
                {
                    if (e == stroke)
                    {
                        continue;
                    }
                    if (childidx < childrenBounds.Count)
                    {
                        //if (e.GetType().Name.Contains("Expander")) Diagram.Debug(e.ToString() + " arranged: " + Diagram.Str(childrenBounds[childidx]));
                        e.Arrange(childrenBounds[childidx++]);
                    }
                }

                //Diagram.Debug(" LinkPanelA+ " + (link.Data != null ? link.Data.ToString() : ""));

                Node label = link.LabelNode;
                if (label != null)
                {
                    Group labelgroup = label as Group;
                    foreach (Node m in (labelgroup != null ? labelgroup.MemberNodes : new Node[1] {
                        label
                    }))
                    {
                        if (nPoints < 2)
                        {
                            continue;
                        }
                        UIElement e     = m.VisualElement;
                        Size      sz    = new Size(m.Bounds.Width, m.Bounds.Height);
                        int       index = GetIndex(e);
                        double    frac  = ComputeFraction(GetFraction(e));
                        Spot      align = GetAlignment(e);
                        if (align.IsNoSpot)
                        {
                            align = Spot.Center;
                        }
                        LabelOrientation orient = GetOrientation(e);
                        Point            nodept;                  // model coordinates
                        if (index < -nPoints || index >= nPoints) // beyond range? assume at the MidPoint, with the MidAngle
                        {
                            Point  mid      = route.MidPoint;
                            double segangle = route.MidAngle;
                            // maybe rotate the label
                            double labelangle = 0;
                            if (orient != LabelOrientation.None)
                            {
                                labelangle = ComputeAngle(e, orient, segangle);
                                m.SetAngle(e, labelangle, align);
                            }
                            // maybe the alignment point is away from the line
                            nodept = mid; // model coordinates
                            Point offset = ComputeOffset(e, index, segangle, sz, labelangle);
                            nodept = Geo.Add(nodept, offset);
                        }
                        else // on a particular segment, given by Index, at a point given by Fraction
                        // negative index means start from last point, going "backwards"
                        {
                            Point a, b;
                            if (index >= 0)
                            {
                                a = pts[index];
                                b = (index < nPoints - 1) ? pts[index + 1] : a;
                            }
                            else
                            {
                                int i = nPoints + index; // remember that index is negative here
                                a = pts[i];
                                b = (i > 0) ? pts[i - 1] : a;
                            }
                            // compute the fractional point along the line, in model coordinates
                            nodept = new Point(a.X + (b.X - a.X) * frac, a.Y + (b.Y - a.Y) * frac);
                            double segangle = (index >= 0 ? Geo.GetAngle(a, b) : Geo.GetAngle(b, a));
                            // maybe rotate the label
                            double labelangle = 0;
                            if (orient != LabelOrientation.None)
                            {
                                labelangle = ComputeAngle(e, orient, segangle);
                                m.SetAngle(e, labelangle, align);
                            }
                            // maybe the alignment point is away from the line
                            Point offset = ComputeOffset(e, index, segangle, sz, labelangle);
                            nodept = Geo.Add(nodept, offset);
                        }
                        Rect hb = align.RectForPoint(nodept, sz);
                        m.Position = new Point(hb.X, hb.Y);
                    }
                }
            }

            return(finalSize);
        }
Exemple #8
0
        /// <summary>
        /// Determine the size of the union of the bounds of the positioned and rotated child elements.
        /// </summary>
        /// <param name="availableSize"></param>
        /// <returns></returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            Part part = Diagram.FindAncestor <Part>(this);

            if (part == null)
            {
                return(new Size());
            }

            if (!part.IsMeasuringArranging)
            {
                return(new Size());
            }

            Link link = part as Link;

            if (link == null)
            {
                Adornment ad = part as Adornment;
                if (ad != null)
                {
                    link = ad.AdornedPart as Link;
                }
                if (link == null)
                {
                    return(new Size());
                }
            }

            //Diagram.Debug(" LinkPanelM- " + (link.Data != null ? link.Data.ToString() : ""));

            Shape stroke = this.Path; // may be null

            link.Path = stroke;       // the Link caches what the Path really is

            Route route       = link.Route;
            Rect  routeBounds = route.RouteBounds; // in model coordinates
            Rect  linkBounds  = routeBounds;       // includes all labels

            childrenBounds = new List <Rect>();    // in local coordinates
            if (stroke != null)
            {
                stroke.Measure(Geo.Unlimited);
                Size sz = stroke.DesiredSize;
                linkBounds.Width  = Math.Max(linkBounds.Width, sz.Width);
                linkBounds.Height = Math.Max(linkBounds.Height, sz.Height);
                childrenBounds.Add(new Rect(0, 0, linkBounds.Width, linkBounds.Height));
            }

            IList <Point> pts     = (List <Point>)route.Points;
            int           nPoints = pts.Count;

            foreach (UIElement e in this.Children)
            {
                if (e == stroke)
                {
                    continue;       // already measured the stroke, above
                }
                e.Measure(Geo.Unlimited);
                //if (e.GetType().Name.Contains("Expander")) Diagram.Debug(e.ToString() + " measured: " + Diagram.Str(e.DesiredSize));
                if (nPoints < 2)
                {
                    continue;
                }
                Size   sz    = e.DesiredSize;
                int    index = GetIndex(e);
                double frac  = ComputeFraction(GetFraction(e));
                Spot   align = GetAlignment(e);
                if (align.IsNoSpot)
                {
                    align = Spot.Center;
                }
                LabelOrientation orient = GetOrientation(e);
                Point            eltpt;                   // local coordinates
                if (index < -nPoints || index >= nPoints) // beyond range? assume at the MidPoint, with the MidAngle
                {
                    Point mid = route.MidPoint;
                    if (this.Implementation == LinkPanelImplementation.Stretch)
                    {
                        Point p0 = pts[0];
                        Point pn = pts[nPoints - 1];
                        sz.Width = Math.Sqrt(Geo.DistanceSquared(pn, p0));
                    }
                    double segangle = route.MidAngle;
                    // maybe rotate the label
                    double labelangle = 0;
                    if (orient != LabelOrientation.None)
                    {
                        labelangle = ComputeAngle(e, orient, segangle);
                        link.SetAngle(e, labelangle, align);
                    }
                    // maybe the alignment point is away from the line
                    eltpt = new Point(mid.X - routeBounds.X, mid.Y - routeBounds.Y); // local coordinates
                    Point offset = ComputeOffset(e, index, segangle, sz, labelangle);
                    eltpt = Geo.Add(eltpt, offset);
                }
                else // on a particular segment, given by Index, at a point given by Fraction
                // negative index means start from last point, going "backwards"
                {
                    Point a, b;
                    if (index >= 0)
                    {
                        a = pts[index];
                        b = (index < nPoints - 1) ? pts[index + 1] : a;
                    }
                    else
                    {
                        int i = nPoints + index; // remember that index is negative here
                        a = pts[i];
                        b = (i > 0) ? pts[i - 1] : a;
                    }
                    // compute the fractional point along the line, in local coordinates
                    eltpt = new Point(a.X + (b.X - a.X) * frac - routeBounds.X, a.Y + (b.Y - a.Y) * frac - routeBounds.Y);
                    double segangle = (index >= 0 ? Geo.GetAngle(a, b) : Geo.GetAngle(b, a));
                    // maybe rotate the label
                    double labelangle = 0;
                    if (orient != LabelOrientation.None)
                    {
                        labelangle = ComputeAngle(e, orient, segangle);
                        link.SetAngle(e, labelangle, align);
                    }
                    // maybe the alignment point is away from the line
                    Point offset = ComputeOffset(e, index, segangle, sz, labelangle);
                    eltpt = Geo.Add(eltpt, offset);
                }
                Rect cb = align.RectForPoint(eltpt, sz);
                childrenBounds.Add(cb);                                                                      // local coordinates
                linkBounds.Union(new Rect(cb.X + routeBounds.X, cb.Y + routeBounds.Y, cb.Width, cb.Height)); // model coordinates
            }

            // if this panel is the "whole" link, update the link's Bounds
            if (link.VisualElement == this)
            {
                //Diagram.Debug(" LinkPanelM+ " + (link.Data != null ? link.Data.ToString() : "") + " " + Diagram.Str(routeBounds) + Diagram.Str(linkBounds));
                link.Bounds = new Rect(routeBounds.X, routeBounds.Y, linkBounds.Width, linkBounds.Height);
            }

            return(new Size(routeBounds.Width, routeBounds.Height));
        }
Exemple #9
0
 /// <summary>
 /// Sets an element's intended rotation policy.
 /// </summary>
 /// <param name="d">a child element of a <see cref="LinkPanel"/></param>
 /// <param name="v"></param>
 public static void SetOrientation(DependencyObject d, LabelOrientation v)
 {
     d.SetValue(OrientationProperty, v);
 }
Exemple #10
0
        /// <summary>
        /// Save Features.Charts settings to the settings file
        /// </summary>
        /// <param name="generalNode">XML-node for the Features.Charts settings</param>
        public void Save(XmlNode chartsNode)
        {
            string  xpath;
            XmlNode node;

            xpath = "./height";
            SettingsHelper.SetSettingValue(xpath, chartsNode, Height.ToString());

            xpath = "./maxHeight";
            SettingsHelper.SetSettingValue(xpath, chartsNode, MaxHeight.ToString());

            xpath = "./width";
            SettingsHelper.SetSettingValue(xpath, chartsNode, Width.ToString());

            xpath = "./maxWidth";
            SettingsHelper.SetSettingValue(xpath, chartsNode, MaxWidth.ToString());

            xpath = "./colors";
            SettingsHelper.SetSettingValue(xpath, chartsNode, "color", Colors);

            xpath = "./lineThickness";
            SettingsHelper.SetSettingValue(xpath, chartsNode, LineThickness.ToString());

            xpath = "./maxLineThickness";
            SettingsHelper.SetSettingValue(xpath, chartsNode, MaxLineThickness.ToString());

            xpath = "./logotype";
            SettingsHelper.SetSettingValue(xpath, chartsNode, Logotype);

            xpath = "./maxValues";
            SettingsHelper.SetSettingValue(xpath, chartsNode, MaxValues.ToString());

            xpath = "./timeSortOrder";
            SettingsHelper.SetSettingValue(xpath, chartsNode, TimeSortOrder.ToString());

            xpath = "./labelOrientation";
            SettingsHelper.SetSettingValue(xpath, chartsNode, LabelOrientation.ToString());

            xpath = "./font";
            node  = SettingsHelper.GetNode(chartsNode, xpath);
            _fontSettings.Save(node);

            xpath = "./legend";
            node  = SettingsHelper.GetNode(chartsNode, xpath);
            _legendSettings.Save(node);

            xpath = "./guidelines";
            node  = SettingsHelper.GetNode(chartsNode, xpath);
            _guidelinesSettings.Save(node);

            xpath = "./showSourse";
            SettingsHelper.SetSettingValue(xpath, chartsNode, ShowSource.ToString());

            xpath = "./showLogo";
            SettingsHelper.SetSettingValue(xpath, chartsNode, ShowLogo.ToString());

            xpath = "./lineThicknessPhrame";
            SettingsHelper.SetSettingValue(xpath, chartsNode, LineThicknessPhrame.ToString());

            xpath = "./lineColorPhrame";
            SettingsHelper.SetSettingValue(xpath, chartsNode, LineColorPhrame.ToString());

            xpath = "./backgroundColorGraphs";
            SettingsHelper.SetSettingValue(xpath, chartsNode, BackgroundColorGraphs.ToString());
        }
Exemple #11
0
 /// <summary>
 /// Dynamically compute the desired angle of an element along a segment of the route.
 /// </summary>
 /// <param name="elt">the <c>UIElement</c> being rotated</param>
 /// <param name="orient">the <see cref="LabelOrientation"/> declared for the element</param>
 /// <param name="angle">the angle of the segment of the route where the element is attached</param>
 /// <returns>the intended angle for the element</returns>
 /// <remarks>
 /// This method is not called unless the <see cref="GetOrientation"/> attached property value is
 /// not <see cref="LabelOrientation.None"/>.
 /// </remarks>
 protected virtual double ComputeAngle(UIElement elt, LabelOrientation orient, double angle) {
   double a;
   switch (orient) {
     default:
     case LabelOrientation.None: a = 0; break;
     case LabelOrientation.Along: a = angle; break;
     case LabelOrientation.Plus90: a = angle + 90; break;
     case LabelOrientation.Minus90: a = angle - 90; break;
     case LabelOrientation.Opposite: a = angle + 180; break;
     case LabelOrientation.Upright:  // like Along
       a = Geo.NormalizeAngle(angle);
       if (a > 90 && a < 270) a -= 180;  // make sure never upside-down
       break;
     case LabelOrientation.Plus90Upright:  // like Plus90
       a = Geo.NormalizeAngle(angle + 90);
       if (a > 90 && a < 270) a -= 180;  // make sure never upside-down
       break;
     case LabelOrientation.Minus90Upright:  // like Minus90
       a = Geo.NormalizeAngle(angle - 90);
       if (a > 90 && a < 270) a -= 180;  // make sure never upside-down
       break;
     case LabelOrientation.Upright45:  // like Along
       a = Geo.NormalizeAngle(angle);
       if (a > 45 && a < 135) return 0;  // make sure never angled too much
       if (a > 225 && a < 315) return 0;
       if (a > 90 && a < 270) a -= 180;  // make sure never upside-down
       break;
   }
   return Geo.NormalizeAngle(a);
 }
Exemple #12
0
 /// <summary>
 /// Sets an element's intended rotation policy.
 /// </summary>
 /// <param name="d">a child element of a <see cref="LinkPanel"/></param>
 /// <param name="v"></param>
 public static void SetOrientation(DependencyObject d, LabelOrientation v) { d.SetValue(OrientationProperty, v); }
Exemple #13
0
 private float CalcLabelHeight(UnitSize unitSize, float margin, LabelOrientation orientation)
 {
     return((orientation == LabelOrientation.Vertical ? unitSize.Height : unitSize.Width) / 2 - margin);
 }