public SurfaceBackgroundChangeMemento(Surface surface, Matrix matrix) {
			_surface = surface;
			_image = surface.Image;
			_matrix = matrix.Clone();
			// Make sure the reverse is applied
			_matrix.Invert();
		}
		/// <summary>
		/// Constructor
		/// </summary>
		public FreehandContainer(Surface parent) : base(parent) {
			Init();
			Width = parent.Width;
			Height = parent.Height;
			Top = 0;
			Left = 0;
		}
Exemple #3
0
 public FilterContainer(Surface parent)
     : base(parent)
 {
     AddField(GetType(), FieldType.LINE_THICKNESS, 0);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.SHADOW, false);
 }
 public EllipseContainer(Surface parent)
     : base(parent)
 {
     AddField(GetType(), FieldType.LINE_THICKNESS, 2);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
     AddField(GetType(), FieldType.SHADOW, true);
 }
 public LineContainer(Surface parent)
     : base(parent)
 {
     Init();
     AddField(GetType(), FieldType.LINE_THICKNESS, 1);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.SHADOW, false);
 }
 public HighlightContainer(Surface parent)
     : base(parent)
 {
     AddField(GetType(), FieldType.LINE_THICKNESS, 0);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.SHADOW, false);
     AddField(GetType(), FieldType.PREPARED_FILTER_HIGHLIGHT, FilterContainer.PreparedFilter.TEXT_HIGHTLIGHT);
     init();
 }
 public ArrowContainer(Surface parent)
     : base(parent)
 {
     AddField(GetType(), FieldType.ARROWHEADS, 2);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
     AddField(GetType(), FieldType.SHADOW, true);
     AddField(GetType(), FieldType.ARROWHEADS, Greenshot.Drawing.ArrowContainer.ArrowHeadCombination.END_POINT);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public FreehandContainer(Surface parent)
     : base(parent)
 {
     Init();
     AddField(GetType(), FieldType.LINE_THICKNESS, 3);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     Width = parent.Width;
     Height = parent.Height;
     Top = 0;
     Left = 0;
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (image != null)
         {
             image.Dispose();
             image = null;
         }
         surface = null;
     }
 }
		protected virtual void Dispose(bool disposing) {
			if (disposing) {
				if (_matrix != null) {
					_matrix.Dispose();
					_matrix = null;
				}
				if (_image != null) {
					_image.Dispose();
					_image = null;
				}
				_surface = null;
			}
		}
 public TextContainer(Surface parent)
     : base(parent)
 {
     Init();
     AddField(GetType(), FieldType.LINE_THICKNESS, 2);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.SHADOW, true);
     AddField(GetType(), FieldType.FONT_ITALIC, false);
     AddField(GetType(), FieldType.FONT_BOLD, false);
     AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
     AddField(GetType(), FieldType.FONT_FAMILY, FontFamily.GenericSansSerif.Name);
     AddField(GetType(), FieldType.FONT_SIZE, 11f);
 }
        public ImageEditorForm()
        {
            InitializeComponent();

            surface = new Surface();
            surface.SizeMode = PictureBoxSizeMode.AutoSize;
            surface.TabStop = false;
            surface.MovingElementChanged += new SurfaceElementEventHandler(surfaceMovingElementChanged);
            panel1.Controls.Add(surface);

            this.colorDialog.RecentColors = conf.Editor_RecentColors;

            UpdateFormControls();
        }
Exemple #13
0
 public TextContainer(Surface parent)
     : base(parent)
 {
     Init();
     AddField(GetType(), FieldType.LINE_THICKNESS, 2);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.SHADOW, true);
     AddField(GetType(), FieldType.FONT_ITALIC, false);
     AddField(GetType(), FieldType.FONT_BOLD, false);
     AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
     AddField(GetType(), FieldType.FONT_FAMILY, FontFamily.GenericSansSerif.Name);
     AddField(GetType(), FieldType.FONT_SIZE, 11f);
     AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, HorizontalAlignment.Center);
     AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, VerticalAlignment.CENTER);
     stringFormat = new StringFormat();
     stringFormat.Trimming = StringTrimming.EllipsisWord;
 }
		public void Test()
		{

			FieldType t = FieldType.LINE_THICKNESS;

			Surface s = new Surface();
			FieldAggregator ep = new FieldAggregator();
			//ep.SetFieldValue(t,598);

			RectangleContainer rc = new RectangleContainer(s);
			rc.SetFieldValue(t,597);
			//Assert.AreNotEqual(ep.GetField(t), rc.GetField(t));
			ep.BindElement(rc);
			Assert.AreEqual(597, ep.GetField(t).Value);
			Assert.AreEqual(597, rc.GetField(t).Value);
			
			RectangleContainer rc2 = new RectangleContainer(s);
			Assert.AreEqual(597, ep.GetField(t).Value);
			rc2.SetFieldValue(t,595);
			Assert.AreEqual(595, rc2.GetField(t).Value);
			ep.BindElement(rc2);
			Assert.AreEqual(595, ep.GetField(t).Value);
			Assert.AreEqual(597, rc.GetField(t).Value);
			
			RectangleContainer rc3 = new RectangleContainer(s);
			rc3.SetFieldValue(t,600);
			ep.BindElement(rc3);
			
			//Assert.AreEqual(600, ep.GetField(t).Value);
			Assert.AreEqual(600, rc3.GetField(t).Value);
			Assert.AreEqual(597, rc.GetField(t).Value);
			
			ep.SetFieldValue(t, 599);
			Assert.AreEqual(599, ep.GetField(t).Value);
			Assert.AreEqual(599, rc.GetField(t).Value);
			Assert.AreEqual(599, rc2.GetField(t).Value);
			Assert.AreEqual(599, rc3.GetField(t).Value);
			
			
			
			
			
		}
Exemple #15
0
        public static Image AnnotateImage(Image img, string imgPath, bool allowSave, string configPath,
            Action<Image> clipboardCopyRequested,
            Action<Image> imageUploadRequested,
            Action<Image, string> imageSaveRequested,
            Func<Image, string, string> imageSaveAsRequested,
            Action<Image> printImageRequested)
        {
            if (!IniConfig.isInitialized)
            {
                IniConfig.AllowSave = allowSave;
                IniConfig.Init(configPath);
            }

            using (Image cloneImage = img != null ? (Image)img.Clone() : LoadImage(imgPath))
            using (ICapture capture = new Capture { Image = cloneImage })
            using (Surface surface = new Surface(capture))
            using (ImageEditorForm editor = new ImageEditorForm(surface, true))
            {
                editor.IsTaskWork = img != null;
                editor.SetImagePath(imgPath);
                editor.ClipboardCopyRequested += clipboardCopyRequested;
                editor.ImageUploadRequested += imageUploadRequested;
                editor.ImageSaveRequested += imageSaveRequested;
                editor.ImageSaveAsRequested += imageSaveAsRequested;
                editor.PrintImageRequested += printImageRequested;

                DialogResult result = editor.ShowDialog();

                if (result == DialogResult.OK && editor.IsTaskWork)
                {
                    using (img)
                    {
                        return editor.GetImageForExport();
                    }
                }

                if (result == DialogResult.Abort)
                {
                    return null;
                }
            }

            return img;
        }
 public SurfaceBackgroundChangeMemento(Surface surface, Point offset)
 {
     this.surface = surface;
     image = surface.Image;
     this.offset = new Point(-offset.X, -offset.Y);
 }
Exemple #17
0
		protected virtual void SwitchParent(Surface newParent) {
			// Target gripper
			if (_parent != null && _targetGripper != null) {
				_parent.Controls.Remove(_targetGripper);
			}
			// Normal grippers
			if (_parent != null && _grippers != null) {
				for (int i=0; i<_grippers.Length; i++) {
					_parent.Controls.Remove(_grippers[i]);
				}
			} else if (_grippers == null) {
				InitControls();
			}
			_parent = newParent;
			// Target gripper
			if (_parent != null && _targetGripper != null) {
				_parent.Controls.Add(_targetGripper);
			}
			// Normal grippers
			if (_grippers != null) {
				_parent.Controls.AddRange(_grippers);				
			}

			foreach(IFilter filter in Filters) {
				filter.Parent = this;
			}
		}
 public CursorContainer(Surface parent, string filename)
     : base(parent)
 {
     Load(filename);
 }
Exemple #19
0
		public FilterContainer(Surface parent) : base(parent) {
		}
Exemple #20
0
		protected virtual void Dispose(bool disposing) {
			//if (disposing) { }
			drawableContainer = null;
			surface = null;
		}
Exemple #21
0
 public RectangleContainer(Surface parent) : base(parent)
 {
 }
Exemple #22
0
 public CropContainer(Surface parent) : base(parent)
 {
 }
 public IconContainer(Surface parent, string filename)
     : base(parent)
 {
     Load(filename);
 }
Exemple #24
0
 public TextContainer(Surface parent)
     : base(parent)
 {
     Init();
 }
 public IconContainer(Surface parent)
     : base(parent)
 {
 }
 public ObfuscateContainer(Surface parent)
     : base(parent)
 {
     AddField(GetType(), FieldType.PREPARED_FILTER_OBFUSCATE, PreparedFilter.PIXELIZE);
     init();
 }
Exemple #27
0
 public BitmapContainer(Surface parent, string filename) : this(parent) {
     AddField(GetType(), FieldType.SHADOW, false);
     Load(filename);
 }
 public DrawableContainer(Surface parent)
 {
     InitializeFields();
     _parent = parent;
     InitControls();
 }
 public EllipseContainer(Surface parent) : base(parent)
 {
 }
        public ImageEditorForm(Surface surface, bool outputMade)
        {
            //
             // The InitializeComponent() call is required for Windows Forms designer support.
             //
             InitializeComponent();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
             Image backgroundForTransparency = (Image)resources.GetObject("checkerboard.Image");
             surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
             // Make sure Double-buffer is enabled
             SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

             // Intial "saved" flag for asking if the image needs to be save
             surface.Modified = !outputMade;

             // resizing the panel is futile, since it is docked. however, it seems
             // to fix the bug (?) with the vscrollbar not being able to shrink to
             // a smaller size than the initial panel size (as set by the forms designer)
             panel1.Height = 10;

             // init surface
             this.surface = surface;
             surface.TabStop = false;

             surface.MovingElementChanged += delegate { refreshEditorControls(); };
             surface.DrawingModeChanged += new SurfaceDrawingModeEventHandler(surface_DrawingModeChanged);
             surface.SurfaceSizeChanged += new SurfaceSizeChangeEventHandler(SurfaceSizeChanged);

             this.fontFamilyComboBox.PropertyChanged += new PropertyChangedEventHandler(FontPropertyChanged);

             surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler(FieldAggregatorFieldChanged);
             obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
             highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;

             panel1.Controls.Add(surface);

             lang = Language.GetInstance();

             // Make sure the editor is placed on the same location as the last editor was on close
             WindowDetails thisForm = new WindowDetails(this.Handle);
             thisForm.SetWindowPlacement(editorConfiguration.GetEditorPlacement());

             SurfaceSizeChanged(this.Surface);

             updateUI();
             IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

             bindFieldControls();
             refreshEditorControls();
             // Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it.
             hideToolstripItems();

             toolbarButtons = new ToolStripButton[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
             //toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};

             PluginHelper.instance.CreateImageEditorOpenEvent(this);
             pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;

             emailToolStripMenuItem.Enabled = EmailConfigHelper.HasMAPI() || EmailConfigHelper.HasOutlook();

             // Workaround: for the MouseWheel event which doesn't get to the panel
             this.MouseWheel += new MouseEventHandler(PanelMouseWheel);
        }
Exemple #31
0
 public SpeechbubbleContainer(Surface parent)
     : base(parent)
 {
 }
Exemple #32
0
 public EllipseContainer(Surface parent)
     : base(parent)
 {
 }
Exemple #33
0
 public ArrowContainer(Surface parent)
     : base(parent)
 {
 }
 public CropContainer(Surface parent)
     : base(parent)
 {
     AddField(GetType(), FieldType.FLAGS, FieldType.Flag.CONFIRMABLE);
 }
 public HighlightContainer(Surface parent) : base(parent)
 {
     Init();
 }
Exemple #36
0
 public IconContainer(Surface parent)
     : base(parent)
 {
 }
Exemple #37
0
 public ObfuscateContainer(Surface parent) : base(parent)
 {
     Init();
 }
Exemple #38
0
		public DrawableContainer(Surface parent) {
			InitializeFields();
			_parent = parent;
			InitControls();
		}
 public FilterContainer(Surface parent) : base(parent)
 {
     AddField(GetType(), FieldType.LINE_THICKNESS, 0);
     AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
     AddField(GetType(), FieldType.SHADOW, false);
 }
 public CursorContainer(Surface parent)
     : base(parent)
 {
 }
Exemple #41
0
        /// <summary>
        /// Change the surface
        /// </summary>
        /// <param name="newSurface"></param>
        private void SetSurface(ISurface newSurface)
        {
            if (Surface != null && Surface.Modified) {
                throw new ApplicationException("Surface modified");
            }

            RemoveSurface();

            panel1.Height = 10;
            panel1.Width = 10;
            surface = newSurface as Surface;
            panel1.Controls.Add(surface as Surface);
            Image backgroundForTransparency = GreenshotResources.getImage("Checkerboard.Image");
            surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);

            surface.MovingElementChanged += delegate {
                refreshEditorControls();
            };
            surface.DrawingModeChanged += surface_DrawingModeChanged;
            surface.SurfaceSizeChanged += SurfaceSizeChanged;
            surface.SurfaceMessage += SurfaceMessageReceived;
            surface.FieldAggregator.FieldChanged += FieldAggregatorFieldChanged;
            SurfaceSizeChanged(Surface, null);

            bindFieldControls();
            refreshEditorControls();
            // Fix title
            if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
                Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
            }
            WindowDetails.ToForeground(Handle);
        }
Exemple #42
0
		public CropContainer(Surface parent) : base(parent) {
		}
        /// <summary>
        /// Add items to a context menu for the selected item
        /// </summary>
        /// <param name="menu"></param>
        public virtual void AddContextMenuItems(ContextMenuStrip menu, Surface surface)
        {
            bool push = surface.Elements.CanPushDown(this);
            bool pull = surface.Elements.CanPullUp(this);

            ToolStripMenuItem item;

            // Pull "up"
            if (pull)
            {
                item        = new ToolStripMenuItem("Up to top");
                item.Click += delegate
                {
                    surface.Elements.PullElementsToTop(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
                item        = new ToolStripMenuItem("Up one level");
                item.Click += delegate
                {
                    surface.Elements.PullElementsUp(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
            }
            // Push "down"
            if (push)
            {
                item        = new ToolStripMenuItem("Down to bottom");
                item.Click += delegate
                {
                    surface.Elements.PushElementsToBottom(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
                item        = new ToolStripMenuItem("Down one level");
                item.Click += delegate
                {
                    surface.Elements.PushElementsDown(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
            }

            // Duplicate
            item        = new ToolStripMenuItem("Duplicate selected element");
            item.Click += delegate
            {
                DrawableContainerList dcs = this.Clone();
                dcs.Parent = surface;
                dcs.MoveBy(10, 10);
                surface.AddElements(dcs);
                surface.DeselectAllElements();
                surface.SelectElements(dcs);
            };
            menu.Items.Add(item);

            // Copy
            item        = new ToolStripMenuItem("Copy");
            item.Image  = ((Image)(editorFormResources.GetObject("copyToolStripMenuItem.Image")));
            item.Click += delegate
            {
                ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), this);
            };
            menu.Items.Add(item);

            // Cut
            item        = new ToolStripMenuItem("Cut");
            item.Image  = ((Image)(editorFormResources.GetObject("btnCut.Image")));
            item.Click += delegate
            {
                ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), this);
                List <DrawableContainer> containersToDelete = new List <DrawableContainer>();
                foreach (DrawableContainer container in this)
                {
                    containersToDelete.Add(container);
                }
                foreach (DrawableContainer container in containersToDelete)
                {
                    surface.RemoveElement(container, true);
                }
            };
            menu.Items.Add(item);

            // Delete
            item        = new ToolStripMenuItem("Delete");
            item.Image  = ((Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
            item.Click += delegate
            {
                List <DrawableContainer> containersToDelete = new List <DrawableContainer>();
                foreach (DrawableContainer container in this)
                {
                    containersToDelete.Add(container);
                }
                foreach (DrawableContainer container in containersToDelete)
                {
                    surface.RemoveElement(container, true);
                }
            };
            menu.Items.Add(item);

            // Reset
            bool canReset = false;

            foreach (DrawableContainer container in this)
            {
                if (container.hasDefaultSize)
                {
                    canReset = true;
                }
            }
            if (canReset)
            {
                item = new ToolStripMenuItem("Reset size");
                //item.Image = ((System.Drawing.Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
                item.Click += delegate
                {
                    foreach (DrawableContainer container in this)
                    {
                        if (container.hasDefaultSize)
                        {
                            Size defaultSize = container.DefaultSize;
                            container.Invalidate();
                            container.MakeBoundsChangeUndoable(false);
                            container.Width  = defaultSize.Width;
                            container.Height = defaultSize.Height;
                            container.Invalidate();
                        }
                    }
                };
                menu.Items.Add(item);
            }
        }
 public DeleteElementMemento(Surface surface, IDrawableContainer drawableContainer)
 {
     this.surface = surface;
     this.drawableContainer = drawableContainer;
 }
Exemple #45
0
 public ObfuscateContainer(Surface parent)
     : base(parent)
 {
     Init();
 }
Exemple #46
0
 public StepLabelContainer(Surface parent)
     : base(parent)
 {
     parent.AddStepLabel(this);
     InitContent();
 }
Exemple #47
0
 public BitmapContainer(Surface parent) : base(parent)
 {
     AddField(GetType(), FieldType.SHADOW, false);
 }