[svn] r6817: vs-plugin/trunk/Nemerle.VsIntegration: GUI GUI/GoToTypeForm.Designer.cs GUI/GoToTypeForm.cs G...

VladD2 svnadmin at nemerle.org
Wed Nov 1 20:21:07 CET 2006


Log:
Move Goto dialog into separate file.

Author: VladD2
Date: Wed Nov  1 20:21:05 2006
New Revision: 6817

Added:
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.resx
Modified:
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.Designer.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.Designer.cs	Wed Nov  1 20:21:05 2006
@@ -0,0 +1,97 @@
+namespace Nemerle.VisualStudio.GUI
+{
+  partial class GoToTypeForm
+  {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing)
+    {
+      if (disposing && (components != null))
+      {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent()
+    {
+      this._listView = new System.Windows.Forms.ListView();
+      this.colFile = new System.Windows.Forms.ColumnHeader();
+      this.colLine = new System.Windows.Forms.ColumnHeader();
+      this.colPath = new System.Windows.Forms.ColumnHeader();
+      this.SuspendLayout();
+      // 
+      // _listView
+      // 
+      this._listView.BorderStyle = System.Windows.Forms.BorderStyle.None;
+      this._listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.colFile,
+            this.colLine,
+            this.colPath});
+      this._listView.Dock = System.Windows.Forms.DockStyle.Fill;
+      this._listView.FullRowSelect = true;
+      this._listView.Location = new System.Drawing.Point(0, 0);
+      this._listView.Name = "_listView";
+      this._listView.ShowItemToolTips = true;
+      this._listView.Size = new System.Drawing.Size(555, 272);
+      this._listView.TabIndex = 0;
+      this._listView.UseCompatibleStateImageBehavior = false;
+      this._listView.View = System.Windows.Forms.View.Details;
+      this._listView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick);
+      // 
+      // colFile
+      // 
+      this.colFile.Text = "File";
+      this.colFile.Width = 100;
+      // 
+      // colLine
+      // 
+      this.colLine.Text = "Line";
+      this.colLine.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+      this.colLine.Width = 96;
+      // 
+      // colPath
+      // 
+      this.colPath.Text = "Path";
+      this.colPath.Width = 237;
+      // 
+      // GoToTypeForm
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.ClientSize = new System.Drawing.Size(555, 272);
+      this.Controls.Add(this._listView);
+      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
+      this.KeyPreview = true;
+      this.Name = "GoToTypeForm";
+      this.ShowInTaskbar = false;
+      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+      this.Text = "Select file:";
+      this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GoToTypeForm_KeyPress);
+      this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GoToTypeForm_FormClosing);
+      this.Load += new System.EventHandler(this.GoToTypeForm_Load);
+      this.ResumeLayout(false);
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.ListView _listView;
+    private System.Windows.Forms.ColumnHeader colFile;
+    private System.Windows.Forms.ColumnHeader colLine;
+    private System.Windows.Forms.ColumnHeader colPath;
+  }
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs	Wed Nov  1 20:21:05 2006
@@ -0,0 +1,93 @@
+// TODO: Âű÷čńëčňü őîň˙ áű HWND TextEditor'ŕ čëč őîň˙ áű ăëŕâíîăî îęíŕ ńňóäčč.
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Nemerle.Completion2;
+using System.IO;
+
+namespace Nemerle.VisualStudio.GUI
+{
+  public partial class GoToTypeForm : Form
+  {
+    public GotoInfo Result;
+
+    public GoToTypeForm(GotoInfo[] gotoInfos)
+    {
+      InitializeComponent();
+
+      foreach (GotoInfo gotoInfo in gotoInfos)
+      {
+        ListViewItem lvi = new ListViewItem(new string[]
+        {
+          Path.GetFileName(gotoInfo.FilePath), 
+          gotoInfo.LineStart.ToString(), 
+          Path.GetDirectoryName(gotoInfo.FilePath)
+        });
+        lvi.Tag = gotoInfo;
+        _listView.Items.Add(lvi);
+      }
+    }
+
+    private void GoToTypeForm_Load(object sender, EventArgs e)
+    {
+      // Resize columns by content.
+      foreach (ColumnHeader hdr in _listView.Columns)
+        hdr.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
+
+      // Resize window.
+
+      // Calc width
+      int width = SystemInformation.SmallIconSize.Width + 2;
+      foreach (ColumnHeader hdr in _listView.Columns)
+        width += hdr.Width;
+      ClientSize = new System.Drawing.Size(width, ClientSize.Height);
+
+      Left = (Screen.FromControl(this).WorkingArea.Width - Width) / 2;
+
+      // Calc height
+      if (_listView.Items.Count > 0)
+      {
+        int height = _listView.Items.Count * _listView.GetItemRect(0).Height;
+        ClientSize = new Size(ClientSize.Width,
+          height + 30); //TODO: Try get header height.
+      }
+
+      Top = (Screen.FromControl(this).WorkingArea.Height - Height) / 2;
+    }
+
+    private void GoToTypeForm_KeyPress(object sender, KeyPressEventArgs e)
+    {
+      if (e.KeyChar == (char)Keys.Escape)
+        DialogResult = DialogResult.Cancel;
+      else if (e.KeyChar == '\r' || e.KeyChar == ' ')
+        DialogResult = DialogResult.OK;
+      else
+        return;
+
+      Close();
+    }
+
+    private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
+    {
+      DialogResult = DialogResult.OK;
+      Close();
+    }
+
+    private void GoToTypeForm_FormClosing(object sender, FormClosingEventArgs e)
+    {
+      if (DialogResult == DialogResult.OK)
+        if (_listView.FocusedItem.Tag == null)
+        {
+          e.Cancel = true;
+          MessageBox.Show(this, "You must select item.", "Goto tyoe",
+            MessageBoxButtons.OK, MessageBoxIcon.Error);
+        }
+        else
+          Result = (GotoInfo)_listView.FocusedItem.Tag;
+    }
+  }
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.resx
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.resx	Wed Nov  1 20:21:05 2006
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
\ No newline at end of file

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs	Wed Nov  1 20:21:05 2006
@@ -9,8 +9,8 @@
 using Microsoft.VisualStudio.TextManager.Interop;
 
 using Nemerle.Completion2;
-
 using Nemerle.VisualStudio.Project;
+using Nemerle.VisualStudio.GUI;
 
 namespace Nemerle.VisualStudio.LanguageService
 {
@@ -167,95 +167,33 @@
 			}
 			else
 			{
-				// TODO: Âűíĺńňč âĺńü UI ęóäŕ ďîäŕëüřĺ.
-				// TODO: Âű÷čńëčňü őîň˙ áű HWND TextEditor'ŕ čëč őîň˙ áű ăëŕâíîăî îęíŕ ńňóäčč.
-
-				Form     popup = new Form();
-				ListView lv    = new ListView();
-				ColumnHeader colFile = new ColumnHeader();
-				ColumnHeader colLine = new ColumnHeader();
-				ColumnHeader colPath = new ColumnHeader();
-
-				popup.StartPosition = FormStartPosition.CenterScreen;
-				popup.ShowInTaskbar = false;
-				popup.Text = "Select location:";
-				popup.FormBorderStyle = FormBorderStyle.FixedToolWindow;
-				popup.Controls.Add(lv);
-				popup.Width = 600;
-				popup.Load += delegate(object sender, EventArgs e)
-				{
-					Form form = ((Form)sender);
-					foreach (ColumnHeader hdr in ((ListView)form.Controls[0]).Columns)
-						hdr.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
-				};
-
-				lv.BorderStyle = BorderStyle.None;
-				lv.Dock = DockStyle.Fill;
-				lv.View = View.Details;
-				lv.ShowItemToolTips = true;
-				lv.FullRowSelect = true;
-				lv.Columns.AddRange(new ColumnHeader[]{colFile, colLine, colPath});
+        GotoInfo[] gotoInfos = Array.FindAll(info, delegate(GotoInfo inf)
+          { return inf.HasLocation; });
 
-				foreach (GotoInfo gotoInfo in info)
-				{
-					if (gotoInfo.HasLocation)
+        if (gotoInfos.Length <= 0)
+          return null;
+        else if (gotoInfos.Length == 1)
+          return SetTextSpan(ref span, gotoInfos[0]);
+        else
 					{
-						ListViewItem lvi = new ListViewItem(new string[]{Path.GetFileName(gotoInfo.FilePath), gotoInfo.LineStart.ToString(), Path.GetDirectoryName(gotoInfo.FilePath)});
-						lvi.Tag = gotoInfo;
-						lv.Items.Add(lvi);
+          GoToTypeForm popup = new GoToTypeForm(gotoInfos);
+
+          if (popup.ShowDialog() == DialogResult.OK)
+            return SetTextSpan(ref span, popup.Result);
 					}
 				}
 
-				if (lv.Items.Count == 0)
-				{
-					// Sorry guys, the .pdb file is missing.
-					//
 					return null;
 				}
 
-				lv.KeyPress += delegate(object sender, KeyPressEventArgs e)
-				{
-					Control ctl   = sender as Control;
-					Form    owner = ctl.FindForm();
-
-					if (e.KeyChar == (char) Keys.Escape)
-						owner.DialogResult = DialogResult.Cancel;
-					else if (e.KeyChar == '\r' || e.KeyChar == ' ')
-						owner.DialogResult = DialogResult.OK;
-					else
-						return;
-
-					owner.Close();
-				};
-				lv.DoubleClick += delegate(object sender, EventArgs e)
-				{
-					Control ctl   = sender as Control;
-					Form    owner = ctl.FindForm();
-
-					owner.DialogResult = DialogResult.OK;
-					owner.Close();
-				};
-
-				colFile.Text = "File";
-				colLine.Text = "Line";
-				colPath.Text = "Path";
-
-				if (DialogResult.OK == popup.ShowDialog())
+    private static string SetTextSpan(ref TextSpan span, GotoInfo result)
 				{
-					if (null != lv.SelectedItems[0])
-					{
-						GotoInfo selectedFile = (GotoInfo)lv.SelectedItems[0].Tag;
-						span.iStartLine  = selectedFile.LineStart;
-						span.iEndLine    = selectedFile.LineEnd;
-						span.iStartIndex = selectedFile.ColStart;
-						span.iEndIndex   = selectedFile.ColEnd;
-
-						return selectedFile.FilePath;
-					}
-				}
-			}
+      span.iStartLine = result.LineStart;
+      span.iEndLine = result.LineEnd;
+      span.iStartIndex = result.ColStart;
+      span.iEndIndex = result.ColEnd;
 
-			return null;
+      return result.FilePath;
 		}
 
 		public override Declarations GetDeclarations(

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj	Wed Nov  1 20:21:05 2006
@@ -122,6 +122,12 @@
     <Compile Include="$(VisualStudioIntegration)\Common\Source\CSharp\RegistrationAttributes\WebSiteProjectRelatedFilesAttribute.cs">
       <Link>RegistrationAttributes\WebSiteProjectRelatedFilesAttribute.cs</Link>
     </Compile>
+    <Compile Include="GUI\GoToTypeForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="GUI\GoToTypeForm.Designer.cs">
+      <DependentUpon>GoToTypeForm.cs</DependentUpon>
+    </Compile>
     <Compile Include="LanguageService\NemerleAuthoringScope.cs" />
     <Compile Include="LanguageService\NemerleAuthoringSink.cs" />
     <Compile Include="LanguageService\NemerleColorableItem.cs" />
@@ -253,6 +259,10 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="Resources\Nemerle.ico" />
+    <EmbeddedResource Include="GUI\GoToTypeForm.resx">
+      <SubType>Designer</SubType>
+      <DependentUpon>GoToTypeForm.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Resources\NemerleImageList.bmp" />
     <ZipProject Include="Templates\Projects\WindowsApplication\NemerleMacroLibrary.vstemplate" />
     <ZipProject Include="Templates\Projects\WindowsApplication\Nemerle.ico" />



More information about the svn mailing list