示例#1
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     this.currentPaintCommand        = PaintCommand.clear;
     this.toolStripStatusLabel2.Text = "Clear";
     this.panel4.Invalidate();
     this.panel4.Update();
 }
示例#2
0
 private void performNewCommand(PaintCommand command)
 {
     if (!undoStack.Contains(command))
     {
         redoStack.Clear();
         undoStack.Push(command);
     }
     //Debug.Log ("new command pushed " + "undo "+ undoStack.Count + "redo " + redoStack.Count);
 }
示例#3
0
 public void redoCommand()
 {
     if (redoStack.Count > 0)
     {
         PaintCommand command = redoStack.Pop();
         command.redo();
         undoStack.Push(command);
         //Debug.Log ("new command redone " + "undo "+ undoStack.Count + "redo " + redoStack.Count);
     }
 }
示例#4
0
        private void Paint_Internal(PaintEntry entry, bool isTemporary)
        {
            Assert.ArgumentNotNull(entry, nameof(entry));

            var material = entry.brushSnapshot.material;

            var go = new GameObject("PaintEntry");

            var renderer = go.AddComponent <MeshRenderer> ();

            renderer.material                  = material;
            renderer.lightProbeUsage           = UnityEngine.Rendering.LightProbeUsage.Off;
            renderer.reflectionProbeUsage      = UnityEngine.Rendering.ReflectionProbeUsage.Off;
            renderer.receiveShadows            = false;
            renderer.shadowCastingMode         = UnityEngine.Rendering.ShadowCastingMode.Off;
            renderer.allowOcclusionWhenDynamic = false;

            var meshFilter = go.AddComponent <MeshFilter> ();

            meshFilter.mesh = entry.Mesh;

            var objectWidth = entry.BrushPositions.Count * distanceBetweenBrushes;

            if (isTemporary)
            {
                rendererStation.UseItTemporary(go, objectWidth);
                var chunksToRender = CalculateChunksToRender(entry.brushSnapshot.percentageSize, entry.BrushPositions);
                var renderContext  = CalculateRenderContext(chunksToRender);
                NotifyNeedRender(renderContext);

                entry.BrushPositionAdded += l =>
                {
                    meshFilter.mesh = entry.Mesh;
                    var newChunksToRender = CalculateChunksToRender(entry.brushSnapshot.percentageSize, l);
                    var newRenderContext  = CalculateRenderContext(newChunksToRender);
                    NotifyNeedRender(newRenderContext);
                };
            }
            else
            {
                var chunksToRender = CalculateChunksToRender(entry.brushSnapshot.percentageSize, entry.BrushPositions);
                var renderContext  = CalculateRenderContext(chunksToRender);
                var command        = new PaintCommand(rendererStation, go, objectWidth, () => NotifyNeedRender(renderContext));
                undoRedoManager.Do(command);
            }
        }
示例#5
0
        private Boolean breakOut = true; // when set to true it should break out of the next iteration and stop the current plot.  This is not very functional but works

        /// <summary>
        /// panel4_Paint ... change name to GraphicPaint or Layer Paint etc...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void panel4_Paint(object sender, PaintEventArgs e)
        {
            if (this.currentPaintCommand == PaintCommand.opaque)
            {
                if (this.runIt == true)
                {
                    while (qpts.Count > 0)
                    {
                        var pt = qpts.Dequeue();

                        //e.Graphics.DrawLine(new Pen(myBrush1), pt, new Point(pt.X - 1, pt.Y));
                        //e.Graphics.DrawLine(new Pen(myBrush2), pt, new Point(pt.X, pt.Y - 1));
                        //e.Graphics.DrawLine(new Pen(myBrush3), pt, new Point(pt.X, pt.Y));
                        //e.Graphics.DrawLine(new Pen(myBrush4), pt, new Point(pt.X - 1, pt.Y - 1));

                        //e.Graphics.DrawLine(new Pen(myBrush3), pt.X, pt.Y, pt.X + 1, pt.Y + 1);

                        e.Graphics.FillRectangle(myBrush3, pt.X, pt.Y, 1, 1);
                        e.Graphics.FillRectangle(myBrush4, pt.X + 1, pt.Y + 1, 1, 1);
                        e.Graphics.FillRectangle(myBrush1, pt.X + 1, pt.Y, 1, 1);
                        e.Graphics.FillRectangle(myBrush2, pt.X, pt.Y + 1, 1, 1);

                        //e.Graphics.DrawLine(new Pen(myBrush4),
                        //    pt,
                        //    new Point(pt.X + 1, pt.Y + 1)
                        //);
                    }
                    this.dequeing_flag = false;
                }
            }
            else if (this.currentPaintCommand == PaintCommand.clear)
            {
                this.panel4.Invalidate();
                this.currentPaintCommand        = PaintCommand.opaque;
                this.toolStripStatusLabel2.Text = "Opaque";
            }
        }