diff --git a/PInvoke.Core/Controls/TranslateSnippetControl.Designer.cs b/PInvoke.Core/Controls/TranslateSnippetControl.Designer.cs index 7e262d4..f4acaef 100644 --- a/PInvoke.Core/Controls/TranslateSnippetControl.Designer.cs +++ b/PInvoke.Core/Controls/TranslateSnippetControl.Designer.cs @@ -35,90 +35,91 @@ protected override void Dispose(bool disposing) [System.Diagnostics.DebuggerStepThrough()] private void InitializeComponent() { - components = null; - this.TableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.FlowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.m_autoGenerateBtn = new System.Windows.Forms.CheckBox(); - this.m_generateBtn = new System.Windows.Forms.Button(); + this._autoGenerateButton = new System.Windows.Forms.CheckBox(); + this._generateButton = new System.Windows.Forms.Button(); this.m_errorsTb = new System.Windows.Forms.RichTextBox(); this.Label1 = new System.Windows.Forms.Label(); this.Label2 = new System.Windows.Forms.Label(); this.Label3 = new System.Windows.Forms.Label(); - this.m_langTypeCb = new System.Windows.Forms.ComboBox(); - this.m_nativeCodeTb = new System.Windows.Forms.TextBox(); + this._languageTypeComboBox = new System.Windows.Forms.ComboBox(); + this._nativeCodeTextBox = new System.Windows.Forms.TextBox(); this.SplitContainer1 = new System.Windows.Forms.SplitContainer(); - this.m_bgWorker = new System.ComponentModel.BackgroundWorker(); - this.m_managedCodeBox = new PInvoke.Controls.CodeBox(); + this._backgroundWorker = new System.ComponentModel.BackgroundWorker(); + this._managedCodeTextBox = new PInvoke.Controls.CodeBox(); this.TableLayoutPanel1.SuspendLayout(); this.FlowLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.SplitContainer1)).BeginInit(); this.SplitContainer1.Panel1.SuspendLayout(); this.SplitContainer1.Panel2.SuspendLayout(); this.SplitContainer1.SuspendLayout(); this.SuspendLayout(); - // - //TableLayoutPanel1 - // + // + // TableLayoutPanel1 + // this.TableLayoutPanel1.ColumnCount = 2; - this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 62f)); - this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f)); + this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 62F)); + this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.TableLayoutPanel1.Controls.Add(this.FlowLayoutPanel1, 0, 5); this.TableLayoutPanel1.Controls.Add(this.m_errorsTb, 0, 4); this.TableLayoutPanel1.Controls.Add(this.Label1, 0, 1); this.TableLayoutPanel1.Controls.Add(this.Label2, 0, 3); this.TableLayoutPanel1.Controls.Add(this.Label3, 0, 0); - this.TableLayoutPanel1.Controls.Add(this.m_langTypeCb, 1, 0); - this.TableLayoutPanel1.Controls.Add(this.m_nativeCodeTb, 0, 2); + this.TableLayoutPanel1.Controls.Add(this._languageTypeComboBox, 1, 0); + this.TableLayoutPanel1.Controls.Add(this._nativeCodeTextBox, 0, 2); this.TableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.TableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.TableLayoutPanel1.Name = "TableLayoutPanel1"; this.TableLayoutPanel1.RowCount = 6; this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50f)); + this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50f)); + this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.TableLayoutPanel1.Size = new System.Drawing.Size(318, 450); this.TableLayoutPanel1.TabIndex = 0; - // - //FlowLayoutPanel1 - // + // + // FlowLayoutPanel1 + // this.FlowLayoutPanel1.Anchor = System.Windows.Forms.AnchorStyles.Right; this.FlowLayoutPanel1.AutoSize = true; this.FlowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.TableLayoutPanel1.SetColumnSpan(this.FlowLayoutPanel1, 2); - this.FlowLayoutPanel1.Controls.Add(this.m_autoGenerateBtn); - this.FlowLayoutPanel1.Controls.Add(this.m_generateBtn); + this.FlowLayoutPanel1.Controls.Add(this._autoGenerateButton); + this.FlowLayoutPanel1.Controls.Add(this._generateButton); this.FlowLayoutPanel1.Location = new System.Drawing.Point(136, 421); this.FlowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); this.FlowLayoutPanel1.Name = "FlowLayoutPanel1"; this.FlowLayoutPanel1.Size = new System.Drawing.Size(182, 29); this.FlowLayoutPanel1.TabIndex = 7; - // - //m_autoGenerateBtn - // - this.m_autoGenerateBtn.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.m_autoGenerateBtn.AutoSize = true; - this.m_autoGenerateBtn.Location = new System.Drawing.Point(3, 6); - this.m_autoGenerateBtn.Name = "m_autoGenerateBtn"; - this.m_autoGenerateBtn.Size = new System.Drawing.Size(95, 17); - this.m_autoGenerateBtn.TabIndex = 8; - this.m_autoGenerateBtn.Text = "&Auto Generate"; - this.m_autoGenerateBtn.UseVisualStyleBackColor = true; - // - //m_generateBtn - // - this.m_generateBtn.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.m_generateBtn.Location = new System.Drawing.Point(104, 3); - this.m_generateBtn.Name = "m_generateBtn"; - this.m_generateBtn.Size = new System.Drawing.Size(75, 23); - this.m_generateBtn.TabIndex = 9; - this.m_generateBtn.Text = "&Generate"; - this.m_generateBtn.UseVisualStyleBackColor = true; - // - //m_errorsTb - // + // + // _autoGenerateButton + // + this._autoGenerateButton.Anchor = System.Windows.Forms.AnchorStyles.Left; + this._autoGenerateButton.AutoSize = true; + this._autoGenerateButton.Location = new System.Drawing.Point(3, 6); + this._autoGenerateButton.Name = "_autoGenerateButton"; + this._autoGenerateButton.Size = new System.Drawing.Size(95, 17); + this._autoGenerateButton.TabIndex = 8; + this._autoGenerateButton.Text = "&Auto Generate"; + this._autoGenerateButton.UseVisualStyleBackColor = true; + this._autoGenerateButton.CheckedChanged += new System.EventHandler(this.OnAutoGenerateCodeCheckChanged); + // + // _generateButton + // + this._generateButton.Anchor = System.Windows.Forms.AnchorStyles.Right; + this._generateButton.Location = new System.Drawing.Point(104, 3); + this._generateButton.Name = "_generateButton"; + this._generateButton.Size = new System.Drawing.Size(75, 23); + this._generateButton.TabIndex = 9; + this._generateButton.Text = "&Generate"; + this._generateButton.UseVisualStyleBackColor = true; + this._generateButton.Click += new System.EventHandler(this.OnGenerateCodeClick); + // + // m_errorsTb + // this.TableLayoutPanel1.SetColumnSpan(this.m_errorsTb, 2); this.m_errorsTb.Dock = System.Windows.Forms.DockStyle.Fill; this.m_errorsTb.Location = new System.Drawing.Point(3, 240); @@ -127,9 +128,9 @@ private void InitializeComponent() this.m_errorsTb.Size = new System.Drawing.Size(312, 178); this.m_errorsTb.TabIndex = 6; this.m_errorsTb.Text = ""; - // - //Label1 - // + // + // Label1 + // this.Label1.Anchor = System.Windows.Forms.AnchorStyles.Left; this.Label1.AutoSize = true; this.TableLayoutPanel1.SetColumnSpan(this.Label1, 2); @@ -138,9 +139,9 @@ private void InitializeComponent() this.Label1.Size = new System.Drawing.Size(105, 13); this.Label1.TabIndex = 3; this.Label1.Text = "&Native Code Snippet"; - // - //Label2 - // + // + // Label2 + // this.Label2.Anchor = System.Windows.Forms.AnchorStyles.Left; this.Label2.AutoSize = true; this.TableLayoutPanel1.SetColumnSpan(this.Label2, 2); @@ -149,9 +150,9 @@ private void InitializeComponent() this.Label2.Size = new System.Drawing.Size(34, 13); this.Label2.TabIndex = 5; this.Label2.Text = "&Errors"; - // - //Label3 - // + // + // Label3 + // this.Label3.Anchor = System.Windows.Forms.AnchorStyles.Left; this.Label3.AutoSize = true; this.Label3.Location = new System.Drawing.Point(3, 7); @@ -159,60 +160,60 @@ private void InitializeComponent() this.Label3.Size = new System.Drawing.Size(55, 13); this.Label3.TabIndex = 1; this.Label3.Text = "&Language"; - // - //m_langTypeCb - // - this.m_langTypeCb.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right); - this.m_langTypeCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.m_langTypeCb.FormattingEnabled = true; - this.m_langTypeCb.Location = new System.Drawing.Point(65, 3); - this.m_langTypeCb.Name = "m_langTypeCb"; - this.m_langTypeCb.Size = new System.Drawing.Size(250, 21); - this.m_langTypeCb.TabIndex = 2; - // - //m_nativeCodeTb - // - this.TableLayoutPanel1.SetColumnSpan(this.m_nativeCodeTb, 2); - this.m_nativeCodeTb.Dock = System.Windows.Forms.DockStyle.Fill; - this.m_nativeCodeTb.Location = new System.Drawing.Point(3, 43); - this.m_nativeCodeTb.Multiline = true; - this.m_nativeCodeTb.Name = "m_nativeCodeTb"; - this.m_nativeCodeTb.Size = new System.Drawing.Size(312, 178); - this.m_nativeCodeTb.TabIndex = 4; - // - //SplitContainer1 - // + // + // _languageTypeComboBox + // + this._languageTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this._languageTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this._languageTypeComboBox.FormattingEnabled = true; + this._languageTypeComboBox.Location = new System.Drawing.Point(65, 3); + this._languageTypeComboBox.Name = "_languageTypeComboBox"; + this._languageTypeComboBox.Size = new System.Drawing.Size(250, 21); + this._languageTypeComboBox.TabIndex = 2; + this._languageTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.OnLanguageTypeChanged); + // + // _nativeCodeTextBox + // + this.TableLayoutPanel1.SetColumnSpan(this._nativeCodeTextBox, 2); + this._nativeCodeTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this._nativeCodeTextBox.Location = new System.Drawing.Point(3, 43); + this._nativeCodeTextBox.Multiline = true; + this._nativeCodeTextBox.Name = "_nativeCodeTextBox"; + this._nativeCodeTextBox.Size = new System.Drawing.Size(312, 178); + this._nativeCodeTextBox.TabIndex = 4; + this._nativeCodeTextBox.TextChanged += new System.EventHandler(this.OnNativeCodeChanged); + // + // SplitContainer1 + // this.SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.SplitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; this.SplitContainer1.Location = new System.Drawing.Point(0, 0); this.SplitContainer1.Name = "SplitContainer1"; - // - //SplitContainer1.Panel1 - // + // + // SplitContainer1.Panel1 + // this.SplitContainer1.Panel1.Controls.Add(this.TableLayoutPanel1); this.SplitContainer1.Panel1MinSize = 125; - // - //SplitContainer1.Panel2 - // - this.SplitContainer1.Panel2.Controls.Add(this.m_managedCodeBox); + // + // SplitContainer1.Panel2 + // + this.SplitContainer1.Panel2.Controls.Add(this._managedCodeTextBox); this.SplitContainer1.Size = new System.Drawing.Size(673, 450); this.SplitContainer1.SplitterDistance = 318; this.SplitContainer1.TabIndex = 10; - // - //m_bgWorker - // - // - //m_managedCodeBox - // - this.m_managedCodeBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.m_managedCodeBox.Location = new System.Drawing.Point(0, 0); - this.m_managedCodeBox.Name = "m_managedCodeBox"; - this.m_managedCodeBox.Size = new System.Drawing.Size(351, 450); - this.m_managedCodeBox.TabIndex = 11; - // - //TranslateSnippetControl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + // + // _managedCodeTextBox + // + this._managedCodeTextBox.Code = ""; + this._managedCodeTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this._managedCodeTextBox.Location = new System.Drawing.Point(0, 0); + this._managedCodeTextBox.Name = "_managedCodeTextBox"; + this._managedCodeTextBox.Size = new System.Drawing.Size(351, 450); + this._managedCodeTextBox.TabIndex = 11; + // + // TranslateSnippetControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.SplitContainer1); this.Name = "TranslateSnippetControl"; @@ -223,24 +224,25 @@ private void InitializeComponent() this.FlowLayoutPanel1.PerformLayout(); this.SplitContainer1.Panel1.ResumeLayout(false); this.SplitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.SplitContainer1)).EndInit(); this.SplitContainer1.ResumeLayout(false); this.ResumeLayout(false); } internal System.Windows.Forms.TableLayoutPanel TableLayoutPanel1; internal System.Windows.Forms.RichTextBox m_errorsTb; - internal System.Windows.Forms.Button m_generateBtn; + internal System.Windows.Forms.Button _generateButton; internal System.Windows.Forms.Label Label1; internal System.Windows.Forms.Label Label2; internal System.Windows.Forms.SplitContainer SplitContainer1; - internal PInvoke.Controls.CodeBox m_managedCodeBox; - internal System.ComponentModel.BackgroundWorker m_bgWorker; + internal PInvoke.Controls.CodeBox _managedCodeTextBox; + internal System.ComponentModel.BackgroundWorker _backgroundWorker; internal System.Windows.Forms.FlowLayoutPanel FlowLayoutPanel1; - internal System.Windows.Forms.CheckBox m_autoGenerateBtn; + internal System.Windows.Forms.CheckBox _autoGenerateButton; internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.ComboBox m_langTypeCb; + internal System.Windows.Forms.ComboBox _languageTypeComboBox; - internal System.Windows.Forms.TextBox m_nativeCodeTb; + internal System.Windows.Forms.TextBox _nativeCodeTextBox; } } diff --git a/PInvoke.Core/Controls/TranslateSnippetControl.cs b/PInvoke.Core/Controls/TranslateSnippetControl.cs index 97323ff..4771df5 100644 --- a/PInvoke.Core/Controls/TranslateSnippetControl.cs +++ b/PInvoke.Core/Controls/TranslateSnippetControl.cs @@ -32,8 +32,8 @@ private class ResponseData private bool _changed; public bool AutoGenerate { - get { return m_autoGenerateBtn.Checked; } - set { m_autoGenerateBtn.Checked = value; } + get { return _autoGenerateButton.Checked; } + set { _autoGenerateButton.Checked = value; } } @@ -45,8 +45,8 @@ public TranslateSnippetControl() _storage = new BasicSymbolStorage(); // Add any initialization after the InitializeComponent() call. - m_langTypeCb.Items.AddRange(EnumUtil.GetAllValuesObject()); - m_langTypeCb.SelectedItem = LanguageType.VisualBasic; + _languageTypeComboBox.Items.AddRange(EnumUtil.GetAllValuesObject()); + _languageTypeComboBox.SelectedItem = LanguageType.VisualBasic; } public TranslateSnippetControl(INativeSymbolStorage storage) @@ -66,14 +66,14 @@ public LanguageType LanguageType { get { - if (m_langTypeCb.SelectedItem == null) + if (_languageTypeComboBox.SelectedItem == null) { return Transform.LanguageType.VisualBasic; } - return (LanguageType)m_langTypeCb.SelectedItem; + return (LanguageType)_languageTypeComboBox.SelectedItem; } - set { m_langTypeCb.SelectedItem = value; } + set { _languageTypeComboBox.SelectedItem = value; } } public INativeSymbolStorage Storage @@ -97,7 +97,7 @@ public TransformKindFlags TransformKindFlags public string ManagedCode { - get { return m_managedCodeBox.Text; } + get { return _managedCodeTextBox.Text; } } #endregion @@ -106,7 +106,7 @@ public string ManagedCode private void OnNativeCodeChanged(object sender, EventArgs e) { - if (m_bgWorker.IsBusy) + if (_backgroundWorker.IsBusy) { _changed = true; } @@ -124,6 +124,8 @@ private static void OnDoBackgroundWork(System.Object sender, System.ComponentMod RequestData req = (RequestData)e.Argument; string code = req.Text; NativeCodeAnalyzer analyzer = NativeCodeAnalyzerFactory.CreateForMiniParse(OsVersion.WindowsVista, req.InitialMacroList); + + // TODO: shouldn't include this analyzer.IncludePathList.Add("c:\\program files (x86)\\windows kits\\8.1\\include\\shared"); using (var reader = new StringReader(code)) { @@ -155,7 +157,7 @@ private void OnBackgroundOperationCompleted(System.Object sender, System.Compone { RunWorker(); } - else if (m_autoGenerateBtn.Checked) + else if (_autoGenerateButton.Checked) { GenerateCode(); } @@ -169,7 +171,7 @@ private void OnGenerateCodeClick(object sender, EventArgs e) private void OnAutoGenerateCodeCheckChanged(object sender, EventArgs e) { - if (m_autoGenerateBtn.Checked) + if (_autoGenerateButton.Checked) { GenerateCode(); } @@ -177,7 +179,7 @@ private void OnAutoGenerateCodeCheckChanged(object sender, EventArgs e) private void OnLanguageTypeChanged(object sender, EventArgs e) { - if (m_autoGenerateBtn.Checked) + if (_autoGenerateButton.Checked) { GenerateCode(); } @@ -192,7 +194,7 @@ private void m_nativeCodeTb_KeyDown(System.Object sender, System.Windows.Forms.K { if (e.KeyCode == Keys.A & e.Modifiers == Keys.Control) { - m_nativeCodeTb.SelectAll(); + _nativeCodeTextBox.SelectAll(); e.Handled = true; } } @@ -212,8 +214,8 @@ private void RunWorker() RequestData data = new RequestData(); data.InitialMacroList = new ReadOnlyCollection(_initialMacroList); - data.Text = m_nativeCodeTb.Text; - m_bgWorker.RunWorkerAsync(data); + data.Text = _nativeCodeTextBox.Text; + _backgroundWorker.RunWorkerAsync(data); } private void GenerateCode() @@ -222,11 +224,11 @@ private void GenerateCode() { var conv = new BasicConverter(LanguageType, _storage); conv.TransformKindFlags = _transKind; - m_managedCodeBox.Code = conv.ConvertNativeCodeToPInvokeCode(m_nativeCodeTb.Text); + _managedCodeTextBox.Code = conv.ConvertNativeCodeToPInvokeCode(_nativeCodeTextBox.Text); } catch (Exception ex) { - m_managedCodeBox.Code = ex.Message; + _managedCodeTextBox.Code = ex.Message; } } diff --git a/PInvoke.Core/Controls/TranslateSnippetControl.resx b/PInvoke.Core/Controls/TranslateSnippetControl.resx index d3f1537..99d3d9d 100644 --- a/PInvoke.Core/Controls/TranslateSnippetControl.resx +++ b/PInvoke.Core/Controls/TranslateSnippetControl.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/WindowsTool/MainForm.cs b/WindowsTool/MainForm.cs index 4e803a0..a691b5d 100644 --- a/WindowsTool/MainForm.cs +++ b/WindowsTool/MainForm.cs @@ -10,6 +10,8 @@ using System.Threading; using PInvoke; using PInvoke.Controls; +using PInvoke.Storage; +using System.IO; namespace WindowsTool { @@ -1120,7 +1122,10 @@ private void LoadNativeStorage(object invokeUntyped) { try { - _nativeStorage = new BasicSymbolStorage(); + using (var stream = File.Open("windows.csv", FileMode.Open)) + { + _nativeStorage = StorageUtil.ReadCsv(stream); + } } catch (Exception ex) { diff --git a/WindowsToolLauncher/WindowsToolLauncher.csproj b/WindowsToolLauncher/WindowsToolLauncher.csproj index 536bd47..8d101e1 100644 --- a/WindowsToolLauncher/WindowsToolLauncher.csproj +++ b/WindowsToolLauncher/WindowsToolLauncher.csproj @@ -116,6 +116,6 @@ --> - copy /y $(ProjectDir)..\StorageGenerator\Data\windows.xml $(TargetDir) + copy /y $(ProjectDir)..\StorageGenerator\Data\windows.csv $(TargetDir) \ No newline at end of file