Esempio n. 1
0
        /// <summary>
        /// 绘制控件
        /// </summary>
        /// <param name="drawingContext"></param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (Child != null)
            {
                Geometry cg    = null;
                Brush    brush = null;
                //DpiScale dpi = base.getd();
                Pen pen = new Pen
                {
                    Brush     = this.BorderBrush,
                    Thickness = IndictorPanel.RoundLayoutValue(BorderThickness.Left, 0.5)
                };

                switch (Placement)
                {
                case Placement.LeftTop:
                case Placement.LeftBottom:
                case Placement.LeftCenter:
                    //生成小尾巴在左侧的图形和底色
                    cg    = CreateGeometryTailAtLeft();
                    brush = CreateFillBrush();
                    break;

                case Placement.RightTop:
                case Placement.RightCenter:
                case Placement.RightBottom:
                    //生成小尾巴在右侧的图形和底色
                    cg    = CreateGeometryTailAtRight();
                    brush = CreateFillBrush();
                    break;

                case Placement.TopLeft:
                case Placement.TopCenter:
                case Placement.TopRight:
                    //生成小尾巴在右侧的图形和底色
                    cg    = CreateGeometryTailAtTop();
                    brush = CreateFillBrush();
                    break;

                case Placement.BottomLeft:
                case Placement.BottomCenter:
                case Placement.BottomRight:
                    //生成小尾巴在右侧的图形和底色
                    cg    = CreateGeometryTailAtBottom();
                    brush = CreateFillBrush();
                    break;

                default:
                    break;
                }
                GuidelineSet guideLines = new GuidelineSet();
                drawingContext.PushGuidelineSet(guideLines);
                drawingContext.DrawGeometry(brush, pen, cg);
            }
        }
Esempio n. 2
0
        private static double RoundLayoutValue(double value, double dpiScale)
        {
            double num;

            if (!IndictorPanel.AreClose(dpiScale, 1.0))
            {
                num = Math.Round(value * dpiScale) / dpiScale;
                if (double.IsInfinity(num) || IndictorPanel.AreClose(num, 1.7976931348623157E+308))
                {
                    num = value;
                }
            }
            else
            {
                num = Math.Round(value);
            }
            return(num);
        }