Пример #1
0
        protected override void OnDraw(GraphicsCache graphics, System.Drawing.RectangleF area)
        {
            base.OnDraw(graphics, area);

            ButtonState state;
            if (Style == ButtonStyle.Disabled)
                state = ButtonState.Inactive;
            else if (Style == ButtonStyle.Pressed)
                state = ButtonState.Pushed;
            else if (Style == ButtonStyle.Hot)
                state = ButtonState.Normal;
            else
                state = ButtonState.Normal;

            ControlPaint.DrawButton(graphics.Graphics, Rectangle.Round(area), state);

            if (Style == ButtonStyle.NormalDefault)
            {
                graphics.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(area));
            }

            if (Style == ButtonStyle.Focus)
            {
                using (MeasureHelper measure = new MeasureHelper(graphics))
                {
                    ControlPaint.DrawFocusRectangle(graphics.Graphics, Rectangle.Round(GetBackgroundContentRectangle(measure, area)));
                }
            }
        }
Пример #2
0
 protected override System.Drawing.SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize)
 {
     if (Value != null)
         return Value.Size;
     else
         return SizeF.Empty;
 }
Пример #3
0
        public override RectangleF GetBackgroundContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
        {
            backGroundArea = base.GetBackgroundContentRectangle(measure, backGroundArea);

            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
                return GetRenderer(GetBackgroundElement()).GetBackgroundContentRectangle(measure.Graphics, Rectangle.Round(backGroundArea));
            else
                return mStandardHeader.GetBackgroundContentRectangle(measure, backGroundArea);
        }
Пример #4
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     if (SortStyle != HeaderSortStyle.None && Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetSortElement()))
     {
         VisualStyleRenderer renderer = GetRenderer(GetSortElement());
         return renderer.GetPartSize(measure.Graphics, ThemeSizeType.Draw);
     }
     else
         return base.OnMeasureContent(measure, maxSize);
 }
Пример #5
0
        public override SizeF GetBackgroundExtent(MeasureHelper measure, SizeF contentSize)
        {
            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                Rectangle content = new Rectangle(new Point(0, 0), Size.Ceiling(contentSize));
                contentSize = GetRenderer(GetBackgroundElement()).GetBackgroundExtent(measure.Graphics, content).Size;
            }
            else
            {
                contentSize = mStandardHeader.GetBackgroundExtent(measure, contentSize);
            }

            return(base.GetBackgroundExtent(measure, contentSize));
        }
Пример #6
0
        public override RectangleF GetBackgroundContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
        {
            //First calls the base class for standard calculation
            backGroundArea = base.GetBackgroundContentRectangle(measure, backGroundArea);

            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                return(GetRenderer(GetBackgroundElement()).GetBackgroundContentRectangle(measure.Graphics, Rectangle.Round(backGroundArea)));
            }
            else
            {
                return(mStandardHeader.GetBackgroundContentRectangle(measure, backGroundArea));
            }
        }
Пример #7
0
        /// <summary>
        /// Gets the area where the visual element will be drawed.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="area"></param>
        /// <returns></returns>
        public RectangleF GetDrawingArea(MeasureHelper measure, System.Drawing.RectangleF area)
        {
            RectangleF destContentArea = area;

            if (AnchorArea != null && !AnchorArea.IsEmpty)
            {
                //[email protected]: Measure method accepts max size,
                //max size is important in the calculation of drawing rectangle.
                //Maximum size would be the area\destContentArea
                SizeF measureSize = Measure(measure, SizeF.Empty, area.Size);
                destContentArea = AnchorArea.CalculateArea(area, measureSize, AnchorArea);
            }

            return(destContentArea);
        }
Пример #8
0
        protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
        {
            SizeF clienSize = new SizeF(0, 0);

            //In this case the elements are drawed one over the another so to measure I must simply take the greatest
            if (ElementsDrawMode == ElementsDrawMode.Covering)
            {
                foreach (IVisualElement element in GetElements())
                {
                    SizeF elementSize = element.Measure(measure, Size.Empty, maxSize);

                    //[email protected] : using the wrapper for CalculateSizeWithAnchor
                    //instead of directly the method, so that for MultiImagesViews
                    elementSize = CalculateContentSizeWithAnchor(elementSize, element.AnchorArea, maxSize);

                    if (elementSize.Width > clienSize.Width)
                    {
                        clienSize.Width = elementSize.Width;
                    }
                    if (elementSize.Height > clienSize.Height)
                    {
                        clienSize.Height = elementSize.Height;
                    }
                }
            }
            //In this case the elements are drawed considering an alignment, so to measure I must consider the anchor area of the element and add the size to the if the alignment is set. This code reflect the drawing code
            else if (ElementsDrawMode == ElementsDrawMode.Align)
            {
                AnchorArea previousAnchor = null;
                foreach (IVisualElement element in GetElements())
                {
                    SizeF elementSize = element.Measure(measure, Size.Empty, maxSize);

                    elementSize = CalculateContentSizeWithAnchor(elementSize, element.AnchorArea, maxSize);

                    clienSize = CalculateSizeWithContent(clienSize, previousAnchor, elementSize);

                    previousAnchor = element.AnchorArea;
                }
            }
            else
            {
                throw new ApplicationException("DrawMode not supported");
            }

            return(GetExtent(measure, clienSize));
        }
Пример #9
0
        protected override void OnDraw(GraphicsCache graphics, RectangleF area)
        {
            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                GetRenderer(GetBackgroundElement()).DrawBackground(graphics.Graphics, Rectangle.Round(area));

                if (Style == ButtonStyle.Focus)
                {
                    using (MeasureHelper measure = new MeasureHelper(graphics))
                    {
                        ControlPaint.DrawFocusRectangle(graphics.Graphics, Rectangle.Round(area));
                    }
                }
            }
            else
                mStandardButton.Draw(graphics, area);
        }
Пример #10
0
        public override System.Drawing.RectangleF GetBackgroundContentRectangle(MeasureHelper measure, System.Drawing.RectangleF backGroundArea)
        {
            backGroundArea = base.GetBackgroundContentRectangle(measure, backGroundArea);

            if (backGroundArea.Width > 4)
            {
                backGroundArea.X += 2;
                backGroundArea.Width -= 4;
            }

            if (backGroundArea.Height > 4)
            {
                backGroundArea.Y += 2;
                backGroundArea.Height -= 4;
            }

            return backGroundArea;
        }
Пример #11
0
        public override System.Drawing.RectangleF GetBackgroundContentRectangle(MeasureHelper measure, System.Drawing.RectangleF backGroundArea)
        {
            backGroundArea = base.GetBackgroundContentRectangle(measure, backGroundArea);

            if (backGroundArea.Width > 4)
            {
                backGroundArea.X     += 2;
                backGroundArea.Width -= 4;
            }

            if (backGroundArea.Height > 4)
            {
                backGroundArea.Y      += 2;
                backGroundArea.Height -= 4;
            }

            return(backGroundArea);
        }
Пример #12
0
        protected override void OnDraw(GraphicsCache graphics, RectangleF area)
        {
            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                GetRenderer(GetBackgroundElement()).DrawBackground(graphics.Graphics, Rectangle.Round(area));

                if (Style == ButtonStyle.Focus)
                {
                    using (MeasureHelper measure = new MeasureHelper(graphics)) {
                        ControlPaint.DrawFocusRectangle(graphics.Graphics, Rectangle.Round(area));
                    }
                }
            }
            else
            {
                mStandardButton.Draw(graphics, area);
            }
        }
Пример #13
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
     {
         var size = GetRenderer(GetBackgroundElement()).GetPartSize(measure.Graphics, ThemeSizeType.True);
         // in Win-7 machines size is returned as 7
         // Increase it to 16, so it matches the standard drop-down width
         if (size.Width < 16)
         {
             size.Width = 16;
         }
         return(size);
     }
     else
     {
         return(mStandardButton.Measure(measure, Size.Empty, maxSize));
     }
 }
Пример #14
0
        /// <summary>
        /// Получить архивные данные кадра
        /// </summary>
        /// <param name="dateStart"></param>
        /// <param name="dateFinish"></param>
        /// <param name="kadr"></param>
        /// <param name="dataRegistry"></param>
        /// <returns></returns>
        private List <ParamData> GetDataArc(DateTime dateStart, DateTime dateFinish, RetroKadr kadr, DataRegistry dataRegistry)
        {
            var result = new List <ParamData>();

            lock (dataRegistry.Locker)
            {
                using (dataRegistry.ConnHolder)
                {
                    foreach (IArchive arc in kadr.Parameters)
                    {
                        result.Add(new ParamData(
                                       MeasureHelper.GetByTablePeriod(dataRegistry, arc.Retfname, new RsduTime(dateStart), new RsduTime(dateFinish)),
                                       arc));
                    }
                }
            }

            return(result);
        }
Пример #15
0
        /// <summary>
        /// Calculate the total area used by the backgound and the content, adding the background area to the content area.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="contentSize"></param>
        /// <returns></returns>
        public SizeF GetExtent(MeasureHelper measure, SizeF contentSize)
        {
            if (Background is IBackground)
            {
                contentSize = ((IBackground)Background).GetBackgroundExtent(measure, contentSize);
            }

            if (Padding.IsEmpty == false)
            {
                contentSize = Padding.GetExtent(contentSize);
            }

            if (Border != null)
            {
                contentSize = Border.GetExtent(contentSize);
            }

            return(contentSize);
        }
Пример #16
0
        /// <summary>
        /// Calculate the client area where the content can be drawed, usually removing the area used by the background, for example removing a border.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="backGroundArea"></param>
        /// <returns></returns>
        public RectangleF GetContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
        {
            if (Border != null)
            {
                backGroundArea = Border.GetContentRectangle(backGroundArea);
            }

            if (Padding.IsEmpty == false)
            {
                backGroundArea = Padding.GetContentRectangle(backGroundArea);
            }

            if (Background is IBackground)
            {
                backGroundArea = ((IBackground)Background).GetBackgroundContentRectangle(measure, backGroundArea);
            }

            return(backGroundArea);
        }
Пример #17
0
        /// <summary>
        /// Measure the current content of the VisualElement.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="maxSize">If empty is not used.</param>
        /// <returns></returns>
        protected override SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize)
        {
            Size proposedSize;

            if (maxSize != System.Drawing.SizeF.Empty)
            {
                proposedSize = Size.Ceiling(maxSize);

                //Remove the 0 because cause some auto size problems expecially when used with the EndEllipses flag.
                if (proposedSize.Width == 0)
                    proposedSize.Width = int.MaxValue;
                if (proposedSize.Height == 0)
                    proposedSize.Height = int.MaxValue;
            }
            else
                // Declare a proposed size with dimensions set to the maximum integer value.
                proposedSize = new Size(int.MaxValue, int.MaxValue);

            return System.Windows.Forms.TextRenderer.MeasureText(measure.Graphics, Value, Font, proposedSize, TextFormatFlags);
        }
Пример #18
0
        protected override void OnDraw(GraphicsCache graphics, RectangleF area)
        {
            // [email protected] : This is added to keep the width and height of the
            // dropdown button same in the view
            ProportionateSize(ref area);
            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                GetRenderer(GetBackgroundElement()).DrawBackground(graphics.Graphics, Rectangle.Round(area));

                if (Style == ButtonStyle.Focus)
                {
                    using (MeasureHelper measure = new MeasureHelper(graphics))
                    {
                        ControlPaint.DrawFocusRectangle(graphics.Graphics, Rectangle.Round(area));
                    }
                }
            }
            else
            {
                mStandardButton.Draw(graphics, area);
            }
        }
Пример #19
0
        protected override void OnDraw(GraphicsCache graphics, System.Drawing.RectangleF area)
        {
            base.OnDraw(graphics, area);

            ButtonState state;

            if (Style == ButtonStyle.Disabled)
            {
                state = ButtonState.Inactive;
            }
            else if (Style == ButtonStyle.Pressed)
            {
                state = ButtonState.Pushed;
            }
            else if (Style == ButtonStyle.Hot)
            {
                state = ButtonState.Normal;
            }
            else
            {
                state = ButtonState.Normal;
            }

            ControlPaint.DrawButton(graphics.Graphics, Rectangle.Round(area), state);

            if (Style == ButtonStyle.NormalDefault)
            {
                graphics.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(area));
            }

            if (Style == ButtonStyle.Focus)
            {
                using (MeasureHelper measure = new MeasureHelper(graphics))
                {
                    ControlPaint.DrawFocusRectangle(graphics.Graphics, Rectangle.Round(GetBackgroundContentRectangle(measure, area)));
                }
            }
        }
Пример #20
0
        private string GetParam()
        {
            var items = new List <string[]>();

            foreach (var item in ShoppingCart)
            {
                var size = item.Offer.Product.Size.Split('|');
                for (int i = 0; i < item.Amount; i++)
                {
                    items.Add(size);
                }
            }

            var heightAvg = 10;
            var widthAvg  = 10;
            var lengthAvg = 10;

            var dimensions = MeasureHelper.GetDimensions(items, heightAvg, widthAvg, lengthAvg);

            var length = dimensions[0];
            var width  = dimensions[1];
            var height = dimensions[2];

            var a = new StringBuilder();

            a.Append("to_city=" + CityTo);
            a.Append("&zip=" + Zip);
            a.Append("&weight=" + ShoppingCart.TotalShippingWeight.ToString("F3"));
            a.Append("&strah=" + (Rate != 0 ? TotalPrice / Rate : TotalPrice).ToString("F2"));
            a.Append("&id=" + ShopId);
            a.Append("&p=" + Password);
            a.Append("&ln=" + length);
            a.Append("&wd=" + width);
            a.Append("&hg=" + height);
            return(a.ToString());
        }
Пример #21
0
        protected override void OnDraw(GraphicsCache graphics, RectangleF area)
        {
            base.OnDraw(graphics, area);

            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                GetRenderer(GetBackgroundElement()).DrawBackground(graphics.Graphics, Rectangle.Round(area));

                if (Style == ButtonStyle.Focus)
                {
                    using (MeasureHelper measure = new MeasureHelper(graphics))
                    {
                        //[email protected]: With the default implementation it was seen that the ractangle is not drawn at the desired location.
                        //Inorder to correct that we provide an overridable method which can make minor adjustments to area
                        RectangleF focusRectangle = GetFocusRectangle(measure, area);
                        ControlPaint.DrawFocusRectangle(graphics.Graphics, Rectangle.Round(focusRectangle));
                    }
                }
            }
            else
            {
                mStandardButton.Draw(graphics, area);
            }
        }
Пример #22
0
        public void Init()
        {
            var items = new List <string[]>();

            foreach (var item in ShoppingCart)
            {
                if (item.Offer.Product != null)
                {
                    var size = item.Offer.Product.Size.Split('|');
                    for (int i = 0; i < item.Amount; i++)
                    {
                        items.Add(size);
                    }
                }
            }

            var weight     = ShoppingCart.TotalShippingWeight;
            var dimensions = MeasureHelper.GetDimensions(items, HeightAvg, WidthAvg, LengthAvg);

            Length = dimensions[0];
            Width  = dimensions[1];
            Height = dimensions[2];
            Weight = weight > 0 ? weight : WeightAvg;
        }
Пример #23
0
        public override SizeF GetBackgroundExtent(MeasureHelper measure, SizeF contentSize)
        {
            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
            {
                Rectangle content = new Rectangle(new Point(0, 0), Size.Ceiling(contentSize));
                contentSize = GetRenderer(GetBackgroundElement()).GetBackgroundExtent(measure.Graphics, content).Size;
            }
            else
                contentSize = mStandardRowHeader.GetBackgroundExtent(measure, contentSize);

            return base.GetBackgroundExtent(measure, contentSize);
        }
Пример #24
0
        /// <summary>
        /// Measure the current content of the VisualElement.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="maxSize">If empty is not used.</param>
        /// <returns></returns>
        protected override SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize)
        {
            String s = String.Empty;

            if (Value != null && Value.Rtf.Length > 0)
            {
                s = DevAge.Windows.Forms.RichTextConversion.RichTextToString(Value);
            }

            return measure.Graphics.MeasureString(s, Font, maxSize);
        }
Пример #25
0
 /// <summary>
 /// Calculate the total area used by the backgound and the content, adding the background area to the content area.
 /// </summary>
 /// <returns></returns>
 public virtual SizeF GetBackgroundExtent(MeasureHelper measure, SizeF contentSize)
 {
     return(contentSize);
 }
Пример #26
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     return SizeF.Empty;
 }
Пример #27
0
        /// <summary>
        /// Gets the area where the visual element will be drawed.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="area"></param>
        /// <returns></returns>
        public RectangleF GetDrawingArea(MeasureHelper measure, System.Drawing.RectangleF area)
        {
            RectangleF destContentArea = area;

            if (AnchorArea != null && !AnchorArea.IsEmpty)
            {
                SizeF measureSize = Measure(measure, SizeF.Empty, SizeF.Empty);
                destContentArea = AnchorArea.CalculateArea(area, measureSize, AnchorArea);
            }

            return destContentArea;
        }
Пример #28
0
        public override System.Drawing.SizeF GetBackgroundExtent(MeasureHelper measure, System.Drawing.SizeF contentSize)
        {
            contentSize = new SizeF(contentSize.Width + 4, contentSize.Height + 4);

            return base.GetBackgroundExtent(measure, contentSize);
        }
Пример #29
0
        /// <summary>
        /// Get the element at the specified point. Usually this methods simply return the current element, but an element can return inner elements drawed inside the main elements.
        /// Returns a list of elements, where the last element is the upper element and the first element is the background element.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="area"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        public virtual VisualElementList GetElementsAtPoint(MeasureHelper measure, System.Drawing.RectangleF area, PointF point)
        {
            VisualElementList list = new VisualElementList();

            if (GetDrawingArea(measure, area).Contains(point))
                list.Add(this);

            return list;
        }
Пример #30
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
         return GetRenderer(GetBackgroundElement()).GetPartSize(measure.Graphics, ThemeSizeType.True);
     else
         return mStandardCheckBox.Measure(measure, Size.Empty, maxSize);
 }
Пример #31
0
        /// <summary>
        /// Measure the current VisualElement using the specified settings.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="minSize">If Empty is not used.</param>
        /// <param name="maxSize">If Empty is not used.</param>
        /// <returns></returns>
        public System.Drawing.SizeF Measure(MeasureHelper measure, System.Drawing.SizeF minSize, System.Drawing.SizeF maxSize)
        {
            SizeF measureSize = OnMeasureContent(measure, maxSize);

            return Utilities.CheckMeasure(measureSize, minSize, maxSize);
        }
Пример #32
0
        /// <summary>
        /// Measure the current content of the VisualElement.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="maxSize">If empty is not used.</param>
        /// <returns></returns>
        protected override System.Drawing.SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize)
        {
            Font font = System.Windows.Forms.Control.DefaultFont;

            if (maxSize != System.Drawing.SizeF.Empty)
                return measure.Graphics.MeasureString(Value.Rtf, font, maxSize);
            else
                return measure.Graphics.MeasureString(Value.Rtf, font);
        }
Пример #33
0
 /// <summary>
 /// Measure the current content of the VisualElement.
 /// </summary>
 /// <param name="measure"></param>
 /// <param name="maxSize">If empty is not used.</param>
 /// <returns></returns>
 protected abstract System.Drawing.SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize);
Пример #34
0
 /// <summary>
 /// Measure the current content of the VisualElement.
 /// </summary>
 /// <param name="measure"></param>
 /// <param name="maxSize">If empty is not used.</param>
 /// <returns></returns>
 protected override System.Drawing.SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize)
 {
     if (maxSize != System.Drawing.SizeF.Empty)
         return measure.Graphics.MeasureString(Value, Font, maxSize);
     else
         return measure.Graphics.MeasureString(Value, Font);
 }
Пример #35
0
        /// <summary>
        /// Draw the current VisualElement in the specified Graphics object.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="area"></param>
        /// <param name="drawingArea"></param>
        public void Draw(GraphicsCache graphics, System.Drawing.RectangleF area, out System.Drawing.RectangleF drawingArea)
        {
            using (MeasureHelper measure = new MeasureHelper(graphics))
            {
                drawingArea = GetDrawingArea(measure, area);

                OnDraw(graphics, drawingArea);
            }
        }
Пример #36
0
        /// <summary>
        /// Calculate the client area where the content can be drawed, usually removing the area used by the background, for example removing a border.
        /// </summary>
        /// <returns></returns>
        public RectangleF GetContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
        {
            if (Border != null)
            {
                backGroundArea = Border.GetContentRectangle(backGroundArea);
            }

            if (Padding.IsEmpty == false)
            {
                backGroundArea = Padding.GetContentRectangle(backGroundArea);
            }

            if (Background is IBackground)
            {
                backGroundArea = ((IBackground)Background).GetBackgroundContentRectangle(measure, backGroundArea);
            }

            return backGroundArea;
        }
Пример #37
0
        /// <summary>
        /// Measure the current VisualElement using the specified settings.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="minSize">If Empty is not used.</param>
        /// <param name="maxSize">If Empty is not used.</param>
        /// <returns></returns>
        public System.Drawing.SizeF Measure(MeasureHelper measure, System.Drawing.SizeF minSize, System.Drawing.SizeF maxSize)
        {
            SizeF measureSize = OnMeasureContent(measure, maxSize);

            return(Utilities.CheckMeasure(measureSize, minSize, maxSize));
        }
Пример #38
0
        protected override void OnDraw(GraphicsCache graphics, RectangleF area)
        {
            OnDrawBackground(graphics, area);

            using (MeasureHelper measure = new MeasureHelper(graphics))
            {
                RectangleF contentArea = GetContentRectangle(measure, area);
                OnDrawContent(graphics, contentArea);
            }
        }
Пример #39
0
        protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
        {
            SizeF clienSize = new SizeF(0, 0);

            //In this case the elements are drawed one over the another so to measure I must simply take the greatest
            if (ElementsDrawMode == ElementsDrawMode.Covering)
            {
                foreach (IVisualElement element in GetElements())
                {
                    SizeF elementSize = element.Measure(measure, Size.Empty, maxSize);

                    elementSize = CalculateSizeWithAnchor(elementSize, element.AnchorArea, maxSize);

                    if (elementSize.Width > clienSize.Width)
                        clienSize.Width = elementSize.Width;
                    if (elementSize.Height > clienSize.Height)
                        clienSize.Height = elementSize.Height;
                }
            }
            //In this case the elements are drawed considering an alignment, so to measure I must consider the anchor area of the element and add the size to the if the alignment is set. This code reflect the drawing code
            else if (ElementsDrawMode == ElementsDrawMode.Align)
            {
                AnchorArea previousAnchor = null;
                foreach (IVisualElement element in GetElements())
                {
                    SizeF elementSize = element.Measure(measure, Size.Empty, maxSize);

                    elementSize = CalculateSizeWithAnchor(elementSize, element.AnchorArea, maxSize);

                    clienSize = CalculateSizeWithContent(clienSize, previousAnchor, elementSize);

                    previousAnchor = element.AnchorArea;
                }
            }
            else
                throw new ApplicationException("DrawMode not supported");

            return GetExtent(measure, clienSize);
        }
Пример #40
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     //TODO Check to see if it is possible to get the real default size...
     return(new SizeF(16, 16));
 }
Пример #41
0
        protected virtual void OnDrawContent(GraphicsCache graphics, RectangleF area)
        {
            //In this case the elements are drawed one over the another
            if (ElementsDrawMode == ElementsDrawMode.Covering)
            {
                foreach (IVisualElement element in GetElements())
                    element.Draw(graphics, area);
            }
            //In this case the elements are drawed considering an alignment
            else if (ElementsDrawMode == ElementsDrawMode.Align)
            {
                using (MeasureHelper measure = new MeasureHelper(graphics))
                {
                    foreach (IVisualElement element in GetElements())
                    {
                        RectangleF elementArea;
                        element.Draw(graphics, area, out elementArea);

                        area = CalculateRemainingArea(area, element.AnchorArea, elementArea);
                    }
                }
            }
            else
                throw new ApplicationException("DrawMode not supported");
        }
Пример #42
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
     {
         var size = GetRenderer(GetBackgroundElement()).GetPartSize(measure.Graphics, ThemeSizeType.True);
         // in Win-7 machines size is returned as 7
         // Increase it to 16, so it matches the standard drop-down width
         if (size.Width < 16)
         	size.Width = 16;
         return size;
     }
     else
         return mStandardButton.Measure(measure, Size.Empty, maxSize);
 }
Пример #43
0
        public override SizeF GetBackgroundExtent(MeasureHelper measure, SizeF contentSize)
        {
            contentSize = mBackground.GetBackgroundExtent(measure, contentSize);

            return(base.GetBackgroundExtent(measure, contentSize));
        }
Пример #44
0
        public override System.Drawing.SizeF GetBackgroundExtent(MeasureHelper measure, System.Drawing.SizeF contentSize)
        {
            contentSize = new SizeF(contentSize.Width + 4, contentSize.Height + 4);

            return(base.GetBackgroundExtent(measure, contentSize));
        }
Пример #45
0
        public static bool CreateOrder(Order order)
        {
            var multishipParams = ShippingMethodService.GetShippingParams(order.ShippingMethodId);

            var items = new List <string[]>();

            foreach (var item in order.OrderItems)
            {
                var product = ProductService.GetProduct(Convert.ToInt32(item.ProductID));
                if (product != null)
                {
                    var size = product.Size.Split('|');
                    for (int i = 0; i < item.Amount; i++)
                    {
                        items.Add(size);
                    }
                }
            }

            var heightAvg = Convert.ToInt32(multishipParams.ElementOrDefault(MultishipTemplate.HeightAvg));
            var widthAvg  = Convert.ToInt32(multishipParams.ElementOrDefault(MultishipTemplate.WidthAvg));
            var lengthAvg = Convert.ToInt32(multishipParams.ElementOrDefault(MultishipTemplate.LengthAvg));

            var dimensions = MeasureHelper.GetDimensions(items, heightAvg, widthAvg, lengthAvg);

            var length = dimensions[0];
            var width  = dimensions[1];
            var height = dimensions[2];

            var weight = order.OrderItems.Sum(x => x.Weight * x.Amount);

            weight = weight != 0 ? weight : Convert.ToInt32(multishipParams.ElementOrDefault(MultishipTemplate.WeightAvg));

            MultishipAdditionalData additionalData = null;

            try
            {
                if (order.OrderPickPoint != null && order.OrderPickPoint.AdditionalData.IsNotEmpty())
                {
                    additionalData =
                        JsonConvert.DeserializeObject <MultishipAdditionalData>(order.OrderPickPoint.AdditionalData);
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                return(false);
            }


            var dict = new Dictionary <string, object>()
            {
                { "order_date", order.OrderDate.ToUniversalTime() },

                { "order_weight", weight.ToString("F2").Replace(",", ".") },
                { "order_height", height },
                { "order_width", width },
                { "order_length", length },

                { "order_payment_method", "1" },
                { "order_delivery_cost", order.ShippingCost.ToString("F2").Replace(",", ".") },
                { "order_assessed_value", order.OrderItems.Sum(x => x.Price * x.Amount).ToString("F2").Replace(",", ".") },

                { "order_sender", multishipParams.ElementOrDefault(MultishipTemplate.SenderId) },
                { "order_requisite", multishipParams.ElementOrDefault(MultishipTemplate.RequisiteId) },
                { "order_warehouse", multishipParams.ElementOrDefault(MultishipTemplate.WarehouseId) },

                { "recipient_first_name", order.OrderCustomer.FirstName },
                { "recipient_last_name", "" },
                { "recipient_middle_name", "" },
                { "recipient_phone", order.OrderCustomer.MobilePhone.Replace("+", "").Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "") },

                { "delivery_direction", additionalData != null ? additionalData.direction : 0 },
                { "delivery_delivery", additionalData != null ? additionalData.delivery : 0 },
                { "delivery_price", additionalData != null ? additionalData.price : 0 },
                { "delivery_pickuppoint", order.OrderPickPoint != null ? order.OrderPickPoint.PickPointId : "1" },
                { "delivery_to_ms_warehouse", additionalData != null ? additionalData.to_ms_warehouse : 0 },

                { "deliverypoint_city", order.ShippingContact.City },
                { "deliverypoint_index", order.ShippingContact.Zip },
                { "deliverypoint_street", order.ShippingContact.Address },

                { "order_num", order.OrderID },
                { "order_user_status_id", "-2" },
                { "recipient_comment", order.CustomerComment },
                { "client_id", multishipParams.ElementOrDefault(MultishipTemplate.ClientId) }
            };

            var dict2 = new Dictionary <string, object>(dict);

            dict2.Add("order_items", order.OrderItems.ToArray());

            var sign = GetSign(dict2, multishipParams.ElementOrDefault(MultishipTemplate.SecretKeyCreateOrder));

            var dataPost = string.Format("{0}&{1}&secret_key={2}",
                                         String.Join("&", dict.Select(x => x.Key + "=" + x.Value)),
                                         GetOrderItems(order.OrderItems),
                                         sign);


            var request = WebRequest.Create(OpenApiUrl + "/createOrder") as HttpWebRequest;

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded";

            byte[] bytes = Encoding.UTF8.GetBytes(dataPost);
            request.ContentLength = bytes.Length;

            using (var requestStream = request.GetRequestStream())
            {
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
            }

            var responseContent = "";

            using (var response = request.GetResponse() as HttpWebResponse)
            {
                using (var stream = response.GetResponseStream())
                {
                    if (stream != null)
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            responseContent = reader.ReadToEnd();
                        }
                    }
                }
            }

            if (responseContent.IsNullOrEmpty() || responseContent.Contains("error") || !responseContent.Contains("status"))
            {
                Debug.LogError(responseContent);
                return(false);
            }

            return(true);
        }
Пример #46
0
 /// <summary>
 /// [email protected]: added FocusRectangle method Calculator. Focus rectangle is not appearing properly.
 /// So here we provide a default implementation. and in UIGrid we override it to correct it.
 /// </summary>
 /// <param name="measure"></param>
 /// <param name="backgroundArea"></param>
 /// <returns></returns>
 protected virtual RectangleF GetFocusRectangle(MeasureHelper measure, RectangleF backgroundArea)
 {
     return(GetBackgroundContentRectangle(measure, backgroundArea));
 }
Пример #47
0
 /// <summary>
 /// Calculate the client area where the content can be drawed, usually removing the area used by the background, for example removing a border.
 /// </summary>
 /// <returns></returns>
 public virtual RectangleF GetBackgroundContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
 {
     return(backGroundArea);
 }
Пример #48
0
        /// <inheritdoc cref="ChartElement{TDrawingContext}.Measure(Chart{TDrawingContext})"/>
        public override void Measure(Chart <TDrawingContext> chart)
        {
            var cartesianChart = (CartesianChart <TDrawingContext>)chart;
            var primaryAxis    = cartesianChart.YAxes[ScalesYAt];
            var secondaryAxis  = cartesianChart.XAxes[ScalesXAt];

            var drawLocation         = cartesianChart.DrawMarginLocation;
            var drawMarginSize       = cartesianChart.DrawMarginSize;
            var secondaryScale       = new Scaler(drawLocation, drawMarginSize, secondaryAxis);
            var primaryScale         = new Scaler(drawLocation, drawMarginSize, primaryAxis);
            var previousPrimaryScale = primaryAxis.PreviousDataBounds is null
                ? null
                : new Scaler(drawLocation, drawMarginSize, primaryAxis, true);
            var previousSecondaryScale = secondaryAxis.PreviousDataBounds is null
                ? null
                : new Scaler(drawLocation, drawMarginSize, secondaryAxis, true);

            var helper  = new MeasureHelper(secondaryScale, cartesianChart, this, secondaryAxis, primaryScale.ToPixels(pivot));
            var pHelper = previousSecondaryScale == null || previousPrimaryScale == null
                ? null
                : new MeasureHelper(
                previousSecondaryScale, cartesianChart, this, secondaryAxis, previousPrimaryScale.ToPixels(pivot));

            var actualZIndex = ZIndex == 0 ? ((ISeries)this).SeriesId : ZIndex;

            if (Fill is not null)
            {
                Fill.ZIndex = actualZIndex + 0.1;
                Fill.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(Fill);
            }
            if (Stroke is not null)
            {
                Stroke.ZIndex = actualZIndex + 0.2;
                Stroke.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(Stroke);
            }
            if (DataLabelsPaint is not null)
            {
                DataLabelsPaint.ZIndex = actualZIndex + 0.3;
                //DataLabelsPaint.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(DataLabelsPaint);
            }

            var dls            = (float)DataLabelsSize;
            var toDeletePoints = new HashSet <ChartPoint>(everFetched);

            var rx = (float)Rx;
            var ry = (float)Ry;

            foreach (var point in Fetch(cartesianChart))
            {
                var visual    = point.Context.Visual as TVisual;
                var primary   = primaryScale.ToPixels(point.PrimaryValue);
                var secondary = secondaryScale.ToPixels(point.SecondaryValue);
                var b         = Math.Abs(primary - helper.p);

                if (point.IsNull)
                {
                    if (visual is not null)
                    {
                        visual.X                 = secondary - helper.uwm + helper.cp;
                        visual.Y                 = helper.p;
                        visual.Width             = helper.uw;
                        visual.Height            = 0;
                        visual.RemoveOnCompleted = true;
                        point.Context.Visual     = null;
                    }
                    continue;
                }

                if (visual is null)
                {
                    var xi  = secondary - helper.uwm + helper.cp;
                    var pi  = helper.p;
                    var uwi = helper.uw;
                    var hi  = 0f;

                    if (previousSecondaryScale is not null && previousPrimaryScale is not null && pHelper is not null)
                    {
                        var previousPrimary = previousPrimaryScale.ToPixels(point.PrimaryValue);
                        var bp  = Math.Abs(previousPrimary - pHelper.p);
                        var cyp = point.PrimaryValue > pivot ? previousPrimary : previousPrimary - bp;

                        xi  = previousSecondaryScale.ToPixels(point.SecondaryValue) - pHelper.uwm + pHelper.cp;
                        pi  = cartesianChart.IsZoomingOrPanning ? cyp : pHelper.p;
                        uwi = pHelper.uw;
                        hi  = cartesianChart.IsZoomingOrPanning ? bp : 0;
                    }

                    var r = new TVisual
                    {
                        X      = xi,
                        Y      = pi,
                        Width  = uwi,
                        Height = hi
                    };

                    if (_isRounded)
                    {
                        var rounded = (IRoundedRectangleChartPoint <TDrawingContext>)r;
                        rounded.Rx = rx;
                        rounded.Ry = ry;
                    }

                    visual = r;
                    point.Context.Visual = visual;
                    OnPointCreated(point);

                    _ = everFetched.Add(point);
                }

                if (Fill is not null)
                {
                    Fill.AddGeometryToPaintTask(cartesianChart.Canvas, visual);
                }
                if (Stroke is not null)
                {
                    Stroke.AddGeometryToPaintTask(cartesianChart.Canvas, visual);
                }

                var cy = point.PrimaryValue > pivot ? primary : primary - b;
                var x  = secondary - helper.uwm + helper.cp;

                visual.X      = x;
                visual.Y      = cy;
                visual.Width  = helper.uw;
                visual.Height = b;
                if (_isRounded)
                {
                    var rounded = (IRoundedRectangleChartPoint <TDrawingContext>)visual;
                    rounded.Rx = rx;
                    rounded.Ry = ry;
                }
                visual.RemoveOnCompleted = false;

                var ha = new RectangleHoverArea().SetDimensions(secondary - helper.uwm + helper.cp, cy, helper.uw, b);
                point.Context.HoverArea = ha;

                _ = toDeletePoints.Remove(point);

                if (DataLabelsPaint is not null)
                {
                    var label = (TLabel?)point.Context.Label;

                    if (label is null)
                    {
                        var l = new TLabel {
                            X = secondary - helper.uwm + helper.cp, Y = helper.p, RotateTransform = (float)DataLabelsRotation
                        };

                        _ = l.TransitionateProperties(nameof(l.X), nameof(l.Y))
                            .WithAnimation(animation =>
                                           animation
                                           .WithDuration(AnimationsSpeed ?? cartesianChart.AnimationsSpeed)
                                           .WithEasingFunction(EasingFunction ?? cartesianChart.EasingFunction));

                        l.CompleteAllTransitions();
                        label = l;
                        point.Context.Label = l;
                    }

                    DataLabelsPaint.AddGeometryToPaintTask(cartesianChart.Canvas, label);

                    label.Text     = DataLabelsFormatter(new TypedChartPoint <TModel, TVisual, TLabel, TDrawingContext>(point));
                    label.TextSize = dls;
                    label.Padding  = DataLabelsPadding;
                    var labelPosition = GetLabelPosition(
                        x, cy, helper.uw, b, label.Measure(DataLabelsPaint),
                        DataLabelsPosition, SeriesProperties, point.PrimaryValue > Pivot, drawLocation, drawMarginSize);
                    label.X = labelPosition.X;
                    label.Y = labelPosition.Y;
                }

                OnPointMeasured(point);
            }

            foreach (var point in toDeletePoints)
            {
                if (point.Context.Chart != cartesianChart.View)
                {
                    continue;
                }
                SoftDeleteOrDisposePoint(point, primaryScale, secondaryScale);
                _ = everFetched.Remove(point);
            }
        }
Пример #49
0
        protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
        {
            SizeF clienSize = SizeF.Empty;

            return(GetBackgroundExtent(measure, clienSize));
        }
Пример #50
0
        /// <summary>
        /// Calculate the total area used by the backgound and the content, adding the background area to the content area.
        /// </summary>
        /// <returns></returns>
        public override SizeF GetBackgroundExtent(MeasureHelper measure, SizeF contentSize)
        {
            SizeF extend = base.GetBackgroundExtent(measure, contentSize);

            extend = mBorder.GetExtent(contentSize);

            return extend;
        }
Пример #51
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     return(SizeF.Empty);
 }
Пример #52
0
        public override RectangleF GetBackgroundContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
        {
            backGroundArea = base.GetBackgroundContentRectangle(measure, backGroundArea);

            return mBackground.GetBackgroundContentRectangle(measure, backGroundArea);
        }
Пример #53
0
        /// <summary>
        /// Calculate the total area used by the backgound and the content, adding the background area to the content area.
        /// </summary>
        /// <returns></returns>
        public SizeF GetExtent(MeasureHelper measure, SizeF contentSize)
        {
            if (Background is IBackground)
            {
                contentSize = ((IBackground)Background).GetBackgroundExtent(measure, contentSize);
            }

            if (Padding.IsEmpty == false)
            {
                contentSize = Padding.GetExtent(contentSize);
            }

            if (Border != null)
            {
                contentSize = Border.GetExtent(contentSize);
            }

            return contentSize;
        }
Пример #54
0
        public override SizeF GetBackgroundExtent(MeasureHelper measure, SizeF contentSize)
        {
            contentSize = mBackground.GetBackgroundExtent(measure, contentSize);

            return base.GetBackgroundExtent(measure, contentSize);
        }
Пример #55
0
        /// <summary>
        /// Calculate the client area where the content can be drawed, usually removing the area used by the background, for example removing a border.
        /// </summary>
        /// <returns></returns>
        public override RectangleF GetBackgroundContentRectangle(MeasureHelper measure, RectangleF backGroundArea)
        {
            backGroundArea = mBorder.GetContentRectangle(backGroundArea);

            return(base.GetBackgroundContentRectangle(measure, backGroundArea));
        }
Пример #56
0
        /// <summary>
        /// Get the element at the specified point. Usually this methods simply return the current element, but an element can return inner elements drawed inside the main elements.
        /// Returns a list of elements, where the last element is the upper (foremost) element and the first element is the background element.
        /// </summary>
        /// <param name="measure"></param>
        /// <param name="area"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        public override VisualElementList GetElementsAtPoint(MeasureHelper measure, System.Drawing.RectangleF area, PointF point)
        {
            VisualElementList list = base.GetElementsAtPoint(measure, area, point);

            area = GetContentRectangle(measure, area);

            //Use the same code of the OnDrawContent method
            //In this case the elements are drawed one over the another
            if (ElementsDrawMode == ElementsDrawMode.Covering)
            {
                foreach (IVisualElement element in GetElements())
                {
                    list.AddRange(element.GetElementsAtPoint(measure, area, point));
                }
            }
            //In this case the elements are drawed considering an alignment
            else if (ElementsDrawMode == ElementsDrawMode.Align)
            {
                foreach (IVisualElement element in GetElements())
                {
                    list.AddRange(element.GetElementsAtPoint(measure, area, point));

                    RectangleF elementArea = element.GetDrawingArea(measure, area);
                    area = CalculateRemainingArea(area, element.AnchorArea, elementArea);
                }
            }
            else
                throw new ApplicationException("DrawMode not supported");

            return list;
        }
Пример #57
0
 /// <summary>
 /// Measure the current content of the VisualElement.
 /// </summary>
 /// <param name="measure"></param>
 /// <param name="maxSize">If empty is not used.</param>
 /// <returns></returns>
 protected abstract System.Drawing.SizeF OnMeasureContent(MeasureHelper measure, System.Drawing.SizeF maxSize);
Пример #58
0
 protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
 {
     //TODO Check to see if it is possible to get the real default size...
     return new SizeF(16, 16);
 }