Inheritance: Observable, IDisposable
        void NewEffect_Click(object sender, RoutedEventArgs e)
        {
            var edit = (EditGroup)DataContext;

            var newEffect = new Effect(edit);

            edit.Effects.Add(newEffect);
            edit.Parent.SelectedEffect = newEffect;
        }
Beispiel #2
0
        public async Task Load(CanvasDevice device, StorageFile file)
        {
            using (var stream = await file.OpenReadAsync())
            {
                SourceBitmap = await CanvasBitmap.LoadAsync(device, stream);
            }

            bitmapFormat = sourceBitmap.Format;
            bitmapData = sourceBitmap.GetPixelBytes();

            Size = sourceBitmap.Size.ToVector2();

            Edits.Clear();
            Edits.Add(new EditGroup(this));

            SelectedEffect = null;
        }
Beispiel #3
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;
        }