Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GeoMap"/> class.
        /// </summary>
        public GeoMap()
        {
            Canvas = new Canvas();
            Map = new Canvas();

            Canvas.Children.Add(Map);
            Content = Canvas;

            Canvas.SetBinding(WidthProperty,
                new Binding { Path = new PropertyPath("ActualWidth"), Source = this });
            Canvas.SetBinding(HeightProperty,
                new Binding { Path = new PropertyPath("ActualHeight"), Source = this });

            Lands = new Dictionary<string, MapData>();

            this.SetIfNotSet(BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 96, 125, 138)));
            /*Current*/
            SetValue(GradientStopCollectionProperty, new GradientStopCollection
            {
                new GradientStop()
                {
                    Color = Color.FromArgb(100, 2, 119, 188),
                    Offset = 0d
                },
                new GradientStop()
                {
                    Color = Color.FromArgb(255, 2, 119, 188),
                    Offset = 1d
                },
            });
            this.SetIfNotSet(HeatMapProperty, new Dictionary<string, double>());
            /*Current*/
            SetValue(GeoMapTooltipProperty, new DefaultGeoMapTooltip {Visibility = Visibility.Collapsed}); //Visibility.Hidden});
            Canvas.Children.Add(GeoMapTooltip);

            SizeChanged += (sender, e) =>
            {
                Draw();
            };

            //MouseWheel += (sender, e) =>
            //{
            //    if (!EnableZoomingAndPanning) return;

            //    e.Handled = true;
            //    var rt = Map.RenderTransform as ScaleTransform;
            //    var p = rt == null ? 1 : rt.ScaleX;
            //    p += e.Delta > 0 ? .05 : -.05;
            //    p = p < 1 ? 1 : p;
            //    var o = e.GetPosition(this);
            //    if (e.Delta > 0) Map.RenderTransformOrigin = new Point(o.X/ActualWidth,o.Y/ActualHeight);
            //    Map.RenderTransform = new ScaleTransform(p, p);
            //};

            //MouseDown += (sender, e) =>
            //{
            //    if (!EnableZoomingAndPanning) return;

            //    DragOrigin = e.GetPosition(this);
            //};

            //MouseUp += (sender, e) =>
            //{
            //    if (!EnableZoomingAndPanning) return;

            //    var end = e.GetPosition(this);
            //    var delta = new Point(DragOrigin.X - end.X, DragOrigin.Y - end.Y);

            //    var l = Canvas.GetLeft(Map) - delta.X;
            //    var t = Canvas.GetTop(Map) - delta.Y;

            //    if (DisableAnimations)
            //    {
            //        Canvas.SetLeft(Map, l);
            //        Canvas.SetTop(Map, t);
            //    }
            //    else
            //    {
            //        Map.CreateCanvasStoryBoardAndBegin(l, t, AnimationsSpeed);
            //    }
            //};
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AngularGauge"/> class.
        /// </summary>
        public AngularGauge()
        {
            Canvas = new Canvas();

            Content = Canvas;

            StickRotateTransform = new RotateTransform {Angle = 180};
            Stick = new Path
            {
                Data = GeometryHelper.Parse("m0,90 a5,5 0 0 0 20,0 l-8,-88 a2,2 0 0 0 -4 0 z"),
                Fill = new SolidColorBrush(Colors.CornflowerBlue),
                Stretch = Stretch.Fill,
                RenderTransformOrigin = new Point(0.5, 0.9),
                RenderTransform = StickRotateTransform
            };
            Canvas.Children.Add(Stick);
            Canvas.SetZIndex(Stick, 1);

            Canvas.SetBinding(WidthProperty,
                new Binding { Path = new PropertyPath("ActualWidth"), Source = this });
            Canvas.SetBinding(HeightProperty,
                new Binding { Path = new PropertyPath("ActualHeight"), Source = this });

            this.SetIfNotSet(SectionsProperty, new List<AngularSection>());

            Stick.SetBinding(Shape.FillProperty,
                new Binding {Path = new PropertyPath("NeedleFill"), Source = this});

            Func<double, string> defaultFormatter = x => x.ToString(CultureInfo.InvariantCulture);
            this.SetIfNotSet(LabelFormatterProperty, defaultFormatter);
            // this.SetIfNotSet(LabelsEffectProperty, new DropShadowEffect {ShadowDepth = 2, RenderingBias = RenderingBias.Performance});

            SizeChanged += (sender, args) =>
            {
                IsControlLaoded = true;
                Draw();
            };

            Slices = new Dictionary<AngularSection, PieSlice>();
        }