Inheritance: Observable, IDisposable
コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: cugayck5/stuart
        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;
        }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: cugayck5/stuart
        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;
        }
コード例 #3
0
ファイル: Photo.cs プロジェクト: cugayck5/stuart
        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);
        }
コード例 #4
0
ファイル: Effect.cs プロジェクト: shawnhar/stuart
        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;
        }
コード例 #5
0
ファイル: Effect.cs プロジェクト: cugayck5/stuart
        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);
        }
コード例 #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);
        }
コード例 #7
0
ファイル: EditGroup.cs プロジェクト: shawnhar/stuart
        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;
        }
コード例 #8
0
ファイル: Effect.cs プロジェクト: shawnhar/stuart
 public Effect(EditGroup parent)
 {
     Parent = parent;
 }
コード例 #9
0
ファイル: MainPage.xaml.cs プロジェクト: shawnhar/stuart
        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;
        }
コード例 #10
0
ファイル: MainPage.xaml.cs プロジェクト: shawnhar/stuart
        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;
        }
コード例 #11
0
ファイル: Effect.cs プロジェクト: cugayck5/stuart
 public Effect(EditGroup parent)
 {
     Parent = parent;
 }