Inheritance: Observable, IDisposable
Beispiel #1
0
        void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            if (editingRegion == null)
            {
                return;
            }

            try
            {
                editingRegion.EditRegionMask(regionPoints, scrollView.ZoomFactor);
            }
            catch (Exception exception) when(canvas.Device.IsDeviceLost(exception.HResult))
            {
                canvas.Device.RaiseDeviceLost();
            }

            editingRegion = null;
            regionPoints.Clear();

            // Restore the manipulation mode so input goes to the parent ScrollViewer again.
            canvas.ManipulationMode = ManipulationModes.System;
            canvas.ReleasePointerCapture(e.Pointer);

            canvas.Invalidate();
            e.Handled = true;
        }
Beispiel #2
0
        void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (editingRegion != null)
            {
                return;
            }

            // If any of the edit groups is in edit region mode, set that as our current region.
            editingRegion = photo.Edits.SingleOrDefault(edit => edit.IsEditingRegion);

            if (editingRegion == null)
            {
                return;
            }

            // Add the start point.
            regionPoints.Add(ConvertDipsToPixels(e.GetCurrentPoint(canvas)));

            // Set the manipulation mode so we grab all input, bypassing our parent ScrollViewer.
            canvas.ManipulationMode = ManipulationModes.All;
            canvas.CapturePointer(e.Pointer);

            cachedImage.Reset();

            canvas.Invalidate();
            e.Handled = true;
        }
Beispiel #3
0
        public void RestoreSuspendedState(CanvasDevice device, BinaryReader reader)
        {
            bitmapFormat = (DirectXPixelFormat)reader.ReadInt32();
            bitmapData   = reader.ReadByteArray();

            Size = reader.ReadVector2();

            reader.ReadCollection(Edits, () => EditGroup.RestoreSuspendedState(this, reader));

            RecoverAfterDeviceLost(device);
        }
Beispiel #4
0
        public static Effect RestoreSuspendedState(EditGroup parent, BinaryReader reader)
        {
            var effect = new Effect(parent);

            effect.IsEnabled = reader.ReadBoolean();
            effect.Type = (EffectType)reader.ReadInt32();

            reader.ReadCollection(effect.parameters, () =>
            {
                string key = reader.ReadString();
                object value;

                switch (reader.ReadString())
                {
                    case "Single":
                        value = reader.ReadSingle();
                        break;

                    case "Int32":
                        value = reader.ReadInt32();
                        break;

                    case "Boolean":
                        value = reader.ReadBoolean();
                        break;

                    case "Color":
                        value = reader.ReadColor();
                        break;

                    case "Rect":
                        value = reader.ReadRect();
                        break;

                    default:
                        throw new NotImplementedException();
                }

                return new KeyValuePair<string, object>(key, value);
            });

            return effect;
        }
Beispiel #5
0
        public static Effect RestoreSuspendedState(EditGroup parent, BinaryReader reader)
        {
            var effect = new Effect(parent);

            effect.IsEnabled = reader.ReadBoolean();
            effect.Type      = (EffectType)reader.ReadInt32();

            reader.ReadCollection(effect.parameters, () =>
            {
                string key = reader.ReadString();
                object value;

                switch (reader.ReadString())
                {
                case "Single":
                    value = reader.ReadSingle();
                    break;

                case "Int32":
                    value = reader.ReadInt32();
                    break;

                case "Boolean":
                    value = reader.ReadBoolean();
                    break;

                case "Color":
                    value = reader.ReadColor();
                    break;

                case "Rect":
                    value = reader.ReadRect();
                    break;

                default:
                    throw new NotImplementedException();
                }

                return(new KeyValuePair <string, object>(key, value));
            });

            return(effect);
        }
Beispiel #6
0
        public static EditGroup RestoreSuspendedState(Photo parent, BinaryReader reader)
        {
            var group = new EditGroup(parent);

            group.IsEnabled                = reader.ReadBoolean();
            group.IsEditingRegion          = reader.ReadBoolean();
            group.ShowRegion               = reader.ReadBoolean();
            group.RegionSelectionMode      = (SelectionMode)reader.ReadInt32();
            group.RegionSelectionOperation = (SelectionOperation)reader.ReadInt32();
            group.RegionFeather            = reader.ReadSingle();
            group.RegionDilate             = reader.ReadInt32();
            group.CanUndo = reader.ReadBoolean();

            group.currentRegionMask  = reader.ReadByteArray();
            group.previousRegionMask = reader.ReadByteArray();

            reader.ReadCollection(group.Effects, () => Effect.RestoreSuspendedState(group, reader));

            return(group);
        }
Beispiel #7
0
        public static EditGroup RestoreSuspendedState(Photo parent, BinaryReader reader)
        {
            var group = new EditGroup(parent);

            group.IsEnabled = reader.ReadBoolean();
            group.IsEditingRegion = reader.ReadBoolean();
            group.ShowRegion = reader.ReadBoolean();
            group.RegionSelectionMode = (SelectionMode)reader.ReadInt32();
            group.RegionSelectionOperation = (SelectionOperation)reader.ReadInt32();
            group.RegionFeather = reader.ReadSingle();
            group.RegionDilate = reader.ReadInt32();
            group.CanUndo = reader.ReadBoolean();

            group.currentRegionMask = reader.ReadByteArray();
            group.previousRegionMask = reader.ReadByteArray();

            reader.ReadCollection(group.Effects, () => Effect.RestoreSuspendedState(group, reader));

            return group;
        }
Beispiel #8
0
 public Effect(EditGroup parent)
 {
     Parent = parent;
 }
Beispiel #9
0
        void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            if (editingRegion == null)
                return;

            try
            {
                editingRegion.EditRegionMask(regionPoints, scrollView.ZoomFactor);
            }
            catch (Exception exception) when (canvas.Device.IsDeviceLost(exception.HResult))
            {
                canvas.Device.RaiseDeviceLost();
            }

            editingRegion = null;
            regionPoints.Clear();

            // Restore the manipulation mode so input goes to the parent ScrollViewer again.
            canvas.ManipulationMode = ManipulationModes.System;
            canvas.ReleasePointerCapture(e.Pointer);

            canvas.Invalidate();
            e.Handled = true;
        }
Beispiel #10
0
        void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (editingRegion != null)
                return;

            // If any of the edit groups is in edit region mode, set that as our current region.
            editingRegion = photo.Edits.SingleOrDefault(edit => edit.IsEditingRegion);

            if (editingRegion == null)
                return;

            // Add the start point.
            regionPoints.Add(ConvertDipsToPixels(e.GetCurrentPoint(canvas)));

            // Set the manipulation mode so we grab all input, bypassing our parent ScrollViewer.
            canvas.ManipulationMode = ManipulationModes.All;
            canvas.CapturePointer(e.Pointer);

            cachedImage.Reset();

            canvas.Invalidate();
            e.Handled = true;
        }
Beispiel #11
0
 public Effect(EditGroup parent)
 {
     Parent = parent;
 }