Exemple #1
0
        private void EnsureShapePropertyControlUpdated(object propertyName)
        {
            PaintDotNet.UI.FrameworkElement element;
            Property property = this.TryGetChanges().ShapePropertySchema[propertyName];

            if (!(property is DoubleVectorProperty))
            {
                throw new InternalErrorException();
            }
            if (!this.propertyNameToControlMap.TryGetValue(propertyName, out element))
            {
                CircleHandleDrawing drawing       = new CircleHandleDrawing();
                HandleElement       handleElement = new HandleElement(drawing);
                handleElement.SetBinding(DrawingElement.ScaleProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
                handleElement.SetBinding <double, PaintDotNet.UI.Thickness>(DrawingElement.PaddingProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay, new Func <double, PaintDotNet.UI.Thickness>(ShapesToolUI.GetHandlePadding));
                handleElement.SetBinding <bool, Cursor>(PaintDotNet.UI.FrameworkElement.CursorProperty, this, new PaintDotNet.ObjectModel.PropertyPath(UIElement.IsMouseCaptureWithinProperty), BindingMode.OneWay, delegate(bool imcw) {
                    if (!imcw)
                    {
                        return(this.handCursor);
                    }
                    return(this.handMouseDownCursor);
                });
                DependencyFunc <ShapesToolChanges, SizeDouble, PointDouble> func = new DependencyFunc <ShapesToolChanges, SizeDouble, PointDouble>((stc, actsz) => GetShapePropertyControlCanvasOffset(propertyName, stc, actsz));
                func.SetArgInput <ShapesToolChanges>(1, this.toolChanges);
                func.SetArgInput(2, handleElement, new PaintDotNet.ObjectModel.PropertyPath(PaintDotNet.UI.FrameworkElement.ActualSizeProperty));
                handleElement.SetBinding(PaintDotNet.UI.Controls.Canvas.LeftProperty, func, new PaintDotNet.ObjectModel.PropertyPath(func.GetValueProperty().Name + ".X", Array.Empty <object>()), BindingMode.OneWay);
                handleElement.SetBinding(PaintDotNet.UI.Controls.Canvas.TopProperty, func, new PaintDotNet.ObjectModel.PropertyPath(func.GetValueProperty().Name + ".Y", Array.Empty <object>()), BindingMode.OneWay);
                DependencyObjectTagger.Set <DependencyFunc <ShapesToolChanges, SizeDouble, PointDouble> >(handleElement, shapePropertyControlCanvasOffsetTagKey, func);
                AnimationStateHelper helper = new AnimationStateHelper {
                    Element = handleElement
                };
                helper.EnableAnimations += delegate(object <sender>, EventArgs <e>) {
                    AnimatedDouble sourceObject = new AnimatedDouble(1.0);
                    handleElement.SetBinding(UIElement.OpacityProperty, sourceObject, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
                    sourceObject.AnimateRawValue((s, v) => InitializeHandleOpacityStoryboard(s, v, 0.5), null);
                    DependencyObjectTagger.Set <AnimatedDouble>(handleElement, shapePropertyControlOpacityAnimationTagKey, sourceObject);
                };
                helper.DisableAnimations += delegate(object <sender>, EventArgs <e>) {
                    AnimatedDouble num;
                    handleElement.ClearBinding(UIElement.OpacityProperty);
                    if (DependencyObjectTagger.TryGet <AnimatedDouble>(handleElement, shapePropertyControlOpacityAnimationTagKey, out num))
                    {
                        num.StopAnimation();
                        num.Dispose();
                        DependencyObjectTagger.Remove(handleElement, shapePropertyControlOpacityAnimationTagKey);
                    }
                };
                DependencyObjectTagger.Set <AnimationStateHelper>(handleElement, shapePropertyControlOpacityAnimationStateHelperTagKey, helper);
                ClickDragBehavior.SetAllowClick(handleElement, false);
                ClickDragBehavior.SetAllowDoubleClick(handleElement, false);
                ClickDragBehavior.SetAllowDrag(handleElement, true);
                ClickDragBehavior.SetIsEnabled(handleElement, true);
                SetShapePropertyName(handleElement, propertyName);
                SetHandleType(handleElement, ShapesToolHandleType.ShapeProperty);
                base.AddVisualChild(handleElement);
                element = handleElement;
                this.propertyNameToControlMap.Add(propertyName, element);
            }
        }
Exemple #2
0
 public ColorWheel() : base(FactorySource.PerThread)
 {
     this.selectorNubBrush                = new SolidColorBrush();
     this.selectorWidth                   = 7;
     this.selectorOffset                  = 4;
     this.snapMarkBrush                   = new SolidColorBrush(new ColorRgba128Float(0f, 0f, 0f, 0.25f));
     this.snapLineBrush                   = new SolidColorBrush(new ColorRgba128Float(0f, 0f, 0f, 0.25f));
     this.lockRadiusGuideBrush            = new SolidColorBrush(new ColorRgba128Float(0f, 0f, 0f, 0.25f));
     this.lockHueGuideBrush               = new SolidColorBrush(new ColorRgba128Float(0f, 0f, 0f, 0.25f));
     this.modifierKeysCheckTimer          = new System.Windows.Forms.Timer();
     this.modifierKeysCheckTimer.Interval = 0x19;
     this.modifierKeysCheckTimer.Tick    += new EventHandler(this.OnModifierKeysCheckTimerTick);
     this.snapOpacity = new AnimatedDouble();
     this.snapOpacity.ValueChanged       += new ValueChangedEventHandler <double>(this.OnOpacityValueChanged);
     this.lockRadiusOpacity               = new AnimatedDouble();
     this.lockRadiusOpacity.ValueChanged += new ValueChangedEventHandler <double>(this.OnOpacityValueChanged);
     this.lockHueOpacity = new AnimatedDouble();
     this.lockHueOpacity.ValueChanged += new ValueChangedEventHandler <double>(this.OnOpacityValueChanged);
 }
Exemple #3
0
 public FloatingToolForm()
 {
     base.KeyPreview             = true;
     this.controlAddedDelegate   = new ControlEventHandler(this.ControlAddedHandler);
     this.controlRemovedDelegate = new ControlEventHandler(this.ControlRemovedHandler);
     this.keyUpDelegate          = new KeyEventHandler(this.KeyUpHandler);
     this.mouseEnterDelegate     = new EventHandler(this.MouseEnterHandler);
     this.mouseLeaveDelegate     = new EventHandler(this.MouseLeaveHandler);
     this.InitializeComponent();
     try
     {
         SystemEvents.SessionSwitch          += new SessionSwitchEventHandler(this.OnSystemEventsSessionSwitch);
         SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemEventsDisplaySettingsChanged);
     }
     catch (Exception)
     {
     }
     base.ControlAdded   += this.controlAddedDelegate;
     base.ControlRemoved += this.controlRemovedDelegate;
     this.opacityVariable = new AnimatedDouble(1.0);
     this.opacityVariable.ValueChanged += new ValueChangedEventHandler <double>(this.OnOpacityVariableValueChanged);
 }
Exemple #4
0
 protected virtual void OnLoaded(object sender, EventArgs e)
 {
     this.UpdateCursor();
     this.brushPreviewElementOpacity = new AnimatedDouble(1.0);
     this.brushPreviewElement.SetBinding(UIElement.OpacityProperty, this.brushPreviewElementOpacity, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
 }
        public OrcasAvalonApplicationCanvas()
        {
            Width  = DefaultWidth;
            Height = DefaultHeight;

            this.ClipToBounds = true;

            Colors.Blue.ToGradient(Colors.Black, DefaultHeight / 4).Select(
                (c, i) =>
                new Rectangle
            {
                Fill   = new SolidColorBrush(c),
                Width  = DefaultWidth,
                Height = 5,
            }.MoveTo(0, i * 4).AttachTo(this)
                ).ToArray();



            var mouse = new Image
            {
                Source = (KnownAssets.Path.Assets + "/mouse.png").ToSource(),
                Width  = 32,
                Height = 32
            }.MoveTo(0, 0).AttachTo(this);


            var img = new Image
            {
                Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource()
            }.MoveTo(DefaultWidth - 96, 0).AttachTo(this);


            var Content = new Canvas
            {
                Width  = DefaultWidth,
                Height = DefaultHeight,
            }.AttachTo(this);

            var ContentY = new AnimatedDouble(0);

            ContentY.ValueChanged += y => Content.MoveTo(0, y);

            {
                var maze   = new MazeGenerator(12, 8, null);
                var blocks = new BlockMaze(maze);
                var w      = new BlockMaze(maze);
                Colors.Black.ToGradient(Colors.Yellow, 30).ForEach(
                    (c, i) =>
                    RenderMaze(60 + i * 0.1, w, new SolidColorBrush(c), Content)
                    );
            }

            var TouchOverlay = new Rectangle
            {
                Fill    = Brushes.Yellow,
                Opacity = 0,
                Width   = DefaultWidth,
                Height  = DefaultHeight
            }.AttachTo(this);

            TouchOverlay.MouseEnter +=
                delegate
            {
                mouse.Show();
            };
            TouchOverlay.MouseLeave +=
                delegate
            {
                mouse.Hide();
            };
            TouchOverlay.Cursor     = Cursors.None;
            TouchOverlay.MouseMove +=
                (s, args) =>
            {
                var p = args.GetPosition(this);

                mouse.MoveTo(p.X - 4, p.Y - 4);
            };

            TouchOverlay.MouseLeftButtonUp +=
                (s, args) =>
            {
                var p = args.GetPosition(this);

                ShowExplosion(Convert.ToInt32(p.X), Convert.ToInt32(p.Y), Content);
                ("assets/AvalonMouseMaze/explosion.mp3").PlaySound();
                150.AtDelay(
                    delegate
                {
                    ShowExplosion(Convert.ToInt32(p.X + 6), Convert.ToInt32(p.Y - 6), Content);
                }
                    );

                300.AtDelay(
                    delegate
                {
                    ShowExplosion(Convert.ToInt32(p.X + 4), Convert.ToInt32(p.Y + 6), Content);

                    ContentY.SetTarget(DefaultHeight);
                }
                    );

                1500.AtDelay(
                    delegate
                {
                    ContentY.SetTarget(0);
                }
                    );
            };


            new GameMenuWithGames(DefaultWidth, DefaultHeight, 32).AttachContainerTo(this).Hide();
        }
 public TextCursorCanvasLayer()
 {
     this.calculateInvalidRect = new CalculateInvalidRectCallback(this.CalculateInvalidRect);
     this.opacityAnimation     = new AnimatedDouble(1.0);
 }
Exemple #7
0
        private void StartAnimation(List <Entry> List)
        {
            double y = new Random().NextDouble() * List.Count * 3;

            const double maxspeed = 0.1;
            var          aspeed   = new AnimatedDouble(-maxspeed);
            var          bspeed   = new AnimatedDouble(1);

            this.MouseEnter +=
                delegate
            {
                bspeed.SetTarget(0.4);

                foreach (var k in List)
                {
                    k.Shadow.Opacity       = 0.5;
                    k.ShadowBottom.Opacity = 0.7;
                    k.Text.Show();
                }
            };

            this.MouseLeave +=
                delegate
            {
                bspeed.SetTarget(1);

                foreach (var k in List)
                {
                    k.Shadow.Opacity       = 0;
                    k.ShadowBottom.Opacity = 0;
                    k.Text.Hide();
                }
            };

            (1000 / 30).AtInterval(
                delegate
            {
                y += aspeed.Value * bspeed.Value * 0.1;

                if (aspeed.Value > 0)
                {
                    if (y > List.Count * 3)
                    {
                        aspeed.SetTarget(maxspeed / 2);


                        300.AtDelay(
                            () => aspeed.SetTarget(-maxspeed / 2)
                            );

                        500.AtDelay(
                            () => aspeed.SetTarget(-maxspeed)
                            );
                    }
                }

                if (aspeed.Value < 0)
                {
                    if (y < 0)
                    {
                        aspeed.SetTarget(-maxspeed / 2);

                        300.AtDelay(
                            () => aspeed.SetTarget(maxspeed / 2)
                            );

                        500.AtDelay(
                            () => aspeed.SetTarget(maxspeed)
                            );
                    }
                }

                List.ForEach(
                    (Entry c, int i) =>
                {
                    if (Convert.ToInt32(Math.Floor(y)) % 4 > 1)
                    {
                        var qy = ((i + 1) * GameReferenceExtensions.Height + GameReferenceExtensions.Height * y) % (GameReferenceExtensions.Height * List.Count);
                        qy    -= GameReferenceExtensions.Height;
                        c.Canvas.MoveTo(0, qy);
                        c.TouchOverlay.MoveTo(0, qy);
                    }
                    else
                    {
                        var qx = ((i + 1) * GameReferenceExtensions.Width + GameReferenceExtensions.Width * y) % (GameReferenceExtensions.Width * List.Count);
                        qx    -= GameReferenceExtensions.Width;
                        c.Canvas.MoveTo(qx, 0);
                        c.TouchOverlay.MoveTo(qx, 0);
                    }
                }
                    );
            }
                );
        }
Exemple #8
0
 public ShapesToolUI()
 {
     this.toolChanges.ValueChanged += new ValueChangedEventHandler <ShapesToolChanges>(this.OnToolChangesChanged);
     this.toolChanges.SetBinding(this.toolChanges.GetValueProperty(), this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".Changes", Array.Empty <object>()), BindingMode.OneWay);
     this.canvasHandle = new HandleElement();
     SetHandleType(this.canvasHandle, ShapesToolHandleType.Canvas);
     this.canvasHandle.Focusable    = true;
     this.canvasHandle.ClipToBounds = false;
     ClickDragBehavior.SetAllowClick(this.canvasHandle, false);
     ClickDragBehavior.SetAllowDrag(this.canvasHandle, true);
     ClickDragBehavior.SetIsEnabled(this.canvasHandle, true);
     this.canvasHandle.SetBinding <bool, Cursor>(PaintDotNet.UI.FrameworkElement.CursorProperty, this, new PaintDotNet.ObjectModel.PropertyPath(UIElement.IsMouseCaptureWithinProperty), BindingMode.OneWay, delegate(bool imcw) {
         if (!imcw)
         {
             return(this.canvasMouseUpCursor);
         }
         return(this.canvasMouseDownCursor);
     });
     this.transformControl = new TransformControl();
     this.transformControl.HitTestPadding = 8.0;
     this.transformControl.SetBinding <TransactedToolState, bool>(TransformControl.AllowBackgroundClickProperty, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".State", Array.Empty <object>()), BindingMode.OneWay, new Func <TransactedToolState, bool>(ShapesToolUI.GetTransformControlAllowBackgroundClick));
     this.transformControl.SetBinding <bool, Cursor>(TransformControl.BackgroundCursorProperty, this, new PaintDotNet.ObjectModel.PropertyPath(UIElement.IsMouseCaptureWithinProperty), BindingMode.OneWay, delegate(bool imcw) {
         if (!imcw)
         {
             return(this.canvasMouseUpCursor);
         }
         return(this.canvasMouseDownCursor);
     });
     this.transformControl.SetBinding <SizeDouble, double>(PaintDotNet.UI.FrameworkElement.WidthProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasSizeProperty), BindingMode.OneWay, s => s.Width);
     this.transformControl.SetBinding <SizeDouble, double>(PaintDotNet.UI.FrameworkElement.HeightProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasSizeProperty), BindingMode.OneWay, s => s.Height);
     this.transformControl.SetBinding(TransformControl.HairWidthProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
     this.transformControlVisibility = new DependencyFunc <TransactedToolState, ShapesToolChanges, Visibility>(new Func <TransactedToolState, ShapesToolChanges, Visibility>(ShapesToolUI.GetTransformControlVisibility));
     this.transformControlVisibility.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".State", Array.Empty <object>()));
     this.transformControlVisibility.SetArgInput(2, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".Changes", Array.Empty <object>()));
     this.transformControl.SetBinding(UIElement.VisibilityProperty, this.transformControlVisibility, new PaintDotNet.ObjectModel.PropertyPath(this.transformControlVisibility.GetValueProperty()), BindingMode.OneWay);
     this.transformControlAreScaleHandlesVisible = new DependencyFunc <TransactedToolState, ShapesToolChanges, bool>(new Func <TransactedToolState, ShapesToolChanges, bool>(ShapesToolUI.GetTransformControlAreScaleHandlesVisible));
     this.transformControlAreScaleHandlesVisible.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".State", Array.Empty <object>()));
     this.transformControlAreScaleHandlesVisible.SetArgInput(2, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".Changes", Array.Empty <object>()));
     this.transformControl.SetBinding(TransformControl.AreScaleHandlesVisibleProperty, this.transformControlAreScaleHandlesVisible, new PaintDotNet.ObjectModel.PropertyPath(this.transformControlAreScaleHandlesVisible.GetValueProperty()), BindingMode.OneWay);
     this.transformControl.EditingBegin     += new TransformEditingBeginEventHandler(this.OnTransformControlEditingBegin);
     this.transformControl.EditingCancelled += new RoutedEventHandler(this.OnTransformControlEditingCancelled);
     this.transformControl.EditChanged      += new RoutedEventHandler(this.OnTransformControlEditChanged);
     this.transformControl.EditingFinished  += new RoutedEventHandler(this.OnTransformControlEditingFinished);
     this.startEndPointHandleVisibility      = new DependencyFunc <TransactedToolState, ShapesToolChanges, Visibility>(new Func <TransactedToolState, ShapesToolChanges, Visibility>(ShapesToolUI.GetStartEndPointHandleVisibility));
     this.startEndPointHandleVisibility.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".State", Array.Empty <object>()));
     this.startEndPointHandleVisibility.SetArgInput(2, this, new PaintDotNet.ObjectModel.PropertyPath(ToolUICanvas.ToolProperty.Name + ".Changes", Array.Empty <object>()));
     this.startPointHandle = new HandleElement(new CircleHandleDrawing());
     ClickDragBehavior.SetAllowClick(this.startPointHandle, false);
     ClickDragBehavior.SetAllowDrag(this.startPointHandle, true);
     ClickDragBehavior.SetIsEnabled(this.startPointHandle, true);
     SetHandleType(this.startPointHandle, ShapesToolHandleType.StartPoint);
     this.startPointHandle.SetBinding(UIElement.VisibilityProperty, this.startEndPointHandleVisibility, new PaintDotNet.ObjectModel.PropertyPath(this.startEndPointHandleVisibility.GetValueProperty()), BindingMode.OneWay);
     this.startPointHandle.SetBinding <bool, Cursor>(PaintDotNet.UI.FrameworkElement.CursorProperty, this, new PaintDotNet.ObjectModel.PropertyPath(UIElement.IsMouseCaptureWithinProperty), BindingMode.OneWay, delegate(bool imcw) {
         if (!imcw)
         {
             return(this.handCursor);
         }
         return(this.handMouseDownCursor);
     });
     this.startPointCanvasOffset = new DependencyFunc <ShapesToolChanges, SizeDouble, PointDouble>((ch, actsz) => GetStartEndPointHandleCanvasOffset(ShapesToolHandleType.StartPoint, ch, actsz));
     this.startPointCanvasOffset.SetArgInput <ShapesToolChanges>(1, this.toolChanges);
     this.startPointCanvasOffset.SetArgInput(2, this.startPointHandle, new PaintDotNet.ObjectModel.PropertyPath(PaintDotNet.UI.FrameworkElement.ActualSizeProperty));
     this.startPointHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.LeftProperty, this.startPointCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath(this.startPointCanvasOffset.GetValueProperty().Name + ".X", Array.Empty <object>()), BindingMode.OneWay);
     this.startPointHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.TopProperty, this.startPointCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath(this.startPointCanvasOffset.GetValueProperty().Name + ".Y", Array.Empty <object>()), BindingMode.OneWay);
     this.startPointHandle.SetBinding(DrawingElement.ScaleProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
     this.startPointHandle.SetBinding <double, PaintDotNet.UI.Thickness>(DrawingElement.PaddingProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay, new Func <double, PaintDotNet.UI.Thickness>(ShapesToolUI.GetHandlePadding));
     this.startPointAnimationHelper                   = new AnimationStateHelper();
     this.startPointAnimationHelper.Element           = this.startPointHandle;
     this.startPointAnimationHelper.EnableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.startPointOpacity = new AnimatedDouble(1.0);
         this.startPointHandle.SetBinding(UIElement.OpacityProperty, this.startPointOpacity, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
         this.startPointOpacity.AnimateRawValue((s, v) => InitializeHandleOpacityStoryboard(s, v, 0.0), null);
     };
     this.startPointAnimationHelper.DisableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.startPointHandle.ClearBinding(UIElement.OpacityProperty);
         DisposableUtil.Free <AnimatedDouble>(ref this.startPointOpacity);
     };
     this.endPointHandle = new HandleElement(new CircleHandleDrawing());
     ClickDragBehavior.SetAllowClick(this.endPointHandle, false);
     ClickDragBehavior.SetAllowDrag(this.endPointHandle, true);
     ClickDragBehavior.SetIsEnabled(this.endPointHandle, true);
     SetHandleType(this.endPointHandle, ShapesToolHandleType.EndPoint);
     this.endPointHandle.SetBinding(UIElement.VisibilityProperty, this.startEndPointHandleVisibility, new PaintDotNet.ObjectModel.PropertyPath(this.startEndPointHandleVisibility.GetValueProperty()), BindingMode.OneWay);
     this.endPointHandle.SetBinding <bool, Cursor>(PaintDotNet.UI.FrameworkElement.CursorProperty, this, new PaintDotNet.ObjectModel.PropertyPath(UIElement.IsMouseCaptureWithinProperty), BindingMode.OneWay, delegate(bool imcw) {
         if (!imcw)
         {
             return(this.handCursor);
         }
         return(this.handMouseDownCursor);
     });
     this.endPointCanvasOffset = new DependencyFunc <ShapesToolChanges, SizeDouble, PointDouble>((ch, actsz) => GetStartEndPointHandleCanvasOffset(ShapesToolHandleType.EndPoint, ch, actsz));
     this.endPointCanvasOffset.SetArgInput <ShapesToolChanges>(1, this.toolChanges);
     this.endPointCanvasOffset.SetArgInput(2, this.endPointHandle, new PaintDotNet.ObjectModel.PropertyPath(PaintDotNet.UI.FrameworkElement.ActualSizeProperty));
     this.endPointHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.LeftProperty, this.endPointCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath(this.endPointCanvasOffset.GetValueProperty().Name + ".X", Array.Empty <object>()), BindingMode.OneWay);
     this.endPointHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.TopProperty, this.endPointCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath(this.endPointCanvasOffset.GetValueProperty().Name + ".Y", Array.Empty <object>()), BindingMode.OneWay);
     this.endPointHandle.SetBinding(DrawingElement.ScaleProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
     this.endPointHandle.SetBinding <double, PaintDotNet.UI.Thickness>(DrawingElement.PaddingProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay, new Func <double, PaintDotNet.UI.Thickness>(ShapesToolUI.GetHandlePadding));
     this.endPointAnimationHelper                   = new AnimationStateHelper();
     this.endPointAnimationHelper.Element           = this.endPointHandle;
     this.endPointAnimationHelper.EnableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.endPointOpacity = new AnimatedDouble(1.0);
         this.endPointHandle.SetBinding(UIElement.OpacityProperty, this.endPointOpacity, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
         this.endPointOpacity.AnimateRawValue((s, v) => InitializeHandleOpacityStoryboard(s, v, 0.5), null);
     };
     this.endPointAnimationHelper.DisableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.endPointHandle.ClearBinding(UIElement.OpacityProperty);
         DisposableUtil.Free <AnimatedDouble>(ref this.endPointOpacity);
     };
     base.Children.Add(this.canvasHandle);
     base.Children.Add(this.transformControl);
     base.Children.Add(this.startPointHandle);
     base.Children.Add(this.endPointHandle);
     base.Loaded   += new EventHandler(this.OnLoaded);
     base.Unloaded += new EventHandler(this.OnUnloaded);
 }
Exemple #9
0
 public GradientToolUI()
 {
     SetHandleType(this.canvasHandle, GradientToolHandleType.Canvas);
     this.canvasHandle.ClipToBounds = false;
     ClickDragBehavior.SetAllowClick(this.canvasHandle, false);
     this.startHandle = new HandleElement(new CircleHandleDrawing());
     SetHandleType(this.startHandle, GradientToolHandleType.Start);
     this.startHandle.SetBinding <TransactedToolState, Visibility>(UIElement.VisibilityProperty, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.State", Array.Empty <object>()), BindingMode.OneWay, new Func <TransactedToolState, Visibility>(GradientToolUI.GetHandleVisibility));
     this.startHandleCanvasOffset = new DependencyFunc <PointDouble, SizeDouble, PointDouble>(new Func <PointDouble, SizeDouble, PointDouble>(GradientToolUI.GetHandleCanvasOffset));
     this.startHandleCanvasOffset.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.Changes.GradientStartPoint", Array.Empty <object>()));
     this.startHandleCanvasOffset.SetArgInput(2, this.startHandle, new PaintDotNet.ObjectModel.PropertyPath(PaintDotNet.UI.FrameworkElement.ActualSizeProperty.Name, Array.Empty <object>()));
     this.startHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.LeftProperty, this.startHandleCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath("Value.X", Array.Empty <object>()), BindingMode.OneWay);
     this.startHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.TopProperty, this.startHandleCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath("Value.Y", Array.Empty <object>()), BindingMode.OneWay);
     this.startHandle.SetBinding(DrawingElement.ScaleProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
     this.startHandle.SetBinding <double, PaintDotNet.UI.Thickness>(DrawingElement.PaddingProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay, new Func <double, PaintDotNet.UI.Thickness>(GradientToolUI.GetHandlePadding));
     this.startHandleOpacityHelper                   = new AnimationStateHelper();
     this.startHandleOpacityHelper.Element           = this.startHandle;
     this.startHandleOpacityHelper.EnableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.startHandleOpacity = new AnimatedDouble(1.0);
         this.startHandle.SetBinding(UIElement.OpacityProperty, this.startHandleOpacity, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
         this.startHandleOpacity.AnimateRawValue((s, v) => InitializeHandleOpacityStoryboard(s, v, 0.0), null);
     };
     this.startHandleOpacityHelper.DisableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.startHandle.ClearBinding(UIElement.OpacityProperty);
         DisposableUtil.Free <AnimatedDouble>(ref this.startHandleOpacity);
     };
     this.endHandle = new HandleElement(new CircleHandleDrawing());
     SetHandleType(this.endHandle, GradientToolHandleType.End);
     this.endHandle.SetBinding <TransactedToolState, Visibility>(UIElement.VisibilityProperty, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.State", Array.Empty <object>()), BindingMode.OneWay, new Func <TransactedToolState, Visibility>(GradientToolUI.GetHandleVisibility));
     this.endHandleCanvasOffset = new DependencyFunc <PointDouble, SizeDouble, PointDouble>(new Func <PointDouble, SizeDouble, PointDouble>(GradientToolUI.GetHandleCanvasOffset));
     this.endHandleCanvasOffset.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.Changes.GradientEndPoint", Array.Empty <object>()));
     this.endHandleCanvasOffset.SetArgInput(2, this.endHandle, new PaintDotNet.ObjectModel.PropertyPath(PaintDotNet.UI.FrameworkElement.ActualSizeProperty.Name, Array.Empty <object>()));
     this.endHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.LeftProperty, this.endHandleCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath("Value.X", Array.Empty <object>()), BindingMode.OneWay);
     this.endHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.TopProperty, this.endHandleCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath("Value.Y", Array.Empty <object>()), BindingMode.OneWay);
     this.endHandle.SetBinding(DrawingElement.ScaleProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
     this.endHandle.SetBinding <double, PaintDotNet.UI.Thickness>(DrawingElement.PaddingProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay, new Func <double, PaintDotNet.UI.Thickness>(GradientToolUI.GetHandlePadding));
     this.endHandleOpacityHelper                   = new AnimationStateHelper();
     this.endHandleOpacityHelper.Element           = this.endHandle;
     this.endHandleOpacityHelper.EnableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.endHandleOpacity = new AnimatedDouble(1.0);
         this.endHandle.SetBinding(UIElement.OpacityProperty, this.endHandleOpacity, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
         this.endHandleOpacity.AnimateRawValue((s, v) => InitializeHandleOpacityStoryboard(s, v, 0.33333333333333331), null);
     };
     this.endHandleOpacityHelper.DisableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.endHandle.ClearBinding(UIElement.OpacityProperty);
         DisposableUtil.Free <AnimatedDouble>(ref this.endHandleOpacity);
     };
     this.moveHandle = new HandleElement(new CompassHandleDrawing());
     SetHandleType(this.moveHandle, GradientToolHandleType.Move);
     this.moveHandle.SetBinding <TransactedToolState, Visibility>(UIElement.VisibilityProperty, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.State", Array.Empty <object>()), BindingMode.OneWay, new Func <TransactedToolState, Visibility>(GradientToolUI.GetHandleVisibility));
     this.moveHandle.RenderTransformOrigin = new PointDouble(0.5, 0.5);
     this.moveHandleCanvasOffset           = new DependencyFunc <PointDouble, PointDouble, double, SizeDouble, PointDouble>(new Func <PointDouble, PointDouble, double, SizeDouble, PointDouble>(GradientToolUI.GetMoveHandleCanvasOffset));
     this.moveHandleCanvasOffset.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.Changes.GradientStartPoint", Array.Empty <object>()));
     this.moveHandleCanvasOffset.SetArgInput(2, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.Changes.GradientEndPoint", Array.Empty <object>()));
     this.moveHandleCanvasOffset.SetArgInput(3, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty));
     this.moveHandleCanvasOffset.SetArgInput(4, this.moveHandle, new PaintDotNet.ObjectModel.PropertyPath(PaintDotNet.UI.FrameworkElement.ActualSizeProperty.Name, Array.Empty <object>()));
     this.moveHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.LeftProperty, this.moveHandleCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath("Value.X", Array.Empty <object>()), BindingMode.OneWay);
     this.moveHandle.SetBinding(PaintDotNet.UI.Controls.Canvas.TopProperty, this.moveHandleCanvasOffset, new PaintDotNet.ObjectModel.PropertyPath("Value.Y", Array.Empty <object>()), BindingMode.OneWay);
     this.moveHandle.SetBinding(DrawingElement.ScaleProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay);
     this.moveHandle.SetBinding <double, PaintDotNet.UI.Thickness>(DrawingElement.PaddingProperty, this, PropertyPathUtil.Combine(ToolUICanvas.CanvasViewProperty, CanvasView.CanvasHairWidthProperty), BindingMode.OneWay, new Func <double, PaintDotNet.UI.Thickness>(GradientToolUI.GetHandlePadding));
     this.moveHandleOpacityHelper                   = new AnimationStateHelper();
     this.moveHandleOpacityHelper.Element           = this.moveHandle;
     this.moveHandleOpacityHelper.EnableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.moveHandleOpacity = new AnimatedDouble(1.0);
         this.moveHandle.SetBinding(UIElement.OpacityProperty, this.moveHandleOpacity, new PaintDotNet.ObjectModel.PropertyPath(AnimatedValue <double> .ValuePropertyName, Array.Empty <object>()), BindingMode.OneWay);
         this.moveHandleOpacity.AnimateRawValue((s, v) => InitializeHandleOpacityStoryboard(s, v, 0.66666666666666663), null);
     };
     this.moveHandleOpacityHelper.DisableAnimations += delegate(object <sender>, EventArgs <e>) {
         this.moveHandle.ClearBinding(UIElement.OpacityProperty);
         DisposableUtil.Free <AnimatedDouble>(ref this.moveHandleOpacity);
     };
     this.handles = new HandleElement[] { this.canvasHandle, this.startHandle, this.endHandle, this.moveHandle };
     foreach (HandleElement element in this.handles)
     {
         ClickDragBehavior.SetIsEnabled(element, true);
         base.Children.Add(element);
     }
     this.handCursor               = CursorUtil.LoadResource("Cursors.PanToolCursor.cur");
     this.handMouseDownCursor      = CursorUtil.LoadResource("Cursors.PanToolCursorMouseDown.cur");
     this.crosshairCursor          = CursorUtil.LoadResource("Cursors.GenericToolCursor.cur");
     this.crosshairMouseDownCursor = CursorUtil.LoadResource("Cursors.GenericToolCursorMouseDown.cur");
     this.canvasHandle.Cursor      = this.crosshairCursor;
     for (int i = 1; i < this.handles.Length; i++)
     {
         this.handles[i].SetBinding <TransactedToolState, Cursor>(PaintDotNet.UI.FrameworkElement.CursorProperty, this, new PaintDotNet.ObjectModel.PropertyPath("Tool.State", Array.Empty <object>()), BindingMode.OneWay, new Func <TransactedToolState, Cursor>(this.GetHandleCursor));
     }
 }