示例#1
0
 /*static M(){
     drag_update = ChangeMapOffset;
 }*/
 public static DragTracker GetMapDrag(Point p)
 {
     DragTracker d = new DragTracker();
     d.target = null;
     d.update = SetMapOffset;
     d.start_location = p;
     d.click_offset_from_target_origin = new Point(p.X - map_offset.col,p.Y - map_offset.row);
     return d;
 }
示例#2
0
 public static void MouseUpHandler(object sender,MouseButtonEventArgs args)
 {
     if(args.Button == MouseButton.Middle){
         HandleMiddleClick();
         return;
     }
     if(args.Button == MouseButton.Right){
         HandleRightClick();
         return;
     }
     bool dragging = (dragTarget != null && dragTarget.dragging);
     dragTarget = null;
     if(!dragging){
         if(!G.CommandEntered){
             if(ButtonClicked(args.Position)){
                 return; //todo
             }
             Tile t = ClickedTile(args.Position);
             if(t != null){
                 //t.super_todo_extra_highlighted = true;
                 //G.terrain.Update();
                 G.LastTile = t;
                 G.LastCommand = Command.Click;
                 G.CommandEntered = true;
             }
         }
     }
 }
示例#3
0
 public static void HandleRightClick()
 {
     if(dragTarget != null && dragTarget.dragging && dragTarget.update != null){
         //dragTarget.update(dragTarget.start_location.X,dragTarget.start_location.Y);
         dragTarget.update(dragTarget.start_location.X - dragTarget.click_offset_from_target_origin.X,dragTarget.start_location.Y - dragTarget.click_offset_from_target_origin.Y);
     }
     dragTarget = null;
 }
示例#4
0
 public static void MouseDownHandler(object sender,MouseButtonEventArgs args)
 {
     if(args.Button == MouseButton.Middle || args.Button == MouseButton.Right){
         return;
     }
     var d = CheckForDrag(args.Position);
     if(d != null){
         dragTarget = d;
     }
     else{
         bool map = true; // todo !
         if(map){
             dragTarget = M.GetMapDrag(args.Position);
         }
     }
 }
示例#5
0
 public virtual DragTracker CheckDrag(Point p)
 {
     if(rect.Contains(p)){
         if(sub_buttons != null){
             foreach(IMouseTarget sub in sub_buttons){
                 var d = sub.CheckDrag(p);
                 if(d != null){
                     if(d.perimeter.IsEmpty && !nonblocking){ //the perimeter will be the first parent of the target.
                         d.perimeter = rect;
                     }
                     return d;
                 }
             }
         }
         if(draggable){
             DragTracker d = new DragTracker();
             d.target = this;
             d.update = MoveTo;
             d.start_location = p;
             d.click_offset_from_target_origin = new Point(p.X - rect.X,p.Y - rect.Y);
             d.locked_horizontal = locked_horizontal;
             d.locked_vertical = locked_vertical;
             return d;
         }
     }
     return null;
 }