コード例 #1
0
ファイル: PetTalentItem.xaml.cs プロジェクト: rakot/rawr
        public void Update()
        {
#if SILVERLIGHT
            string iconPrefix = "/Rawr.Hunter;component/Resources";
#else
            string iconPrefix = "/Rawr.Hunter.WPF;component/Resources";
#endif

            if (pettalentData != null)
            {
                Brush b;
                if (Current == pettalentData.MaxPoints)
                {
                    b = new SolidColorBrush(Colors.Yellow);
                    OverlayImage.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/icon-over-yellow.png", UriKind.Relative));
                }
                else
                {
                    if (CanPutPoints())
                    {
                        b = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
                    }
                    else
                    {
                        b = new SolidColorBrush(Colors.White);
                    }

                    if (Current > 0)
                    {
                        OverlayImage.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/icon-over-green.png", UriKind.Relative));
                    }
                    else
                    {
                        OverlayImage.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/icon-over-grey.png", UriKind.Relative));
                    }
                }

                RankLabel.Text       = string.Format("{0}/{1}", Current, pettalentData.MaxPoints);
                RankLabel.Foreground = b;

                TalentImage.Source = Icons.TalentIcon(PetTalentTree.Class, PetTalentTree.TreeName, pettalentData.Icon, Current > 0);

                ToolTipService.SetToolTip(this, GetTooltipString());
                this.Visibility = Visibility.Visible;
            }
            else
            {
                this.Visibility = Visibility.Collapsed;
            }
        }
コード例 #2
0
        public void UpdatePrereqs()
        {
            foreach (KeyValuePair <int, PetTalentDataAttribute> kvp in talentAttributes)
            {
                if (kvp.Value.Prerequisites[Tree] >= 0)
                {
                    PetTalentDataAttribute prereq = GetAttribute(kvp.Value.Prerequisites[Tree]);
                    int row = kvp.Value.Rows[Tree] - prereq.Rows[Tree];
                    int col = kvp.Value.Columns[Tree] - prereq.Columns[Tree];

                    string suffix;
                    if (kvp.Value.MaxPoints == Talents.Data[kvp.Value.Index])
                    {
                        suffix = "-yellow.png";
                    }
                    else if (PointsBelowRow(kvp.Value.Rows[Tree]) >= (kvp.Value.Rows[Tree] - 1) * 5 &&
                             Talents.Data[prereq.Index] == prereq.MaxPoints)
                    {
                        suffix = "-green.png";
                    }
                    else
                    {
                        suffix = "-grey.png";
                    }

                    Image image;
                    if (prereqArrows.ContainsKey(kvp.Value.Index))
                    {
                        image = prereqArrows[kvp.Value.Index];
                    }
                    else
                    {
                        image = new Image();
                        Grid.SetColumn(image, kvp.Value.Columns[Tree]);
                        Grid.SetRow(image, kvp.Value.Rows[Tree]);
#if SILVERLIGHT
                        image.Stretch = Stretch.None;
#else
                        // it looks like these images have non standard dpi, so make sure wpf doesn't stretch it around
                        image.Stretch = Stretch.Fill;
                        image.SetBinding(Image.WidthProperty, new System.Windows.Data.Binding()
                        {
                            Path = new PropertyPath("Source.PixelWidth"), RelativeSource = new System.Windows.Data.RelativeSource(System.Windows.Data.RelativeSourceMode.Self)
                        });
                        image.SetBinding(Image.HeightProperty, new System.Windows.Data.Binding()
                        {
                            Path = new PropertyPath("Source.PixelHeight"), RelativeSource = new System.Windows.Data.RelativeSource(System.Windows.Data.RelativeSourceMode.Self)
                        });
#endif
                        image.HorizontalAlignment = HorizontalAlignment.Left;
                        image.VerticalAlignment   = VerticalAlignment.Top;
                        GridPanel.Children.Add(image);
                        prereqArrows[kvp.Value.Index] = image;
                    }

#if SILVERLIGHT
                    string iconPrefix = "/Rawr.Hunter;component/Resources";
#else
                    string iconPrefix = "/Rawr.Hunter.WPF;component/Resources";
#endif

                    if (row == 0)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/across-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(47, 15, 0, 0);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/across-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-17, 15, 0, 0);
                        }
                    }
                    else if (row == 1)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -44, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-1" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(14, -17, 0, 0);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-18, -44, 0, 0);
                        }
                    }
                    else if (row == 2)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-2-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-18, 20, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-2" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -81, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-2-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(46, 20, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                    }
                    else if (row == 3)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-3-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-18, 84, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-3" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -145, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-3-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(46, 84, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                    }
                    else if (row == 4)
                    {
                        if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/down-4" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -209, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void UpdatePrereqs()
        {
            foreach (KeyValuePair <int, PetTalentDataAttribute> kvp in talentAttributes)
            {
                if (kvp.Value.Prerequisites[Tree] >= 0)
                {
                    PetTalentDataAttribute prereq = GetAttribute(kvp.Value.Prerequisites[Tree]);
                    int row = kvp.Value.Rows[Tree] - prereq.Rows[Tree];
                    int col = kvp.Value.Columns[Tree] - prereq.Columns[Tree];

                    string suffix;
                    if (kvp.Value.MaxPoints == Talents.Data[kvp.Value.Index])
                    {
                        suffix = "-yellow.png";
                    }
                    else if (PointsBelowRow(kvp.Value.Rows[Tree]) >= (kvp.Value.Rows[Tree] - 1) * 5 &&
                             Talents.Data[prereq.Index] == prereq.MaxPoints)
                    {
                        suffix = "-green.png";
                    }
                    else
                    {
                        suffix = "-grey.png";
                    }

                    Image image;
                    if (prereqArrows.ContainsKey(kvp.Value.Index))
                    {
                        image = prereqArrows[kvp.Value.Index];
                    }
                    else
                    {
                        image = new Image();
                        Grid.SetColumn(image, kvp.Value.Columns[Tree]);
                        Grid.SetRow(image, kvp.Value.Rows[Tree]);
                        image.Stretch             = Stretch.None;
                        image.HorizontalAlignment = HorizontalAlignment.Left;
                        image.VerticalAlignment   = VerticalAlignment.Top;
                        GridPanel.Children.Add(image);
                        prereqArrows[kvp.Value.Index] = image;
                    }

                    if (row == 0)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/across-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(47, 15, 0, 0);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/across-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-17, 15, 0, 0);
                        }
                    }
                    else if (row == 1)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -44, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-1" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(14, -17, 0, 0);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-18, -44, 0, 0);
                        }
                    }
                    else if (row == 2)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-2-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-18, 20, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-2" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -81, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-2-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(46, 20, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                    }
                    else if (row == 3)
                    {
                        if (col == -1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-3-left" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(-18, 84, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-3" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -145, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                        else if (col == 1)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-3-right" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(46, 84, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                    }
                    else if (row == 4)
                    {
                        if (col == 0)
                        {
                            image.Source = Icons.NewBitmapImage(new Uri("/Rawr.Hunter;component/Resources/down-4" + suffix, UriKind.Relative));
                            image.Margin = new Thickness(13, -209, 0, 0);
                            Grid.SetRowSpan(image, 2);
                        }
                    }
                }
            }
        }