Beispiel #1
0
        public ToolbarButton(object viewModel, Bitmap bitmap, ComboBox combobox, Dictionary <string, DependencyProperty> bindings)
        {
            _image = new System.Windows.Controls.Image()
            {
                Source = ToBitmapSource.Bitmap2BitmapSource(bitmap)
            };


            var stackPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            stackPanel.Children.Add(_image);
            stackPanel.Children.Add(combobox);
            if (bindings != null)
            {
                foreach (var b in bindings)
                {
                    this.SetBinding(b.Value, new Binding(b.Key));
                }
            }
            DataContext    = viewModel;
            Content        = stackPanel;
            this.IsEnabled = true;
        }
Beispiel #2
0
        private static void OnBitmapPropertyChanged(DependencyObject source,
                                                    DependencyPropertyChangedEventArgs e)
        {
            ToolbarButton button = source as ToolbarButton;
            var           bitmap = button.ImageBitmap;

            if (bitmap != null)
            {
                button._image.Source = ToBitmapSource.Bitmap2BitmapSource(bitmap);
                RefreshBitmap(button, button.IsEnabled);
            }
        }
Beispiel #3
0
        public static ContextMenu InitContextMenu(IEnumerable <ICommandDescriptor> commands)
        {
            var contextMenu = new ContextMenu();

            foreach (var c in commands)
            {
                var m = new MenuItem
                {
                    Header  = c.Name,
                    Command = c.Command,
                    Icon    = c.Bitmap != null ?
                              new BitmapImage {
                        Source = ToBitmapSource.Bitmap2BitmapSource(c.Bitmap)
                    } :
                    null
                };
                contextMenu.Items.Add(m);
            }
            ;

            return(contextMenu);
        }
Beispiel #4
0
        public ToolbarButton(object viewModel, Bitmap bitmap, Dictionary <string, DependencyProperty> bindings)
        {
            this.Margin = new Thickness(5, 0, 0, 0);
            _image      = new System.Windows.Controls.Image()
            {
                Source = ToBitmapSource.Bitmap2BitmapSource(bitmap)
            };


            var stackPanel = new StackPanel();

            stackPanel.Children.Add(_image);
            if (bindings != null)
            {
                foreach (var b in bindings)
                {
                    this.SetBinding(b.Value, new Binding(b.Key));
                }
            }
            DataContext    = viewModel;
            Content        = stackPanel;
            this.IsEnabled = true;
        }