Exemple #1
0
        private ContentControl AddImage(HWImage img)
        {
            Image       image       = new Image();
            BitmapImage bitmapImage = ImageHelper.GetImage(img.Res_name);

            image.Source  = bitmapImage;
            image.Width   = bitmapImage.PixelWidth;
            image.Height  = bitmapImage.PixelHeight;
            image.Stretch = Stretch.Fill;

            ContentControl control = new ContentControl
            {
                Width  = image.Width,
                Height = image.Height,
                Style  = (Style)Application.Current.Resources["DesignerItemStyle"]
            };

            control.Content = image;
            canvas.Children.Add(control);
            DesignerItemDecorator.SetCanResize(control, false);

            Canvas.SetTop(control, img.Y);
            Canvas.SetLeft(control, img.X);
            return(control);
        }
        private static void ShowDecoratorProperty_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DesignerItemDecorator decorator = (DesignerItemDecorator)d;
            bool showDecorator = (bool)e.NewValue;

            if (showDecorator)
            {
                decorator.ShowAdorner();
            }
            else
            {
                decorator.HideAdorner();
            }
        }