private void LV_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            ListViewItem    item = VisualUpwardSearch(e.OriginalSource as DependencyObject);
            CompareListItem cli  = item?.Content as CompareListItem;

            if (cli != null)
            {
                if (cli.BI != null)
                {
                    System.Diagnostics.Process.Start(cli.BI.Item.WikiURL);
                }
                e.Handled = true;
            }
        }
示例#2
0
        /// <summary>
        /// Handles the <see cref="Selector.SelectionChanged"/> event for the "Compare" <see
        /// cref="ListView"/> on the <see cref="TablesTab"/> page.</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>OnCompareTableSelected</b> updates the "Defeat" and "Victory" text boxes and the
        /// "Faction" list view to reflect the selected ranking criterion.</remarks>

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

            // retrieve selected item, if any
            CompareListItem item = CompareTableList.SelectedItem as CompareListItem;

            // clear faction list
            FactionList.Items.Clear();

            // clear thresholds if selection cleared
            if (item == null)
            {
                DefeatInfo.Clear();
                VictoryInfo.Clear();
                return;
            }

            // retrieve selected criterion
            string id       = item.Item3 as String;
            var    resource = item.Item3 as ResourceClass;

            if (resource != null)
            {
                id = resource.Id;
            }

            // show faction ranking
            CreateFactionRows(resource, id);

            string defeatText  = "—"; // em dash
            string victoryText = "—"; // em dash

            if (resource != null)
            {
                // show global thresholds for resource conditions
                if (resource.Defeat != Int32.MinValue)
                {
                    defeatText = resource.Format(resource.Defeat, false);
                }

                if (resource.Victory != Int32.MaxValue)
                {
                    victoryText = resource.Format(resource.Victory, false);
                }
            }
            else
            {
                ConditionParameter parameter = ConditionParameter.Turns;
                switch (id)
                {
                case "sites": parameter = ConditionParameter.Sites; break;

                case "units": parameter = ConditionParameter.Units; break;

                case "unit-strength": parameter = ConditionParameter.UnitStrength; break;
                }

                // show common thresholds for specific conditions
                if (parameter != ConditionParameter.Turns)
                {
                    defeatText  = GetCommonThreshold(false, parameter);
                    victoryText = GetCommonThreshold(true, parameter);
                }
            }

            // show or clear thresholds
            DefeatInfo.Text  = defeatText;
            VictoryInfo.Text = victoryText;
        }
        private void ItemToolTip_Opening(object sender, ToolTipEventArgs e)
        {
            ListViewItem    lvi = sender as ListViewItem;
            CompareListItem cli = lvi.Content as CompareListItem;
            ToolTip         tt  = lvi.ToolTip as ToolTip;

            StackPanel sp = new StackPanel {
                Orientation = Orientation.Vertical
            };

            tt.Content = sp;

            if (cli.Prop != null)
            {
                string lasttype = null;
                foreach (var p in cli.Prop.ItemProperties)
                {
                    string source = p.Owner?.Name;
                    if (source == null)
                    {
                        source = p.SetBonusOwner + " set";
                    }
                    TextBlock tb = new TextBlock();
                    string    l  = null;
                    if (cli.Prop.Property == "Damage Reduction")
                    {
                        l = ((int)p.Value).ToString() + "/" + p.Type;
                    }
                    else if (p.Type == "set")
                    {
                        l = p.Owner.Name;
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(p.Type) && p.Value == 0)
                        {
                            l = source;
                        }
                        else
                        {
                            l += (string.IsNullOrWhiteSpace(p.Type) ? "untyped" : p.Type) + " ";
                            l += p.Value + " (" + source + ")";
                        }
                        if (!cli.Prop.IsGroup && !string.IsNullOrWhiteSpace(lasttype) && p.Type == lasttype)
                        {
                            tb.Foreground = Brushes.Red;
                        }
                        lasttype = p.Type;
                    }
                    tb.Text = l;
                    sp.Children.Add(tb);
                }
            }
            else if (cli.BI != null)
            {
                foreach (var op in cli.BI.OptionProperties)
                {
                    TextBlock tb = new TextBlock();
                    string    t  = op.ToString();
                    tb.Text = t.Substring(1, t.Length - 2);
                    sp.Children.Add(tb);
                }
            }
        }