using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
using System;
using Telerik.Windows.Controls.Map;
using Telerik.Windows.Controls;


namespace Demo.RadMap.UI.Tools
{
    public class BaseMapTool : ITool
    {
        protected InformationLayer iLayer;

        private MouseButtonEventHandler leftButtonDownHandler;
        private MouseButtonEventHandler leftButtonUpHandler;
        protected Telerik.Windows.Controls.RadMap map;
        private MouseEventHandler mouseMoveHandler;

        public virtual void Connect(Telerik.Windows.Controls.RadMap map)
        {
            leftButtonDownHandler = new MouseButtonEventHandler(MouseDown);
            leftButtonUpHandler = new MouseButtonEventHandler(MouseUp);
            mouseMoveHandler = new MouseEventHandler(MouseMove);

            map.MouseLeftButtonDown += leftButtonDownHandler;
            map.MouseLeftButtonUp += leftButtonUpHandler;
            map.MouseMove += mouseMoveHandler;

            this.map = map;
            this.iLayer = map.FindChildByType<InformationLayer>();
        }

        public virtual void Disconnect(Telerik.Windows.Controls.RadMap map)
        {
            map.MouseLeftButtonDown -= this.leftButtonDownHandler;
            map.MouseLeftButtonUp -= this.leftButtonUpHandler;
            map.MouseMove -= this.mouseMoveHandler;
        }

        protected virtual void MouseDown(object sender, MouseButtonEventArgs e)
        {
        }

        protected virtual void MouseMove(object sender, MouseEventArgs e)
        {
        }

        protected virtual void MouseUp(object sender, MouseButtonEventArgs e)
        {
        }
    }
}
