private FrameworkElement CreateForHanyu( Word word, bool showEnglish = false ) { var chars = WordDatabase.Characters( word ); _mainPanel = CreateStackPanel( CreateTextBlock( "SimSun", 30, chars.Select( c => new Run { Text = c.Hanyu, Foreground = new SolidColorBrush( ToneColor( c.Pinyin ) ) } ).ToArray( ) ), CreateTextBlock( "Times New Roman", 20, chars.Select( c => new Run { Text = " " + c.PinyinDiacritics + " ", Foreground = new SolidColorBrush( ToneColor( c.Pinyin ) ) } ).ToArray( ) ), CreateEnglishPanel( showEnglish ? word.ShortEnglish : "" ) ); _mainPanel.SetValue( ToolTipService.ShowDurationProperty, 60000 ); return _mainPanel; }
public static void SetIsFieldGroup(Panel target, bool isFieldGroup) { target.SetValue(IsFieldGroupProperty, isFieldGroup); }
/// <summary> /// Initialize the panel hosting control presenters to duplicate (creating a virtual carousel) /// </summary> /// <param name="panel">Carousel panel</param> /// <param name="presenter">Main control presenter</param> /// <param name="left">Control to add to the left</param> /// <param name="right">Control to add to the right</param> /// <param name="pad">Number of empty padding pixels to add to 'left' and 'right'</param> private void InitializeHost(Panel panel, FrameworkElement presenter, FrameworkElement left, FrameworkElement right, double pad) { // reset/initialize layout with dummy values if (panel.Children.Count == 1) { panel.Children.Insert(0, new Rectangle()); panel.Children.Add(new Rectangle()); } panel.SetValue(Canvas.LeftProperty, 0.0); // insert items ? if (Items.Count > 0) { WriteableBitmap bitmap; Image image; int width; int height; // duplicate left width = (int)(left.ActualWidth + pad); height = (int)left.ActualHeight; bitmap = new WriteableBitmap(width, height); bitmap.Render(left, null); bitmap.Invalidate(); image = new Image(); image.Source = bitmap; panel.Children[0] = image; double offset = bitmap.PixelWidth; // duplicate right width = (int)(right.ActualWidth + pad); height = (int)right.ActualHeight; bitmap = new WriteableBitmap(width, height); bitmap.Render(right, new TranslateTransform() { X = pad }); bitmap.Invalidate(); image = new Image(); image.Source = bitmap; panel.Children[2] = image; // adjust panel position panel.SetValue(Canvas.LeftProperty, -offset); } }