diff --git a/BizHawk.Client.EmuHawk/CustomControls/GDITextRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/GDITextRenderer.cs index 592baac8d7..3d6bcac6a6 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/GDITextRenderer.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/GDITextRenderer.cs @@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls /// Wrapper for GDI text rendering functions
/// This class is not thread-safe as GDI function should be called from the UI thread. /// - public sealed class NativeTextRenderer : IDisposable + public sealed class GDIRenderer : IDisposable { #region Fields and Consts @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls #endregion - public NativeTextRenderer(System.Windows.Forms.Control c) + public GDIRenderer(System.Windows.Forms.Control c) { _c = c; _hdc = GetDC(c.Handle); @@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls /// /// Init. /// - public NativeTextRenderer(Graphics g) + public GDIRenderer(Graphics g) { _g = g; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 0cb4669dda..834731dbc3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -6,18 +6,28 @@ using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.EmuHawk.CustomControls; + namespace BizHawk.Client.EmuHawk { public class InputRoll : Control { public InputRoll() { + CellPadding = 3; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); + this.Font = new Font("Courier New", 8); } #region Properties + /// + /// Gets or sets the amount of padding on the text inside a cell + /// + [DefaultValue(3)] + public int CellPadding { get; set; } + // TODO: remove this, it is put here for more convenient replacing of a virtuallistview in tools with the need to refactor code public bool VirtualMode { get; set; } @@ -45,7 +55,10 @@ namespace BizHawk.Client.EmuHawk [Category("Behavior")] public bool AllowColumnReorder { get; set; } - // TODO: don't expose to the designer + /// + /// Column data + /// + [Category("Behavior")] public RollColumns Columns { get; set; } #endregion @@ -93,9 +106,50 @@ namespace BizHawk.Client.EmuHawk #region Paint + private void DrawColumnBg(GDIRenderer ntr, PaintEventArgs e) + { + if (HorizontalOrientation) + { + + } + else + { + + } + } + + private void DrawBg(GDIRenderer ntr, PaintEventArgs e) + { + var start = StartBg; + + ntr.DrawRectangle(StartBg.X, StartBg.Y, Width, Height); + + if (HorizontalOrientation) + { + + } + else + { + + } + } + protected override void OnPaintBackground(PaintEventArgs pevent) { - base.OnPaintBackground(pevent); + using (var ntr = new GDIRenderer(this)) + { + if (NeedToUpdateColumn() && Columns.Any()) + { + DrawColumnBg(ntr, pevent); + } + + if (NeedToUpdateBg()) + { + DrawBg(ntr, pevent); + } + } + + //base.OnPaintBackground(pevent); } protected override void OnPaint(PaintEventArgs e) @@ -123,7 +177,7 @@ namespace BizHawk.Client.EmuHawk private bool NeedToUpdateColumn() { - return true;// TODO + return true; // TODO } private bool NeedToUpdateText() @@ -141,11 +195,35 @@ namespace BizHawk.Client.EmuHawk return true; } + private Point StartBg + { + get + { + if (Columns.Any()) + { + if (HorizontalOrientation) + { + var x = (Columns.Max(c => c.Text.Length) * TextWidth) + CellPadding; + var y = TextHeight + CellPadding; + return new Point(x, y); + } + else + { + var x = 0; + var y = TextHeight + CellPadding; + return new Point(x, y); + } + } + + return new Point(0, 0); + } + } + private int TextHeight { get { - return 13; // TODO + return this.Font.Height; } } @@ -153,7 +231,7 @@ namespace BizHawk.Client.EmuHawk { get { - return 15; // TODO + return 15; } } @@ -175,21 +253,27 @@ namespace BizHawk.Client.EmuHawk public class RollColumns : List { - public void Add(string name, string text, int width) + public void Add(string name, string text, int width, RollColumn.InputType type = RollColumn.InputType.Boolean) { Add(new RollColumn { Name = name, Text = text, - Width = width + Width = width, + Type = type }); } } + + public class RollColumn { + public enum InputType { Boolean, Float } + public int Width { get; set; } public string Name { get; set; } public string Text { get; set; } + public InputType Type { get; set; } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs index dda4ae30d7..2f2d7ff34e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs @@ -28,65 +28,71 @@ /// private void InitializeComponent() { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.inputRoll1 = new BizHawk.Client.EmuHawk.InputRoll(); - this.menuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.InputView = new BizHawk.Client.EmuHawk.InputRoll(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.settingsToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(404, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // settingsToolStripMenuItem - // - this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(404, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // settingsToolStripMenuItem + // + this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.autoloadToolStripMenuItem}); - this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; - this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); - this.settingsToolStripMenuItem.Text = "&Settings"; - this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.settingsToolStripMenuItem_DropDownOpened); - // - // autoloadToolStripMenuItem - // - this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; - this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(123, 22); - this.autoloadToolStripMenuItem.Text = "Autoload"; - this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click); - // - // inputRoll1 - // - this.inputRoll1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); + this.settingsToolStripMenuItem.Text = "&Settings"; + this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.settingsToolStripMenuItem_DropDownOpened); + // + // autoloadToolStripMenuItem + // + this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; + this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + this.autoloadToolStripMenuItem.Text = "Autoload"; + this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click); + // + // InputView + // + this.InputView.AllowColumnReorder = false; + this.InputView.AllowColumnResize = false; + this.InputView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.inputRoll1.Location = new System.Drawing.Point(12, 103); - this.inputRoll1.Name = "inputRoll1"; - this.inputRoll1.Size = new System.Drawing.Size(380, 303); - this.inputRoll1.TabIndex = 1; - this.inputRoll1.Text = "inputRoll1"; - // - // TasStudioExperiment - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(404, 418); - this.Controls.Add(this.inputRoll1); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "TasStudioExperiment"; - this.Text = "TasStudioExperiment"; - this.Load += new System.EventHandler(this.TasStudioExperiment_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + this.InputView.Columns = null; + this.InputView.HorizontalOrientation = false; + this.InputView.ItemCount = 0; + this.InputView.Location = new System.Drawing.Point(12, 103); + this.InputView.Name = "InputView"; + this.InputView.Size = new System.Drawing.Size(380, 303); + this.InputView.TabIndex = 1; + this.InputView.Text = "inputRoll1"; + this.InputView.VirtualMode = false; + // + // TasStudioExperiment + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(404, 418); + this.Controls.Add(this.InputView); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Name = "TasStudioExperiment"; + this.Text = "TasStudioExperiment"; + this.Load += new System.EventHandler(this.TasStudioExperiment_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -95,6 +101,6 @@ private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; - private InputRoll inputRoll1; + private InputRoll InputView; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs index b83bccb4a6..4e3423bdd4 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs @@ -24,6 +24,7 @@ namespace BizHawk.Client.EmuHawk return; } + InputView.Refresh(); } public void FastUpdate()