private static Inline BuildFont(ElementToken token, Hint hint) { var span = new Span(); string size; if (token.Attributes.TryGetValue("size", out size)) { var fc = new FontSizeConverter(); var sz = (double)fc.ConvertFromString(size); span.FontSize = sz; } string face; if (token.Attributes.TryGetValue("face", out face)) { span.FontFamily = new FontFamily(face); } string color; if (token.Attributes.TryGetValue("color", out color)) { var bc = new BrushConverter(); var br = (Brush)bc.ConvertFromString(color); span.Foreground = br; } return span.Fill(token, hint); }
public Tile(ICase tile, TileFactory tileFactory, List<Unite> listUnite, SolidColorBrush playerBrush) { InitializeComponent(); this.tile = tile; this.nbUnite = listUnite.Count; VisualBrush myBrush = new VisualBrush(); aPanel = new Grid(); aPanel.Background = tileFactory.getViewTile(tile); // Create some text. TextBlock backText = new TextBlock(); Canvas.SetZIndex(backText, 3); if (listUnite != null && listUnite.Count > 0) { backText.Text = " " + listUnite.Count.ToString() + " "; backText.Background = (SolidColorBrush)new BrushConverter().ConvertFromString(listUnite[0].Proprietaire.Couleur); backText.Foreground = Brushes.White; } FontSizeConverter fSizeConverter = new FontSizeConverter(); backText.FontSize = (double)fSizeConverter.ConvertFromString("10pt"); backText.Margin = new Thickness(10); Grid.SetColumn(backText, 0); Grid.SetRow(backText, 0); DropShadowEffect myDropShadowEffect = new DropShadowEffect(); myDropShadowEffect.BlurRadius = 1; myDropShadowEffect.Color = Color.FromRgb(0,0,0); myDropShadowEffect.ShadowDepth = 2; backText.Effect=myDropShadowEffect; aPanel.Children.Add(backText); myBrush.Visual = aPanel; rect.Fill = myBrush; rect1.Stroke = playerBrush; }
private void risuem(int i, int j, int kol, String pathImage) { bool b = false; int w=0, h=0; do { b = false; w = wKvadrat(j, i); h = hKvadrat(i); for (int n = j; n < j + w; n++) { if (pole[i, n] != 0) b = true; } for (int n = i; n < i + h; n++) { if (pole[n, j] != 0) b = true; } } while (b); for (int n = i; n < i + h; n++) for(int p = j; p < j + w; p++) { pole[n, p] = kol; } //Рисуем на канве prjamougolnic = new Rectangle(); prjamougolnic.Width = 30 * w; prjamougolnic.Height = 30 * h; prjamougolnic.Stroke = Brushes.Black; Canvas.SetLeft(prjamougolnic, 100 + (j * 30)); Canvas.SetTop(prjamougolnic, 0 + (i * 30)); //Пишем текст VisualBrush myBrush = new VisualBrush(); StackPanel aPanel = new StackPanel(); TextBlock someText = new TextBlock(); someText.Text = kol.ToString(); FontSizeConverter fSizeConverter = new FontSizeConverter(); someText.FontSize = (double)fSizeConverter.ConvertFromString("16pt"); someText.Margin = new Thickness(10); aPanel.Children.Add(someText); myBrush.Visual = aPanel; prjamougolnic.Fill = myBrush; canvas.Children.Add(prjamougolnic); //Записываем в файл file.Write((j * widthKvadrat + 2) + "," + (i * heightKvadrat + 2)+ ","); //Обрезаем изображение System.Drawing.Bitmap bmp = Crop(pathImage, w * widthKvadrat - 4, h * heightKvadrat - 4, j * widthKvadrat + 4, i * heightKvadrat + 4); bmp.Save(putSave + @"\Level" + textBoxLevel.Text + @"\image" + kol + ".png", System.Drawing.Imaging.ImageFormat.Png); bmp.Dispose(); System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 4); gfxTable.DrawRectangle(pen, new System.Drawing.Rectangle(j * widthKvadrat, i * heightKvadrat, w * widthKvadrat, h * heightKvadrat)); }
public static double ToFontSize(this string fontSize) { var fontSizeConverter = new FontSizeConverter(); return (double)fontSizeConverter.ConvertFromString(fontSize); }