On behalf of Rolanmen: LuaWriter. Added Restore Settings item, when closing, it will save the Zoom Value in Config.cs

LuaWriterColorConfig. Fixed little bug that didn't colored the Library panel. Also made each Color Dialog select it's default color.
This commit is contained in:
adelikat 2012-08-01 02:56:38 +00:00
parent accd643fde
commit 5a28f54454
5 changed files with 239 additions and 175 deletions

View File

@ -556,9 +556,11 @@ namespace BizHawk.MultiClient
public int LuaCommentColor = -16744448;
public int LuaStringColor = -8355712;
public int LuaSymbolColor = -16777216;
public int LuaLibraryColor = -6427649;
//public int LuaLibraryColor = -6427649;
public int LuaLibraryColor = -16711681;
public float LuaWriterFontSize = 11;
public string LuaWriterFont = "Courier New";
public float LuaWriterZoom = 1;
}
public class SMSControllerTemplate

View File

@ -45,6 +45,7 @@
this.PositionLabel = new System.Windows.Forms.Label();
this.ZoomLabel = new System.Windows.Forms.Label();
this.LuaText = new BizHawk.MultiClient.LuaWriterBox();
this.restoreSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -110,7 +111,8 @@
//
this.configToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fontToolStripMenuItem,
this.syntaxHighlightingToolStripMenuItem});
this.syntaxHighlightingToolStripMenuItem,
this.restoreSettingsToolStripMenuItem});
this.configToolStripMenuItem.Name = "configToolStripMenuItem";
this.configToolStripMenuItem.Size = new System.Drawing.Size(55, 20);
this.configToolStripMenuItem.Text = "&Config";
@ -190,6 +192,13 @@
this.LuaText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyUp);
this.LuaText.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.LuaText_PreviewKeyDown);
//
// restoreSettingsToolStripMenuItem
//
this.restoreSettingsToolStripMenuItem.Name = "restoreSettingsToolStripMenuItem";
this.restoreSettingsToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.restoreSettingsToolStripMenuItem.Text = "Restore Settings";
this.restoreSettingsToolStripMenuItem.Click += new System.EventHandler(this.restoreSettingsToolStripMenuItem_Click);
//
// LuaWriter
//
this.AllowDrop = true;
@ -206,6 +215,7 @@
this.MainMenuStrip = this.menuStrip1;
this.Name = "LuaWriter";
this.Text = "LuaWriter";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LuaWriter_FormClosing);
this.Load += new System.EventHandler(this.LuaWriter_Load);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LuaWriter_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.LuaWriter_DragEnter);
@ -233,5 +243,6 @@
private System.Windows.Forms.ListView AutoCompleteView;
private System.Windows.Forms.Label PositionLabel;
private System.Windows.Forms.Label ZoomLabel;
private System.Windows.Forms.ToolStripMenuItem restoreSettingsToolStripMenuItem;
}
}

View File

@ -50,8 +50,16 @@ namespace BizHawk.MultiClient
void LuaText_MouseWheel(object sender, MouseEventArgs e)
{
if(KeyInput.IsPressed(SlimDX.DirectInput.Key.LeftControl))
ZoomLabel.Text = string.Format("Zoom: {0}%", (LuaText.ZoomFactor * 100) + e.Delta / 12);
if (KeyInput.IsPressed(SlimDX.DirectInput.Key.LeftControl))
{
Double Zoom;
if ((LuaText.ZoomFactor == 0.1F && e.Delta < 0) || (LuaText.ZoomFactor == 5.0F && e.Delta > 0))
Zoom = (LuaText.ZoomFactor * 100);
else
Zoom = (LuaText.ZoomFactor * 100) + e.Delta / 12;
ZoomLabel.Text = string.Format("Zoom: {0:0}%", Zoom);
}
}
private void timer_Tick(object sender, EventArgs e)
@ -309,6 +317,8 @@ namespace BizHawk.MultiClient
//LuaTextFont;
LuaText.SelectionTabs = new int[] { 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 480, 500, 520, 540, 560, 580, 600 }; //adelikat: What a goofy way to have to do this
LoadFont();
LuaText.ZoomFactor = Global.Config.LuaWriterZoom;
ZoomLabel.Text = string.Format("Zoom: {0}%", LuaText.ZoomFactor * 100);
GenerateLibraryRegex();
if (!String.IsNullOrWhiteSpace(CurrentFile))
{
@ -607,5 +617,29 @@ namespace BizHawk.MultiClient
//TODO: check for changes and ask save
this.Close();
}
private void LuaWriter_FormClosing(object sender, FormClosingEventArgs e)
{
Global.Config.LuaWriterZoom = LuaText.ZoomFactor;
}
private void restoreSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.LuaDefaultTextColor = -16777216;
Global.Config.LuaKeyWordColor = -16776961;
Global.Config.LuaCommentColor = -16744448;
Global.Config.LuaStringColor = -8355712;
Global.Config.LuaSymbolColor = -16777216;
Global.Config.LuaLibraryColor = -16711681;
ProcessText();
Global.Config.LuaWriterFontSize = 11;
Global.Config.LuaWriterFont = "Courier New";
LuaText.Font = new Font("Courier New", 11);
Global.Config.LuaWriterZoom = 1;
LuaText.ZoomFactor = 1;
ZoomLabel.Text = "Zoom: 100%";
}
}
}

View File

@ -28,175 +28,191 @@
/// </summary>
private void InitializeComponent()
{
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.panelKeyWord = new System.Windows.Forms.Panel();
this.lblKeyWords = new System.Windows.Forms.Label();
this.lblComments = new System.Windows.Forms.Label();
this.panelComment = new System.Windows.Forms.Panel();
this.panelString = new System.Windows.Forms.Panel();
this.lblStrings = new System.Windows.Forms.Label();
this.panelSymbol = new System.Windows.Forms.Panel();
this.lblSymbols = new System.Windows.Forms.Label();
this.panelLibrary = new System.Windows.Forms.Panel();
this.lblLibraries = new System.Windows.Forms.Label();
this.KeyWordColorDialog = new System.Windows.Forms.ColorDialog();
this.CommentColorDialog = new System.Windows.Forms.ColorDialog();
this.StringColorDialog = new System.Windows.Forms.ColorDialog();
this.SymbolColorDialog = new System.Windows.Forms.ColorDialog();
this.LibraryColorDialog = new System.Windows.Forms.ColorDialog();
this.buttonDefaults = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(116, 227);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 10;
this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(197, 227);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 11;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
//
// panelKeyWord
//
this.panelKeyWord.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelKeyWord.Location = new System.Drawing.Point(105, 10);
this.panelKeyWord.Name = "panelKeyWord";
this.panelKeyWord.Size = new System.Drawing.Size(20, 20);
this.panelKeyWord.TabIndex = 1;
this.panelKeyWord.DoubleClick += new System.EventHandler(this.panelKeyWord_DoubleClick);
//
// lblKeyWords
//
this.lblKeyWords.AutoSize = true;
this.lblKeyWords.Location = new System.Drawing.Point(40, 17);
this.lblKeyWords.Name = "lblKeyWords";
this.lblKeyWords.Size = new System.Drawing.Size(59, 13);
this.lblKeyWords.TabIndex = 0;
this.lblKeyWords.Text = "Key Words";
//
// lblComments
//
this.lblComments.AutoSize = true;
this.lblComments.Location = new System.Drawing.Point(43, 57);
this.lblComments.Name = "lblComments";
this.lblComments.Size = new System.Drawing.Size(56, 13);
this.lblComments.TabIndex = 2;
this.lblComments.Text = "Comments";
//
// panelComment
//
this.panelComment.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelComment.Location = new System.Drawing.Point(105, 50);
this.panelComment.Name = "panelComment";
this.panelComment.Size = new System.Drawing.Size(20, 20);
this.panelComment.TabIndex = 3;
this.panelComment.DoubleClick += new System.EventHandler(this.panelComment_DoubleClick);
//
// panelString
//
this.panelString.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelString.Location = new System.Drawing.Point(105, 90);
this.panelString.Name = "panelString";
this.panelString.Size = new System.Drawing.Size(20, 20);
this.panelString.TabIndex = 5;
this.panelString.DoubleClick += new System.EventHandler(this.panelString_DoubleClick);
//
// lblStrings
//
this.lblStrings.AutoSize = true;
this.lblStrings.Location = new System.Drawing.Point(60, 97);
this.lblStrings.Name = "lblStrings";
this.lblStrings.Size = new System.Drawing.Size(39, 13);
this.lblStrings.TabIndex = 4;
this.lblStrings.Text = "Strings";
//
// panelSymbol
//
this.panelSymbol.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelSymbol.Location = new System.Drawing.Point(105, 130);
this.panelSymbol.Name = "panelSymbol";
this.panelSymbol.Size = new System.Drawing.Size(20, 20);
this.panelSymbol.TabIndex = 7;
this.panelSymbol.DoubleClick += new System.EventHandler(this.panelSymbol_DoubleClick);
//
// lblSymbols
//
this.lblSymbols.AutoSize = true;
this.lblSymbols.Location = new System.Drawing.Point(53, 137);
this.lblSymbols.Name = "lblSymbols";
this.lblSymbols.Size = new System.Drawing.Size(46, 13);
this.lblSymbols.TabIndex = 6;
this.lblSymbols.Text = "Symbols";
//
// panelLibrary
//
this.panelLibrary.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelLibrary.Location = new System.Drawing.Point(105, 170);
this.panelLibrary.Name = "panelLibrary";
this.panelLibrary.Size = new System.Drawing.Size(20, 20);
this.panelLibrary.TabIndex = 9;
this.panelLibrary.DoubleClick += new System.EventHandler(this.panelLibrary_DoubleClick);
//
// lblLibraries
//
this.lblLibraries.AutoSize = true;
this.lblLibraries.Location = new System.Drawing.Point(53, 177);
this.lblLibraries.Name = "lblLibraries";
this.lblLibraries.Size = new System.Drawing.Size(46, 13);
this.lblLibraries.TabIndex = 8;
this.lblLibraries.Text = "Libraries";
//
// buttonDefaults
//
this.buttonDefaults.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDefaults.Location = new System.Drawing.Point(12, 227);
this.buttonDefaults.Name = "buttonDefaults";
this.buttonDefaults.Size = new System.Drawing.Size(75, 23);
this.buttonDefaults.TabIndex = 12;
this.buttonDefaults.Text = "&Deafults";
this.buttonDefaults.UseVisualStyleBackColor = true;
this.buttonDefaults.Click += new System.EventHandler(this.buttonDefaults_Click);
//
// LuaWriterColorConfig
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.buttonDefaults);
this.Controls.Add(this.panelLibrary);
this.Controls.Add(this.lblLibraries);
this.Controls.Add(this.panelSymbol);
this.Controls.Add(this.lblSymbols);
this.Controls.Add(this.panelString);
this.Controls.Add(this.lblStrings);
this.Controls.Add(this.panelComment);
this.Controls.Add(this.lblComments);
this.Controls.Add(this.lblKeyWords);
this.Controls.Add(this.panelKeyWord);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Name = "LuaWriterColorConfig";
this.ShowIcon = false;
this.Text = "Syntax Highlight Config";
this.Load += new System.EventHandler(this.LuaWriterColorConfig_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.panelKeyWord = new System.Windows.Forms.Panel();
this.lblKeyWords = new System.Windows.Forms.Label();
this.lblComments = new System.Windows.Forms.Label();
this.panelComment = new System.Windows.Forms.Panel();
this.panelString = new System.Windows.Forms.Panel();
this.lblStrings = new System.Windows.Forms.Label();
this.panelSymbol = new System.Windows.Forms.Panel();
this.lblSymbols = new System.Windows.Forms.Label();
this.panelLibrary = new System.Windows.Forms.Panel();
this.lblLibraries = new System.Windows.Forms.Label();
this.KeyWordColorDialog = new System.Windows.Forms.ColorDialog();
this.CommentColorDialog = new System.Windows.Forms.ColorDialog();
this.StringColorDialog = new System.Windows.Forms.ColorDialog();
this.SymbolColorDialog = new System.Windows.Forms.ColorDialog();
this.LibraryColorDialog = new System.Windows.Forms.ColorDialog();
this.buttonDefaults = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(116, 227);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 10;
this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(197, 227);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 11;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
//
// panelKeyWord
//
this.panelKeyWord.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelKeyWord.Location = new System.Drawing.Point(105, 10);
this.panelKeyWord.Name = "panelKeyWord";
this.panelKeyWord.Size = new System.Drawing.Size(20, 20);
this.panelKeyWord.TabIndex = 1;
this.panelKeyWord.DoubleClick += new System.EventHandler(this.panelKeyWord_DoubleClick);
//
// lblKeyWords
//
this.lblKeyWords.AutoSize = true;
this.lblKeyWords.Location = new System.Drawing.Point(40, 17);
this.lblKeyWords.Name = "lblKeyWords";
this.lblKeyWords.Size = new System.Drawing.Size(59, 13);
this.lblKeyWords.TabIndex = 0;
this.lblKeyWords.Text = "Key Words";
//
// lblComments
//
this.lblComments.AutoSize = true;
this.lblComments.Location = new System.Drawing.Point(43, 57);
this.lblComments.Name = "lblComments";
this.lblComments.Size = new System.Drawing.Size(56, 13);
this.lblComments.TabIndex = 2;
this.lblComments.Text = "Comments";
//
// panelComment
//
this.panelComment.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelComment.Location = new System.Drawing.Point(105, 50);
this.panelComment.Name = "panelComment";
this.panelComment.Size = new System.Drawing.Size(20, 20);
this.panelComment.TabIndex = 3;
this.panelComment.DoubleClick += new System.EventHandler(this.panelComment_DoubleClick);
//
// panelString
//
this.panelString.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelString.Location = new System.Drawing.Point(105, 90);
this.panelString.Name = "panelString";
this.panelString.Size = new System.Drawing.Size(20, 20);
this.panelString.TabIndex = 5;
this.panelString.DoubleClick += new System.EventHandler(this.panelString_DoubleClick);
//
// lblStrings
//
this.lblStrings.AutoSize = true;
this.lblStrings.Location = new System.Drawing.Point(60, 97);
this.lblStrings.Name = "lblStrings";
this.lblStrings.Size = new System.Drawing.Size(39, 13);
this.lblStrings.TabIndex = 4;
this.lblStrings.Text = "Strings";
//
// panelSymbol
//
this.panelSymbol.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelSymbol.Location = new System.Drawing.Point(105, 130);
this.panelSymbol.Name = "panelSymbol";
this.panelSymbol.Size = new System.Drawing.Size(20, 20);
this.panelSymbol.TabIndex = 7;
this.panelSymbol.DoubleClick += new System.EventHandler(this.panelSymbol_DoubleClick);
//
// lblSymbols
//
this.lblSymbols.AutoSize = true;
this.lblSymbols.Location = new System.Drawing.Point(53, 137);
this.lblSymbols.Name = "lblSymbols";
this.lblSymbols.Size = new System.Drawing.Size(46, 13);
this.lblSymbols.TabIndex = 6;
this.lblSymbols.Text = "Symbols";
//
// panelLibrary
//
this.panelLibrary.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelLibrary.Location = new System.Drawing.Point(105, 170);
this.panelLibrary.Name = "panelLibrary";
this.panelLibrary.Size = new System.Drawing.Size(20, 20);
this.panelLibrary.TabIndex = 9;
this.panelLibrary.DoubleClick += new System.EventHandler(this.panelLibrary_DoubleClick);
//
// lblLibraries
//
this.lblLibraries.AutoSize = true;
this.lblLibraries.Location = new System.Drawing.Point(53, 177);
this.lblLibraries.Name = "lblLibraries";
this.lblLibraries.Size = new System.Drawing.Size(46, 13);
this.lblLibraries.TabIndex = 8;
this.lblLibraries.Text = "Libraries";
//
// KeyWordColorDialog
//
this.KeyWordColorDialog.Color = System.Drawing.Color.Blue;
//
// CommentColorDialog
//
this.CommentColorDialog.Color = System.Drawing.Color.Green;
//
// StringColorDialog
//
this.StringColorDialog.Color = System.Drawing.Color.Gray;
//
// LibraryColorDialog
//
this.LibraryColorDialog.Color = System.Drawing.Color.Cyan;
//
// buttonDefaults
//
this.buttonDefaults.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDefaults.Location = new System.Drawing.Point(12, 227);
this.buttonDefaults.Name = "buttonDefaults";
this.buttonDefaults.Size = new System.Drawing.Size(75, 23);
this.buttonDefaults.TabIndex = 12;
this.buttonDefaults.Text = "&Deafults";
this.buttonDefaults.UseVisualStyleBackColor = true;
this.buttonDefaults.Click += new System.EventHandler(this.buttonDefaults_Click);
//
// LuaWriterColorConfig
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.buttonDefaults);
this.Controls.Add(this.panelLibrary);
this.Controls.Add(this.lblLibraries);
this.Controls.Add(this.panelSymbol);
this.Controls.Add(this.lblSymbols);
this.Controls.Add(this.panelString);
this.Controls.Add(this.lblStrings);
this.Controls.Add(this.panelComment);
this.Controls.Add(this.lblComments);
this.Controls.Add(this.lblKeyWords);
this.Controls.Add(this.panelKeyWord);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Name = "LuaWriterColorConfig";
this.ShowIcon = false;
this.Text = "Syntax Highlight Config";
this.Load += new System.EventHandler(this.LuaWriterColorConfig_Load);
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@ -60,7 +60,8 @@ namespace BizHawk.MultiClient.tools
private void SetLibraryColor(int color)
{
LibraryColor = color; //Set new color
panelLibrary.BackColor = Color.FromArgb(color); //Update panel color with new selection
panelLibrary.BackColor = Color.FromArgb(color); //Update panel color with new selection
//MessageBox.Show(color.ToString());
}
//Pop up color dialog when double-clicked
@ -131,7 +132,7 @@ namespace BizHawk.MultiClient.tools
SetCommentColor(-16744448);
SetStringColor(-8355712);
SetSymbolColor(-16777216);
SetLibraryColor(-6427649);
SetLibraryColor(-16711681);
}
}
}