private void SetToolTip(FrameworkElement element, DominionBase.ICard card)
        {
            ToolTip     tt  = new System.Windows.Controls.ToolTip();
            ToolTipCard ttc = new ToolTipCard();

            tt.Content = ttc;
            ToolTipService.SetShowOnDisabled(element, true);
            ToolTipService.SetHasDropShadow(element, true);
            if (wMain.Settings != null)
            {
                if (wMain.Settings.ToolTipShowDuration == ToolTipShowDuration.Off)
                {
                    ToolTipService.SetIsEnabled(element, false);
                }
                else
                {
                    ToolTipService.SetIsEnabled(element, true);
                    ToolTipService.SetShowDuration(element, (int)wMain.Settings.ToolTipShowDuration);
                }
            }
            ToolTipService.SetInitialShowDelay(element, 2000);
            ToolTipService.SetBetweenShowDelay(element, 250);
            ttc.ICard       = card;
            element.ToolTip = tt;
        }
Пример #2
0
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
                _Card = null;
                //memoryLeak = null;
                if (wMain.Settings != null)
                {
                    wMain.Settings.SettingsChanged -= new NET_WPF.Settings.SettingsChangedEventHandler(Settings_SettingsChanged);
                }

                // Note disposing has been done.
                disposed = true;
            }
        }
Пример #3
0
        public static ucCardIcon CreateCardIcon(DominionBase.ICard card)
        {
            ucCardIcon icon = new ucCardIcon();

            icon.Card  = card;
            icon.Count = 1;

            return(icon);
        }
Пример #4
0
        private Tuple <List <UIElement>, String> GenerateElements(DominionBase.ICard item, SolidColorBrush background, SolidColorBrush foreground)
        {
            List <UIElement> elements = new List <UIElement>();
            ucCardIcon       icon     = CardIconUtilities.CreateCardIcon((DominionBase.ICard)item);

            icon.Background = background;
            DockPanel.SetDock(icon, Dock.Left);

            elements.Add(icon);

            return(new Tuple <List <UIElement>, String>(elements, item.Name));
        }
		protected virtual void Dispose(bool disposing)
		{
			// Check to see if Dispose has already been called.
			if (!this.disposed)
			{
				// If disposing equals true, dispose all managed
				// and unmanaged resources.
				if (disposing)
				{
					// Dispose managed resources.
				}

				// Call the appropriate methods to clean up
				// unmanaged resources here.
				// If disposing is false,
				// only the following code is executed.
				_Card = null;
				//memoryLeak = null;
				if (wMain.Settings != null)
				{
					wMain.Settings.SettingsChanged -= new NET_WPF.Settings.SettingsChangedEventHandler(Settings_SettingsChanged);
				}

				// Note disposing has been done.
				disposed = true;
			}
		}
        private void UpdateCardDisplay()
        {
            spExtraStuff.Visibility = System.Windows.Visibility.Visible;
            spExtraStuff.Children.Clear();
            this.Tokens.ForEach(t => spExtraStuff.Children.Add(new Controls.ucTokenIcon {
                Token = t, Size = CardSize.Text
            }));
            if (spExtraStuff.Children.Count == 0)
            {
                spExtraStuff.Visibility = System.Windows.Visibility.Collapsed;
            }

            Size stackOffset = new Size();

            switch (this.CardSize)
            {
            case NET_WPF.CardSize.Text:
                break;

            case NET_WPF.CardSize.SmallText:
                dpName.Height = 16;
                lCount.Margin = new Thickness(0);
                lName.Padding = new Thickness(0);
                lName.Margin  = new Thickness(0, 0, 2, 0);
                this.Padding  = new Thickness(0);
                break;

            case NET_WPF.CardSize.Small:
                stackOffset = new Size(12, 6);
                break;

            case NET_WPF.CardSize.Medium:
                stackOffset = new Size(24, 10);
                break;
            }
            lCount.Visibility = System.Windows.Visibility.Collapsed;
            if (_CardCollection.Count() > 4 || (gImages.Visibility == System.Windows.Visibility.Collapsed && _CardCollection.Count() > 1))
            {
                lCount.Visibility = System.Windows.Visibility.Visible;
                if (IsCardsVisible && PileVisibility == DominionBase.Piles.Visibility.All)
                {
                    lCount.Content = String.Format("{0}x", _CardCollection.Count());
                }
                stackOffset.Width = 0.75 * stackOffset.Width;
            }
            //else if (this.CardSize == NET_WPF.CardSize.SmallText)
            //{
            //    lCount.Visibility = System.Windows.Visibility.Collapsed;
            //}
            if (_CardCollection.Count() > 6 && stackOffset.Height > 0)
            {
                float verticalScale = 56f / (_CardCollection.Count() - 1);
                stackOffset = new Size((int)(0.625 * stackOffset.Width * verticalScale / stackOffset.Height), (int)verticalScale);
            }

            if (this.PileVisibility != DominionBase.Piles.Visibility.All)
            {
                stackOffset.Width = 0;
            }

            for (int index = 0; index < _CardCollection.Count(); index++)
            {
                DominionBase.ICard card = _CardCollection.ElementAt(index);
                if (card == null)
                {
                    continue;
                }

                if (IsCardsVisible && PileVisibility == DominionBase.Piles.Visibility.All || PileVisibility == DominionBase.Piles.Visibility.Top)
                {
                    DominionBase.Cards.Category category = card.Category;
                    if (card is DominionBase.Cards.Card)
                    {
                        category = ((DominionBase.Cards.Card)card).PhysicalCategory;
                    }

                    lName.Background = Caching.BrushRepository.GetBackgroundBrush(category);
                    lName.Foreground = Caching.BrushRepository.GetForegroundBrush(category);

                    if ((category & DominionBase.Cards.Category.Reaction) == DominionBase.Cards.Category.Reaction)
                    {
                        tbName.Effect = Caching.DropShadowRepository.GetDSE(8, Colors.White, 1d);
                    }
                }

                if (gImages.Visibility == System.Windows.Visibility.Visible)
                {
                    Image newImage = new Image();
                    Caching.ImageRepository repo = Caching.ImageRepository.Acquire();
                    switch (this.CardSize)
                    {
                    case NET_WPF.CardSize.Small:
                        if (IsCardsVisible &&
                            (PileVisibility == DominionBase.Piles.Visibility.All || PileVisibility == DominionBase.Piles.Visibility.Top) &&
                            card.CardType != DominionBase.Cards.Universal.TypeClass.Dummy)
                        {
                            newImage.Source = repo.GetBitmapImage(card.Name.Replace(" ", "").Replace("'", ""), "small");
                        }
                        else
                        {
                            switch (card.CardBack)
                            {
                            case DominionBase.Cards.CardBack.Standard:
                                newImage.Source = repo.GetBitmapImage("back", "small");
                                break;

                            case DominionBase.Cards.CardBack.Red:
                                newImage.Source = repo.GetBitmapImage("back_red", "small");
                                break;
                            }
                        }
                        break;

                    case NET_WPF.CardSize.Medium:
                        if (IsCardsVisible &&
                            (PileVisibility == DominionBase.Piles.Visibility.All || PileVisibility == DominionBase.Piles.Visibility.Top) &&
                            card.CardType != DominionBase.Cards.Universal.TypeClass.Dummy)
                        {
                            newImage.Source = repo.GetBitmapImage(card.Name.Replace(" ", "").Replace("'", ""), "medium");
                        }
                        else
                        {
                            switch (card.CardBack)
                            {
                            case DominionBase.Cards.CardBack.Standard:
                                newImage.Source = repo.GetBitmapImage("back", "medium");
                                break;

                            case DominionBase.Cards.CardBack.Red:
                                newImage.Source = repo.GetBitmapImage("back_red", "medium");
                                break;
                            }
                        }
                        break;
                    }
                    Caching.ImageRepository.Release();

                    if (newImage.Source != null)
                    {
                        newImage.Width  = newImage.Source.Width;
                        newImage.Height = newImage.Source.Height;
                    }

                    newImage.HorizontalAlignment = HorizontalAlignment.Left;
                    newImage.VerticalAlignment   = VerticalAlignment.Top;

                    newImage.Margin = new Thickness(index * stackOffset.Width, index * stackOffset.Height, 0, 0);
                    newImage.Tag    = card;

                    gImages.Children.Insert(gImages.Children.Count - 1, newImage);
                }
            }

            this.Title = String.Empty;
            if (_CardCollection.Count() > 0 && IsCardsVisible)
            {
                if (PileVisibility == DominionBase.Piles.Visibility.All || PileVisibility == DominionBase.Piles.Visibility.Top)
                {
                    DominionBase.ICard card = _CardCollection.Last();
                    if (card != null)
                    {
                        this.Title    = card.Name;
                        ttcCard.ICard = card;
                    }
                }
            }

            UpdateGlowEffectAll();

            if (!IsCardsVisible || PileVisibility == DominionBase.Piles.Visibility.None)
            {
                int count = _CardCollection.Count();
                if (this.ExactCount || count <= 1)
                {
                    this.Title = StringUtility.Plural("Card", count);
                }
            }
        }