예제 #1
0
 /// <Summary>
 /// This handles external events in which another GUI element
 /// changes the selection. StarMap can react accordingly and
 /// update it's cursor withour exposing internal variables.
 /// </Summary>
 public void SetCursor(object sender, SelectionArgs e)
 {
     if (e == null || e.Selection == null)
     {
         return;
     }
     else
     {
         SetCursor(e.Selection.Position);
     }
 }
예제 #2
0
        /// <Summary>
        /// Left Shift Mouse: Set Waypoints.
        /// </Summary>
        /// <param name="e"></param>
        /// <param name="snapToObject"></param>
        private void LeftShiftMouse(MouseEventArgs e, bool snapToObject)
        {
            SelectionArgs args = new SelectionArgs(null);

            OnSelectionRequested(args);

            Mappable item = args.Selection;

            if (item == null || !(item is Fleet))
            {
                return;
            }

            NovaPoint       click       = new NovaPoint(e.X, e.Y);
            Fleet           fleet       = item as Fleet;
            NovaPoint       position    = DeviceToLogical(click);
            List <Mappable> nearObjects = FindNearObjects(position);
            Waypoint        waypoint    = new Waypoint();

            waypoint.Position   = position;
            waypoint.WarpFactor = 6;
            waypoint.Task       = new NoTask();

            // If there are no items near the selected position then set the
            // waypoint to just be a position in space. Otherwise, make the target
            // of the waypoint the selected Item.
            //
            // To Do: Handle multiple items at the target location

            if (nearObjects.Count == 0 || snapToObject == false)
            {
                waypoint.Destination = "Space at " + position.ToString();
                waypoint.Position    = position;
            }
            else
            {
                Mappable selected = nearObjects[0];
                waypoint.Position    = selected.Position;
                waypoint.Destination = selected.Name;
            }

            // If the new waypoint is the same as the last one then do nothing.

            int      lastIndex    = fleet.Waypoints.Count - 1;
            Waypoint lastWaypoint = fleet.Waypoints[lastIndex];

            if (waypoint.Destination == lastWaypoint.Destination)
            {
                return;
            }

            WaypointCommand command = new WaypointCommand(CommandMode.Add, waypoint, fleet.Key);

            clientState.Commands.Push(command);

            if (command.IsValid(clientState.EmpireState))
            {
                command.ApplyToState(clientState.EmpireState);
            }

            RefreshStarMap(this, EventArgs.Empty);

            if (WaypointChanged != null)
            {
                WaypointChanged(this, new EventArgs());
            }
        }
예제 #3
0
 /// <summary>
 /// Updates the selected Mappable when it has changed from other panels (Like the Starmap).
 /// </summary>
 /// <param name="sender">The source of the selection change</param>
 /// <param name="e">The new selection</param>
 public void DetailChangeSelection(object sender, SelectionArgs e)
 {
     this.Value = e.Selection;
 }
예제 #4
0
 public void CurrentSelection(object sender, SelectionArgs e)
 {
     e.Selection = Reload();
 }
예제 #5
0
 /// <Summary>
 /// Reacts to Star selection information.
 /// </Summary>
 /// <param name="sender">
 /// A <see cref="System.Object"/>The source of the event.</param>
 /// <param name="e">A <see cref="FleetSelectionArgs"/> that contains the event data.</param>
 public void SummaryChangeSelection(object sender, SelectionArgs e)
 {
     this.SelectionSummary.Value = e.Selection;
 }