public SampleSettings(Font loadedFont, FChar character, int id) { InitializeComponent(); this.character = character; this.id = id; this.loadedFont = loadedFont; Bitmap image = loadedFont.images[character][id]; height = 200; width = (int)(height * (image.Width / (double)image.Height)); ImageCanvas.Width = width; ImageCanvas.Height = height; Preview.Width = width; Preview.Height = height; Preview.Source = BitmapUtils.ImageSourceForBitmap(image); leftBorderPos = loadedFont.leftMargins[character][id]; rightBorderPos = loadedFont.rightMargins[character][id]; LeftBorder.Text = leftBorderPos.ToString("G4", CultureInfo.InvariantCulture); RightBorder.Text = rightBorderPos.ToString("G4", CultureInfo.InvariantCulture); UpdateRectangle(); }
private void UpdatePreview() { if (renderer == null) { PreviousPageButton.IsEnabled = false; NextPageButton.IsEnabled = false; return; } PreviousPageButton.IsEnabled = curPreviewPage != 0; NextPageButton.IsEnabled = curPreviewPage != renderer.GetPageCount() - 1; PreviewImage.Source = BitmapUtils.ImageSourceForBitmap(renderer.GetPage(curPreviewPage)); }
private void UpdateSampleList(object sender, SelectionChangedEventArgs e) { SampleList.Children.Clear(); if (CharacterList.SelectedItem == null) { return; } FChar selectedItem = (FChar)Enum.Parse(typeof(FChar), CharacterList.SelectedItem.ToString()); for (int i = 0; i < loadedFont.images[selectedItem].Count; i++) { Bitmap image = loadedFont.images[selectedItem][i]; int width = 100; int height = (int)(width * (image.Height / (double)image.Width)); var canvas = new Canvas(); canvas.Width = width; canvas.Height = height; int id = i; canvas.MouseLeftButtonDown += (a, b) => OpenSampleSettings(selectedItem, id); var control = new System.Windows.Controls.Image(); control.Source = BitmapUtils.ImageSourceForBitmap(image); control.Width = width; control.Height = height; var rectangle = new System.Windows.Shapes.Rectangle(); rectangle.Stroke = System.Windows.Media.Brushes.Red; rectangle.Fill = System.Windows.Media.Brushes.Transparent; rectangle.StrokeThickness = 2.0; rectangle.Width = (loadedFont.rightMargins[selectedItem][i] - loadedFont.leftMargins[selectedItem][i]) / Font.imageCmW * width; rectangle.Height = height; canvas.Children.Add(control); canvas.Children.Add(rectangle); Canvas.SetLeft(rectangle, loadedFont.leftMargins[selectedItem][i] / Font.imageCmW * width); var border = new Border(); border.BorderBrush = System.Windows.Media.Brushes.Gray; border.BorderThickness = new Thickness(1.0); border.Child = canvas; border.Margin = new Thickness(5.0); SampleList.Children.Add(border); } }