Exemplo n.º 1
0
        public WatermarkTool()
        {
            this.settings = new WatermarkToolSettings();

            this.settings.open.Click += new RoutedEventHandler(Open_Click);

            Uri imageUri = ImageExampleHelper.GetResourceUri("Images/telerik-logo.png");

            this.watermarkBitmap = new RadBitmap(Application.GetResourceStream(imageUri).Stream);

            this.watermarkImage         = new Image();
            this.watermarkImage.Source  = new BitmapImage(imageUri);
            this.watermarkImage.Stretch = Stretch.None;

            this.watermarkCommand     = new WatermarkCommand();
            this.imageRotateTransform = new RotateTransform();
            this.imageScaleTransform  = new ScaleTransform();
            this.imageEditorScale     = new ScaleTransform();

            TransformGroup transform = new TransformGroup();

            transform.Children.Add(this.imageRotateTransform);
            transform.Children.Add(this.imageScaleTransform);
            transform.Children.Add(this.imageEditorScale);
            this.watermarkImage.RenderTransform = transform;

            this.watermarkImage.RenderTransformOrigin = new Point(0.5, 0.5);
            this.watermarkImage.HorizontalAlignment   = HorizontalAlignment.Center;
            this.watermarkImage.VerticalAlignment     = VerticalAlignment.Center;

            this.settings.opacity.ValueChanged  += new EventHandler(settings_ValueChanged);
            this.settings.rotation.ValueChanged += new EventHandler(settings_ValueChanged);
            this.settings.scale.ValueChanged    += new EventHandler(settings_ValueChanged);

            Binding opacityBinding = new Binding("Value");

            opacityBinding.Source = this.settings.opacity;
            BindingOperations.SetBinding(this.watermarkImage, Image.OpacityProperty, opacityBinding);

            Binding rotationBinding = new Binding("Value");

            rotationBinding.Source = this.settings.rotation;
            BindingOperations.SetBinding(this.imageRotateTransform, RotateTransform.AngleProperty, rotationBinding);

            Binding scaleXBinding = new Binding("Value");

            scaleXBinding.Source = this.settings.scale;
            BindingOperations.SetBinding(this.imageScaleTransform, ScaleTransform.ScaleXProperty, scaleXBinding);

            Binding scaleYBinding = new Binding("Value");

            scaleYBinding.Source = this.settings.scale;
            BindingOperations.SetBinding(this.imageScaleTransform, ScaleTransform.ScaleYProperty, scaleYBinding);
        }
Exemplo n.º 2
0
        public WatermarkTool()
        {
            this.settings = new WatermarkToolSettings();

            this.settings.open.Click += new RoutedEventHandler(Open_Click);

            Uri imageUri = ImageExampleHelper.GetResourceUri("Images/telerik-logo.png");
            this.watermarkBitmap = new RadBitmap(Application.GetResourceStream(imageUri).Stream);

            this.watermarkImage = new Image();
            this.watermarkImage.Source = new BitmapImage(imageUri);
            this.watermarkImage.Stretch = Stretch.None;

            this.watermarkCommand = new WatermarkCommand();
            this.imageRotateTransform = new RotateTransform();
            this.imageScaleTransform = new ScaleTransform();
            this.imageEditorScale = new ScaleTransform();

            TransformGroup transform = new TransformGroup();
            transform.Children.Add(this.imageRotateTransform);
            transform.Children.Add(this.imageScaleTransform);
            transform.Children.Add(this.imageEditorScale);
            this.watermarkImage.RenderTransform = transform;

            this.watermarkImage.RenderTransformOrigin = new Point(0.5, 0.5);
            this.watermarkImage.HorizontalAlignment = HorizontalAlignment.Center;
            this.watermarkImage.VerticalAlignment = VerticalAlignment.Center;

            this.settings.opacity.ValueChanged += new EventHandler(settings_ValueChanged);
            this.settings.rotation.ValueChanged += new EventHandler(settings_ValueChanged);
            this.settings.scale.ValueChanged += new EventHandler(settings_ValueChanged);

            Binding opacityBinding = new Binding("Value");
            opacityBinding.Source = this.settings.opacity;
            BindingOperations.SetBinding(this.watermarkImage, Image.OpacityProperty, opacityBinding);

            Binding rotationBinding = new Binding("Value");
            rotationBinding.Source = this.settings.rotation;
            BindingOperations.SetBinding(this.imageRotateTransform, RotateTransform.AngleProperty, rotationBinding);

            Binding scaleXBinding = new Binding("Value");
            scaleXBinding.Source = this.settings.scale;
            BindingOperations.SetBinding(this.imageScaleTransform, ScaleTransform.ScaleXProperty, scaleXBinding);

            Binding scaleYBinding = new Binding("Value");
            scaleYBinding.Source = this.settings.scale;
            BindingOperations.SetBinding(this.imageScaleTransform, ScaleTransform.ScaleYProperty, scaleYBinding);

        }