public SourceContainer(DominionBase.Cards.Source source)
        {
            this.Source = source;
            Caching.ImageRepository repo = Caching.ImageRepository.Acquire();

            this.Image = repo.GetBitmapImage(this.Source.ToString(), String.Empty);

            Caching.ImageRepository.Release();
        }
示例#2
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            if (_Supply != null)
            {
                if (_Supply.Count == 0)
                {
                    if (_SupplyGone == false)
                    {
                        _SupplyGone = true;
                        GrayscaleEffect.GrayscaleEffect gse = new GrayscaleEffect.GrayscaleEffect();
                        imCardIcon.Effect = gse;

                        Caching.ImageRepository repo = Caching.ImageRepository.Acquire();
                        imCardGone.Source = repo.GetBitmapImage("gone", "small");
                        Caching.ImageRepository.Release();

                        imCardGone.Visibility  = System.Windows.Visibility.Visible;
                        tbName.TextDecorations = TextDecorations.Strikethrough;

                        imBuyOverlay.Visibility = imDisableOverlay.Visibility = imSelectOverlay.Visibility = Visibility.Hidden;
                    }
                }
                else
                {
                    if (_SupplyGone == true)
                    {
                        _SupplyGone       = false;
                        this.Clickability = this.Clickability;
                    }
                    _SupplyGone            = false;
                    imCardIcon.Effect      = null;
                    imCardGone.Source      = null;
                    imCardGone.Visibility  = System.Windows.Visibility.Hidden;
                    tbName.TextDecorations = null;
                }

                DominionBase.Cards.Cost supplyCost = _Supply.CurrentCost;
                lCost.Content = String.Format("{0}¢{1}{2}{3}", supplyCost.Coin.Value, supplyCost.Potion.Value > 0 ? " ¤" : "", supplyCost.Special ? "*" : "", supplyCost.CanOverpay ? "+" : "");
                if (supplyCost < _Supply.BaseCost)
                {
                    lCost.Foreground = Brushes.LimeGreen;
                }
                else if (supplyCost > _Supply.BaseCost)
                {
                    lCost.Foreground = Brushes.Red;
                }
                else
                {
                    lCost.Foreground = Brushes.Black;
                }
                lCount.Content = String.Format("({0})", _Supply.Count);
            }
        }
示例#3
0
        public SupplyControl()
        {
            InitializeComponent();
            Caching.ImageRepository repo = Caching.ImageRepository.Acquire();
            imBuyOverlay.Source     = repo.GetBitmapImage("gainable", String.Empty);
            imSelectOverlay.Source  = repo.GetBitmapImage("selectable", String.Empty);
            imDisableOverlay.Source = repo.GetBitmapImage("dither_20", String.Empty);
            Caching.ImageRepository.Release();

            if (wMain.Settings != null)
            {
                wMain.Settings.SettingsChanged += new NET_WPF.Settings.SettingsChangedEventHandler(Settings_SettingsChanged);
                Settings_SettingsChanged(wMain.Settings, null);
            }
        }
示例#4
0
        void _Supply_PileChanged(object sender, DominionBase.Piles.PileChangedEventArgs e)
        {
            if (this.Dispatcher.CheckAccess())
            {
                DominionBase.Piles.Supply supply = sender as DominionBase.Piles.Supply;

                if ((wMain.Settings.DisplaySupplyPileNames && supply.Location == DominionBase.Cards.Location.Kingdom) ||
                    (wMain.Settings.DisplayBasicSupplyPileNames && supply.Location == DominionBase.Cards.Location.General))
                {
                    lName.Visibility = System.Windows.Visibility.Visible;
                    tbName.Text      = supply.Randomizer.Name;

                    lName.Background = Caching.BrushRepository.GetBackgroundBrush(supply.Randomizer.Category);
                    lName.Foreground = Caching.BrushRepository.GetForegroundBrush(supply.Randomizer.Category);

                    if ((supply.Randomizer.Category & DominionBase.Cards.Category.Reaction) == DominionBase.Cards.Category.Reaction)
                    {
                        tbName.Effect = Caching.DropShadowRepository.GetDSE(8, Colors.White, 1d);
                    }
                }
                else
                {
                    lName.Visibility = System.Windows.Visibility.Collapsed;
                    tbName.Text      = String.Empty;
                }

                Caching.ImageRepository repo = Caching.ImageRepository.Acquire();
                if (supply.TopCard != null)
                {
                    imCardIcon.Source = repo.GetBitmapImage(supply.TopCard.Name.Replace(" ", "").Replace("'", ""), "small");
                    ttcCard.ICard     = supply.TopCard;
                }
                else
                {
                    imCardIcon.Source = repo.GetBitmapImage(supply.Name.Replace(" ", "").Replace("'", ""), "small");
                    ttcCard.ICard     = supply.Randomizer;
                }
                Caching.ImageRepository.Release();

                this.InvalidateVisual();
            }
            else
            {
                this.Dispatcher.BeginInvoke(new EventHandler <DominionBase.Piles.PileChangedEventArgs>(_Supply_PileChanged), System.Windows.Threading.DispatcherPriority.Normal, sender, e);
            }
        }
示例#5
0
        public static List <UIElement> RenderText(String text, RenderSize renderSize, Boolean textOnly)
        {
            List <UIElement> elements      = new List <UIElement>();
            TextBlock        textBlockTemp = new TextBlock();
            InlineCollection inlines       = textBlockTemp.Inlines;
            Match            match         = tagMatch.Match(text);

            while (match.Success)
            {
                switch (match.Groups["tag"].Value)
                {
                case "b":                          // Bold
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    Run rB = new Run(match.Groups["text"].Value);
                    rB.FontWeight = FontWeights.Bold;
                    rB.FontSize   = 14;
                    inlines.Add(rB);
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "i":                          // Italics
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    Run rI = new Run(match.Groups["text"].Value);
                    rI.FontStyle = FontStyles.Italic;
                    rI.FontSize  = 11;
                    inlines.Add(rI);
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "u":                          // Underline
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    Run rU = new Run(match.Groups["text"].Value);
                    rU.TextDecorations = TextDecorations.Underline;
                    rU.FontSize        = 11;
                    inlines.Add(rU);
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "h":                          // Header
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    Run rH = new Run(match.Groups["text"].Value);
                    switch (renderSize)
                    {
                    case RenderSize.ExtraLarge:
                        rH.FontSize = 72;
                        break;

                    default:
                        rH.FontSize = 36;
                        break;
                    }
                    rH.FontWeight = FontWeights.Bold;
                    inlines.Add(rH);
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "br":                          // Line break
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    inlines.Add(new LineBreak());
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "sk":                          // Shortcut Key
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    Run rSK = new Run(match.Groups["text"].Value);
                    rSK.TextDecorations = TextDecorations.Underline;
                    rSK.Foreground      = Brushes.Crimson;
                    inlines.Add(rSK);
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "sm":
                    if (match.Index > 0)
                    {
                        inlines.Add(new Run(text.Substring(0, match.Index)));
                    }
                    Run rS = new Run(match.Groups["text"].Value);
                    rS.FontSize = 11;
                    inlines.Add(rS);
                    text = text.Substring(match.Index + match.Length);
                    break;

                case "nbsp":                          // Non-breaking space
                    text = String.Format("{0}{1}{2}", text.Substring(0, match.Index), Convert.ToChar(160), text.Substring(match.Index + match.Length));
                    break;

                case "vp":
                    if (textOnly)
                    {
                        text = String.Format("{0}{1}‡{2}", text.Substring(0, match.Index), match.Groups["text"].Value, text.Substring(match.Index + match.Length));
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(text.Substring(0, match.Index)))
                        {
                            inlines.Add(new Run(text.Substring(0, match.Index)));
                        }
                        inlines.Add(new Run(match.Groups["text"].Value));
                        text = text.Substring(match.Index + match.Length);

                        InlineUIContainer vpUIContainer = new InlineUIContainer();
                        vpUIContainer.BaselineAlignment = BaselineAlignment.Center;
                        Image vp = new Image();
                        Caching.ImageRepository ir = Caching.ImageRepository.Acquire();
                        vp.Source = ir.GetBitmapImage("vp", String.Empty);
                        switch (renderSize)
                        {
                        case RenderSize.Tiny:
                            vp.Height = 14;
                            vp.Width  = 14;
                            break;

                        default:
                            vp.Height = 18;
                            vp.Width  = 18;
                            break;
                        }
                        Caching.ImageRepository.Release();
                        vpUIContainer.Child = vp;
                        inlines.Add(vpUIContainer);
                    }
                    break;

                case "vplg":
                    if (textOnly)
                    {
                        text = String.Format("<h>{0}{1}‡{2}</h>", text.Substring(0, match.Index), match.Groups["text"].Value, text.Substring(match.Index + match.Length));
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(text.Substring(0, match.Index)))
                        {
                            inlines.Add(new Run(text.Substring(0, match.Index)));
                        }
                        Run rVpLg = new Run(match.Groups["text"].Value);
                        switch (renderSize)
                        {
                        case RenderSize.ExtraLarge:
                            rVpLg.FontSize = 72;
                            break;

                        default:
                            rVpLg.FontSize = 36;
                            break;
                        }
                        rVpLg.FontWeight = FontWeights.Bold;
                        inlines.Add(rVpLg);
                        text = text.Substring(match.Index + match.Length);

                        InlineUIContainer vpUIContainer = new InlineUIContainer();
                        vpUIContainer.BaselineAlignment = BaselineAlignment.Center;
                        Image vp = new Image();
                        Caching.ImageRepository ir = Caching.ImageRepository.Acquire();
                        vp.Source = ir.GetBitmapImage("vplg", String.Empty);
                        Caching.ImageRepository.Release();
                        switch (renderSize)
                        {
                        case RenderSize.ExtraLarge:
                            vp.Height = 96;
                            vp.Width  = 96;
                            break;

                        default:
                            vp.Height = 48;
                            vp.Width  = 48;
                            break;
                        }
                        vpUIContainer.Child = vp;
                        inlines.Add(vpUIContainer);
                    }
                    break;

                case "coin":
                    if (textOnly)
                    {
                        text = String.Format("{0}{1}¢{2}", text.Substring(0, match.Index), match.Groups["text"].Value, text.Substring(match.Index + match.Length));
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(text.Substring(0, match.Index)))
                        {
                            inlines.Add(new Run(text.Substring(0, match.Index)));
                        }
                        text = text.Substring(match.Index + match.Length);

                        InlineUIContainer coinUIContainer = new InlineUIContainer();
                        coinUIContainer.BaselineAlignment = BaselineAlignment.Center;
                        Canvas coinCanvas          = new Canvas();
                        Image  coin                = new Image();
                        Caching.ImageRepository ir = Caching.ImageRepository.Acquire();
                        coin.Source = ir.GetBitmapImage("coin", String.Empty);
                        switch (renderSize)
                        {
                        case RenderSize.Tiny:
                            coinCanvas.Height = coin.Height = 14;
                            coinCanvas.Width  = coin.Width = 14;
                            break;

                        default:
                            coinCanvas.Height = coin.Height = 18;
                            coinCanvas.Width  = coin.Width = 18;
                            break;
                        }
                        Caching.ImageRepository.Release();
                        coinCanvas.Children.Add(coin);
                        TextBlock tbNum = new TextBlock();
                        Run       r     = new Run(match.Groups["text"].Value);
                        r.FontWeight = FontWeights.Bold;
                        tbNum.Inlines.Add(r);
                        Canvas.SetLeft(tbNum, 10 - 4 * match.Groups["text"].Value.Length);
                        Canvas.SetTop(tbNum, 2);
                        coinCanvas.Children.Add(tbNum);
                        coinUIContainer.Child = coinCanvas;
                        inlines.Add(coinUIContainer);
                    }
                    break;

                case "coinlg":
                    if (textOnly)
                    {
                        text = String.Format("<h>{0}{1}¢{2}</h>", text.Substring(0, match.Index), match.Groups["text"].Value, text.Substring(match.Index + match.Length));
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(text.Substring(0, match.Index)))
                        {
                            inlines.Add(new Run(text.Substring(0, match.Index)));
                        }
                        text = text.Substring(match.Index + match.Length);

                        InlineUIContainer coinUIContainer = new InlineUIContainer();
                        coinUIContainer.BaselineAlignment = BaselineAlignment.Center;
                        Canvas coinCanvas          = new Canvas();
                        Image  coin                = new Image();
                        Caching.ImageRepository ir = Caching.ImageRepository.Acquire();
                        coin.Source = ir.GetBitmapImage("coinlg", String.Empty);
                        Caching.ImageRepository.Release();

                        coinCanvas.Children.Add(coin);
                        TextBlock tbNum = new TextBlock();

                        Run r = new Run(match.Groups["text"].Value);
                        r.FontWeight = FontWeights.Bold;

                        int blurRadius = 0;
                        switch (renderSize)
                        {
                        case RenderSize.ExtraLarge:
                            r.FontSize        = 72;
                            coinCanvas.Height = coin.Height = 96;
                            coinCanvas.Width  = coin.Width = 96;
                            Canvas.SetLeft(tbNum, 28);
                            blurRadius = 50;
                            break;

                        default:
                            r.FontSize        = 36;
                            coinCanvas.Height = coin.Height = 48;
                            coinCanvas.Width  = coin.Width = 48;
                            Canvas.SetLeft(tbNum, 14);
                            blurRadius = 30;
                            break;
                        }

                        tbNum.Inlines.Add(r);
                        tbNum.Effect = Caching.DropShadowRepository.GetDSE(blurRadius, Color.FromRgb(192, 192, 192), 1d);

                        coinCanvas.Children.Add(tbNum);
                        coinUIContainer.Child = coinCanvas;
                        inlines.Add(coinUIContainer);
                    }
                    break;

                case "potion":
                    if (textOnly)
                    {
                        text = String.Format("{0}{1}¤{2}", text.Substring(0, match.Index), match.Groups["text"].Value, text.Substring(match.Index + match.Length));
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(text.Substring(0, match.Index)))
                        {
                            inlines.Add(new Run(text.Substring(0, match.Index)));
                        }
                        if (match.Groups["text"].Value != "1")
                        {
                            inlines.Add(new Run(match.Groups["text"].Value));
                        }
                        text = text.Substring(match.Index + match.Length);

                        InlineUIContainer potionUIContainer = new InlineUIContainer();
                        potionUIContainer.BaselineAlignment = BaselineAlignment.Center;
                        Image potion = new Image();
                        Caching.ImageRepository ir = Caching.ImageRepository.Acquire();
                        potion.Source = ir.GetBitmapImage("potion", String.Empty);
                        switch (renderSize)
                        {
                        case RenderSize.Tiny:
                            potion.Height = 14;
                            potion.Width  = 14;
                            break;

                        default:
                            potion.Height = 18;
                            potion.Width  = 18;
                            break;
                        }
                        Caching.ImageRepository.Release();
                        potionUIContainer.Child = potion;
                        inlines.Add(potionUIContainer);
                    }
                    break;

                case "potionlg":
                    if (textOnly)
                    {
                        text = String.Format("<h>{0}{1}¤{2}</h>", text.Substring(0, match.Index), match.Groups["text"].Value, text.Substring(match.Index + match.Length));
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(text.Substring(0, match.Index)))
                        {
                            inlines.Add(new Run(text.Substring(0, match.Index)));
                        }
                        Run rPotionLg = new Run(match.Groups["text"].Value);
                        switch (renderSize)
                        {
                        case RenderSize.ExtraLarge:
                            rPotionLg.FontSize = 72;
                            break;

                        default:
                            rPotionLg.FontSize = 36;
                            break;
                        }
                        rPotionLg.FontWeight = FontWeights.Bold;
                        inlines.Add(rPotionLg);
                        text = text.Substring(match.Index + match.Length);

                        InlineUIContainer potionUIContainer = new InlineUIContainer();
                        potionUIContainer.BaselineAlignment = BaselineAlignment.Center;
                        Image potion = new Image();
                        Caching.ImageRepository ir = Caching.ImageRepository.Acquire();
                        potion.Source = ir.GetBitmapImage("potionlg", String.Empty);
                        Caching.ImageRepository.Release();
                        switch (renderSize)
                        {
                        case RenderSize.ExtraLarge:
                            potion.Height = 96;
                            potion.Width  = 96;
                            break;

                        default:
                            potion.Height = 48;
                            potion.Width  = 48;
                            break;
                        }
                        potionUIContainer.Child = potion;
                        inlines.Add(potionUIContainer);
                    }
                    break;

                default:
                    text = String.Empty;
                    break;
                }
                match = tagMatch.Match(text);
            }
            if (!String.IsNullOrEmpty(text))
            {
                inlines.Add(new Run(text));
            }
            if (textBlockTemp != null)
            {
                elements.Add(textBlockTemp);
            }
            return(elements);
        }
        private void SetupDisplay()
        {
            if (this.ICard == null)
            {
                return;
            }

            Boolean fullCardFound = false;

            if (wMain.Settings.UseCustomToolTips)
            {
                iFullCard.Visibility  = System.Windows.Visibility.Visible;
                dpCardFace.Visibility = System.Windows.Visibility.Hidden;
                Caching.ImageRepository repo = Caching.ImageRepository.Acquire();
                BitmapImage             im   = repo.GetBitmapImage(this.ICard.Name.Replace(" ", "").Replace("'", ""), "full");

                if (im != null)
                {
                    iFullCard.Source = im;
                    fullCardFound    = true;
                }
                Caching.ImageRepository.Release();
            }

            if (!fullCardFound)
            {
                iFullCard.Visibility  = System.Windows.Visibility.Hidden;
                dpCardFace.Visibility = System.Windows.Visibility.Visible;

                tbCardName.Text = String.Empty;
                Run rName = null;
                foreach (char letter in this.ICard.Name)
                {
                    if (rName == null || Char.IsUpper(rName.Text[0]) != Char.IsUpper(letter))
                    {
                        if (rName != null)
                        {
                            tbCardName.Inlines.Add(rName);
                        }
                        rName = new Run();
                        if (Char.IsUpper(letter))
                        {
                            rName.FontSize = 14;
                        }
                        else
                        {
                            rName.FontSize = 11;
                        }
                    }
                    rName.Text += Char.ToUpper(letter);
                }
                if (rName != null)
                {
                    tbCardName.Inlines.Add(rName);
                }

                Caching.ImageRepository repo = Caching.ImageRepository.Acquire();

                BitmapImage im = repo.GetBitmapImage(this.ICard.Name.Replace(" ", "").Replace("'", ""), "medium");
                imCardLarge.Source = im;

                String iconName;
                if (this.ICard.Source != Source.Promotional && this.ICard.Source != Source.Custom)
                {
                    iconName = this.ICard.Source.ToString();
                }
                else
                {
                    iconName = this.ICard.Name.Replace(" ", "").Replace("'", "");
                }
                im = repo.GetBitmapImage(iconName, String.Empty);
                imSource.Source = im;

                Caching.ImageRepository.Release();

                List <String> cardTypes = new List <String>();
                if ((this.ICard.Category & Category.Action) == Category.Action)
                {
                    cardTypes.Add("Action");
                }

                if ((this.ICard.Category & Category.Curse) == Category.Curse)
                {
                    cardTypes.Add("Curse");
                }

                if ((this.ICard.Category & Category.Duration) == Category.Duration)
                {
                    cardTypes.Add("Duration");
                }

                if ((this.ICard.Category & Category.Treasure) == Category.Treasure)
                {
                    cardTypes.Add("Treasure");
                }

                if ((this.ICard.Category & Category.Attack) == Category.Attack)
                {
                    cardTypes.Add("Attack");
                }

                if ((this.ICard.Category & Category.Knight) == Category.Knight)
                {
                    cardTypes.Add("Knight");
                }

                if ((this.ICard.Category & Category.Victory) == Category.Victory)
                {
                    cardTypes.Add("Victory");
                }

                if ((this.ICard.Category & Category.Reaction) == Category.Reaction)
                {
                    cardTypes.Add("Reaction");
                }

                if ((this.ICard.Category & Category.Prize) == Category.Prize)
                {
                    cardTypes.Add("Prize");
                }

                if ((this.ICard.Category & Category.Shelter) == Category.Shelter)
                {
                    cardTypes.Add("Shelter");
                }

                if ((this.ICard.Category & Category.Looter) == Category.Looter)
                {
                    cardTypes.Add("Looter");
                }

                if ((this.ICard.Category & Category.Ruins) == Category.Ruins)
                {
                    cardTypes.Add("Ruins");
                }

                tbTreasureValueLeft.Inlines.Clear();
                tbTreasureValueRight.Inlines.Clear();
                tbCardCost.Inlines.Clear();
                spCardText.Children.Clear();

                if ((this.ICard.Category & Category.Treasure) == Category.Treasure)
                {
                    lblTreasureValueLeft.Visibility = lblTreasureValueRight.Visibility = System.Windows.Visibility.Visible;
                    TextBlock tbTreasureValue = (TextBlock)Utilities.RenderText(this.ICard.Benefit.Currency.ToStringInline(), NET_WPF.RenderSize.Small, false)[0];
                    while (tbTreasureValue.Inlines.Count > 0)
                    {
                        tbTreasureValueLeft.Inlines.Add(tbTreasureValue.Inlines.ElementAt(0));
                    }
                    tbTreasureValue = (TextBlock)Utilities.RenderText(this.ICard.Benefit.Currency.ToStringInline(), NET_WPF.RenderSize.Small, false)[0];
                    while (tbTreasureValue.Inlines.Count > 0)
                    {
                        tbTreasureValueRight.Inlines.Add(tbTreasureValue.Inlines.ElementAt(0));
                    }
                }
                else
                {
                    lblTreasureValueLeft.Visibility = lblTreasureValueRight.Visibility = System.Windows.Visibility.Hidden;
                }

                TextBlock tbTemp = (TextBlock)Utilities.RenderText(this.ICard.BaseCost.ToString(), NET_WPF.RenderSize.Small, false)[0];
                while (tbTemp.Inlines.Count > 0)
                {
                    tbCardCost.Inlines.Add(tbTemp.Inlines.ElementAt(0));
                }
                if (this.ICard.BaseCost.Special)
                {
                    Run special = new Run("*");
                    special.FontWeight = FontWeights.Bold;
                    tbCardCost.Inlines.Add(special);
                }
                if (this.ICard.BaseCost.CanOverpay)
                {
                    Run canOverpay = new Run("+");
                    canOverpay.FontWeight = FontWeights.Bold;
                    tbCardCost.Inlines.Add(canOverpay);
                }

                tbCardType.Text = String.Empty;
                Run rCardType = null;
                foreach (char letter in String.Join(" - ", cardTypes.ToArray()))
                {
                    if (rCardType == null || Char.IsUpper(rCardType.Text[0]) != Char.IsUpper(letter))
                    {
                        if (rCardType != null)
                        {
                            tbCardType.Inlines.Add(rCardType);
                        }
                        rCardType = new Run();
                        if (Char.IsUpper(letter))
                        {
                            rCardType.FontSize = 12;
                        }
                        else
                        {
                            rCardType.FontSize = 10;
                        }
                    }
                    rCardType.Text += Char.ToUpper(letter);
                }
                if (rCardType != null)
                {
                    tbCardType.Inlines.Add(rCardType);
                }

                DominionBase.Cards.Category category = this.ICard.Category;
                if (this.ICard is DominionBase.Cards.Card)
                {
                    category = ((DominionBase.Cards.Card) this.ICard).PhysicalCategory;
                }

                lblCardName.Background = bBottomArea.Background = rBackground.Fill = Caching.BrushRepository.GetBackgroundBrush(category);

                lblCardName.Foreground = lblCardType.Foreground = Caching.BrushRepository.GetForegroundBrush(category);
                if ((category & Category.Reaction) == Category.Reaction)
                {
                    tbCardName.Effect = tbCardType.Effect = Caching.DropShadowRepository.GetDSE(8, Colors.White, 1d);
                }

                if (lblCardName.Foreground.CanFreeze)
                {
                    lblCardName.Foreground.Freeze();
                }
                if (lblCardType.Foreground.CanFreeze)
                {
                    lblCardType.Foreground.Freeze();
                }
                if (lblCardCost.Foreground.CanFreeze)
                {
                    lblCardCost.Foreground.Freeze();
                }

                String[] text = this.ICard.Text.Split(new string[] { "<br/>" }, StringSplitOptions.RemoveEmptyEntries);
                for (int index = 0; index < text.Length; index++)
                {
                    if (index > 0)
                    {
                        Line newLine = new Line();
                        newLine.Stretch         = Stretch.Fill;
                        newLine.Stroke          = Brushes.Black;
                        newLine.StrokeThickness = 2;
                        newLine.X2     = 1;
                        newLine.Margin = new Thickness(20, 2, 20, 2);
                        spCardText.Children.Add(newLine);
                    }

                    String    t      = text[index];
                    TextBlock tbBody = new TextBlock();
                    tbBody.HorizontalAlignment = HorizontalAlignment.Center;
                    tbBody.Margin        = new Thickness(10, 0, 10, 0);
                    tbBody.Padding       = new Thickness(0);
                    tbBody.TextWrapping  = TextWrapping.Wrap;
                    tbBody.TextAlignment = TextAlignment.Center;

                    List <UIElement> elements = Utilities.RenderText(t, (this.ICard.Location == Location.General ? NET_WPF.RenderSize.ExtraLarge : NET_WPF.RenderSize.Small), false);
                    foreach (TextBlock tb in elements.OfType <TextBlock>())
                    {
                        tb.HorizontalAlignment = HorizontalAlignment.Center;
                        tb.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                        tb.Margin        = new Thickness(10, 0, 10, 0);
                        tb.Padding       = new Thickness(0);
                        tb.TextWrapping  = TextWrapping.Wrap;
                        tb.TextAlignment = TextAlignment.Center;
                    }
                    elements.ForEach(e => spCardText.Children.Add(e));
                }
            }

            _IsSetup = true;
        }
示例#7
0
 static ImageRepository()
 {
     _Instance = new ImageRepository();
     _Mutex    = new System.Threading.Mutex();
 }