public void MouseMoveSurface(MouseInfo info, ITextSurface surface) { Brush.IsVisible = true; if (!firstPoint.HasValue) { Brush.Position = info.ConsoleLocation; settingsPanel.CircleWidth = 0; settingsPanel.CircleHeight = 0; } else { AnimatedTextSurface animation; // Draw the line (erase old) to where the mouse is // create the animation frame animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(firstPoint.Value.X, info.ConsoleLocation.X) + 1, Math.Max(firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(firstPoint.Value.Y, info.ConsoleLocation.Y) + 1, Settings.Config.ScreenFont); var frame = animation.CreateFrame(); Point p1; if (firstPoint.Value.X > info.ConsoleLocation.X) { if (firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(frame.Width - 1, frame.Height - 1); else p1 = new Point(frame.Width - 1, 0); } else { if (firstPoint.Value.Y > info.ConsoleLocation.Y) p1 = new Point(0, frame.Height - 1); else p1 = new Point(0, 0); } settingsPanel.CircleWidth = frame.Width; settingsPanel.CircleHeight = frame.Height; animation.Center = p1; Settings.QuickEditor.TextSurface = frame; ellipseShape = new SadConsole.Shapes.Ellipse(); ellipseShape.BorderAppearance = borderAppearance; ellipseShape.EndingPoint = new Point(frame.Width - 1, frame.Height - 1); ellipseShape.Draw(Settings.QuickEditor); Brush.Animation = animation; } // TODO: Make this work. They push DOWN on the mouse, start the line from there, if they "Click" then go to mode where they click a second time // If they don't click and hold it down longer than click, pretend a second click happened and draw the line. if (info.LeftClicked) { if (!firstPoint.HasValue) { firstPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); RefreshTool(); } else { secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); Point p1 = new Point(Math.Min(firstPoint.Value.X, secondPoint.Value.X), Math.Min(firstPoint.Value.Y, secondPoint.Value.Y)); Point p2 = new Point(Math.Max(firstPoint.Value.X, secondPoint.Value.X), Math.Max(firstPoint.Value.Y, secondPoint.Value.Y)); Settings.QuickEditor.TextSurface = surface; ellipseShape.StartingPoint = p1; ellipseShape.EndingPoint = p2; ellipseShape.Draw(Settings.QuickEditor); Brush.Animation = Brush.Animations["single"]; Brush.Position = secondPoint.Value; firstPoint = null; secondPoint = null; //surface.ResyncAllCellEffects(); } } else if (info.RightClicked) { if (firstPoint.HasValue && !secondPoint.HasValue) { firstPoint = null; secondPoint = null; settingsPanel.CircleWidth = 0; settingsPanel.CircleHeight = 0; Brush.Animation = Brush.Animations["single"]; Brush.Position = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y); } } }
public void ProcessMouse(MouseConsoleState info, ISurface surface, bool isInBounds) { if (cancelled) { // wait until left button is released... if (info.Mouse.LeftButtonDown) { return; } else { cancelled = false; } } if (info.Mouse.LeftButtonDown) { if (!firstPoint.HasValue) { RefreshTool(); firstPoint = info.ConsolePosition; return; } else { // Check for right click cancel. if (info.Mouse.RightButtonDown) { cancelled = true; firstPoint = null; secondPoint = null; Brush.Animation = Brush.Animations["single"]; settingsPanel.CircleWidth = 0; settingsPanel.CircleHeight = 0; return; } secondPoint = info.ConsolePosition; // Draw the line (erase old) to where the mouse is // create the animation frame AnimatedSurface animation = new AnimatedSurface("line", Math.Max(firstPoint.Value.X, secondPoint.Value.X) - Math.Min(firstPoint.Value.X, secondPoint.Value.X) + 1, Math.Max(firstPoint.Value.Y, secondPoint.Value.Y) - Math.Min(firstPoint.Value.Y, secondPoint.Value.Y) + 1, SadConsoleEditor.Settings.Config.ScreenFont); var frame = animation.CreateFrame(); Point p1; if (firstPoint.Value.X > secondPoint.Value.X) { if (firstPoint.Value.Y > secondPoint.Value.Y) { p1 = Point.Zero; } else { p1 = new Point(0, frame.Height - 1); } } else { if (firstPoint.Value.Y > secondPoint.Value.Y) { p1 = new Point(frame.Width - 1, 0); } else { p1 = new Point(frame.Width - 1, frame.Height - 1); } } animation.Center = p1; settingsPanel.CircleWidth = animation.Width; settingsPanel.CircleHeight = animation.Height; SadConsoleEditor.Settings.QuickEditor.TextSurface = frame; ellipseShape = new SadConsole.Shapes.Ellipse(); ellipseShape.BorderAppearance = borderAppearance; ellipseShape.EndingPoint = new Point(frame.Width - 1, frame.Height - 1); ellipseShape.Draw(SadConsoleEditor.Settings.QuickEditor); Brush.Animation = animation; } } else if (firstPoint.HasValue) { settingsPanel.CircleWidth = 0; settingsPanel.CircleHeight = 0; // We let go outside of bounds if (!isInBounds) { firstPoint = null; cancelled = true; Brush.Animation = Brush.Animations["single"]; return; } // Position the shape and draw Point p1 = new Point(Math.Min(firstPoint.Value.X, secondPoint.Value.X), Math.Min(firstPoint.Value.Y, secondPoint.Value.Y)); Point p2 = new Point(Math.Max(firstPoint.Value.X, secondPoint.Value.X), Math.Max(firstPoint.Value.Y, secondPoint.Value.Y)); SadConsoleEditor.Settings.QuickEditor.TextSurface = surface; ellipseShape.StartingPoint = p1 + info.Console.TextSurface.RenderArea.Location; ellipseShape.EndingPoint = p2 + info.Console.TextSurface.RenderArea.Location; ellipseShape.Draw(SadConsoleEditor.Settings.QuickEditor); Brush.Animation = Brush.Animations["single"]; Brush.Position = secondPoint.Value; firstPoint = null; secondPoint = null; } }