Inheritance: ISurfaceDraw, IDisposable, ICloneable, IDeserializationCallback
示例#1
0
        private IrregularSurface(IrregularSurface cloneMe)
        {
            this.placedSurfaces = new List <PlacedSurface> (cloneMe.placedSurfaces.Count);

            foreach (PlacedSurface ps in cloneMe.placedSurfaces)
            {
                this.placedSurfaces.Add((PlacedSurface)ps.Clone());
            }

            this.region = cloneMe.Region.Copy();
        }
        public override void Redo()
        {
            // Grab the original surface
            IrregularSurface new_surf = new IrregularSurface(PintaCore.Layers[layer_index].Surface, old_surface.Region);

            // Undo to the "old" surface
            old_surface.Draw(PintaCore.Layers[layer_index].Surface);

            // Store the original surface for Redo
            old_surface = new_surf;

            PintaCore.Workspace.Invalidate(old_surface.Region.Clipbox);
        }
        public override void Redo()
        {
            // Grab the original surface
            IrregularSurface new_surf = new IrregularSurface(PintaCore.Layers[layer_index].Surface, old_surface.Region);

            // Undo to the "old" surface
            old_surface.Draw(PintaCore.Layers[layer_index].Surface);

            // Store the original surface for Redo
            old_surface = new_surf;

            PintaCore.Workspace.Invalidate (old_surface.Region.Clipbox);
        }
 public ClippedSurfaceHistoryItem(string icon, string text, IrregularSurface oldSurface, int layerIndex) : base(icon, text)
 {
     old_surface = (IrregularSurface)oldSurface.Clone();
     layer_index = layerIndex;
 }
 public ClippedSurfaceHistoryItem(string icon, string text, IrregularSurface oldSurface, int layerIndex)
     : base(icon, text)
 {
     old_surface = (IrregularSurface)oldSurface.Clone();
     layer_index = layerIndex;
 }
示例#6
0
文件: TextTool.cs 项目: xxgreg/Pinta
        protected override void OnDeactivated()
        {
            //PdnBaseForm.UnregisterFormHotKey(Gdk.Key.Back, OnBackspaceTyped);

            base.OnDeactivated ();
            PintaCore.Palette.PrimaryColorChanged -= HandlePintaCorePalettePrimaryColorChanged;

            switch (mode) {
            case EditingMode.Editing:
                SaveHistoryMemento ();
                break;

            case EditingMode.EmptyEdit:
                RedrawText (false);
                break;

            case EditingMode.NotEditing:
                break;
            default:

                throw new System.ComponentModel.InvalidEnumArgumentException ("Invalid Editing Mode");
            }

            if (saved != null) {
                saved.Dispose ();
                saved = null;
            }

            StopEditing ();
            //this.threadPool = null;
        }
示例#7
0
文件: TextTool.cs 项目: xxgreg/Pinta
        private void SaveHistoryMemento()
        {
            pulseEnabled = false;
            RedrawText (false);

            if (saved != null) {
                Region hitTest = Region.Rectangle (PintaCore.Layers.SelectionPath.GetBounds ());
                hitTest.Intersect (saved.Region);

                if (hitTest.Clipbox.Width != 0 && hitTest.Clipbox.Height != 0) {
                    ClippedSurfaceHistoryItem bha = new ClippedSurfaceHistoryItem (Icon, Name, saved, PintaCore.Layers.CurrentLayerIndex);

                    if (this.currentHA == null) {
                        PintaCore.History.PushNewItem (bha);
                    } else {
                        this.currentHA.Push (bha);
                        this.currentHA = null;
                    }
                }

                hitTest.Dispose ();
                saved.Dispose ();
                saved = null;
            }
        }
示例#8
0
文件: TextTool.cs 项目: xxgreg/Pinta
        /// <summary>
        /// Redraws the Text on the screen
        /// </summary>
        /// <remarks>
        /// assumes that the <b>font</b> and the <b>alignment</b> are already set
        /// </remarks>
        /// <param name="cursorOn"></param>
        private void RedrawText(bool cursorOn)
        {
            Cairo.ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;
            using (Cairo.Context context = new Cairo.Context (surf)) {
                if (this.ignoreRedraw > 0) {
                    return;
                }

                if (saved != null) {
                    saved.Draw (surf);
                    PintaCore.Workspace.Invalidate (saved.Region.Clipbox);
                    saved.Dispose ();
                    saved = null;
                }

                // Save the Space behind the lines
                Rectangle[] rects = new Rectangle[lines.Count + 1];
                Point[] localUls = new Point[lines.Count];

                // All Lines
                bool recalcSizes = false;

                if (this.sizes == null) {
                    recalcSizes = true;
                    this.sizes = new Size[lines.Count + 1];
                }

                if (recalcSizes) {
                    for (int i = 0; i < lines.Count; ++i) {
                        this.MeasureText (i);
                    }
                }

                for (int i = 0; i < lines.Count; ++i) {
                    Point upperLeft = GetUpperLeft (sizes[i], i);
                    localUls[i] = upperLeft;
                    Rectangle rect = new Rectangle (upperLeft, sizes[i]);
                    rects[i] = rect;
                }

                // The Cursor Line
                string cursorLine = ((string)lines[linePos]).Substring (0, textPos);
                Size cursorLineSize;
                Point cursorUL;
                Rectangle cursorRect;
                bool emptyCursorLineFlag;

                if (cursorLine.Length == 0) {
                    emptyCursorLineFlag = true;
                    Size fullLineSize = sizes[linePos];
                    cursorLineSize = new Size (2, FontHeight);
                    cursorUL = GetUpperLeft (fullLineSize, linePos);
                    cursorRect = new Rectangle (cursorUL, cursorLineSize);
                } else if (cursorLine.Length == ((string)lines[linePos]).Length) {
                    emptyCursorLineFlag = false;
                    cursorLineSize = sizes[linePos];
                    cursorUL = localUls[linePos];
                    cursorRect = new Rectangle (cursorUL, cursorLineSize);
                } else {
                    emptyCursorLineFlag = false;
                    cursorLineSize = StringSize (cursorLine);
                    cursorUL = localUls[linePos];
                    cursorRect = new Rectangle (cursorUL, cursorLineSize);
                }

                rects[lines.Count] = cursorRect;

                // Account for overhang on italic or fancy fonts
                int offset = FontHeight;
                for (int i = 0; i < rects.Length; ++i) {
                    rects[i].X -= offset;
                    rects[i].Width += 2 * offset;
                }

                // Set the saved region
                saved = new IrregularSurface (surf, Utility.InflateRectangles (rects, 3));

                // Draw the Lines
                this.uls = localUls;

                for (int i = 0; i < lines.Count; i++)
                    this.RenderText (surf, i);

                // Draw the Cursor
                if (cursorOn) {
                    using (Cairo.Context toolctx = new Cairo.Context (PintaCore.Layers.ToolLayer.Surface)) {
                        if (emptyCursorLineFlag) {
                            toolctx.FillRectangle (cursorRect.ToCairoRectangle (), PintaCore.Palette.PrimaryColor);
                        } else {
                            toolctx.DrawLine (new Cairo.PointD (cursorRect.Right, cursorRect.Top), new Cairo.PointD (cursorRect.Right, cursorRect.Bottom), PintaCore.Palette.PrimaryColor, 1);
                        }
                    }
                }

                //PlaceMoveNub();
                //UpdateStatusText();
                PintaCore.Workspace.Invalidate (saved.Region.Clipbox);
                //Update();
            }
        }
示例#9
0
        private IrregularSurface(IrregularSurface cloneMe)
        {
            this.placedSurfaces = new List<PlacedSurface> (cloneMe.placedSurfaces.Count);

            foreach (PlacedSurface ps in cloneMe.placedSurfaces)
                this.placedSurfaces.Add ((PlacedSurface)ps.Clone ());

            this.region = cloneMe.Region.Copy ();
        }