示例#1
0
        /// <summary>
        /// Handles the <see cref="ToggleButton.Unchecked"/> event for the "Unit" <see
        /// cref="ListView"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnUnitUnchecked</b> synchronizes the collection of selected units with the contents
        /// of the "Unit" list view by removing the newly unchecked unit.
        /// </para><para>
        /// <b>OnUnitUnchecked</b> then calls <see cref="ShowSelection"/> to recalculate the
        /// combined movement range of all currently selected units, and to update the display
        /// accordingly.</para></remarks>

        private void OnUnitUnchecked(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve unchecked unit, if any
            var listItem = TreeHelper.FindParentListItem(args.Source);

            if (listItem == null)
            {
                return;
            }
            UnitListItem item  = (UnitListItem)listItem.Content;
            int          index = UnitList.Items.IndexOf(item);

            // update selection list
            if (this._selected.Contains(item.Item1))
            {
                this._selected.Remove(item.Item1);
            }

            // update list view & map view
            item = new UnitListItem(item.Item1, false);
            UnitList.Items[index] = item;
            UnitList.SelectAndShow(index);

            ShowSelection(true);
        }
示例#2
0
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Uncheck Stack" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnStackUncheck</b> unchecks all checked items in the "Unit" list view.</remarks>

        private void OnStackUncheck(object sender, RoutedEventArgs args)
        {
            args.Handled = true;
            int index = UnitList.SelectedIndex;

            // uncheck all checked items
            for (int i = 0; i < UnitList.Items.Count; i++)
            {
                UnitListItem item = (UnitListItem)UnitList.Items[i];
                if (item.Item2)
                {
                    UnitList.Items[i] = new UnitListItem(item.Item1, false);
                }

                // update selection list
                if (this._selected.Contains(item.Item1))
                {
                    this._selected.Remove(item.Item1);
                }
            }

            // update list view & map view
            UnitList.Items.Refresh();
            UnitList.SelectAndShow(index);
            ShowSelection(true);
        }
示例#3
0
        /// <summary>
        /// Handles the <see cref="Selector.SelectionChanged"/> event for the "Unit" <see
        /// cref="ListView"/>. </summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="SelectionChangedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnUnitSelected</b> updates the "Property" list view to reflect the selected item in
        /// the "Unit" list view. That <see cref="Unit"/> is also moved to the top of its <see
        /// cref="Site"/> stack.</remarks>

        private void OnUnitSelected(object sender, SelectionChangedEventArgs args)
        {
            args.Handled = true;

            // clear property list view
            PropertyList.ShowEntity(null);

            // retrieve selected unit, if any
            int index = UnitList.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            UnitListItem item = (UnitListItem)UnitList.Items[index];

            // show unit in Property list & map view
            PropertyList.ShowEntity(item.Item1);
            this._mapView.ShowEntity(item.Item1);
        }
示例#4
0
        /// <summary>
        /// Handles the <see cref="Control.MouseDoubleClick"/> event for a <see
        /// cref="ListViewItem"/> of the "Unit" <see cref="ListView"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="MouseButtonEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnUnitActivate</b> displays a <see cref="ShowClasses"/> dialog containing information
        /// on the double-clicked item in the "Unit" list view.</remarks>

        private void OnUnitActivate(object sender, MouseButtonEventArgs args)
        {
            args.Handled = true;

            // retrieve double-clicked item, if any
            var source   = args.OriginalSource as DependencyObject;
            var listItem = ItemsControl.ContainerFromElement(UnitList, source) as ListViewItem;

            if (listItem == null)
            {
                return;
            }
            UnitListItem item = (UnitListItem)listItem.Content;

            // show info dialog for this unit
            var dialog = new ShowClasses(item.Item1)
            {
                Owner = this
            };

            dialog.ShowDialog();
        }