DevPin.cs :  » GIS » DeepEarth » ExampleControl » Controls » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GIS » DeepEarth 
DeepEarth » ExampleControl » Controls » DevPin.cs
using System;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using DeepEarth.Client.MapControl.Geometry;

namespace ExampleControl.Controls{
    public class DevPin : PointBase
    {

        private DoubleAnimation _AnimateScaleX;
        private DoubleAnimation _AnimateScaleY;

        private Image _ImageInfo;
        private bool _IsMouseOver;
        private Grid _MaxBalloon;
        private Grid _MinBalloon;
        private Storyboard _ScaleAnimation;
        private ScaleTransform _ScalePin;
        private Storyboard _ShowInfoBalloon;


        //public DevPin(GeometryLayer layer): base(layer)
        public DevPin()
        {
            MouseEnter += MouseEnterPin;
            MouseLeave += MouseLeavePin;
            Style = Application.Current.Resources["DevPinStyle"] as Style;
        }

        #region MouseOver-Based Scaling Functions

        private Storyboard ScaleAnimation
        {
            get
            {
                if (_ScaleAnimation == null)
                {
                    // Create two DoubleAnimations and set their properties.
                    _ScaleAnimation = new Storyboard {Duration = new Duration(TimeSpan.FromSeconds(0.4))};
                    _ScaleAnimation.Children.Add(AnimateScaleX);
                    _ScaleAnimation.Children.Add(AnimateScaleY);
                }
                return _ScaleAnimation;
            }
        }

        private DoubleAnimation AnimateScaleX
        {
            get
            {
                if (_AnimateScaleX == null)
                {
                    _AnimateScaleX = new DoubleAnimation {Duration = new Duration(TimeSpan.FromSeconds(0.4))};
                    Storyboard.SetTarget(_AnimateScaleX, _ScalePin);
                    Storyboard.SetTargetProperty(_AnimateScaleX, new PropertyPath("(ScaleX)"));
                }
                return _AnimateScaleX;
            }
        }

        private DoubleAnimation AnimateScaleY
        {
            get
            {
                if (_AnimateScaleY == null)
                {
                    _AnimateScaleY = new DoubleAnimation {Duration = new Duration(TimeSpan.FromSeconds(0.4))};
                    Storyboard.SetTarget(_AnimateScaleY, _ScalePin);
                    Storyboard.SetTargetProperty(_AnimateScaleY, new PropertyPath("(ScaleY)"));
                }
                return _AnimateScaleY;
            }
        }

        private void MouseEnterPin(object sender, MouseEventArgs e)
        {
            _IsMouseOver = true;
            MapInstance.Events.EnableMouseClicks = false;
            Layer.SendToTop(this);
            UpdateVisualState();
        }

        private void MouseLeavePin(object sender, MouseEventArgs e)
        {
            _IsMouseOver = false;
            MapInstance.Events.EnableMouseClicks = true;
            UpdateVisualState();
        }

        private void UpdateVisualState()
        {
            if (_IsMouseOver)
            {
                ScaleTo(1.5);
            }
            else
            {
                ScaleTo(1);
            }
        }

        internal void ScaleTo(double ToValue)
        {
            AnimateScaleX.To = ToValue;
            AnimateScaleY.To = ToValue;
            ScaleAnimation.Begin();
        }

        #endregion

        #region Balloon Functions

        private bool _CommandsInitialized;

        private void MinBalloon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CaptureMouse();

            InitializeCommands();

            _ShowInfoBalloon.Begin();
            _MaxBalloon.Visibility = Visibility.Visible;
            _MinBalloon.Visibility = Visibility.Collapsed;
        }

        private void HideInfoBalloon(object sender, MouseEventArgs e)
        {
            HideInfoBalloon();
        }

        private void HideInfoBalloon()
        {
            _ShowInfoBalloon.Stop();
            _MaxBalloon.Visibility = Visibility.Collapsed;
            _MinBalloon.Visibility = Visibility.Visible;
        }

        private void InitializeCommands()
        {
            if (_CommandsInitialized == false)
            {
                _MaxBalloon = (Grid) GetTemplateChild("PART_MaxBalloon");
                _MaxBalloon.MouseLeave += HideInfoBalloon;
                _CommandsInitialized = true;
            }
        }

        #endregion

        public override void OnApplyTemplate()
        {
            _ImageInfo = (Image) GetTemplateChild("PART_InfoImage");
            _ScalePin = (ScaleTransform) GetTemplateChild("PART_PinScale");
            _ShowInfoBalloon = (Storyboard) GetTemplateChild("PART_ShowInfoBalloon");
            _MinBalloon = (Grid) GetTemplateChild("PART_MinBalloon");


            bool designTime = (HtmlPage.IsEnabled == false);
            if (designTime == false)
            {
                _ImageInfo.MouseLeftButtonDown += MinBalloon_MouseLeftButtonDown;
                _IsLoaded = true;
                ForceMeasure();
                Layer.UpdateChildLocation(this);
            }
        }


    }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.