public void SetContent(string label, ImageDescription image, ContentPosition position) { if (image.IsNull) { Button.Content = label; } else { SWC.DockPanel grid = new SWC.DockPanel(); var imageCtrl = new ImageBox(Context); imageCtrl.ImageSource = image; SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position)); grid.Children.Add(imageCtrl); if (!string.IsNullOrEmpty(label)) { SWC.Label labelCtrl = new SWC.Label(); labelCtrl.Content = label; grid.Children.Add(labelCtrl); } Button.Content = grid; } Button.InvalidateMeasure(); }
public void SetContent(string label, object imageBackend, ContentPosition position) { if (imageBackend == null) { Button.Content = label; } else { SWC.DockPanel grid = new SWC.DockPanel(); var img = (SWMI.BitmapSource)imageBackend; SWC.Image imageCtrl = new SWC.Image { Source = img, Width = img.Width, Height = img.Height }; SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position)); grid.Children.Add(imageCtrl); SWC.Label labelCtrl = new SWC.Label(); labelCtrl.Content = label; grid.Children.Add(labelCtrl); Button.Content = grid; } }
public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position) { var accessText = new SWC.AccessText(); accessText.Text = label; if (image.IsNull) { if (useMnemonic) { Button.Content = accessText; } else { Button.Content = accessText.Text.Replace("_", "__"); } } else { SWC.DockPanel grid = new SWC.DockPanel(); var imageCtrl = new ImageBox(Context); imageCtrl.ImageSource = image; SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position)); grid.Children.Add(imageCtrl); if (!string.IsNullOrEmpty(label)) { SWC.Label labelCtrl = new SWC.Label(); if (useMnemonic) { labelCtrl.Content = accessText; } else { labelCtrl.Content = label; } labelCtrl.SetBinding(SWC.Label.ForegroundProperty, new Binding("Foreground") { Source = Button }); grid.Children.Add(labelCtrl); } Button.Content = grid; } Button.InvalidateMeasure(); }
public void SetContent(string label, object imageBackend, ContentPosition position) { if (imageBackend == null) { Button.Content = label; } else if (String.IsNullOrEmpty(label)) { Button.Content = new SWC.Image { Source = DataConverter.AsImageSource(imageBackend) } } ; else { SWC.DockPanel grid = new SWC.DockPanel(); var img = DataConverter.AsImageSource(imageBackend); SWC.Image imageCtrl = new SWC.Image { Source = img, Width = img.Width, Height = img.Height }; SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position)); grid.Children.Add(imageCtrl); SWC.Label labelCtrl = new SWC.Label(); labelCtrl.Content = label; grid.Children.Add(labelCtrl); Button.Content = grid; } Button.InvalidateMeasure(); }