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); }
protected CommandBase(GraphicsHost graphicsHost) { if (graphicsHost == null) { throw new ArgumentNullException("graphicsHost"); } GraphicsHost = graphicsHost; }
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(); }
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; }
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); }
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)); }
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; }
/// <inheritdoc /> public override void Dispose() { FontConsolas12.Dispose(); FontConsolas12 = default; DisposeBuffers(); DisposeSurface(); GraphicsHost.ReleaseHdc(GraphicsHostDeviceContext); GraphicsHostDeviceContext = default; GraphicsHost.Dispose(); GraphicsHost = default; base.Dispose(); }
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); }
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); }
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); }
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)); }
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)); }
public void Dispose() { lock (_updateLock) { HostHandle = default; GraphicsHost?.Dispose(); GraphicsHost = default; FpsCounter?.Dispose(); FpsCounter = default; RenderBitmaps.Clear(); RenderBitmaps = default; _fontConsolas12?.Dispose(); _fontConsolas12 = default; } }
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); }
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); }
public override void Redo() { GraphicsHost.AddGraphic(_oldObj); Console.WriteLine("Redo creating graphic {0}.", GraphicName); }
public override void Undo() { _oldObj = GraphicsHost.RemoveGraphic(GraphicName); Console.WriteLine("Undo creating graphic {0}.", GraphicName); }
public RotateGraphicCommand(string graphicName, double newAngle, GraphicsHost graphicsHost) : base(graphicName, graphicsHost) { _newAngle = newAngle; }
public CreateGraphicCommand(string graphicName, GraphicsHost graphicsHost) : base(graphicName, graphicsHost) { }
public override void Undo() { GraphicsHost.RotateGraphic(GraphicName, _oldAngle); Console.WriteLine("Undo rotating graphic {0} degree.", GraphicName); }
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); }
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); }