Esempio n. 1
0
        public override void Execute()
        {
            var graphicObj = new GraphicObj(GraphicName);

            GraphicsHost.AddGraphic(graphicObj);
            Console.WriteLine("Create graphic {0}.", GraphicName);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public RenderHost(IRenderHostSetup renderHostSetup) :
     base(renderHostSetup)
 {
     GraphicsHost = Graphics.FromHwnd(HostHandle);
     GraphicsHostDeviceContext = GraphicsHost.GetHdc();
     CreateSurface(HostInput.Size);
     CreateBuffers(BufferSize);
     FontConsolas12 = new Font("Consolas", 12);
 }
Esempio n. 3
0
        protected CommandBase(GraphicsHost graphicsHost)
        {
            if (graphicsHost == null)
            {
                throw new ArgumentNullException("graphicsHost");
            }

            GraphicsHost = graphicsHost;
        }
Esempio n. 4
0
 private void DisposeGraphicsHost()
 {
     if (GraphicsHost == null)
     {
         throw new NullReferenceException("GrahpicsHost in Drivers\\GraphicsDeviceInterface\\Render\\RenderHost is NULL");
     }
     GraphicsHost.Dispose();
     GraphicsHost = default;
 }
        /// <inheritdoc />
        public override void Dispose()
        {
            FontConsolas12.Dispose();
            FontConsolas12 = default;

            GraphicsHost.Dispose();
            GraphicsHost = default;

            base.Dispose();
        }
Esempio n. 6
0
        private void DisposeGraphicsHostDeviceContext()
        {
            if (GraphicsHostDeviceContext == null || GraphicsHost == null)
            {
                throw new NullReferenceException("GraphicsHostDeviceContext or GraphicsHost in Drivers\\GraphicsDeviceInterface\\Render\\RenderHost is NULL");
            }

            GraphicsHost.ReleaseHdc(GraphicsHostDeviceContext);
            GraphicsHostDeviceContext = default;
        }
Esempio n. 7
0
 public ScreenRenderer(IntPtr hostHandle, Size bufferSize)
 {
     _fontConsolas12           = new Font("Consolas", 12);
     FpsCounter                = new FpsCounter(new TimeSpan(0, 0, 0, 0, 1000));
     BackBuffer                = new DirectBitmap(bufferSize);
     RenderBitmaps             = new ConcurrentBag <Bitmap>();
     GraphicsHost              = Graphics.FromHwnd(hostHandle);
     GraphicsHostDeviceContext = GraphicsHost.GetHdc();
     BufferedGraphics          = BufferedGraphicsManager.Current.Allocate(GraphicsHostDeviceContext, new Rectangle(new Point(0, 0), bufferSize));
     HostHandle                = hostHandle;
     _bufferSize               = bufferSize;
 }
        public override void Undo(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            var graphicName = executionContext.GraphicName;

            GraphicsHost.RemoveGraphic(graphicName);
            Console.WriteLine("Undo adding graphic {0}.", graphicName);
        }
Esempio n. 9
0
        public override ExecutionContext Execute(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            var graphicName = executionContext.GraphicName;
            var removedObj  = GraphicsHost.RemoveGraphic(graphicName);

            Console.WriteLine("Remove graphic {0}.", graphicName);

            return(new ExecutionContext(GetType(), graphicName, graphicName, removedObj));
        }
Esempio n. 10
0
        protected CommandBase(string graphicName, GraphicsHost graphicsHost)
        {
            if (string.IsNullOrEmpty(graphicName))
            {
                throw new ArgumentException("Graphic name can't be null or empty.", "graphicName");
            }

            if (graphicsHost == null)
            {
                throw new ArgumentNullException("graphicsHost");
            }

            GraphicsHost = graphicsHost;
            GraphicName  = graphicName;
        }
Esempio n. 11
0
        /// <inheritdoc />
        public override void Dispose()
        {
            FontConsolas12.Dispose();
            FontConsolas12 = default;

            DisposeBuffers();
            DisposeSurface();

            GraphicsHost.ReleaseHdc(GraphicsHostDeviceContext);
            GraphicsHostDeviceContext = default;

            GraphicsHost.Dispose();
            GraphicsHost = default;

            base.Dispose();
        }
Esempio n. 12
0
        public override void Redo(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextBeforeExecution == null)
            {
                throw new ArgumentException("ContextBeforeExecution can't be null.", "executionContext");
            }

            var newScale = (double)executionContext.ContextBeforeExecution;

            GraphicsHost.ZoomInGraphic(executionContext.GraphicName, newScale);
            Console.WriteLine("Redo zooming graphic {0} to scale {1}", executionContext.GraphicName, newScale);
        }
Esempio n. 13
0
        public override void Undo(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextAfterExecution == null)
            {
                throw new ArgumentException("ContextAfterExecution can't be null.", "executionContext");
            }

            var oldScale = (double)executionContext.ContextAfterExecution;

            GraphicsHost.ZoomInGraphic(executionContext.GraphicName, oldScale);
            Console.WriteLine("Undo zooming graphic {0}, the graphic is rotated back to {1}.", executionContext.GraphicName, oldScale);
        }
Esempio n. 14
0
        public override void Redo(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextBeforeExecution == null)
            {
                throw new ArgumentException("ContextBeforeExecution can't be null.", "executionContext");
            }

            var newPosition = (double)executionContext.ContextBeforeExecution;

            GraphicsHost.MoveGraphic(executionContext.GraphicName, newPosition);
            Console.WriteLine("Redo moving graphic {0} to position {1}", executionContext.GraphicName, newPosition);
        }
Esempio n. 15
0
        public override ExecutionContext Execute(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextBeforeExecution == null)
            {
                throw new ArgumentException("ContextBeforeExecution can't be null.", "executionContext");
            }

            var newScale = (double)executionContext.ContextBeforeExecution;
            var oldScale = GraphicsHost.ZoomInGraphic(executionContext.GraphicName, newScale);

            Console.WriteLine("Rotate graphic {0} to scale {1}", executionContext.GraphicName, newScale);

            return(new ExecutionContext(GetType(), executionContext.GraphicName, newScale, oldScale));
        }
Esempio n. 16
0
        public override ExecutionContext Execute(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextBeforeExecution == null)
            {
                throw new ArgumentException("ContextBeforeExecution can't be null.", "executionContext");
            }

            var newPosition = (double)executionContext.ContextBeforeExecution;
            var oldPosition = GraphicsHost.MoveGraphic(executionContext.GraphicName, newPosition);

            Console.WriteLine("Move graphic {0} to position {1}", executionContext.GraphicName, newPosition);

            return(new ExecutionContext(GetType(), executionContext.GraphicName, newPosition, oldPosition));
        }
Esempio n. 17
0
        public void Dispose()
        {
            lock (_updateLock)
            {
                HostHandle = default;

                GraphicsHost?.Dispose();
                GraphicsHost = default;

                FpsCounter?.Dispose();
                FpsCounter = default;

                RenderBitmaps.Clear();
                RenderBitmaps = default;

                _fontConsolas12?.Dispose();
                _fontConsolas12 = default;
            }
        }
Esempio n. 18
0
        public override void Undo(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextAfterExecution == null)
            {
                throw new ArgumentException("ContextAfterExecution can't be null.", "executionContext");
            }

            var removedObj = executionContext.ContextAfterExecution as GraphicObj;

            if (removedObj == null)
            {
                throw new ArgumentException("ContextAfterExecution should be GraphicObj type.", "executionContext");
            }

            GraphicsHost.AddGraphic(removedObj);
            Console.WriteLine("Undo removing graphic {0}.", executionContext.GraphicName);
        }
        public override void Redo(ExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            if (executionContext.ContextAfterExecution == null)
            {
                throw new ArgumentException("ContextAfterExecution can't be null.", "executionContext");
            }

            var objToAdd = executionContext.ContextAfterExecution as GraphicObj;

            if (objToAdd == null)
            {
                throw new ArgumentException("ContextAfterExecution should be GraphicObj type.", "executionContext");
            }

            GraphicsHost.AddGraphic(objToAdd);
            Console.Write("Redo adding graphic {0}.", executionContext.GraphicName);
        }
Esempio n. 20
0
        public static Dictionary <Type, IStatelessCommand> Createommands()
        {
            var commands    = new Dictionary <Type, IStatelessCommand>();
            var graphicHost = new GraphicsHost();

            IStatelessCommand command = new CreateGraphicCommand(graphicHost);

            commands.Add(command.GetType(), command);

            command = new RemoveGraphicCommand(graphicHost);
            commands.Add(command.GetType(), command);

            command = new MoveGraphicCommand(graphicHost);
            commands.Add(command.GetType(), command);

            command = new RotateGraphicCommand(graphicHost);
            commands.Add(command.GetType(), command);

            command = new ZoomInGraphicCommand(graphicHost);
            commands.Add(command.GetType(), command);

            return(commands);
        }
 public override void Execute()
 {
     _removedGraphicObj = GraphicsHost.RemoveGraphic(GraphicName);
     Console.WriteLine("Reomve graphic {0} degree.", GraphicName);
 }
Esempio n. 22
0
 public override void Redo()
 {
     GraphicsHost.AddGraphic(_oldObj);
     Console.WriteLine("Redo creating graphic {0}.", GraphicName);
 }
Esempio n. 23
0
 public override void Undo()
 {
     _oldObj = GraphicsHost.RemoveGraphic(GraphicName);
     Console.WriteLine("Undo creating graphic {0}.", GraphicName);
 }
Esempio n. 24
0
 public RotateGraphicCommand(string graphicName, double newAngle, GraphicsHost graphicsHost)
     : base(graphicName, graphicsHost)
 {
     _newAngle = newAngle;
 }
Esempio n. 25
0
 public CreateGraphicCommand(string graphicName, GraphicsHost graphicsHost)
     : base(graphicName, graphicsHost)
 {
 }
Esempio n. 26
0
 public override void Undo()
 {
     GraphicsHost.RotateGraphic(GraphicName, _oldAngle);
     Console.WriteLine("Undo rotating graphic {0} degree.", GraphicName);
 }
Esempio n. 27
0
 public override void Execute()
 {
     _oldAngle = GraphicsHost.RotateGraphic(GraphicName, _newAngle);
     Console.WriteLine("Rotate graphic {0} {1} degree.", GraphicName, _newAngle);
 }
 public override void Undo()
 {
     GraphicsHost.AddGraphic(_removedGraphicObj);
     Console.WriteLine("Undo reomving graphic {0} degree.", GraphicName);
 }
Esempio n. 29
0
 public override void Redo()
 {
     _oldAngle = GraphicsHost.RotateGraphic(GraphicName, _newAngle);
     Console.WriteLine("Redo rotating graphic {0} {1} degree.", GraphicName, _newAngle);
 }
 public override void Redo()
 {
     _removedGraphicObj = GraphicsHost.RemoveGraphic(GraphicName);
     Console.WriteLine("Redo reomving graphic {0} degree.", GraphicName);
 }