public CardGUIModel(Models.CardWithGameProperties Card_, GUIPages.GUIGameRoom parent_, Thickness margin, Visibility visibility) { logger = new Log.Logger(); Card = Card_; parent = parent_; // Border Border = new Border(); Border.Width = 73; Border.Height = 100; Border.VerticalAlignment = VerticalAlignment.Top; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = margin; Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; Border.Visibility = visibility; // Button Btn = new Button(); Btn.Style = parent.FindResource("cardButtonStyle") as Style; Btn.Cursor = System.Windows.Input.Cursors.Hand; Btn.Click += cardButton_Click; Border.Child = Btn; // Image Image = new Image(); try { if (Card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/GUI/CardBack.png", UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/Cards/" + Card.Name + ".png", UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Image.MouseRightButtonUp += parent.cardImage_MouseRightButtonUp; Image.MouseRightButtonDown += parent.cardImage_MouseRightButtonDown; Btn.Content = Image; }
public CardGUIModel(Models.CardWithGameProperties Card_, GUIPages.GUIGameRoom parent_, Thickness margin, Visibility visibility, int shieldNumber = -1) { logger = new Log.Logger(); Card = Card_; parent = parent_; ShieldNumber = shieldNumber; // Border Border = new Border(); Border.Width = 75; Border.Height = 100; Border.VerticalAlignment = VerticalAlignment.Top; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = margin; Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; Border.Visibility = visibility; //Grid Grd = new Grid(); // Button Btn = new Button(); Btn.Style = parent.FindResource("cardButtonStyle") as Style; Btn.Cursor = System.Windows.Input.Cursors.Hand; Btn.Click += cardButton_Click; Border.Child = Grd; // Image Image = new Image(); try { if (Card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, cardBackPath), UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}{2}/{3}.jpg", AppDomain.CurrentDomain.BaseDirectory, cardsPath, Card.Set, Card.Name), UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Image.MouseRightButtonUp += parent.cardImage_MouseRightButtonUp; Image.MouseRightButtonDown += parent.cardImage_MouseRightButtonDown; Btn.Content = Image; Grd.Children.Add(Btn); if (shieldNumber != -1) { // Textblock TxtBlock = new TextBlock(); TxtBlock.Text = shieldNumber.ToString(); TxtBlock.FontSize = 15; TxtBlock.Foreground = Brushes.White; TxtBlock.FontWeight = FontWeights.Bold; TxtBlock.HorizontalAlignment = HorizontalAlignment.Left; TxtBlock.VerticalAlignment = VerticalAlignment.Top; TxtBlock.Margin = new Thickness(10, 5, 0, 0); Grd.Children.Add(TxtBlock); } }