示例#1
0
        /// <summary>
        /// Handles the <see cref="Control.MouseDoubleClick"/> event for a <see
        /// cref="ListViewItem"/> of the "Condition" <see cref="ListView"/> on the <see
        /// cref="ConditionsTab"/> page.</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>OnConditionActivate</b> displays a <see cref="ShowVariables"/> dialog containing
        /// information on the double-clicked item in the "Conditions" list view if it indicates a
        /// <see cref="VariableClass"/>.</remarks>

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

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

            if (listItem == null)
            {
                return;
            }

            // check if parameter is a variable class
            ConditionListItem item     = (ConditionListItem)listItem.Content;
            VariableClass     variable = item.Parameter as VariableClass;

            if (variable == null)
            {
                return;
            }

            // show info dialog for variable class
            var dialog = new ShowVariables(variable)
            {
                Owner = this
            };

            dialog.ShowDialog();
        }
示例#2
0
        /// <summary>
        /// Handles the <see cref="Control.MouseDoubleClick"/> event for a <see
        /// cref="ListViewItem"/> of the <see cref="PropertyListView"/>.</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><para>
        /// <b>OnItemActivate</b> should be called by the actual event handler defined for each
        /// concrete instance of <see cref="PropertyListView"/>.
        /// </para><para>
        /// If the current <see cref="MasterSection"/> instance is not a null reference,
        /// <b>OnItemActivate</b> shows a <see cref="Dialog.ShowVariables"/> dialog containing
        /// information on the double-clicked item, if any.</para></remarks>

        public void OnItemActivate(object sender, MouseButtonEventArgs args)
        {
            args.Handled = true;

            // quit if no current scenario instance
            if (MasterSection.Instance == null)
            {
                return;
            }

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

            if (listItem == null)
            {
                return;
            }

            // retrieve supported content, if any
            var item = listItem.Content as PropertyListItem;

            if (item == null)
            {
                return;
            }

            // show info dialog for unit abilities
            if (item.Tag is UnitClass)
            {
                MessageBox.Show(Window.GetWindow(this),
                                Global.Strings.DialogUnitAbilites, Global.Strings.TitleAbilities,
                                MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            // show info dialog for this variable
            VariableClass variable = item.Tag as VariableClass;

            if (variable != null)
            {
                var dialog = new Dialog.ShowVariables(variable);
                dialog.Owner = Window.GetWindow(this);
                dialog.ShowDialog();
            }
        }
示例#3
0
        /// <summary>
        /// Handles the <see cref="Control.MouseDoubleClick"/> event for a <see
        /// cref="ListViewItem"/> of the "Compare" <see cref="ListView"/> on any tab page.</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>OnCompareActivate</b> displays a <see cref="ShowVariable"/> dialog containing
        /// information on the double-clicked item in the "Compare" list view for <see
        /// cref="ResourceClass"/> criteria, or a <see cref="ShowFactions"/> dialog for <see
        /// cref="FactionHistory"/> criteria.</remarks>

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

            // retrieve double-clicked item, if any
            var      source   = args.OriginalSource as DependencyObject;
            ListView listView = (TablesTab.IsSelected ? CompareTableList : CompareGraphList);
            var      listItem = ItemsControl.ContainerFromElement(listView, source) as ListViewItem;

            if (listItem == null || !(listItem.Content is CompareListItem))
            {
                return;
            }
            var item = (CompareListItem)listItem.Content;

            // show info dialog for resources, if applicable
            var resource = item.Item3 as ResourceClass;

            if (resource != null)
            {
                var dialog = new ShowVariables(resource)
                {
                    Owner = this
                };
                dialog.ShowDialog();
                return;
            }

            // show info dialog for factions, if applicable
            var history = item.Item3 as FactionHistory;

            if (history != null)
            {
                var dialog = new ShowFactions(this._mapView, history.FactionClass);
                dialog.Owner = this;
                dialog.ShowDialog();
            }
        }