コード例 #1
0
        public RectangleWatermarkViewModel(WindowViewModel parent)
            : base(parent)
        {
            this.HorizontalAlignment = HorizontalAlignment.Stretch;
            this.VerticalAlignment   = VerticalAlignment.Stretch;

            this.ClearHeight = ReactiveUI.ReactiveCommand.Create(() => this.Height = null);
            this.ClearWidth  = ReactiveUI.ReactiveCommand.Create(() => this.Width = null);
        }
コード例 #2
0
        public void SetupCommands(WindowViewModel parent)
        {
            this.Remove = ReactiveUI.ReactiveCommand.Create(() => parent.Watermarks.Remove(this));

            this.MoveDown = ReactiveUI.ReactiveCommand.Create(() =>
            {
                parent.MoveRequested(1, this);
            });

            this.MoveUp = ReactiveUI.ReactiveCommand.Create(() =>
            {
                parent.MoveRequested(-1, this);
            });
        }
コード例 #3
0
        public ImageWatermarkViewModel(string path, WindowViewModel parent)
            : base(parent)
        {
            this.Path = path;

            if (path.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase) ||
                path.EndsWith(".jpeg", StringComparison.InvariantCultureIgnoreCase))
            {
                var img = new MagickImage(path);
                img.AutoOrient();   // Fix orientation
                img.Strip();        // remove all EXIF information

                var memoryStream = new MemoryStream();
                img.Write(memoryStream);
                img.Dispose();

                memoryStream.Position = 0;

                var image = new BitmapImage();
                image.BeginInit();
                image.CacheOption  = BitmapCacheOption.OnLoad;
                image.StreamSource = memoryStream;
                image.EndInit();

                this.Image = image;
            }
            else
            {
                this.Image = new BitmapImage(new Uri(path));
            }

            this.HorizontalAlignment = HorizontalAlignment.Left;
            this.VerticalAlignment   = VerticalAlignment.Bottom;
            this.Zoom   = 1.0;
            this.Margin = 20.0;
        }
コード例 #4
0
 public WatermarkViewModelBase(WindowViewModel parent)
 {
     this.SetupCommands(parent);
 }
コード例 #5
0
 public TextWatermarkViewModel(WindowViewModel parent)
     : base(parent)
 {
     this.Colour = Colors.Black;
     this.Text   = "New Text";
 }