public CardCanvas(Card card, Image cardImage, double width, double height, Thickness margin, bool isUpgrade, DefaultPage currentPage = null) { string baseLocation = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; filteredLocation = System.IO.Path.GetDirectoryName(baseLocation).Replace("file:\\", "") + "\\Misc\\"; this.margin = margin; this.cardImage = cardImage; this.currentPage = currentPage; this.height = height; this.width = width; this.isUpgrade = isUpgrade; DropShadowEffect dropShadow = new DropShadowEffect(); dropShadow.BlurRadius = Opt.ApResMod(2); dropShadow.ShadowDepth = Opt.ApResMod(1); Effect = dropShadow; if (this.isUpgrade) { upgrade = (Upgrade)card; } else { pilot = (Pilot)card; } ConstructCanvas(); }
public void HideCardIdentifiers() { if (isUpgrade) { identifierHider.Height = Opt.ApResMod(height) * 0.4142259414; } else { identifierHider.Height = Opt.ApResMod(height) * 0.4634146341; } identifierHider.Width = Opt.ApResMod(width); identifierHider.Fill = new SolidColorBrush(Color.FromRgb(50, 50, 50)); identifierHider.UseLayoutRounding = true; identifierHider.Visibility = Visibility.Visible; SetLeft(this.identifierHider, 0); SetTop(this.identifierHider, 0); Children.Add(this.identifierHider); isHidingIdentifiers = true; }
public void ConstructCanvas() { Children.Clear(); Thickness margin = ScaledThicknessFactory.GetThickness(this.margin.Left, this.margin.Top, this.margin.Right, this.margin.Bottom); if (isUpgrade) { pcntDif = width / 166; numberOwnedLeft = Opt.ApResMod(0 * pcntDif); numberOwnedTop = Opt.ApResMod(161 * pcntDif); addButtonLeft = Opt.ApResMod(0 * pcntDif); addButtonTop = Opt.ApResMod(137 * pcntDif); removeButtonLeft = Opt.ApResMod(0 * pcntDif); removeButtonTop = Opt.ApResMod(193 * pcntDif); infoButtonLeft = Opt.ApResMod(0 * pcntDif); infoButtonTop = Opt.ApResMod(0 * pcntDif); } else { pcntDif = width / 292; numberOwnedLeft = Opt.ApResMod(261 * pcntDif); numberOwnedTop = Opt.ApResMod(141 * pcntDif); addButtonLeft = Opt.ApResMod(260 * pcntDif); addButtonTop = Opt.ApResMod(120 * pcntDif); removeButtonLeft = Opt.ApResMod(260 * pcntDif); removeButtonTop = Opt.ApResMod(170 * pcntDif); infoButtonLeft = Opt.ApResMod(0 * pcntDif); infoButtonTop = Opt.ApResMod(0 * pcntDif); } miniButtonSize = Opt.ApResMod(21); Margin = margin; Width = Opt.ApResMod(width); Height = Opt.ApResMod(height); cardImage.Width = Opt.ApResMod(width); cardImage.Height = Opt.ApResMod(height); cardImage.MouseEnter += new MouseEventHandler(MouseHover); cardImage.MouseLeave += new MouseEventHandler(MouseHoverLeave); RenderOptions.SetBitmapScalingMode(this.cardImage, BitmapScalingMode.HighQuality); SetLeft(cardImage, 0); SetTop(cardImage, 0); Children.Add(cardImage); if (isUpgrade) { numberOwned.Text = upgrade.numberOwned.ToString(); } else { numberOwned.Text = pilot.numberOwned.ToString(); } numberOwned.TextAlignment = TextAlignment.Left; numberOwned.Width = Opt.ApResMod(30 * pcntDif); numberOwned.Height = Opt.ApResMod(30 * pcntDif); numberOwned.StrokeThickness = 1; numberOwned.Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 0)); numberOwned.FontWeight = FontWeights.ExtraBold; numberOwned.Fill = new SolidColorBrush(Color.FromRgb(255, 207, 76)); numberOwned.FontSize = Opt.ApResMod(22); numberOwned.FontFamily = new FontFamily("Verdana"); if (currentPage != null) { numberOwned.MouseWheel += new MouseWheelEventHandler(currentPage.ContentScroll); } numberOwned.MouseEnter += new MouseEventHandler(MouseHover); numberOwned.MouseLeave += new MouseEventHandler(MouseHoverLeave); SetLeft(numberOwned, numberOwnedLeft); SetTop(numberOwned, numberOwnedTop); Children.Add(numberOwned); }
public static Thickness GetThickness(double left, double top, double right, double bottom) { return(new Thickness(Opt.ApResMod(left), Opt.ApResMod(top), Opt.ApResMod(right), Opt.ApResMod(bottom))); }
public static Thickness GetThickness(double all) { return(new Thickness(Opt.ApResMod(all))); }
public ImageButton(string imageName, double scale) { switch (imageName) { case "add_pilot": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(173 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "delete_squad": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(224 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "up": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(40 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "down": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(40 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "copy_for_web": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(227 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "add_upgrade": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(225 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "swap_pilot": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(190 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "add_imperial_squad": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(319 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "add_rebel_squad": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(274 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "add_scum_squad": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(274 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "browse_cards": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(236 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "quiz": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(100 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "manage_squads": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(262 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "show_name": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(203 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "next": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(203 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "info": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(22 * scale)), (int)Opt.ApResMod(Math.Round(22 * scale))); break; case "close": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(22 * scale)), (int)Opt.ApResMod(Math.Round(22 * scale))); break; case "add": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(22 * scale)), (int)Opt.ApResMod(Math.Round(22 * scale))); break; case "remove": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(22 * scale)), (int)Opt.ApResMod(Math.Round(22 * scale))); break; case "copy_for_vassal": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(266 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; case "copy": buttonSize = new System.Drawing.Size((int)Opt.ApResMod(Math.Round(106 * scale)), (int)Opt.ApResMod(Math.Round(60 * scale))); break; default: break; } this.imageName = imageName; this.filteredLocation = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "") + "\\Misc\\"; Source = ImageResizer.ResizeImage(System.Drawing.Image.FromFile(filteredLocation + imageName + ".png"), buttonSize); Width = buttonSize.Width; Height = buttonSize.Height; UseLayoutRounding = true; MouseEnter += new MouseEventHandler(ButtonHover); MouseLeave += new MouseEventHandler(ButtonStopHover); MouseDown += new MouseButtonEventHandler(ButtonClicked); Cursor = Cursors.Hand; RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality); }