private void ButtonAddPageNumber_Click(object sender, RoutedEventArgs e) { SelectButton button = new SelectButton() { DefaultBrush = new SolidColorBrush(Color.FromRgb(236, 240, 241)), Hover = new SolidColorBrush(Color.FromArgb(60, 233, 30, 99)), OnChecked = new SolidColorBrush(Color.FromRgb(240, 98, 146)) }; button.Content = "#"; button.FontSize = 20; button.VerticalContentAlignment = VerticalAlignment.Center; ContentPanel.Children.Add(button); if (lastChecked != null) { lastChecked.SetCheckedNoCall(false); } Content_PageNumber Acontent = new Content_PageNumber(); content.contents.Add(Acontent); button.Tag = Acontent; button.OnCheckChanged += Button_OnCheckChanged; button.SetChecked(true); lastChecked = button; }
public DWindow_Content(DataStore dataStore, ContentCreator contentCreator) { InitializeComponent(); data = dataStore; content.contents = contentCreator.contents.ToList(); Debug.WriteLine("Count: " + content.contents.Count); foreach (Content_Default conD in content.contents) { SelectButton button = new SelectButton() { MinWidth = 10, MinHeight = 10, Background = new SolidColorBrush(Color.FromRgb(236, 240, 241)), DefaultBrush = new SolidColorBrush(Color.FromRgb(236, 240, 241)), Hover = new SolidColorBrush(Color.FromArgb(60, 233, 30, 99)), OnChecked = new SolidColorBrush(Color.FromRgb(240, 98, 146)) }; button.VerticalContentAlignment = VerticalAlignment.Center; if (conD.ContentType() == 0) { button.Content = new Image() { Source = data.archive.GetImage(((Content_Image)conD).ImageKey), Stretch = ((Content_Image)conD).stretch }; RenderOptions.SetBitmapScalingMode(button, ((Content_Image)conD).scalingMode); button.Width = ((Content_Image)conD).W; button.Height = ((Content_Image)conD).H; button.Margin = new Thickness(((Content_Image)conD).MarginLeft, 0, 0, 0); button.Tag = ((Content_Image)conD); } else if (conD.ContentType() == 1) { Content_Text text = (Content_Text)conD; button.Content = text.text; button.Margin = new Thickness(text.MarginLeft, 0, 0, 0); button.FontSize = text.fontsize; button.Tag = text; button.Foreground = text.foreground.DeserializeToBrushWithKey(data); if (text.fontFamily != null) { button.FontFamily = text.fontFamily; } if (text.Bold) { button.FontWeight = FontWeights.Bold; } if (text.Italic) { button.FontStyle = FontStyles.Italic; } } else if (conD.ContentType() == 2) { Content_Splitter spl = (Content_Splitter)conD; button.Margin = new Thickness(spl.MarginLeft, 0, 0, 0); button.Tag = spl; button.Content = new Rectangle() { Width = spl.W, Height = 1000, Fill = spl.fill.DeserializeToBrushWithKey(data) }; } else if (conD.ContentType() == 3) { Content_PageNumber acontent = (Content_PageNumber)conD; button.Content = (MainWindow.ActualPage + 1) - acontent.SubtractPages; button.Margin = new Thickness(acontent.MarginLeft, 0, 0, 0); button.FontSize = acontent.fontsize; button.Tag = acontent; button.Foreground = acontent.foreground.DeserializeToBrushWithKey(data); if (acontent.fontFamily != null) { button.FontFamily = acontent.fontFamily; } if (acontent.Bold) { button.FontWeight = FontWeights.Bold; } if (acontent.Italic) { button.FontStyle = FontStyles.Italic; } } else if (conD.ContentType() == 4) { Content_Answers acontent = (Content_Answers)conD; button.Content = "A"; button.Margin = new Thickness(acontent.MarginLeft, 0, 0, 0); button.FontSize = acontent.fontsize; button.Tag = acontent; button.Foreground = acontent.foreground.DeserializeToBrushWithKey(data); if (acontent.fontFamily != null) { button.FontFamily = acontent.fontFamily; } if (acontent.Bold) { button.FontWeight = FontWeights.Bold; } if (acontent.Italic) { button.FontStyle = FontStyles.Italic; } } else if (conD.ContentType() == 5) { Content_Date acontent = (Content_Date)conD; button.Content = acontent.Create(data).Content; button.Margin = new Thickness(acontent.MarginLeft, 0, 0, 0); button.FontSize = acontent.fontsize; button.Tag = acontent; button.Foreground = acontent.foreground.DeserializeToBrushWithKey(data); if (acontent.fontFamily != null) { button.FontFamily = acontent.fontFamily; } if (acontent.Bold) { button.FontWeight = FontWeights.Bold; } if (acontent.Italic) { button.FontStyle = FontStyles.Italic; } } ContentPanel.Children.Add(button); button.OnCheckChanged += Button_OnCheckChanged; } if (ContentPanel.Children.Count > 0) { ((SelectButton)ContentPanel.Children[0]).SetChecked(true); } }