Beispiel #1
0
        public void SetClip(Region region, CombineMode combineMode = CombineMode.Replace)
        {
            switch (combineMode)
            {
            case CombineMode.Intersect:
                _clip.Intersect(region);
                break;

            case CombineMode.Complement:
                _clip.Complement(region);
                break;

            case CombineMode.Exclude:
                _clip.Exclude(region);
                break;

            case CombineMode.Union:
                _clip.Union(region);
                break;

            case CombineMode.Xor:
                _clip.Xor(region);
                break;

            default:
                _clip = region;
                break;
            }
        }
Beispiel #2
0
        protected override void captionButton_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (DHLOOKUP.hpcItemProfiles != null && DHLOOKUP.hpcItemProfiles.Count != 0)
                {
                    captionButton.BackColor = Color.Gray;

                    combineMode++;
                    if ((int)combineMode > (int)CombineMode.Fast)
                    {
                        combineMode = CombineMode.Default;
                    }

                    SetCombineMode(combineMode);
                    WriteConfig();
                }
                else
                {
                    captionButton.BackColor = Color.Red;
                }
            }

            base.captionButton_MouseDown(sender, e);
        }
Beispiel #3
0
        /// <summary>
        /// Determine the current combine mode - various combinations of left/right click
        /// and Ctrl/Shift can override the selected mode from the toolbar.
        /// </summary>
        public CombineMode DetermineCombineMode(ToolMouseEventArgs args)
        {
            CombineMode mode = selected_mode;

            if (args.MouseButton == MouseButton.Left)
            {
                if (args.IsControlPressed)
                {
                    mode = CombineMode.Union;
                }
                else if (args.IsAltPressed)
                {
                    mode = CombineMode.Intersect;
                }
            }
            else if (args.MouseButton == MouseButton.Right)
            {
                if (args.IsControlPressed)
                {
                    mode = CombineMode.Xor;
                }
                else
                {
                    mode = CombineMode.Exclude;
                }
            }

            return(mode);
        }
Beispiel #4
0
        public void SetClip(RectangleF rect, CombineMode combineMode)
        {
            int status = SafeNativeMethods.Gdip.GdipSetClipRect(new HandleRef(this, NativeGraphics), rect.X, rect.Y,
                                                                rect.Width, rect.Height, combineMode);

            SafeNativeMethods.Gdip.CheckStatus(status);
        }
Beispiel #5
0
		protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
		{
			// Ignore extra button clicks while drawing
			if (is_drawing)
				return;

			Document doc = PintaCore.Workspace.ActiveDocument;
			hist = new SelectionHistoryItem(Icon, Name);
			hist.TakeSnapshot();

			reset_origin = args.Event.GetPoint();

            active_control = HandleResize (point);
			if (!active_control.HasValue)
			{
				combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);

				double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
				double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
				shape_origin = new PointD(x, y);

                doc.PreviousSelection.Dispose ();
				doc.PreviousSelection = doc.Selection.Clone();
				doc.Selection.SelectionPolygons.Clear();

                // The bottom right corner should be selected.
                active_control = 3;
			}

            is_drawing = true;
		}
Beispiel #6
0
 /// <summary>
 /// Sets the clipping region of this Graphics object to the result of the
 /// specified operation combining the current clip region and the
 /// specified GraphicsPath object.
 /// </summary>
 /// <param name="path">GraphicsPath object to combine.</param>
 /// <param name="combineMode">Member of the CombineMode enumeration that specifies the combining operation to use.</param>
 public void SetClip(
     GraphicsPath path,
     CombineMode combineMode
     )
 {
     _graphics.SetClip(path, combineMode);
 }
Beispiel #7
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
            {
                return;
            }

            Document doc = PintaCore.Workspace.ActiveDocument;

            hist = new SelectionHistoryItem(Icon, Name);
            hist.TakeSnapshot();

            reset_origin = args.Event.GetPoint();

            active_control = HandleResize(point);
            if (!active_control.HasValue)
            {
                combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);

                double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
                double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
                shape_origin = new PointD(x, y);

                doc.PreviousSelection.Dispose();
                doc.PreviousSelection = doc.Selection.Clone();
                doc.Selection.SelectionPolygons.Clear();

                // The bottom right corner should be selected.
                active_control = 3;
            }

            is_drawing = true;
        }
        public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
        {
            //TODO: reivew clip combine mode

            _gpuPainter.SetClipBox(rect.Left, rect.Top, rect.Right, rect.Bottom);
            _currentClipRect = rect;
        }
Beispiel #9
0
        public static PdnGraphicsPath Combine(PdnGraphicsPath subjectPath, CombineMode combineMode, PdnGraphicsPath clipPath)
        {
            switch (combineMode)
            {
            case CombineMode.Complement:
                return(Combine(clipPath, CombineMode.Exclude, subjectPath));

            case CombineMode.Replace:
                return(clipPath.Clone());

            case CombineMode.Xor:
            case CombineMode.Intersect:
            case CombineMode.Union:
            case CombineMode.Exclude:
                if (subjectPath.IsEmpty && clipPath.IsEmpty)
                {
                    return(new PdnGraphicsPath());    // empty path
                }
                else if (subjectPath.IsEmpty)
                {
                    switch (combineMode)
                    {
                    case CombineMode.Xor:
                    case CombineMode.Union:
                        return(clipPath.Clone());

                    case CombineMode.Intersect:
                    case CombineMode.Exclude:
                        return(new PdnGraphicsPath());

                    default:
                        throw new InvalidEnumArgumentException();
                    }
                }
                else if (clipPath.IsEmpty)
                {
                    switch (combineMode)
                    {
                    case CombineMode.Exclude:
                    case CombineMode.Xor:
                    case CombineMode.Union:
                        return(subjectPath.Clone());

                    case CombineMode.Intersect:
                        return(new PdnGraphicsPath());

                    default:
                        throw new InvalidEnumArgumentException();
                    }
                }
                else
                {
                    GraphicsPath resultPath = PdnGraphics.ClipPath(subjectPath, combineMode, clipPath);
                    return(new PdnGraphicsPath(resultPath));
                }

            default:
                throw new InvalidEnumArgumentException();
            }
        }
 public override void SetClip(Region region, CombineMode combineMode)
 {
     if (_graphics != null)
     {
         _graphics.SetClip(region, combineMode);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Determine the current combine mode - various combinations of left/right click
        /// and Ctrl/Shift can override the selected mode from the toolbar.
        /// </summary>
        public CombineMode DetermineCombineMode(Gtk.ButtonPressEventArgs args)
        {
            CombineMode mode = selected_mode;

            if (args.Event.Button == GtkExtensions.MouseLeftButton)
            {
                if (args.Event.IsControlPressed())
                {
                    mode = CombineMode.Union;
                }
                else if (args.Event.IsShiftPressed())
                {
                    mode = CombineMode.Intersect;
                }
            }
            else if (args.Event.Button == GtkExtensions.MouseRightButton)
            {
                if (args.Event.IsControlPressed())
                {
                    mode = CombineMode.Xor;
                }
                else
                {
                    mode = CombineMode.Exclude;
                }
            }

            return(mode);
        }
Beispiel #12
0
        // nothing = replace
        // Ctrl = union
        // RMB = exclude
        // Ctrl+RMB = xor

        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            //SetCursor (Cursors.WaitCursor);

            if (args.Event.IsControlPressed() && args.Event.Button == 1)
            {
                this.combineMode = CombineMode.Union;
            }
            else if (args.Event.IsControlPressed() && args.Event.Button == 3)
            {
                this.combineMode = CombineMode.Xor;
            }
            else if (args.Event.Button == 3)
            {
                this.combineMode = CombineMode.Exclude;
            }
            else
            {
                this.combineMode = CombineMode.Replace;
            }

            base.OnMouseDown(canvas, args, point);

            doc.ShowSelection = true;
        }
Beispiel #13
0
        // only works if base is empty
        public void SetContinuation(PdnGraphicsPath path, CombineMode combineMode, bool takeOwnership)
        {
            lock (this.syncRoot)
            {
                if (!this.data.basePath.IsEmpty)
                {
                    throw new InvalidOperationException("base path must be empty to use this overload of SetContinuation");
                }

                OnChanging();

                CommitInterimTransform();
                ResetCumulativeTransform();

                this.data.continuationCombineMode = combineMode;

                if (takeOwnership)
                {
                    this.data.continuation.Dispose();
                    this.data.continuation = path;
                }
                else
                {
                    this.data.continuation.Reset();
                    this.data.continuation.AddPath(path, false);
                }

                OnChanged();
            }
        }
Beispiel #14
0
        public void SetToDefaults()
        {
            this.antiAliasing   = true;
            this.fontSmoothing  = FontSmoothing.Smooth;
            this.primaryColor   = ColorBgra.FromBgra(0, 0, 0, 255);
            this.secondaryColor = ColorBgra.FromBgra(255, 255, 255, 255);
            this.gradientInfo   = new GradientInfo(GradientType.LinearClamped, false);
            this.penInfo        = new PenInfo(PenInfo.DefaultDashStyle, 2.0f, PenInfo.DefaultLineCap, PenInfo.DefaultLineCap, PenInfo.DefaultCapScale);
            this.brushInfo      = new BrushInfo(BrushType.Solid, HatchStyle.BackwardDiagonal);

            try
            {
                this.fontInfo = new FontInfo(new FontFamily("Arial"), 12, FontStyle.Regular);
            }

            catch (Exception)
            {
                this.fontInfo = new FontInfo(new FontFamily(GenericFontFamilies.SansSerif), 12, FontStyle.Regular);
            }

            this.textAlignment = TextAlignment.Left;
            this.shapeDrawType = ShapeDrawType.Outline;
            this.alphaBlending = true;
            this.tolerance     = 0.5f;

            this.colorPickerClickBehavior = ColorPickerClickBehavior.NoToolSwitch;
            this.resamplingAlgorithm      = ResamplingAlgorithm.Bilinear;
            this.selectionCombineMode     = CombineMode.Replace;
            this.floodMode             = FloodMode.Local;
            this.selectionDrawModeInfo = SelectionDrawModeInfo.CreateDefault();
        }
Beispiel #15
0
        public void BuildToolbar(Gtk.Toolbar tb)
        {
            if (selection_label == null)
            {
                selection_label = new ToolBarLabel(Catalog.GetString(" Selection Mode: "));
            }

            tb.AppendItem(selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox(170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) =>
                {
                    Gtk.TreeIter iter;
                    if (selection_combo_box.ComboBox.GetActiveIter(out iter))
                    {
                        selected_mode = (CombineMode)selection_combo_box.Model.GetValue(iter, 1);
                    }
                };

                foreach (var mode in combine_modes)
                {
                    selection_combo_box.Model.AppendValues(mode.Value, mode.Key);
                }

                selection_combo_box.ComboBox.Active = 0;
            }

            tb.AppendItem(selection_combo_box);
        }
Beispiel #16
0
        public void SetClip(GraphicsPath path, CombineMode combineMode)
        {
            RestoreInitialClip();
            CombineClippingRegion(combineMode, new Region(path));

            _graphics.IntersectClip(new XGraphicsPath(path.PathData.Points, path.PathData.Types, FillModeToXFillMode(path.FillMode)));
        }
Beispiel #17
0
        /// <summary>
        /// Combines the local clippingRegion with the given region.
        /// </summary>
        /// <param name="combineMode">The combine mode to use.</param>
        /// <param name="region">The region to combine with the clippingRegion.</param>
        private void CombineClippingRegion(CombineMode combineMode, Region region)
        {
            switch (combineMode)
            {
            case CombineMode.Replace:
                _clippingRegion = region;
                break;

            case CombineMode.Intersect:
                _clippingRegion.Intersect(region);
                break;

            case CombineMode.Union:
                _clippingRegion.Union(region);
                break;

            case CombineMode.Xor:
                _clippingRegion.Xor(region);
                break;

            case CombineMode.Exclude:
                _clippingRegion.Exclude(region);
                break;

            case CombineMode.Complement:
                _clippingRegion.Complement(region);
                break;

            default:
                throw new ArgumentOutOfRangeException("combineMode");
            }
        }
Beispiel #18
0
    public static void _CombineMeshes()
    {
        CombineEntry[] combineEntries = new CombineEntry[Selection.transforms.Length];
        for (int i = 0; i < Selection.transforms.Length; i++)
        {
            Transform trs = Selection.transforms[i];
            combineEntries[i] = new CombineEntry(trs.GetComponent <MeshFilter>(), trs);
        }
        GameObject    outputGo         = CombineMeshes.Instance.outputGo;
        CombineMode   combineMode      = CombineMeshes.Instance.combineMode;
        bool          autoSetMaterial  = CombineMeshes.Instance.autoSetMaterial;
        bool          autoSetColliders = CombineMeshes.Instance.autoSetColliders;
        bool          shouldMakeAsset  = CombineMeshes.Instance.shouldMakeAsset;
        string        saveAssetAtPath  = CombineMeshes.Instance.saveAssetAtPath;
        CombineMeshes combineMeshes    = new GameObject().AddComponent <CombineMeshes>();

        combineMeshes.outputGo         = outputGo;
        combineMeshes.combineMode      = combineMode;
        combineMeshes.autoSetMaterial  = autoSetMaterial;
        combineMeshes.autoSetColliders = autoSetColliders;
        combineMeshes.shouldMakeAsset  = shouldMakeAsset;
        combineMeshes.saveAssetAtPath  = saveAssetAtPath;
        combineMeshes.combineEntries   = combineEntries;
        combineMeshes.OnEnable();
        DestroyImmediate(combineMeshes.gameObject);
    }
Beispiel #19
0
        public void SetClip(Region region, CombineMode combineMode)
        {
            RestoreInitialClip();
            CombineClippingRegion(combineMode, region);

            ApplyClip(region);
        }
Beispiel #20
0
        public void BuildToolbar(Gtk.Toolbar tb, ISettingsService settings)
        {
            if (selection_label == null)
            {
                selection_label = new ToolBarLabel(Translations.GetString(" Selection Mode: "));
            }

            tb.AppendItem(selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox(170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) => {
                    selected_mode = combine_modes[selection_combo_box.ComboBox.ActiveText];
                };

                foreach (var mode in combine_modes)
                {
                    selection_combo_box.ComboBox.AppendText(mode.Key);
                }

                selection_combo_box.ComboBox.Active = settings.GetSetting(COMBINE_MODE_SETTING, 0);
            }

            tb.AppendItem(selection_combo_box);
        }
Beispiel #21
0
        public void BuildToolbar (Gtk.Toolbar tb)
        {
            if (selection_label == null)
                selection_label = new ToolBarLabel (Catalog.GetString (" Selection Mode: "));

            tb.AppendItem (selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox (170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) =>
                {
                    Gtk.TreeIter iter;
                    if (selection_combo_box.ComboBox.GetActiveIter (out iter))
                        selected_mode = (CombineMode)selection_combo_box.Model.GetValue (iter, 1);
                };

                foreach (var mode in combine_modes)
                    selection_combo_box.Model.AppendValues (mode.Value, mode.Key);

                selection_combo_box.ComboBox.Active = 0;
            }

            tb.AppendItem (selection_combo_box);
        }
Beispiel #22
0
        public void SetClip(Region region, CombineMode combineMode = CombineMode.Replace)
        {
            switch (combineMode)
            {
            case CombineMode.Replace:
                clip = region;
                break;

            case CombineMode.Intersect:
                clip.Intersect(region);
                break;

            case CombineMode.Union:
                clip.Union(region);
                break;

            case CombineMode.Xor:
                clip.Xor(region);
                break;

            case CombineMode.Exclude:
                clip.Exclude(region);
                break;

            case CombineMode.Complement:
                clip.Complement(region);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #23
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if ((ModifierKeys & Keys.Control) != 0 && e.Button == MouseButtons.Left)
            {
                this.combineMode = CombineMode.Union;
            }
            else if ((ModifierKeys & Keys.Alt) != 0 && e.Button == MouseButtons.Left)
            {
                this.combineMode = CombineMode.Exclude;
            }
            else if ((ModifierKeys & Keys.Control) != 0 && e.Button == MouseButtons.Right)
            {
                this.combineMode = CombineMode.Xor;
            }
            else if ((ModifierKeys & Keys.Alt) != 0 && e.Button == MouseButtons.Right)
            {
                this.combineMode = CombineMode.Intersect;
            }
            else
            {
                this.combineMode = AppEnvironment.SelectionCombineMode;
            }

            base.OnMouseDown(e);
        }
Beispiel #24
0
        public void SetClip(RectangleF rect, CombineMode combineMode)
        {
            RestoreInitialClip();
            CombineClippingRegion(combineMode, new Region(rect));

            _graphics.IntersectClip(rect);
        }
Beispiel #25
0
        public void AddFigures(List <GeometryFigure> figures, List <CombineMode> combineModes)
        {
            int start = 0;

            if (polygons == null)
            {
                polygons = ClipperHelper.Simplify(figures[0].Points, figures[0].FillMode, out tree);
                start    = 1;
            }

            for (int i = start; i < figures.Count; i++)
            {
                CombineMode combineMode    = combineModes[i];
                FillMode    fillMode       = figures[i].FillMode;
                var         currentFigures = new List <List <Vector2> >();
                currentFigures.Add(figures[i].Points);

                while ((i + 1 < figures.Count) && (combineModes[i + 1] == combineMode) && (figures[i + 1].FillMode == fillMode))
                {
                    i++;
                    currentFigures.Add(figures[i].Points);
                }

                polygons = ClipperHelper.Combine(polygons,
                                                 currentFigures,
                                                 FillMode.Alternate,
                                                 fillMode,
                                                 combineMode,
                                                 out tree);
            }
        }
Beispiel #26
0
        protected override void OnMouseDown(Document document, ToolMouseEventArgs e)
        {
            combine_mode = workspace.SelectionHandler.DetermineCombineMode(e);

            base.OnMouseDown(document, e);

            document.Selection.Visible = true;
        }
Beispiel #27
0
		protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;
            combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode (args);

			base.OnMouseDown(canvas, args, point);
			doc.ShowSelection = true;
		}
Beispiel #28
0
 /// <summary>
 /// Sets the clipping region of this <see cref="T:System.Drawing.Graphics"/> to the result of the specified operation combining the current clip region and the rectangle specified by a <see cref="T:System.Drawing.RectangleF"/> structure.
 /// </summary>
 /// <param name="rect"><see cref="T:System.Drawing.RectangleF"/> structure to combine. </param>
 /// <param name="combineMode">Member of the <see cref="T:System.Drawing.Drawing2D.CombineMode"/> enumeration that specifies the combining operation to use. </param>
 public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
 {
     //gx.SetClip(
     //   this.currentClipRect = new System.Drawing.Rectangle(
     //        rect.X, rect.Y,
     //        rect.Width, rect.Height),
     //        (System.Drawing.Drawing2D.CombineMode)combineMode);
 }
Beispiel #29
0
 /// <summary>
 /// Sets the clipping region of this <see cref="T:System.Drawing.Graphics"/> to the result of the specified operation combining the current clip region and the rectangle specified by a <see cref="T:System.Drawing.RectangleF"/> structure.
 /// </summary>
 /// <param name="rect"><see cref="T:System.Drawing.RectangleF"/> structure to combine. </param>
 /// <param name="combineMode">Member of the <see cref="T:System.Drawing.Drawing2D.CombineMode"/> enumeration that specifies the combining operation to use. </param>
 public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
 {
     gx.SetClip(
         new System.Drawing.Rectangle(
             rect.X, rect.Y,
             rect.Width, rect.Height),
         (System.Drawing.Drawing2D.CombineMode)combineMode);
 }
 public void SetClip(Region region, CombineMode combineMode)
 {
     if (_idMapGraphics != null)
     {
         _idMapGraphics.SetClip(region, combineMode);
     }
     _graphics.SetClip(region, combineMode);
 }
 public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
 {
     throw new NotSupportedException();
     //gx.SetClip(
     //  this.currentClipRect = new System.Drawing.Rectangle(
     //        rect.X, rect.Y,
     //        rect.Width, rect.Height),
     //        (System.Drawing.Drawing2D.CombineMode)combineMode);
 }
        /// <summary>
        /// Sets the clipping region of this <see cref="T:System.Drawing.Graphics"/> to the result of the specified operation combining the current clip region and the rectangle specified by a <see cref="T:System.Drawing.RectangleF"/> structure.
        /// </summary>
        /// <param name="rect"><see cref="T:System.Drawing.RectangleF"/> structure to combine. </param>
        /// <param name="combineMode">Member of the <see cref="T:System.Drawing.Drawing2D.CombineMode"/> enumeration that specifies the combining operation to use. </param>
        public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
        {

            gx.SetClip(
               this.currentClipRect = new System.Drawing.Rectangle(
                    rect.X, rect.Y,
                    rect.Width, rect.Height),
                    (System.Drawing.Drawing2D.CombineMode)combineMode);
        }
Beispiel #33
0
 /// <summary>
 /// Sets the clipping region of this <see cref="T:System.Drawing.Graphics"/> to the result of the specified operation combining the current clip region and the rectangle specified by a <see cref="T:System.Drawing.RectangleF"/> structure.
 /// </summary>
 /// <param name="rect"><see cref="T:System.Drawing.RectangleF"/> structure to combine. </param>
 /// <param name="combineMode">Member of the <see cref="T:System.Drawing.Drawing2D.CombineMode"/> enumeration that specifies the combining operation to use. </param>
 public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
 {
     ReleaseHdc();
     gx.SetClip(
         this.currentClipRect = new System.Drawing.Rectangle(
             rect.X, rect.Y,
             rect.Width, rect.Height),
         (System.Drawing.Drawing2D.CombineMode)combineMode);
 }
Beispiel #34
0
 /// <summary>
 /// Configures column HeaderCell.
 /// </summary>
 /// <typeparam name="TPropertyRenderer">Property renderer type.</typeparam>
 /// <param name="propertyRenderer">Property renderer.</param>
 /// <param name="configureHeaderCell">HeaderCell customization action.</param>
 /// <param name="combineMode">Combine mode. Default: AppendToEnd.</param>
 /// <returns>The same renderer instance.</returns>
 public static TPropertyRenderer ConfigureHeaderCell <TPropertyRenderer>(
     this TPropertyRenderer propertyRenderer,
     Action <CellContext> configureHeaderCell,
     CombineMode combineMode = CombineMode.AppendToEnd)
     where TPropertyRenderer : IPropertyRenderer
 {
     return(propertyRenderer.ConfigureMetadata <TPropertyRenderer, ExcelColumnMetadata>(
                metadata => metadata.WithCombinedConfigure(ExcelColumnMetadata.ConfigureHeaderCell, configureHeaderCell, combineMode)));
 }
Beispiel #35
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);

            base.OnMouseDown(canvas, args, point);
            doc.ShowSelection = true;
        }
Beispiel #36
0
 public Data()
 {
     this.basePath = new PdnGraphicsPath();
     this.continuation = new PdnGraphicsPath();
     this.continuationCombineMode = CombineMode.Xor;
     this.cumulativeTransform = new Matrix();
     this.cumulativeTransform.Reset();
     this.interimTransform = new Matrix();
     this.interimTransform.Reset();            
 }
        public IGeometry Combine(CombineMode mode, IGeometry other)
        {
            var otherImplementation = other.import();

            var combined = Path.Geometry(
                Geometry.Factory,
                sink => Geometry.Combine(otherImplementation, mode.import(), sink));

            return new GeometryImplementation(combined);
        }
        static void test(CombineMode mode, IDrawingTarget target, IDrawingBackend backend)
        {
            var c1 = backend.Ellipse(15, 5, 30, 30);
            var c2 = backend.Ellipse(35, 5, 30, 30);

            var r = c1.Combine(mode, c2);

            target.Fill(color: new Color(0.7, 0.7, 1.0));
            target.Geometry(r);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnonymousCommandWrapper"/> class.
 /// </summary>
 /// <param name="serviceProvider">A service provider that can provide a <see cref="ITransactionalActionStack"/> to use for this view model.</param>
 /// <param name="name">The name of this command.</param>
 /// <param name="combineMode">The combine mode to apply to this command.</param>
 /// <param name="redo">The do/redo function.</param>
 /// <param name="undo">The undo action, if the command can be undone.</param>
 /// <param name="dirtiables">The <see cref="IDirtiableViewModel"/> instances associated to this command.</param>
 /// <param name="discardTransactions">The transaction will be discarded if true, otherwise it is ended.</param>
 public AnonymousCommandWrapper(IViewModelServiceProvider serviceProvider, string name, CombineMode combineMode, Func<object, UndoToken> redo, Action<object, UndoToken> undo, IEnumerable<IDirtiableViewModel> dirtiables, bool discardTransactions = true)
     : base(serviceProvider, dirtiables)
 {
     if (name == null) throw new ArgumentNullException(nameof(name));
     if (redo == null) throw new ArgumentNullException(nameof(redo));
     Name = name;
     CombineMode = combineMode;
     this.redo = (parameter, creatingActionItem) => redo(parameter);
     this.undo = undo;
     DiscardTransactions = discardTransactions;
 }
Beispiel #40
0
        public static List<List<Vector2>> Combine(List<List<Vector2>> subjectPolygons, List<List<Vector2>> clippingPolygons,
                                                  FillMode subjectFillMode, FillMode clipFillMode, CombineMode combineMode, out PolyTree tree)
        {
            Clipper.Clear();
            Clipper.AddPaths(subjectPolygons, PolyType.ptSubject, true);
            Clipper.AddPaths(clippingPolygons, PolyType.ptClip, true);

            tree = new PolyTree();
            Clipper.Execute(combineMode.ToClipType(), tree, subjectFillMode.ToPolyFillType(), clipFillMode.ToPolyFillType());
            return Clipper.ClosedPathsFromPolyTree(tree);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnonymousCommandWrapper"/> class.
 /// </summary>
 /// <param name="serviceProvider">A service provider that can provide a <see cref="ITransactionalActionStack"/> to use for this view model.</param>
 /// <param name="name">The name of this command.</param>
 /// <param name="combineMode">The combine mode to apply to this command.</param>
 /// <param name="redo">The do/redo function.</param>
 /// <param name="undo">The undo action, if the command can be undone.</param>
 /// <param name="dirtiables">The <see cref="IDirtiableViewModel"/> instances associated to this command.</param>
 public AnonymousCommandWrapper(IViewModelServiceProvider serviceProvider, string name, CombineMode combineMode, Func<object, UndoToken> redo, Action<object, UndoToken> undo, IEnumerable<IDirtiableViewModel> dirtiables)
     : base(serviceProvider, dirtiables)
 {
     if (name == null) throw new ArgumentNullException("name");
     if (redo == null) throw new ArgumentNullException("redo");
     this.name = name;
     this.combineMode = combineMode;
     this.redo = redo;
     this.undo = undo;
     this.serviceProvider = serviceProvider;
 }
        /// <summary>
        /// Sets the clipping region of this <see cref="T:System.Drawing.Graphics"/> to the result of the specified operation combining the current clip region and the rectangle specified by a <see cref="T:System.Drawing.RectangleF"/> structure.
        /// </summary>
        /// <param name="rect"><see cref="T:System.Drawing.RectangleF"/> structure to combine. </param>
        /// <param name="combineMode">Member of the <see cref="T:System.Drawing.Drawing2D.CombineMode"/> enumeration that specifies the combining operation to use. </param>
        public override void SetClipRect(Rectangle rect, CombineMode combineMode = CombineMode.Replace)
        {
            skCanvas.ClipRect(this.currentClipRect = new SkiaSharp.SKRect(
                rect.Left, rect.Top,
                rect.Right, rect.Bottom));

            //gx.SetClip(
            //   this.currentClipRect = new System.Drawing.Rectangle(
            //        rect.X, rect.Y,
            //        rect.Width, rect.Height),
            //        (System.Drawing.Drawing2D.CombineMode)combineMode);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnonymousCommandWrapper"/> class.
 /// </summary>
 /// <param name="serviceProvider">A service provider that can provide a <see cref="ITransactionalActionStack"/> to use for this view model.</param>
 /// <param name="name">The name of this command.</param>
 /// <param name="combineMode">The combine mode to apply to this command.</param>
 /// <param name="redo">The do/redo function.</param>
 /// <param name="undo">The undo action, if the command can be undone.</param>
 /// <param name="dirtiables">The <see cref="IDirtiableViewModel"/> instances associated to this command.</param>
 /// <param name="discardTransactions">The transaction will be discarded if true, otherwise it is ended.</param>
 public AnonymousCommandWrapper(IViewModelServiceProvider serviceProvider, string name, CombineMode combineMode, Func<object, bool, UndoToken> redo, Action<object, UndoToken> undo, IEnumerable<IDirtiableViewModel> dirtiables, bool discardTransactions = true)
     : base(serviceProvider, dirtiables)
 {
     if (name == null) throw new ArgumentNullException("name");
     if (redo == null) throw new ArgumentNullException("redo");
     this.name = name;
     this.combineMode = combineMode;
     this.redo = redo;
     this.undo = undo;
     this.serviceProvider = serviceProvider;
     this.DiscardTransactions = discardTransactions;
     this.AllowReentrancy = false;
 }
Beispiel #44
0
        public static bool Check(CombineMode combineMode)
        {
            switch (combineMode)
            {
                case CombineMode.Exclude:
                case CombineMode.Intersect:
                case CombineMode.Union:
                case CombineMode.Xor:
                    return true;

                case CombineMode.Complement:
                case CombineMode.Replace:
                default:
                    return false;
            }
        }
Beispiel #45
0
		protected override void OnMouseDown (Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
		{
			if (is_drawing)
				return;

			hist = new SelectionHistoryItem (Icon, Name);
			hist.TakeSnapshot ();

			combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode (args);			
			path = null;
			is_drawing = true;

			var doc = PintaCore.Workspace.ActiveDocument;
			doc.PreviousSelection.Dispose ();
			doc.PreviousSelection = doc.Selection.Clone();
		}
Beispiel #46
0
        public static GraphicsPath ClipPath(GraphicsPath subjectPath, CombineMode combineMode, GraphicsPath clipPath)
        {
            GpcWrapper.Polygon.Validate(combineMode);

            GpcWrapper.Polygon basePoly = new GpcWrapper.Polygon(subjectPath);

            GraphicsPath clipClone = (GraphicsPath)clipPath.Clone();
            clipClone.CloseAllFigures();
            GpcWrapper.Polygon clipPoly = new GpcWrapper.Polygon(clipClone);
            clipClone.Dispose();

            GpcWrapper.Polygon clippedPoly = GpcWrapper.Polygon.Clip(combineMode, basePoly, clipPoly);

            GraphicsPath returnPath = clippedPoly.ToGraphicsPath();
            returnPath.CloseAllFigures();
            return returnPath;
        }
 public ImageFrame(ImageFrame f1, ImageFrame f2, CombineMode mode)
 {
     switch (mode)
     {
         case CombineMode.SideBySide:
             f1.OffsetX = 0;
             f2.OffsetX = f1.Width;
             Width = f1.Width + f2.Width;
             Height = Math.Max(f1.Height, f2.Height);
             break;
         case CombineMode.OneBelowOther:
             f1.OffsetY = 0;
             f2.OffsetY = f1.Height;
             Width = Math.Max(f1.Width, f2.Width);
             Height = f1.Height + f2.Height;
             break;
         default:
             throw new ArgumentException("invalid combine mode");
     }
     //Console.WriteLine(string.Format("New Combo: {0}x{1}, from f1 {2}x{3}, f2 {4}x{5}", Width, Height, f1.Width, f1.Height, f2.Width, f2.Height));
     SubFrames = new ImageFrame[2];
     SubFrames[0] = f1;
     SubFrames[1] = f2;
 }
Beispiel #48
0
 public void SetClip(Region region, CombineMode combineMode = CombineMode.Replace)
 {
     switch (combineMode)
     {
         case CombineMode.Intersect:
             _clip.Intersect(region);
             break;
         case CombineMode.Complement:
             _clip.Complement(region);
             break;
         case CombineMode.Exclude:
             _clip.Exclude(region);
             break;
         case CombineMode.Union:
             _clip.Union(region);
             break;
         case CombineMode.Xor:
             _clip.Xor(region);
             break;
         default:
             _clip = region;
             break;
     }
 }
Beispiel #49
0
 internal static extern GpStatus GdipSetClipHrgn(GpGraphics graphics, HRGN hRgn, CombineMode combineMode);
Beispiel #50
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            this.Cursor = GetCursor();

            if (tracking)
            {
                moveOriginMode = true;
                lastXY = new Point(e.X, e.Y);
                OnMouseMove(e);
            }
            else if ((e.Button & MouseButtons.Left) == MouseButtons.Left ||
                (e.Button & MouseButtons.Right) == MouseButtons.Right)
            {
                tracking = true;
                hasMoved = false;
                startTime = DateTime.Now;

                tracePoints = new List<Point>();
                tracePoints.Add(new Point(e.X, e.Y));

                undoAction = new SelectionHistoryMemento("sentinel", this.Image, DocumentWorkspace);

                wasNotEmpty = !Selection.IsEmpty;

                // Determine this.combineMode

                if ((ModifierKeys & Keys.Control) != 0 && e.Button == MouseButtons.Left)
                {
                    this.combineMode = CombineMode.Union;
                }
                else if ((ModifierKeys & Keys.Alt) != 0 && e.Button == MouseButtons.Left)
                {
                    this.combineMode = CombineMode.Exclude;
                }
                else if ((ModifierKeys & Keys.Control) != 0 && e.Button == MouseButtons.Right)
                {
                    this.combineMode = CombineMode.Xor;
                }
                else if ((ModifierKeys & Keys.Alt) != 0 && e.Button == MouseButtons.Right)
                {
                    this.combineMode = CombineMode.Intersect;
                }
                else
                {
                    this.combineMode = AppEnvironment.SelectionCombineMode;
                }


                DocumentWorkspace.EnableSelectionOutline = false;

                this.newSelection.Reset();
                PdnGraphicsPath basePath = Selection.CreatePath();
                this.newSelection.SetContinuation(basePath, CombineMode.Replace, true);
                this.newSelection.CommitContinuation();

                bool newSelectionRendererVisible = true;

                // Act on this.combineMode
                switch (this.combineMode)
                {
                    case CombineMode.Xor:
                        append = true;
                        Selection.ResetContinuation();
                        break;

                    case CombineMode.Union:
                        append = true;
                        Selection.ResetContinuation();
                        break;

                    case CombineMode.Exclude:
                        append = true;
                        Selection.ResetContinuation();
                        break;

                    case CombineMode.Replace:
                        append = false;
                        Selection.Reset();
                        break;

                    case CombineMode.Intersect:
                        append = true;
                        Selection.ResetContinuation();
                        break;

                    default:
                        throw new InvalidEnumArgumentException();
                }

                this.newSelectionRenderer.Visible = newSelectionRendererVisible;
            }
        }
        public void SetClip(Region region, CombineMode combineMode)
        {
            // We need to reset the clip that is active now so that the graphic
            // states are correct when we set them.
            ResetClip ();

            switch (combineMode)
            {
            case CombineMode.Replace:
                // Set our clip region by cloning the region that is passed for now
                clipRegion = region.Clone ();
                break;
            case CombineMode.Intersect:

                clipRegion.Intersect (region);

                break;
            case CombineMode.Union:

                clipRegion.Union (region);

                break;
            case CombineMode.Exclude:

                clipRegion.Exclude (region);

                break;
            case CombineMode.Xor:

                clipRegion.Xor (region);

                break;
            default:
                throw new NotImplementedException ("SetClip for CombineMode " + combineMode + " not implemented");
            }

            //Unlike the current path, the current clipping path is part of the graphics state.
            //Therefore, to re-enlarge the paintable area by restoring the clipping path to a
            //prior state, you must save the graphics state before you clip and restore the graphics
            //state after you’ve completed any clipped drawing.
            context.SaveState ();
            if (clipRegion.IsEmpty) {
                context.ClipToRect (CGRect.Empty);
            } else {
                //context.ClipToRect ((RectangleF)clipRegion.regionObject);
                context.AddPath (clipRegion.regionPath);
                context.ClosePath ();
                context.Clip ();
            }
            clipSet++;
        }
 public void SetClip(Graphics g, CombineMode combineMode)
 {
     throw new NotImplementedException ();
 }
 public void SetClip(GraphicsPath graphicsPath, CombineMode combineMode)
 {
     SetClip (new Region (graphicsPath), combineMode);
 }
 public void SetClip(Rectangle rect, CombineMode combineMode)
 {
     SetClip (rect.ToRectangleF (), combineMode);
 }
 public void SetClip(RectangleF rect, CombineMode combineMode)
 {
     SetClip (new Region (rect), combineMode);
 }
Beispiel #56
0
 public void SetContinuation(Point[][] polygonSet, CombineMode combineMode)
 {
     lock (this.syncRoot)
     {
         OnChanging();
         CommitInterimTransform();
         ResetCumulativeTransform();
         this.data.continuationCombineMode = combineMode;
         this.data.continuation.Reset();
         this.data.continuation.AddPolygons(polygonSet);
         OnChanged();
     }
 }
Beispiel #57
0
        // only works if base is empty 
        public void SetContinuation(PdnGraphicsPath path, CombineMode combineMode, bool takeOwnership)
        {
            lock (this.syncRoot)
            {
                if (!this.data.basePath.IsEmpty)
                {
                    throw new InvalidOperationException("base path must be empty to use this overload of SetContinuation");
                }

                OnChanging();

                CommitInterimTransform();
                ResetCumulativeTransform();

                this.data.continuationCombineMode = combineMode;

                if (takeOwnership)
                {
                    this.data.continuation.Dispose();
                    this.data.continuation = path;
                }
                else
                {
                    this.data.continuation.Reset();
                    this.data.continuation.AddPath(path, false);
                }

                OnChanged();
            }
        }
Beispiel #58
0
        public static void PerformSelectionMode (CombineMode mode,  List<List<IntPoint>> polygons)
        {
            var doc = PintaCore.Workspace.ActiveDocument;
            doc.Selection.Dispose ();
            doc.Selection = doc.PreviousSelection.Clone ();

            using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface))
            {
                //Make sure time isn't wasted if the CombineMode is Replace - Replace is much simpler than the other 4 selection modes.
                if (mode == CombineMode.Replace)
                {
                    //Clear any previously stored Polygons.
                    doc.Selection.SelectionPolygons.Clear ();

                    //Set the resulting selection path to the new selection path.
                    doc.Selection.SelectionPolygons = polygons;
                }
                else
                {
                    var resultingPolygons = new List<List<IntPoint>> ();

                    //Specify the Clipper Subject (the previous Polygons) and the Clipper Clip (the new Polygons).
                    //Note: for Union, ignore the Clipper Library instructions - the new polygon(s) should be Clips, not Subjects!
                    doc.Selection.SelectionClipper.AddPolygons (doc.Selection.SelectionPolygons, PolyType.ptSubject);
                    doc.Selection.SelectionClipper.AddPolygons (polygons, PolyType.ptClip);

                    switch (mode)
                    {
                        case CombineMode.Xor:
                            //Xor means "Combine both Polygon sets, but leave out any areas of intersection between the two."
                            doc.Selection.SelectionClipper.Execute (ClipType.ctXor, resultingPolygons);
                            break;
                        case CombineMode.Exclude:
                            //Exclude == Difference

                            //Exclude/Difference means "Subtract any overlapping areas of the new Polygon set from the old Polygon set."
                            doc.Selection.SelectionClipper.Execute (ClipType.ctDifference, resultingPolygons);
                            break;
                        case CombineMode.Intersect:
                            //Intersect means "Leave only the overlapping areas between the new and old Polygon sets."
                            doc.Selection.SelectionClipper.Execute (ClipType.ctIntersection, resultingPolygons);
                            break;
                        default:
                            //Default should only be *CombineMode.Union*, but just in case...

                            //Union means "Combine both Polygon sets, and keep any overlapping areas as well."
                            doc.Selection.SelectionClipper.Execute (ClipType.ctUnion, resultingPolygons);
                            break;
                    }

                    //After using Clipper, it has to be cleared so there are no conflicts with its next usage.
                    doc.Selection.SelectionClipper.Clear ();

                    //Set the resulting selection path to the calculated ("clipped") selection path.
                    doc.Selection.SelectionPolygons = resultingPolygons;
                }

                doc.Selection.MarkDirty ();
            }
        }
Beispiel #59
0
 //GpStatus SetClip( GraphicsPlus g,
 //               CombineMode combineMode)
 //{
 //    return SetStatus(NativeMethods.GdipSetClipGraphics(nativeGraphics,
 //                                                     g.nativeGraphics,
 //                                                     combineMode));
 //}
 //GpStatus SetClip( GpRectF rect,
 //               CombineMode combineMode)
 //{
 //    return SetStatus(NativeMethods.GdipSetClipRect(nativeGraphics,
 //                                                 rect.X, rect.Y,
 //                                                 rect.Width, rect.Height,
 //                                                 combineMode));
 //}
 //GpStatus SetClip( GpRect rect,
 //               CombineMode combineMode)
 //{
 //    return SetStatus(NativeMethods.GdipSetClipRectI(nativeGraphics,
 //                                                  rect.X, rect.Y,
 //                                                  rect.Width, rect.Height,
 //                                                  combineMode));
 //}
 //GpStatus SetClip( GraphicsPath path,
 //               CombineMode combineMode )
 //{
 //    return SetStatus(NativeMethods.GdipSetClipPath(nativeGraphics,
 //                                                 path.nativePath,
 //                                                 combineMode));
 //}
 //GpStatus SetClip( RegionPlus region,
 //               CombineMode combineMode)
 //{
 //    return SetStatus(NativeMethods.GdipSetClipRegion(nativeGraphics,
 //                                                   region.nativeRegion,
 //                                                   combineMode));
 //}
 // This is different than the other SetClip methods because it assumes
 // that the HRGN is already in device units, so it doesn't transform
 // the coordinates in the HRGN.
 GpStatus SetClip(HRGN hRgn,
                CombineMode combineMode)
 {
     return SetStatus(NativeMethods.GdipSetClipHrgn(nativeGraphics, hRgn,
                                                  combineMode));
 }
Beispiel #60
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if ((ModifierKeys & Keys.Control) != 0 && e.Button == MouseButtons.Left)
            {
                this.combineMode = CombineMode.Union;
            }
            else if ((ModifierKeys & Keys.Alt) != 0 && e.Button == MouseButtons.Left)
            {
                this.combineMode = CombineMode.Exclude;
            }
            else if ((ModifierKeys & Keys.Control) != 0 && e.Button == MouseButtons.Right)
            {
                this.combineMode = CombineMode.Xor;
            }
            else if ((ModifierKeys & Keys.Alt) != 0 && e.Button == MouseButtons.Right)
            {
                this.combineMode = CombineMode.Intersect;
            }
            else
            {
                this.combineMode = AppEnvironment.SelectionCombineMode;
            }

            base.OnMouseDown(e);
        }