示例#1
0
        public MainWindow()
        {
            InitializeComponent();


            grid = Graph;// new VirtualCanvas();
            grid.SmallScrollIncrement = new Size(_tileWidth + _tileMargin, _tileHeight + _tileMargin);

            //Scroller.Content = grid;
            object v = Scroller.GetValue(ScrollViewer.CanContentScrollProperty);

            Canvas target = grid.ContentCanvas;

            zoom     = new MapZoom(target);
            pan      = new Pan(target, zoom);
            rectZoom = new RectangleSelectionGesture(target, zoom, ModifierKeys.Control);
            rectZoom.ZoomSelection = true;
            autoScroll             = new AutoScroll(target, zoom);
            zoom.ZoomChanged      += new EventHandler(OnZoomChanged);

            grid.VisualsChanged     += new EventHandler <VisualChangeEventArgs>(OnVisualsChanged);
            ZoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler <double>(OnZoomSliderValueChanged);

            grid.Scale.Changed     += new EventHandler(OnScaleChanged);
            grid.Translate.Changed += new EventHandler(OnScaleChanged);

            grid.Background = new SolidColorBrush(Color.FromRgb(0xd0, 0xd0, 0xd0));
            grid.ContentCanvas.Background = Brushes.White;

            AllocateNodes();
        }
示例#2
0
 /// <summary>
 /// Construct new AutoScroll object that will scroll the given target object within it's container
 /// by attaching to the mouse events of the container.
 /// </summary>
 /// <param name="target">The target object to scroll</param>
 /// <param name="zoom">The master MapZoom object that manages the actual render transform</param>
 public AutoScroll(FrameworkElement target, MapZoom zoom)
 {
     _container             = target.Parent as Panel;
     _target                = target;
     _container.MouseDown  += new MouseButtonEventHandler(OnMouseDown);
     _container.MouseMove  += new MouseEventHandler(OnMouseMove);
     _container.MouseWheel += new MouseWheelEventHandler(OnMouseWheel);
     Keyboard.AddKeyDownHandler(_container, new KeyEventHandler(OnKeyDown));
     _zoom = zoom;
 }
示例#3
0
 /// <summary>
 /// Construct new Pan gesture object.
 /// </summary>
 /// <param name="target">The target to be panned, must live inside a container Panel</param>
 /// <param name="zoom"></param>
 public Pan(FrameworkElement target, MapZoom zoom)
 {
     this._target    = target;
     this._container = target.Parent as Panel;
     if (this._container == null)
     {
         // todo: localization
         throw new ArgumentException("Target object must live in a Panel");
     }
     this._zoom = zoom;
     _container.MouseLeftButtonDown += new MouseButtonEventHandler(OnMouseLeftButtonDown);
     _container.MouseLeftButtonUp   += new MouseButtonEventHandler(OnMouseLeftButtonUp);
     _container.MouseMove           += new MouseEventHandler(OnMouseMove);
 }
示例#4
0
 /// <summary>
 /// Construct new RectangleSelectionGesture object for selecting things in the given target object.
 /// </summary>
 /// <param name="target">A FrameworkElement</param>
 /// <param name="zoom">The MapZoom object that wraps this same target object</param>
 public RectangleSelectionGesture(FrameworkElement target, MapZoom zoom, ModifierKeys mods)
 {
     _mods      = mods;
     _target    = target;
     _container = target.Parent as Panel;
     if (_container == null)
     {
         throw new ArgumentException("Target object must live in a Panel");
     }
     _zoom = zoom;
     _container.MouseLeftButtonDown += new MouseButtonEventHandler(OnMouseLeftButtonDown);
     _container.MouseLeftButtonUp   += new MouseButtonEventHandler(OnMouseLeftButtonUp);
     _container.MouseMove           += new MouseEventHandler(OnMouseMove);
 }