[nemerle] r8414 committed - [No log message]

2 views
Skip to first unread message

codesite...@google.com

unread,
Oct 30, 2009, 1:59:13 PM10/30/09
to nemer...@googlegroups.com
Revision: 8414
Author: v...@rsdn.ru
Date: Fri Oct 30 10:58:03 2009
Log: [No log message]
http://code.google.com/p/nemerle/source/detail?r=8414

Added:
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.Designer.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.resx

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Program.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/AssemblyInfo.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Resources.Designer.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Resources.resx

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Settings.Designer.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Settings.settings

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/WinFormTestHint.csproj
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintRoot.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintSource.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ElementToken.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/HintParser.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ParamParser.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ParseToken.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/Range.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/RangeList.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/RootToken.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/TextToken.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/PopupWindow.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Properties
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintBuilder.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintControl.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintDecorator.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/ParamPanel.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/SoftBreak.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Win32.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/WpfHint.csproj
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/nemerle.snk
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint.sln
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint.suo
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NativeMethods.cs
Modified:
/nemerle/trunk/VsIntegration/Nemerle.VSIP.sln
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleSource.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleViewFilter.cs

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Nemerle.VisualStudio.csproj
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NemerlePackage.cs

=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.Designer.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,131 @@
+namespace WinFormTestHint
+{
+ partial class Form1
+ {
+ /// <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()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(Form1));
+ this.button1 = new System.Windows.Forms.Button();
+ this.richTextBox1 = new System.Windows.Forms.RichTextBox();
+ this.checkBox1 = new System.Windows.Forms.CheckBox();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.checkBox2 = new System.Windows.Forms.CheckBox();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.button1.Location = new System.Drawing.Point(255, 333);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(278, 41);
+ this.button1.TabIndex = 0;
+ this.button1.Text = "test button";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.MouseEnter += new
System.EventHandler(this.button1_MouseEnter);
+ //
+ // richTextBox1
+ //
+ this.richTextBox1.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.richTextBox1.Location = new System.Drawing.Point(10, 11);
+ this.richTextBox1.Name = "richTextBox1";
+ this.richTextBox1.Size = new System.Drawing.Size(538, 307);
+ this.richTextBox1.TabIndex = 4;
+ this.richTextBox1.Text =
resources.GetString("richTextBox1.Text");
+ //
+ // checkBox1
+ //
+ this.checkBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.checkBox1.AutoSize = true;
+ this.checkBox1.Location = new System.Drawing.Point(10, 333);
+ this.checkBox1.Name = "checkBox1";
+ this.checkBox1.Size = new System.Drawing.Size(136, 17);
+ this.checkBox1.TabIndex = 5;
+ this.checkBox1.Text = "Change hint after 2 sec";
+ this.checkBox1.UseVisualStyleBackColor = true;
+ //
+ // textBox1
+ //
+ this.textBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.textBox1.Location = new System.Drawing.Point(77, 351);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(62, 20);
+ this.textBox1.TabIndex = 6;
+ this.textBox1.Text = "600";
+ //
+ // label1
+ //
+ this.label1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(10, 353);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(61, 13);
+ this.label1.TabIndex = 7;
+ this.label1.Text = "Wrap width";
+ //
+ // checkBox2
+ //
+ this.checkBox2.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.checkBox2.AutoSize = true;
+ this.checkBox2.Location = new System.Drawing.Point(10, 377);
+ this.checkBox2.Name = "checkBox2";
+ this.checkBox2.Size = new System.Drawing.Size(203, 17);
+ this.checkBox2.TabIndex = 8;
+ this.checkBox2.Text = "Change wrap width to 200 after 2 sec";
+ this.checkBox2.UseVisualStyleBackColor = true;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(569, 420);
+ this.Controls.Add(this.checkBox2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.textBox1);
+ this.Controls.Add(this.checkBox1);
+ this.Controls.Add(this.richTextBox1);
+ this.Controls.Add(this.button1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.RichTextBox richTextBox1;
+ private System.Windows.Forms.CheckBox checkBox1;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.CheckBox checkBox2;
+ }
+}
+
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Forms;
+using WpfHint;
+
+namespace WinFormTestHint
+{
+ public partial class Form1 : Form
+ {
+ private Hint hint = new Hint();
+ private readonly Timer timer = new Timer { Interval = 2000 };
+
+ public Form1()
+ {
+ InitializeComponent();
+ timer.Tick += timer_Tick;
+ hint.Click += hint_Click;
+ }
+
+ static void hint_Click(Hint ht, string handler)
+ {
+ Console.WriteLine("Hint clicked, handler name: " + handler);
+ }
+
+ private void button1_MouseEnter(object sender, EventArgs e)
+ {
+ if (hint.IsOpen) return;
+
+ timer.Start();
+
+ var but = (Button)sender;
+ var rt = but.RectangleToScreen(but.ClientRectangle);
+
+ hint.WrapWidth = Int32.Parse(textBox1.Text);
+ hint.Show(IntPtr.Zero, new Rect(rt.Left, rt.Top, rt.Width,
rt.Height), richTextBox1.Text);
+ }
+
+ void timer_Tick(object sender, EventArgs e)
+ {
+ timer.Stop();
+ if (checkBox1.Checked)
+ hint.Text = "<hint>Hello world !!!</hint>";
+ else if (checkBox2.Checked)
+ hint.WrapWidth = 200;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.resx
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,145 @@
+<?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>
+ <data name="richTextBox1.Text" xml:space="preserve">
+ <value>&lt;hint&gt;
+&lt;code&gt;
+&lt;pre&gt;&lt;keyword&gt;static internal &lt;/keyword&gt;&lt;ref
handler='GoToDef'&gt;RunErrorOccured&lt;/ref&gt;(&lt;params&gt;&lt;pname&gt;[NotNull]
location&lt;/pname&gt;&lt;ptype&gt; : &lt;ref handler='GoToTypeDef1'
hint='Nemerle.Compiler.Location'&gt;Location&lt;/ref&gt;&lt;/ptype&gt;,
&lt;pname&gt;msg&lt;/pname&gt;&lt;ptype&gt; : &lt;keyword&gt;&lt;span
hint='System.String'&gt;string&lt;/span&gt;&lt;/keyword&gt;&lt;/ptype&gt;&lt;/params&gt;) :
&lt;keyword&gt;void&lt;/keyword&gt;,
+&lt;b&gt;
+ bold &lt;/b&gt;,
+
+
+&lt;/pre&gt;
+&lt;/code&gt;
+
+&lt;font size="20" face="Times New Roman" color="Green"&gt;
+&lt;u&gt;
+&lt;b&gt; bold
+ &lt;i&gt; and italic&lt;/i&gt;
+&lt;/b&gt;,&lt;lb/&gt;
+line break
+&lt;/u&gt;
+&lt;/font&gt;
+
+&lt;/hint&gt;
+
+
+</value>
+ </data>
+</root>
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Program.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using System.Xml.Linq;
+using WpfHint;
+
+namespace WinFormTestHint
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ var xml = "<test>aaaa\r\n<b>bbb</b>\r\nccc</test>";
+ var root = XElement.Parse(xml);
+ foreach (var element in root.Elements())
+ {
+ Console.WriteLine(element.Value);
+ }
+ foreach (var node in root.Nodes())
+ {
+ Console.WriteLine(node);
+ }
+
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/AssemblyInfo.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the
following
+// set of attributes. Change these attribute values to modify the
information
+// associated with an assembly.
+[assembly: AssemblyTitle("WinFormTestHint")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Computer")]
+[assembly: AssemblyProduct("WinFormTestHint")]
+[assembly: AssemblyCopyright("Copyright © Computer 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is
exposed to COM
+[assembly: Guid("8120e2b1-0916-45ae-90ab-83e43c14c214")]
+
+// Version information for an assembly consists of the following four
values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and
Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Resources.Designer.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.3053
+//
+// Changes to this file may cause incorrect behavior and will be lost
if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WinFormTestHint.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized
strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager
resourceMan;
+
+ private static global::System.Globalization.CultureInfo
resourceCulture;
+
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this
class.
+ /// </summary>
+
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager
ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new
global::System.Resources.ResourceManager("WinFormTestHint.Properties.Resources",
typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for
all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Resources.resx
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,117 @@
+<?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.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: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" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </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"
msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string"
msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string"
msdata:Ordinal="4" />
+ </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>
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Settings.Designer.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.3053
+//
+// Changes to this file may cause incorrect behavior and will be lost
if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WinFormTestHint.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings :
global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance =
((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new
Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Properties/Settings.settings
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile
xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings"
CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/WinFormTestHint.csproj
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)'
== '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{7663D2C3-250E-451E-9A63-BE89FA4D3033}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>WinFormTestHint</RootNamespace>
+ <AssemblyName>WinFormTestHint</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|
AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|
AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="WindowsBase">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Form1.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Form1.Designer.cs">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="Form1.resx">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\WpfHint\WpfHint.csproj">
+ <Project>{7670DE22-B023-4783-BA19-BB2DB50E1762}</Project>
+ <Name>WpfHint</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the
targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,101 @@
+using System;
+using System.Windows;
+using System.Windows.Interop;
+
+namespace WpfHint
+{
+ public class Hint
+ {
+ private HintWindow _hintWindow;
+ private HintSource _hintSource;
+ private string _text;
+ private double _wrapWidth = 400.0;
+
+ public event Action<Hint, string> Click;
+ public event Action<Hint> Closed;
+
+ /// <summary>
+ /// Deafult = 400.0
+ /// </summary>
+ public double WrapWidth
+ {
+ get { return _wrapWidth; }
+ set
+ {
+ _wrapWidth = value;
+
+ if (_hintWindow != null)
+ _hintWindow.WrapWidth = value;
+ }
+ }
+
+ /// <summary>
+ /// Placment rect, relative to the screen
+ /// (in screen coord)
+ /// </summary>
+ public Rect PlacementRect { get; set; }
+
+ /// <summary>
+ /// Hint text, could be change any time
+ /// </summary>
+ public string Text
+ {
+ get { return _text; }
+ set
+ {
+ _text = value;
+ if (_hintWindow == null) return;
+ foreach (Window window in _hintWindow.OwnedWindows) window.Close();
+ _hintWindow.Text = _text;
+ }
+ }
+
+ public bool IsOpen { get { return _hintWindow != null; } }
+
+ public void Close()
+ {
+ if (_hintWindow != null)
+ _hintWindow.Close();
+ }
+
+ public void Show(IntPtr owner, Rect placementRect, string text)
+ {
+ PlacementRect = placementRect;
+ Text = text;
+ Show(owner);
+ }
+
+ public void Show(IntPtr owner)
+ {
+ if (_hintWindow != null)
+ throw new NotSupportedException("Hint already shown");
+
+ // subclass
+ _hintSource = new HintSource();
+ _hintSource.Activate += Close;
+ _hintSource.SubClass(owner);
+
+ // create hint window
+ var ht = HintRoot.Create(PlacementRect, _hintSource);
+ _hintWindow = new HintWindow(this, ht) { Text = _text };
+ new WindowInteropHelper(_hintWindow) { Owner = _hintSource.Owner };
+ _hintWindow.Closed += HintWindowClosed;
+
+ _hintWindow.WrapWidth = _wrapWidth;
+ _hintWindow.Show();
+ }
+
+ void HintWindowClosed(object sender, EventArgs e)
+ {
+ _hintSource.UnSubClass();
+ _hintSource = null;
+ _hintWindow = null;
+ if (Closed != null) Closed(this);
+ }
+
+ internal void RaiseClick(string handler)
+ {
+ if (Click != null) Click(this, handler);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintRoot.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,146 @@
+using System;
+using System.Windows;
+using System.Windows.Input;
+
+namespace WpfHint
+{
+ internal abstract class HintRoot : IDisposable
+ {
+ public event Action MouseLeave;
+ public Rect ActiveRect { get; protected set; }
+
+ public abstract bool IsMouseOver { get; }
+ protected void RaiseEvent()
+ {
+ if (MouseLeave != null) MouseLeave();
+ }
+
+ #region IDisposable Members
+
+ public virtual void Dispose() { }
+
+ #endregion
+
+ public static HintRoot Create(FrameworkElement fe)
+ {
+ return new HintRootWpf(fe);
+ }
+
+ public static HintRoot Create(Rect rect, HintSource source)
+ {
+ return new HintRootWin32(rect, source);
+ }
+
+ private class HintRootWpf : HintRoot
+ {
+ private readonly FrameworkElement _fe;
+
+ public HintRootWpf(FrameworkElement fe)
+ {
+ _fe = fe;
+ var pt = fe.PointToScreen(new Point());
+ var pt2 = fe.PointToScreen(new Point(fe.ActualWidth,
fe.ActualHeight));
+ ActiveRect = new Rect(pt.X, pt.Y, pt2.X - pt.X, pt2.Y - pt.Y);
+
+ fe.MouseLeave += OnMouse;
+ }
+
+ void OnMouse(object sender, MouseEventArgs e)
+ {
+ RaiseEvent();
+ }
+
+ public override bool IsMouseOver
+ {
+ get { return _fe.IsMouseOver; }
+ }
+
+ public override void Dispose()
+ {
+ _fe.MouseLeave -= OnMouse;
+ }
+
+ #region Equality
+
+ public bool Equals(HintRootWpf other)
+ {
+ if (ReferenceEquals(null, other))
+ return false;
+
+ if (ReferenceEquals(this, other))
+ return true;
+
+ return Equals(other._fe, _fe);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ return false;
+
+ if (ReferenceEquals(this, obj))
+ return true;
+
+ if (obj.GetType() != typeof(HintRootWpf))
+ return false;
+
+ return Equals((HintRootWpf)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (_fe != null ? _fe.GetHashCode() : 0);
+ }
+
+ public static bool operator ==(HintRootWpf left, HintRootWpf right)
+ {
+ return Equals(left, right);
+ }
+
+ public static bool operator !=(HintRootWpf left, HintRootWpf right)
+ {
+ return !Equals(left, right);
+ }
+
+ #endregion
+ }
+
+ private class HintRootWin32 : HintRoot
+ {
+ private readonly HintSource source;
+
+ public HintRootWin32(Rect rect, HintSource source)
+ {
+ this.source = source;
+ ActiveRect = rect;
+ source.MouseMove += OnMouse;
+ source.MouseLeave += OnMouse;
+ }
+
+ private void OnMouse()
+ {
+ if (!IsMouseOver) RaiseEvent();
+ }
+
+ public override bool IsMouseOver
+ {
+ get
+ {
+ var pt = Win32.GetCursorPos();
+ var rect = ActiveRect;
+ if (pt.X < rect.Left) return false;
+ if (pt.X > rect.Right - 1) return false;
+ if (pt.Y < rect.Top) return false;
+ if (pt.Y > rect.Bottom - 1) return false;
+ return true;
+ }
+ }
+
+ public override void Dispose()
+ {
+ source.MouseMove -= OnMouse;
+ source.MouseLeave -= OnMouse;
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintSource.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,83 @@
+using System;
+
+namespace WpfHint
+{
+ internal class HintSource
+ {
+ private Win32.Callback _ownerWndProc;
+ private Win32.Callback _rootWndProc;
+
+ private Win32.Callback _oldRoot;
+ private Win32.Callback _oldOwner;
+
+ private IntPtr _owner; // text editor window handle
+ private IntPtr _root; // main window handle (visual studio)
+
+ public event Action Activate;
+ public event Action MouseMove;
+ public event Action MouseLeave;
+
+ public IntPtr Owner { get { return _owner; } }
+
+ public void SubClass(IntPtr owner)
+ {
+ var pt = Win32.GetCursorPos();
+ var pt1 = new Win32.POINT(pt.X, pt.Y);
+
+ _owner = owner == IntPtr.Zero ? Win32.WindowFromPoint(pt1) : owner;
+
+ if (_owner == IntPtr.Zero)
+ throw new NullReferenceException("Can't find owner");
+
+ _root = Win32.GetAncestor(_owner, Win32.GA_ROOT);
+ if (_root == IntPtr.Zero)
+ throw new NullReferenceException("Can't find root");
+
+ _ownerWndProc = WndProc;
+ _oldOwner = Win32.SetWindowLong(_owner, Win32.GWL_WNDPROC,
_ownerWndProc);
+
+ if (_oldOwner == null)
+ throw new InvalidOperationException("Failed subclass");
+
+ _rootWndProc = RootWndProc;
+ _oldRoot = Win32.SetWindowLong(_root, Win32.GWL_WNDPROC,
_rootWndProc);
+
+ if (_rootWndProc == null)
+ throw new InvalidOperationException("Failed subclass");
+ }
+
+ public void UnSubClass()
+ {
+ if (_owner != IntPtr.Zero && _oldOwner != null)
+ Win32.SetWindowLong(_owner, Win32.GWL_WNDPROC, _oldOwner);
+
+ if (_root != IntPtr.Zero && _oldRoot != null)
+ Win32.SetWindowLong(_root, Win32.GWL_WNDPROC, _oldRoot);
+ }
+
+ private int WndProc(IntPtr hwnd, int msg, int wParam, int lParam)
+ {
+ if ((msg == Win32.WM_KEYDOWN || msg == Win32.WM_MOUSEWHEEL) &&
Activate != null)
+ Activate();
+
+ if ((msg == Win32.WM_LBUTTONDOWN || msg == Win32.WM_RBUTTONDOWN) &&
Activate != null)
+ Activate();
+
+ if (msg == Win32.WM_MOUSEMOVE && MouseMove != null)
+ MouseMove();
+
+ if (msg == Win32.WM_MOUSELEAVE && MouseLeave != null)
+ MouseLeave();
+
+ return Win32.CallWindowProc(_oldOwner, hwnd, msg, wParam, lParam);
+ }
+
+ private int RootWndProc(IntPtr hwnd, int msg, int wParam, int lParam)
+ {
+ if ((msg == Win32.WM_ACTIVATE || msg == Win32.WM_ACTIVATEAPP) &&
Activate != null)
+ Activate();
+
+ return Win32.CallWindowProc(_oldRoot, hwnd, msg, wParam, lParam);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,17 @@
+<c:PopupWindow x:Class="WpfHint.HintWindow" x:ClassModifier="internal"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:c="clr-namespace:WpfHint" FontSize="16" FontFamily="Calibri"
Title="">
+ <Border x:Name="border"
+ Background="#FFFFFFE1"
+ Padding="5"
+ Margin="0,0,3,3"
+ CornerRadius="5"
+ BorderThickness="1"
+ BorderBrush="Black">
+ <Border.Effect>
+ <DropShadowEffect Color="Gray" ShadowDepth="2" BlurRadius="2"/>
+ </Border.Effect>
+ <TextBlock Text="test !!!"/>
+ </Border>
+</c:PopupWindow>
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+using WpfHint.Parsing;
+using WpfHint.UIBuilding;
+
+namespace WpfHint
+{
+ /// <summary>
+ /// Interaction logic for HintWindow.xaml
+ /// </summary>
+ internal partial class HintWindow
+ {
+ private readonly Hint hint;
+ private readonly HintRoot hintRoot;
+ private readonly DispatcherTimer timer =
+ new DispatcherTimer { Interval =
TimeSpan.FromMilliseconds(100) };
+
+ private string text;
+ public string Text
+ {
+ get { return text; }
+ set
+ {
+ text = value;
+ var root = HintParser.Parse(value);
+ var fe = HintBuilder.Build(root);
+ border.Child = fe;
+ }
+ }
+
+ public double WrapWidth
+ {
+ get { return ((HintDecorator) border.Child).WrapWidth; }
+ set { ((HintDecorator) border.Child).WrapWidth = value; }
+ }
+
+ public HintWindow(Hint hint, HintRoot root)
+ {
+ InitializeComponent();
+
+ this.hint = hint;
+ hintRoot = root;
+
+ // window props
+ Left = 0;
+ Top = 0;
+ SizeToContent = SizeToContent.WidthAndHeight;
+ Opacity = 0.9;
+
+ timer.Tick += OnTimerTick;
+ LayoutUpdated += OnLayoutUpdated;
+ MouseLeave += OnMouseLeave;
+ hintRoot.MouseLeave += TestMouseOver;
+
+ HintControl.AddClickHandler(this, OnClick);
+ HintControl.AddMouseHoverHandler(this, OnMouseHover);
+ }
+
+ protected override void OnClosed(EventArgs e)
+ {
+ hintRoot.MouseLeave -= TestMouseOver;
+ MouseLeave -= OnMouseLeave;
+
+ timer.Stop();
+ hintRoot.Dispose();
+ base.OnClosed(e);
+ }
+
+ #region HintControl event handling
+
+ private void OnClick(object sender, RoutedEventArgs e)
+ {
+ var hc = e.Source as HintControl;
+ if (hc == null) return;
+ if (hc.Handler != null) hint.RaiseClick(hc.Handler);
+ }
+
+ private void OnMouseHover(object sender, RoutedEventArgs e)
+ {
+ var hc = e.Source as HintControl;
+ if (hc == null) return;
+ if (hc.Hint != null) ShowSubHint(hc, hc.Hint);
+ }
+
+ private void ShowSubHint(FrameworkElement el, string hintText)
+ {
+ var ht = HintRoot.Create(el);
+ foreach (HintWindow window in OwnedWindows)
+ {
+ if (!window.hintRoot.Equals(ht)) continue;
+ ht.Dispose();
+ return;
+ }
+
+ var wnd = new HintWindow(hint, ht) { Text = hintText, Owner =
this };
+ wnd.Show();
+ }
+
+ #endregion
+
+ #region Mouse leave checking
+
+ void OnMouseLeave(object sender, MouseEventArgs e)
+ {
+ TestMouseOver();
+ }
+
+ void TestMouseOver()
+ {
+ // restart timer
+ timer.Stop();
+ timer.Start();
+ }
+
+ void OnTimerTick(object sender, EventArgs e)
+ {
+ timer.Stop();
+
+ if (OwnedWindows.Count > 0) return;
+ if (IsMouseOver) return;
+ if (hintRoot.IsMouseOver) return;
+
+ this.Close();
+ var owner = Owner as HintWindow;
+ if (owner != null) owner.TestMouseOver();
+ }
+
+ #endregion
+
+ #region Window layout relative to screen
+
+ void OnLayoutUpdated(object sender, EventArgs e)
+ {
+ var dx = 1.0;
+ var dy = 1.0;
+
+ var src = PresentationSource.FromVisual(this);
+ if (src != null)
+ {
+ var m = src.CompositionTarget.TransformToDevice;
+ dx = m.M11;
+ dy = m.M22;
+ }
+
+ var rect = hintRoot.ActiveRect;
+
+ var size = new Size(ActualWidth*dx, ActualHeight*dy);
+ var scrSize = new Size(SystemParameters.PrimaryScreenWidth*dx,
+
SystemParameters.PrimaryScreenHeight*dy);
+
+ var pos = rect.BottomLeft;
+ if (rect.Bottom + size.Height > scrSize.Height)
+ {
+ pos.Y = rect.Top - size.Height;
+ }
+
+ if (rect.Left + size.Width > scrSize.Width)
+ {
+ pos.X = scrSize.Width - size.Width;
+ }
+
+ // update location
+ this.Left = pos.X/dx;
+ this.Top = pos.Y/dy;
+ }
+
+ #endregion
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ElementToken.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,69 @@
+using System.Collections.Generic;
+using System.Text;
+using System.Linq;
+
+namespace WpfHint.Parsing
+{
+ public class ElementToken : ParseToken
+ {
+ private readonly int _startIndex;
+
+ public ElementToken(int index, RangeList rangeList)
+ : base(rangeList)
+ {
+ _startIndex = index;
+ _rangeList = rangeList;
+
+ Tokens = new LinkedList<ParseToken>();
+ Attributes = new Dictionary<string, string>();
+ }
+
+ public override int StartIndex
+ {
+ get
+ {
+ return Tokens.Count == 0 ? _startIndex :
Tokens.First.Value.StartIndex;
+ }
+ }
+
+ public override int Length
+ {
+ get { return Tokens.Count == 0 ? 0 : Tokens.Last.Value.EndIndex -
StartIndex; }
+ }
+
+ public string Name { get; set; }
+ public Dictionary<string, string> Attributes { get; private set; }
+ public override LinkedList<ParseToken> Tokens
+ {
+ get { return base.Tokens; }
+ protected set { base.Tokens = value; }
+ }
+
+
+ public override string ToString()
+ {
+ return "<" + Name + ">" + Tokens.Aggregate("", (a, o) => a + o)
+ "</" + Name + ">";
+ }
+
+
+ public ElementToken Split(LinkedListNode<ParseToken> splitNode, bool
after)
+ {
+ var token = splitNode.Value;
+ var index = after ? token.EndIndex : token.StartIndex;
+
+ var newToken = new ElementToken(index, _rangeList) { Name = Name };
+ newToken.Attributes = this.Attributes;
+
+ // split nodes
+ var cur = after ? splitNode.Next : splitNode;
+ while (cur != null)
+ {
+ var tmp = cur.Next;
+ Tokens.Remove(cur);
+ newToken.Tokens.AddLast(cur);
+ cur = tmp;
+ }
+ return newToken;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/HintParser.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,132 @@
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+
+namespace WpfHint.Parsing
+{
+ public class HintParser
+ {
+ public static RootToken Parse(string text)
+ {
+ var root = XElement.Parse(text,
LoadOptions.PreserveWhitespace);
+
+ var rlist = new RangeList(root.Value);
+ var rn = new RootToken(root, rlist);
+
+ //ParamParser.Parse(rn);
+ RemoveWhitespaces(rn, rlist);
+ RemoveFormating(rn);
+ return rn;
+ }
+
+ static void RemoveWhitespaces(RootToken rt, RangeList list)
+ {
+ var i1 = Clear(rt.StartIndex, rt, list);
+ ClearRange(i1, rt.EndIndex, list);
+ }
+
+ static int Clear(int i1, ElementToken root, RangeList list)
+ {
+ foreach (var node in root.Tokens)
+ {
+ var i2 = node.StartIndex;
+ if (!(node is ElementToken)) continue;
+
+ var el = (ElementToken)node;
+ if (el.Name != "pre")
+ {
+ i1 = Clear(i1, el, list);
+ }
+ else
+ {
+ ClearParamsInPre(el, list);
+ // clear range
+ ClearRange(i1, i2, list);
+ i1 = el.EndIndex;
+ }
+ }
+ return i1;
+ }
+
+ static void ClearRange(int i1, int i2, RangeList list)
+ {
+ if (i1 == i2) return;
+
+ var str = list.GetText(i1, i2 - i1);
+
+ // find seq-s of whitespace
+ var regex = new Regex("\\s+");
+ var ms = regex.Matches(str);
+
+ foreach (Match m in ms)
+ {
+ var j1 = i1 + m.Index;
+ var j2 = j1 + m.Length;
+ list.Chars[j1] = ' ';
+ for (var i = j1 + 1; i < j2; i++)
+ {
+ list.Chars[i] = '\0';
+ }
+ }
+ }
+
+
+ static void ClearParamsInPre(ElementToken token, RangeList list)
+ {
+ foreach (var node in token.Tokens)
+ {
+ if (!(node is ElementToken)) continue;
+
+ var el = (ElementToken)node;
+ if (el.Name != "params")
+ {
+ ClearParamsInPre(el, list);
+ }
+ else
+ {
+ var i1 = el.StartIndex;
+ var i2 = el.EndIndex;
+ // clear range
+ ClearRange(i1, i2, list);
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// remove pre
+ /// </summary>
+ static void RemoveFormating(ElementToken root)
+ {
+ var node = root.Tokens.First;
+ while (node != null)
+ {
+ var item = node.Value;
+ if (!(item is ElementToken))
+ {
+ node = node.Next;
+ continue;
+ }
+
+ var el = (ElementToken)item;
+ RemoveFormating(el);
+
+ if (el.Name == "pre")
+ {
+ foreach (var subNode in el.Tokens)
+ {
+ root.Tokens.AddBefore(node, subNode);
+ }
+
+ var next = node.Next;
+ root.Tokens.Remove(node);
+ node = next;
+ }
+ else
+ {
+ node = node.Next;
+ continue;
+ }
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ParamParser.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+
+namespace WpfHint.Parsing
+{
+ public class ParamParser
+ {
+ const string Pat = @"\((?:\s*(?<name>\w(?:\w|\d|
_)*\s*)(?<type>:\s*\w+\s*,))*(?<name>\s*\w+\s*)(?<type>:\s*\w+\s*)\)";
+ //const string pat =
@"\((?:(?<name>\s*\s*\w+\s*)(?<type>:\s*\w+\s*,))*(?<name>\s*\w+\s*)(?<type>:\s*\w+\s*)\)";
+ private static readonly Regex r = new Regex(Pat);
+
+ public static void Parse(RootToken rootToken)
+ {
+ var text = rootToken.Text;
+ var matches = r.Matches(text);
+ if (matches.Count == 0) return;
+
+ foreach (Match m in matches)
+ {
+ var i1 = m.Index + 1;
+ var i2 = m.Index + m.Length - 1;
+
+ var names = m.Groups["name"];
+ var types = m.Groups["type"];
+ var n = names.Captures.Count;
+
+ var param = FindParamToken(rootToken, i1, i2);
+ var el = InsertElement(param, i1, i2, "params");
+ for (int i = 0; i < n; i++)
+ {
+ var name = names.Captures[i];
+ var j1 = name.Index;
+ var j2 = name.Index + name.Length;
+ InsertElement(el, j1, j2, "pname");
+
+ var type = types.Captures[i];
+ j1 = type.Index;
+ j2 = type.Index + type.Length;
+ InsertElement(el, j1, j2, "ptype");
+ }
+ }
+ }
+
+ static ElementToken FindParamToken(ElementToken rootToken, int i1, int
i2)
+ {
+ foreach (var child in rootToken.Tokens)
+ {
+ var r = child;
+ var a1 = r.Contains(i1);
+ var a2 = r.Contains(i2);
+
+ if (a1 && a2) // both
+ {
+ if (child is TextToken) return rootToken;
+ return FindParamToken((ElementToken)child, i1, i2);
+ }
+
+ if (a1 || a2) return rootToken;
+ }
+ return null;
+ }
+
+ static ElementToken InsertElement(ElementToken token, int i1, int i2,
string name)
+ {
+ var newToken = Split(token, i1);
+ newToken.Name = name;
+ token.Tokens.AddLast(newToken);
+
+ var tmp = SplitBack(newToken, i2);
+ foreach (var t in tmp.Tokens)
+ {
+ token.Tokens.AddLast(t);
+ }
+
+ return newToken;
+ }
+
+ static ElementToken Split(ElementToken token, int index)
+ {
+ for (var node = token.Tokens.First; ; node = node.Next)
+ {
+ var r = node.Value;
+
+ if (index == r.StartIndex) return token.Split(node, false);
+ if (index < r.EndIndex) return SplitNode(token, node, index,
false);
+ }
+ }
+
+ static ElementToken SplitBack(ElementToken token, int index)
+ {
+ for (var node = token.Tokens.Last; ; node = node.Previous)
+ {
+ var r = node.Value;
+
+ if (index == r.EndIndex) return token.Split(node, true);
+ if (index > r.StartIndex) return SplitNode(token, node, index,
true);
+ }
+ }
+
+ static ElementToken SplitNode(ElementToken token,
LinkedListNode<ParseToken> node, int index, bool back)
+ {
+ var curToken = node.Value;
+
+ ParseToken newToken = null;
+ if (curToken is TextToken)
+ {
+ // split text
+ newToken = ((TextToken)curToken).Split(index);
+ }
+ else if (curToken is ElementToken)
+ {
+ newToken = back
+ ? SplitBack((ElementToken)curToken, index)
+ : Split((ElementToken)curToken, index);
+ }
+
+ // add new node after curNode
+ token.Tokens.AddAfter(node, newToken);
+
+ // split by node
+ return token.Split(node, true);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ParseToken.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using System.Text;
+using System.Xml.Linq;
+
+namespace WpfHint.Parsing
+{
+ public abstract class ParseToken
+ {
+ protected RangeList _rangeList;
+
+ protected ParseToken(RangeList rangeList)
+ {
+ _rangeList = rangeList;
+ Tokens = new LinkedList<ParseToken>();
+ }
+
+ public virtual LinkedList<ParseToken> Tokens { get; protected set; }
+
+ public abstract int StartIndex { get; }
+ public abstract int Length { get; }
+ public int EndIndex { get { return StartIndex + Length; } }
+
+ public bool Contains(int index)
+ {
+ return index >= StartIndex && index < EndIndex;
+ }
+
+ public string Text { get { return _rangeList.GetText(StartIndex,
Length); } }
+
+ public override string ToString()
+ {
+ return Text;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/Range.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,17 @@
+using System.Text;
+
+namespace WpfHint.Parsing
+{
+ public class Range
+ {
+ public int StartIndex { get; set; }
+ public int Length { get; set; }
+ public int EndIndex { get { return StartIndex + Length; } }
+
+
+ public override string ToString()
+ {
+ return "[" + StartIndex + "-" + EndIndex + "]";
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/RangeList.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using System.Text;
+
+namespace WpfHint.Parsing
+{
+ public class RangeList
+ {
+ private readonly LinkedList<Range> list;
+
+ public RangeList(string root)
+ {
+ list = new LinkedList<Range>();
+ Chars = root.ToCharArray();
+ }
+
+ public char[] Chars { get; private set; }
+
+ public string GetText(int index, int count)
+ {
+ var sb = new StringBuilder();
+ for (var i = index; i < index + count; ++i)
+ {
+ var c = Chars[i];
+ if (c != '\0') sb.Append(c);
+ }
+ return sb.ToString();
+ }
+
+ public Range AddRange(int index, int len)
+ {
+ var r = new Range { StartIndex = index, Length = len };
+ list.AddLast(r);
+ return r;
+ }
+
+ public bool RemoveRange(Range r)
+ {
+ return list.Remove(r);
+ }
+
+ public Range SplitRange(Range r, int index)
+ {
+ var range = new Range { StartIndex = index, Length =
r.EndIndex - index };
+ r.Length = index - r.StartIndex;
+
+ var node = list.Find(r);
+ list.AddAfter(node, range);
+ return range;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/RootToken.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+
+namespace WpfHint.Parsing
+{
+ public class RootToken : ElementToken
+ {
+ public RootToken(XElement root,RangeList rangeList)
+ : base(0, rangeList)
+ {
+ ParseElement(this, root, 0, _rangeList);
+ }
+
+ public override LinkedList<ParseToken> Tokens
+ {
+ get { return base.Tokens; } protected set { base.Tokens = value;
}
+ }
+
+ static void ParseElement(ElementToken en, XElement el, int index,
RangeList list)
+ {
+ // parse name & attributes
+ en.Name = el.Name.ToString();
+ foreach (var attr in el.Attributes())
+ {
+ en.Attributes[attr.Name.ToString()] = attr.Value;
+ }
+
+ // parse nodes
+ foreach (var node in el.Nodes())
+ {
+ var pn = Create(node, index, list);
+ en.Tokens.AddLast(pn);
+ index += pn.Length;
+ }
+ }
+
+ static ParseToken Create(XNode node, int index, RangeList list)
+ {
+ if (node is XText)
+ {
+ var len = ((XText)node).Value.Length;
+ return new TextToken(index, len, list);
+ }
+ if (node is XElement)
+ {
+ var el = (XElement)node;
+ var en = new ElementToken(index, list);
+ ParseElement(en, el, index, list);
+ return en;
+ }
+ throw new NotSupportedException(node.NodeType.ToString());
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/TextToken.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+using System.Text;
+using System.Xml.Linq;
+
+namespace WpfHint.Parsing
+{
+ public class TextToken : ParseToken
+ {
+ private TextToken(RangeList rangeList)
+ : base(rangeList)
+ {
+ }
+
+ public TextToken(int index, int len, RangeList rangeList)
+ : base(rangeList)
+ {
+ Range = _rangeList.AddRange(index, len);
+ }
+
+ public Range Range { get; private set; }
+
+ public override int StartIndex { get { return Range.StartIndex; } }
+
+ public override int Length { get { return Range.Length; } }
+
+ public TextToken Split(int index)
+ {
+ return new TextToken(_rangeList) { Range =
_rangeList.SplitRange(Range, index) };
+ }
+
+ public override string ToString()
+ {
+ return Text;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/PopupWindow.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,50 @@
+using System;
+using System.Windows;
+using System.Windows.Interop;
+using System.Windows.Media;
+
+namespace WpfHint
+{
+ internal class PopupWindow : Window
+ {
+ public PopupWindow()
+ {
+ AllowsTransparency = true;
+ WindowStyle = WindowStyle.None;
+ Background = Brushes.Transparent;
+ FontSize = 12.0d * (96d / 72d);
+
+ Topmost = true;
+ ShowActivated = false;
+ ShowInTaskbar = false;
+
+ Loaded += InvisibleWindow_Loaded;
+ }
+
+ void InvisibleWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ var source = HwndSource.FromHwnd(
+ new WindowInteropHelper(this).Handle);
+ if (source != null) source.AddHook(WndProc);
+ }
+
+ // Prevent activation of window
+ private static IntPtr WndProc(IntPtr hwnd, int msg,
+ IntPtr wParam, IntPtr lParam, ref bool
handled)
+ {
+ // ReSharper disable InconsistentNaming
+ const int WM_MOUSEACTIVATE = 0x0021;
+ const int MA_NOACTIVATE = 3;
+ //const int MA_NOACTIVATEANDEAT = 4;
+ // ReSharper restore InconsistentNaming
+
+ if (msg == WM_MOUSEACTIVATE)
+ {
+ handled = true;
+ return new IntPtr(MA_NOACTIVATE);
+ }
+
+ return IntPtr.Zero;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintBuilder.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,166 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Media;
+using WpfHint.Parsing;
+using System.Linq;
+
+namespace WpfHint.UIBuilding
+{
+ internal static class HintBuilder
+ {
+ public static FrameworkElement Build(RootToken rootToken)
+ {
+ return new HintDecorator { Child = new TextBlock().Fill(rootToken) };
+ }
+
+ private static Span Fill(this Span span, ElementToken token)
+ {
+ Fill(span.Inlines, token);
+ return span;
+ }
+
+ private static TextBlock Fill(this TextBlock tb, ElementToken token)
+ {
+ Fill(tb.Inlines, token);
+ return tb;
+ }
+
+ private static void Fill(InlineCollection inlines, ElementToken token)
+ {
+ foreach (var t in token.Tokens)
+ {
+ inlines.Add(GetInline(t));
+ }
+ }
+
+ private static Inline GetInline(ParseToken token)
+ {
+ if (token is TextToken)
+ {
+ var tt = (TextToken)token;
+ return new Run(tt.Text);
+ }
+ if (token is ElementToken)
+ {
+ var et = (ElementToken)token;
+ switch (et.Name)
+ {
+ case "b":
+ return new Bold().Fill(et);
+ case "u":
+ return new Underline().Fill(et);
+ case "i":
+ return new Italic().Fill(et);
+ case "lb":
+ return new LineBreak();
+ case "code":
+ return new Span { FontFamily = new FontFamily("Consolas"),
FontSize = 12.0d * (96d / 72d) }.Fill(et);
+ case "font":
+ return BuildFont(et);
+ case "keyword":
+ return new Span { Foreground = Brushes.Blue }.Fill(et);
+ case "span":
+ return BuildHint(et);
+ case "ref":
+ return BuildRef(et);
+ case "params":
+ return BuildParam(et);
+ default:
+ throw new NotSupportedException(et.Name);
+ }
+ }
+ throw new NotSupportedException();
+ }
+
+ private static Inline BuildFont(ElementToken token)
+ {
+ var span = new Span();
+
+ string size;
+ if (token.Attributes.TryGetValue("size", out size))
+ {
+ var fc = new FontSizeConverter();
+ var sz = (double)fc.ConvertFromString(size);
+ span.FontSize = sz;
+ }
+
+ string face;
+ if (token.Attributes.TryGetValue("face", out face))
+ {
+ span.FontFamily = new FontFamily(face);
+ }
+
+ string color;
+ if (token.Attributes.TryGetValue("color", out color))
+ {
+ var bc = new BrushConverter();
+ var br = (Brush)bc.ConvertFromString(color);
+ span.Foreground = br;
+ }
+ return span.Fill(token);
+ }
+
+ private static Inline BuildHint(ElementToken token)
+ {
+ string hint;
+ token.Attributes.TryGetValue("hint", out hint);
+ return hint == null ? new Span().Fill(token) : BuildRef(token);
+ }
+
+ private static Inline BuildRef(ElementToken token)
+ {
+ string handler;
+ token.Attributes.TryGetValue("handler", out handler);
+
+ string hint;
+ token.Attributes.TryGetValue("hint", out hint);
+ if (hint != null)
+ {
+ hint = "<code>" + hint + "</code>";
+ }
+ var hc = new HintControl(hint, handler);
+ Fill(hc.Inlines, token);
+ return new InlineUIContainer { Child = hc };
+ }
+
+ private static Inline BuildParam(ElementToken token)
+ {
+ var pp = new ParamPanel();
+ foreach (ParseToken pt in token.Tokens)
+ {
+ var et = pt as ElementToken;
+ if (et != null)
+ {
+ var tb = new TextBlock().Fill(et);
+ pp.Children.Add(tb);
+ if (et.Name == "pname")
+ ParamPanel.SetNameColumn(tb, true);
+
+ continue;
+ }
+
+ var tt = pt as TextToken;
+ if (tt != null && pp.Children.Count > 0)
+ {
+ var elem = pp.Children[pp.Children.Count - 1] as TextBlock;
+ if (elem != null)
+ elem.Inlines.Add(GetInline(tt));
+
+ continue;
+ }
+ }
+
+ var span = new Span();
+ span.Inlines.Add(new SoftBreak());
+ span.Inlines.Add(new InlineUIContainer
+ {
+ Child = pp,
+ BaselineAlignment = BaselineAlignment.Bottom
+ });
+ span.Inlines.Add(new SoftBreak());
+ return span;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintControl.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,81 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+
+namespace WpfHint.UIBuilding
+{
+ internal class HintControl : TextBlock
+ {
+ #region ClickEvent
+
+ public static readonly RoutedEvent ClickEvent =
+ EventManager.RegisterRoutedEvent(
+ "Click",
+ RoutingStrategy.Bubble,
+ typeof (RoutedEventHandler),
+ typeof (HintControl));
+
+ public static void AddClickHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null) element.AddHandler(ClickEvent, handler);
+ }
+
+
+ public static void RemoveClickHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null) element.RemoveHandler(ClickEvent,
handler);
+ }
+
+ #endregion
+
+ #region MouseHover
+
+ public static readonly RoutedEvent MouseHoverEvent =
+ EventManager.RegisterRoutedEvent(
+ "MouseHover",
+ RoutingStrategy.Bubble,
+ typeof (RoutedEventHandler),
+ typeof (HintControl));
+
+ public static void AddMouseHoverHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null) element.AddHandler(MouseHoverEvent,
handler);
+ }
+
+ public static void RemoveMouseHoverHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null) element.RemoveHandler(MouseHoverEvent,
handler);
+ }
+
+ #endregion
+
+ private readonly Span span;
+ public string Handler { get; private set; }
+ public string Hint { get; private set; }
+ public new InlineCollection Inlines { get { return span.Inlines; }
}
+
+ public HintControl(string hintText, string handler)
+ {
+ Hint = hintText;
+ Handler = handler;
+
+ MouseEnter += delegate { RaiseEvent(new
RoutedEventArgs(MouseHoverEvent)); };
+
+ if (handler != null)
+ {
+ var hLink = new Hyperlink { Focusable = false };
+ hLink.Click += delegate { RaiseEvent(new
RoutedEventArgs(ClickEvent)); };
+ span = hLink;
+ }
+ else
+ {
+ span = new Span();
+ }
+ base.Inlines.Add(span);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintDecorator.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,80 @@
+using System;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace WpfHint.UIBuilding
+{
+ internal class HintDecorator : Decorator
+ {
+ public double WrapWidth
+ {
+ get { return (double)GetValue(WrapWidthProperty); }
+ set { SetValue(WrapWidthProperty, value); }
+ }
+
+ public static readonly DependencyProperty WrapWidthProperty =
+ DependencyProperty.Register(
+ "WrapWidth",
+ typeof (double),
+ typeof(HintDecorator),
+ new FrameworkPropertyMetadata
+ {
+ DefaultValue = 400.0,
+ PropertyChangedCallback = (d, e) => ((UIElement)
d).InvalidateMeasure(),
+ AffectsArrange = true,
+ AffectsMeasure = true
+ });
+
+
+ public static bool GetWrap(DependencyObject obj)
+ {
+ return (bool)obj.GetValue(WrapProperty);
+ }
+
+ public static void SetWrap(DependencyObject obj, bool value)
+ {
+ obj.SetValue(WrapProperty, value);
+ }
+
+ public static readonly DependencyProperty WrapProperty =
+ DependencyProperty.RegisterAttached(
+ "Wrap",
+ typeof (bool),
+ typeof(HintDecorator),
+ new FrameworkPropertyMetadata(false));
+
+
+ private bool _wrap;
+
+ protected override Size MeasureOverride(Size constraint)
+ {
+ var child = base.Child;
+ if (child == null)
+ return new Size();
+
+ child.Measure(constraint);
+ var sz = child.DesiredSize;
+
+ if (!_wrap && sz.Width > WrapWidth)
+ {
+ _wrap = true;
+ OnWrap(this);
+
+ child.Measure(constraint);
+ sz = child.DesiredSize;
+ }
+
+ return sz;
+ }
+
+ private static void OnWrap(DependencyObject d)
+ {
+ foreach (var dobj in
LogicalTreeHelper.GetChildren(d).OfType<DependencyObject>().ToList())
+ {
+ SetWrap(dobj, true);
+ OnWrap(dobj);
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/ParamPanel.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,122 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace WpfHint.UIBuilding
+{
+ internal class ParamPanel : Panel
+ {
+ public static bool GetNameColumn(DependencyObject obj)
+ {
+ return (bool) obj.GetValue(NameColumnProperty);
+ }
+
+ public static void SetNameColumn(DependencyObject obj, bool value)
+ {
+ obj.SetValue(NameColumnProperty, value);
+ }
+
+ public static readonly DependencyProperty NameColumnProperty =
+ DependencyProperty.RegisterAttached(
+ "NameColumn", typeof (bool), typeof (ParamPanel),
+ new FrameworkPropertyMetadata(false));
+
+
+ public static readonly DependencyProperty WrapProperty =
+ HintDecorator.WrapProperty.AddOwner(
+ typeof (ParamPanel),
+ new FrameworkPropertyMetadata((d, e) => ((UIElement)
d).InvalidateMeasure()));
+
+ #region Layout
+
+ private const double tabSpace = 20;
+ private double nameColumnWidth;
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ var panelSize = new Size();
+
+ if (!HintDecorator.GetWrap(this))
+ {
+ foreach (UIElement child in base.InternalChildren)
+ {
+ child.Measure(availableSize);
+ var desiredSize = child.DesiredSize;
+
+ panelSize.Width += desiredSize.Width;
+ panelSize.Height = Math.Max(panelSize.Height,
desiredSize.Height);
+ }
+ }
+ else
+ {
+ nameColumnWidth = 0.0;
+ var typeColumnWidth = 0.0;
+ var rowHeight = 0.0;
+
+ foreach (UIElement child in base.InternalChildren)
+ {
+ child.Measure(availableSize);
+ var ds = child.DesiredSize;
+
+ if (GetNameColumn(child))
+ {
+ panelSize.Height += rowHeight;
+
+ // tab sapce
+ ds.Width += tabSpace;
+
+ if (ds.Width > nameColumnWidth) nameColumnWidth = ds.Width;
+ rowHeight = ds.Height;
+ }
+ else
+ {
+ if (ds.Width > typeColumnWidth) typeColumnWidth = ds.Width;
+ rowHeight = Math.Max(rowHeight, ds.Height);
+ }
+ }
+
+ panelSize.Height += rowHeight;
+ panelSize.Width = nameColumnWidth + typeColumnWidth;
+ }
+ return panelSize;
+ }
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ if (!HintDecorator.GetWrap(this))
+ {
+ var pt = new Point();
+ foreach (UIElement child in base.InternalChildren)
+ {
+ var size = child.DesiredSize;
+ child.Arrange(new Rect(pt, size));
+ pt.X += size.Width;
+ }
+ }
+ else
+ {
+ var ht = 0.0;
+ var y = 0.0;
+
+ foreach (UIElement child in base.InternalChildren)
+ {
+ var size = child.DesiredSize;
+
+ if (GetNameColumn(child))
+ {
+ child.Arrange(new Rect(tabSpace, y, nameColumnWidth -
tabSpace, size.Height));
+ ht = size.Height;
+ }
+ else
+ {
+ child.Arrange(new Rect(nameColumnWidth, y, size.Width,
size.Height));
+ y += Math.Max(ht, size.Height);
+ }
+ }
+ }
+ return finalSize;
+ }
+
+ #endregion
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/SoftBreak.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,18 @@
+using System.Windows;
+using System.Windows.Documents;
+
+namespace WpfHint.UIBuilding
+{
+ internal class SoftBreak : Run
+ {
+ public static readonly DependencyProperty WrapProperty =
+ HintDecorator.WrapProperty.AddOwner(
+ typeof(SoftBreak),
+ new FrameworkPropertyMetadata((d, e) =>
((SoftBreak)d).Update()));
+
+ private void Update()
+ {
+ Text = HintDecorator.GetWrap(this) ? "\r\n" : "";
+ }
+ }
+}
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Win32.cs
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,69 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+namespace WpfHint
+{
+// ReSharper disable InconsistentNaming
+ public static class Win32
+ {
+ public delegate int Callback(IntPtr wHwnd, int msg, int wParam,
int lParam);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct POINT
+ {
+ public POINT(double x, double y)
+ {
+ X = (int) x;
+ Y = (int) y;
+ }
+ public int X;
+ public int Y;
+ }
+
+ public const int GA_PARENT = 1;
+ public const int GA_ROOT = 2;
+ public const int GA_ROOTOWNER = 3;
+
+ public const int WM_ACTIVATE = 0x0006;
+ public const int WM_ACTIVATEAPP = 0x001C;
+
+ public const int WM_KEYDOWN = 0x0100;
+ public const int WM_MOUSEWHEEL = 0x020A;
+ public const int WM_RBUTTONDOWN = 0x204;
+ public const int WM_LBUTTONDOWN = 0x201;
+ public const int WM_LBUTTONUP = 0x202;
+ public const int WM_MOUSEMOVE = 0x0200;
+ public const int WM_MOUSELEAVE = 0x02A3;
+ public const int WM_MOUSEHOVER = 0x02A1;
+ public const int GWL_WNDPROC = -4;
+
+ [DllImport("user32.dll")]
+ public static extern bool ClientToScreen(IntPtr hWnd, POINT[]
lpPoint);
+ [DllImport("user32.dll")]
+ public static extern bool ClientToScreen(IntPtr hWnd, ref POINT
lpPoint);
+
+ [DllImport("user32.dll", CallingConvention =
CallingConvention.StdCall, EntryPoint = "SetWindowLong", CharSet =
CharSet.Auto)]
+ public static extern Callback SetWindowLong(IntPtr hwnd, int
nIndex, Callback dwNewLong);
+
+ [DllImport("user32.dll", CallingConvention =
CallingConvention.StdCall, EntryPoint = "CallWindowProc", CharSet =
CharSet.Auto)]
+ public static extern int CallWindowProc(Callback lpPrevWndFunc,
IntPtr hwnd, int msg, int wParam, int lParam);
+
+ [DllImport("user32.dll")]
+ public static extern IntPtr WindowFromPoint(POINT Point);
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool GetCursorPos(out POINT lpPoint);
+
+ [DllImport("user32.dll", ExactSpelling = true)]
+ public static extern IntPtr GetAncestor(IntPtr hwnd, uint gaFlags);
+
+ public static Point GetCursorPos()
+ {
+ POINT pt;
+ GetCursorPos(out pt);
+ return new Point(pt.X, pt.Y);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/WpfHint.csproj
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)'
== '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{7670DE22-B023-4783-BA19-BB2DB50E1762}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>WpfHint</RootNamespace>
+ <AssemblyName>WpfHint</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ <StartupObject>
+ </StartupObject>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>nemerle.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|
AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|
AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="WindowsBase" />
+ <Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
+ </ItemGroup>
+ <ItemGroup>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Hint.cs" />
+ <Compile Include="Parsing\HintParser.cs" />
+ <Compile Include="UIBuilding\HintBuilder.cs" />
+ <Compile Include="HintRoot.cs" />
+ <Compile Include="HintSource.cs" />
+ <Compile Include="HintWindow.xaml.cs">
+ <DependentUpon>HintWindow.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Parsing\ElementToken.cs" />
+ <Compile Include="Parsing\ParamParser.cs" />
+ <Compile Include="Parsing\ParseToken.cs" />
+ <Compile Include="Parsing\Range.cs" />
+ <Compile Include="Parsing\RangeList.cs" />
+ <Compile Include="Parsing\RootToken.cs" />
+ <Compile Include="Parsing\TextToken.cs" />
+ <Compile Include="UIBuilding\HintControl.cs" />
+ <Compile Include="UIBuilding\HintDecorator.cs" />
+ <Compile Include="UIBuilding\ParamPanel.cs" />
+ <Compile Include="PopupWindow.cs" />
+ <Compile Include="UIBuilding\SoftBreak.cs" />
+ <Compile Include="Win32.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Page Include="HintWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="nemerle.snk" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the
targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/nemerle.snk
Fri Oct 30 10:58:03 2009
@@ -0,0 +1,14 @@
+ $ RSA2 uNx G Fùošë‰Ú¬è`ì¤ J¢Ú-¾Gz)zÌ3 Š b 3
Ѩ4² ˆñ'¾IŸ"ØÆå þƒÊ)ò »¬ì&1u`Çelš%›XÍmY5€Œ ëܳkðšh‚] ä²E삈 zz¯Œ˜~ DìÒpKu‡¡†ªÀ–
+âYÒNÐ[Í“sÉÛj ÿƒ·‰Ä |B¡HcW›
+‰íðë é p-ûõþ öPÖ ‹?¡Ž„× n&@ëkÛ• > D1ù C½×T>–úïd 0ÿó—0>=Ðö(ò­– ”Nýõó˜ ÝZÑ«+o
+
+þíþG(lX ëÕ<
+íâ!e“ ¨gãÂmèõ”ÉäœÍÍõ÷
+t@1~%± ßÞ fy ” ‰®ñpþ[ â(šF2¹! >ªF‚ì–
+ô QB×ÃiÇÝ1 ¸r{þ σ¨x>@ÉHrûŠð' E
ƒ¤—y©“ Ýš¢+G@ä‡ ¬Ž >J¾ lH ¤b\E²’Æuwï †8‚½IßQúxLyÒÛŒ‰PCo G éÓ† x^„iKá©,wê 5 ¹Ú ëtñH I&1+6áטâ; ^dUVôÀß p-i
YÁ›ÒŠ qŒÐÐã &ÄRáðÿ2ÿ×\ f ¿a䯂{þ« ”IÇ¢
+–æàåãIìJéº_ h ݨ= ª-p¨ÂÙå<˜ÊèÿåHÍ&Ûv|ã

+iù¥Š ¢Ã¤ Ÿ JÓ2 ¬ä º)·@lîò_à|hDÿ ­ ^
+æ£ûÍa×;Æ<Žöë
+ ¹
+úÉH
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint.sln Fri
Oct 30 10:58:03 2009
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "WpfHint", "WpfHint\WpfHint.csproj", "{7670DE22-B023-4783-BA19-BB2DB50E1762}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "WinFormTestHint", "WinFormTestHint\WinFormTestHint.csproj", "{7663D2C3-250E-451E-9A63-BE89FA4D3033}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Any CPU.ActiveCfg = Debug|
Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Any CPU.Build.0 = Debug|Any
CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Any CPU.ActiveCfg =
Release|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Any CPU.Build.0 = Release|
Any CPU
+ {7663D2C3-250E-451E-9A63-BE89FA4D3033}.Debug|Any CPU.ActiveCfg = Debug|
Any CPU
+ {7663D2C3-250E-451E-9A63-BE89FA4D3033}.Debug|Any CPU.Build.0 = Debug|Any
CPU
+ {7663D2C3-250E-451E-9A63-BE89FA4D3033}.Release|Any CPU.ActiveCfg =
Release|Any CPU
+ {7663D2C3-250E-451E-9A63-BE89FA4D3033}.Release|Any CPU.Build.0 = Release|
Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint.suo Fri
Oct 30 10:58:03 2009
Binary file, no diff available.
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NativeMethods.cs Fri
Oct 30 10:58:03 2009
@@ -0,0 +1,14 @@
+using System;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.OLE.Interop;
+
+namespace Nemerle.VisualStudio
+{
+ class NemerleNativeMethods
+ {
+ [DllImport("user32.dll")]
+ public static extern bool ClientToScreen(IntPtr hWnd, POINT[] lpPoint);
+ [DllImport("user32.dll")]
+ public static extern bool ClientToScreen(IntPtr hWnd, ref POINT
lpPoint);
+ }
+}
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.VSIP.sln Wed Oct 28 16:13:10 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.VSIP.sln Fri Oct 30 10:58:03 2009
@@ -17,6 +17,8 @@
EndProject
Project("{EDCC3B85-0BAD-11DB-BC1A-00112FDE8B61}")
= "Nemerle.Compiler.Utils", "Nemerle.Compiler.Utils\Nemerle.Compiler.Utils.nproj", "{DBC77173-9367-485F-B425-74E6D6AB3F82}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "WpfHint", "Nemerle.VisualStudio\GUI\WpfHint\WpfHint.csproj", "{7670DE22-B023-4783-BA19-BB2DB50E1762}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -77,6 +79,16 @@
{DBC77173-9367-485F-B425-74E6D6AB3F82}.Release|Mixed Platforms.ActiveCfg
= Release|Any CPU
{DBC77173-9367-485F-B425-74E6D6AB3F82}.Release|Mixed Platforms.Build.0 =
Release|Any CPU
{DBC77173-9367-485F-B425-74E6D6AB3F82}.Release|Win32.ActiveCfg = Release|
Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Any CPU.ActiveCfg = Debug|
Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Any CPU.Build.0 = Debug|Any
CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Mixed Platforms.ActiveCfg =
Debug|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Mixed Platforms.Build.0 =
Debug|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Win32.ActiveCfg = Debug|Any
CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Any CPU.ActiveCfg =
Release|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Any CPU.Build.0 = Release|
Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Mixed Platforms.ActiveCfg
= Release|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Mixed Platforms.Build.0 =
Release|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Win32.ActiveCfg = Release|
Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
Wed Oct 28 21:02:28 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
Fri Oct 30 10:58:03 2009
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing;
+//using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
@@ -18,7 +18,8 @@
using Nemerle.Compiler.Utils.Async;

using Nemerle.VisualStudio.Project;
-
+using WpfHint;
+using Color = System.Drawing.Color;
using VsShell = Microsoft.VisualStudio.Shell.VsShellUtilities;
using Nemerle.VisualStudio.GUI;
using Nemerle.Utility;
@@ -26,6 +27,7 @@

using Nemerle.VisualStudio.Properties;
using Microsoft.VisualStudio.Package;
+using System.Windows;

// ReSharper disable LocalizableElement
namespace Nemerle.VisualStudio.LanguageService
@@ -34,7 +36,7 @@
/// This is the base class for a language service that supplies language
features including syntax highlighting, brace matching, auto-completion,
IntelliSense support, and code snippet expansion.
///</summary>
[Guid(NemerleConstants.LanguageServiceGuidString)]
- public class NemerleLanguageService :
Microsoft.VisualStudio.Package.LanguageService, IVsTipWindow
+ public class NemerleLanguageService :
Microsoft.VisualStudio.Package.LanguageService
{
#region Fields

@@ -60,9 +62,9 @@
AstToolControl.ShowLocation += GotoLocation;

if (DefaultEngine == null)
- {
DefaultEngine = new Engine(EngineCallbackStub.Default, new
TraceWriter(), true);
- }
+
+ Hint = new Hint();
}

///<summary>
@@ -249,7 +251,7 @@

};

- Dictionary<IVsTextLines, NemerleColorizer> _colorizers = new
Dictionary<IVsTextLines,NemerleColorizer>();
+ readonly Dictionary<IVsTextLines, NemerleColorizer> _colorizers = new
Dictionary<IVsTextLines,NemerleColorizer>();

public override Colorizer GetColorizer(IVsTextLines buffer)
{
@@ -740,30 +742,43 @@

#region IVsTipWindow Members

- void IVsTipWindow.Dismiss()
- {
- throw new NotImplementedException();
- }
-
- int IVsTipWindow.GetContextStream(out int piPos, out int piLength)
- {
- throw new NotImplementedException();
- }
-
- int
IVsTipWindow.GetSizePreferences(Microsoft.VisualStudio.OLE.Interop.RECT[]
prcCtxBounds, TIPSIZEDATA[] pSizeData)
- {
- throw new NotImplementedException();
- }
-
- int IVsTipWindow.Paint(IntPtr hdc,
Microsoft.VisualStudio.OLE.Interop.RECT[] prc)
- {
- throw new NotImplementedException();
- }
-
- int IVsTipWindow.WndProc(IntPtr hwnd, uint iMsg, IntPtr wParam, IntPtr
lParam)
- {
- throw new NotImplementedException();
- }
+ public Hint Hint { get; private set; }
+
+ public bool ShowHint(IVsTextView view, TextSpan hintSpan, string
hintText)
+ {
+ var hWnd = view.GetWindowHandle();
+
+ int lineHeight;
+ ErrorHelper.ThrowOnFailure(view.GetLineHeight(out lineHeight));
+
+ var ptStart = new Microsoft.VisualStudio.OLE.Interop.POINT[1];
+ var ptEnd = new Microsoft.VisualStudio.OLE.Interop.POINT[1];
+
ErrorHelper.ThrowOnFailure(view.GetPointOfLineColumn(hintSpan.iStartLine,
hintSpan.iStartIndex, ptStart));
+
ErrorHelper.ThrowOnFailure(view.GetPointOfLineColumn(hintSpan.iEndLine,
hintSpan.iEndIndex, ptEnd));
+
+ NemerleNativeMethods.ClientToScreen(hWnd, ref ptStart[0]);
+ NemerleNativeMethods.ClientToScreen(hWnd, ref ptEnd[0]);
+
+ var hintXml = "<hint>" +
hintText.Replace("<unknown>", "&lt;unknown&gt;").Replace("\r", "")
+ .Replace("\n", "<lb/>") + "</hint>";
+
+ var rect = new Rect(new Point(ptStart[0].x, ptStart[0].y), new
Point(ptEnd[0].x, ptEnd[0].y + lineHeight));
+
+ if (Hint.IsOpen)
+ {
+ if (Hint.PlacementRect == rect)
+ {
+ Hint.Text = hintXml;
+ return true;
+ }
+
+ Hint.Close();
+ }
+
+ Hint.Show(hWnd, rect, hintXml);
+
+ return true;
+ }

#endregion
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleSource.cs
Wed Oct 28 16:13:10 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleSource.cs
Fri Oct 30 10:58:03 2009
@@ -1,3 +1,5 @@
+using System.Windows;
+using System.Windows.Forms;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.Project;
@@ -14,7 +16,6 @@
using System.Linq;
using System.Runtime.InteropServices;
using System;
-
using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID;
using TopDeclaration = Nemerle.Compiler.Parsetree.TopDeclaration;
using TupleIntInt = Nemerle.Builtins.Tuple<int, int>;
@@ -24,7 +25,6 @@
using System.Text;
using Nemerle.Compiler.Utils.Async;
using Nemerle.VisualStudio.GUI;
-using System.Windows.Forms;
using Nemerle.Compiler.Parsetree;

// ReSharper disable LocalizableElement
@@ -124,7 +124,7 @@

if (projectInfo.IsDocumentOpening)
{
- //TODO: Ðåàëèçîâàòü ñ÷èòûâàíèå èíôîðìàöèè î ðåãèîíàõ è ñòðóêòóðå
ôàéëà íà áàçå CompileUnit-à ïîëó÷àåìîãî ïðè ïàðñèíãå.
+ //TODO: Реализовать считывание информации о регионах и структуре
файла на базе CompileUnit-а получаемого при парсинге.
projectInfo.Engine.BeginUpdateCompileUnit(this);
return;
}
@@ -296,32 +296,32 @@
}

/// <summary>
- /// Ýòîò ìåòîä ïûòàåòñÿ íàéòè ïîçèöèè ïåðåõîäà íà îñíîâàíèè èìåþùåõñÿ
òèïîâ ñ÷èòàííûõ èç äðóãèõ ñáîðîê,
- /// àíàëèçà .pdb-ôàéëîâ (ôàéëîâ ñîäåæàùèõ îòëàäî÷íóþ èíôîðìàöèþ) è
ïàðñèíãà èñõîäíèêîâ.
+ /// Этот метод пытается найти позиции перехода на основании имеющехся
типов считанных из других сборок,
+ /// анализа .pdb-файлов (файлов содежащих отладочную информацию) и
парсинга исходников.
/// </summary>
/// <param name="engine"></param>
/// <param name="inf"></param>
/// <returns></returns>
/// <remarks>
- /// Îïèñàíèå ïðîáëåìû:
- /// Ê ñîæàëåíèþ .pdb-ôàéëû íå ñîäåðæàò ïîëíîé èíôîðìàöèè î
ìåñòîïîëîæåíèÿõ òèîïîâ. Ìåñòîïîëîæåíèÿ ñîäåðæàòñÿ
- /// òîëüêî äëÿ ìåòîäîâ (òàê êàê èìåííî îíè ïîäâåðãàþòñÿ îòëàäêå). Íàì
æå íóæíî íàõîäèòü íå òàê æå òèïû
- /// (ïðè÷åì òèïû ìîãóò ðàñïîëàãàòüñÿ áîëåå ÷åì â îäíîì ôàéëå). Ïîýòîìó
ïîñòóïàåì ñëåäóþùèì îáðàçîì...
- /// 1. Èçâëåêàåì òèï äëÿ êîòîðîãî íóæíî ïîëó÷èòü èíôîðìàöèþ äëÿ
ïåðåõîäà. Ýòî ìîæåò áûòü èëè íåïîñðåäñòâåííî
- /// ÷ëåí íà êîòðûé îñóùåñòâëÿåòÿ ïåðåõîä, èëè òèï â êîòîðîì îáúÿâëåí
ýòîò ÷ëåí (åñëè ïåðõîä èäåò íà ÷ëåí
- /// îòëè÷íûé îò òèïà.
- /// 2. Ïîëó÷àåì ïîëíûé ñïèñîê ÷ëåíîâ â êîòîðîì òèïà ïîëó÷åííîãî íà
øàãå 1.
- /// 3. Ïîëó÷àåì ìåñòîïîëîæåíèÿ ÷ëåíîâ (âìåñòå ñ ïóòåì ê ôàéëó).
Ìåñòîïîëîæåíèÿ ìîãóò áûòü íå ïîëíûìè. Íàïðèìåð,
- /// ìîæåò áûòü çàäàí òîëüêî ïóòü ê ôàéëó, à ïîçèöèÿ â ôàéëå ìîæåò áûòü
íå âåðíîé (ïðè ýòîì, â êîëîíêå
- /// ñîäåðæèòñÿ 0). Åñëè ìû íàøëè ìåñòîïëîæåíèå äëÿ èñêîìîãî ÷ëåíà è
îíî êîððåêòíî, òî èñïîëüçóåì åãî
- /// (íà ýòîì ïîèñê íóæíî ïðåêðàòèòü).  ïðîòèâíîì ñëó÷àå ïåðåõîäèì ê
ñëåäóþùåìó øàãó.
- /// 4. Ìû ïîëó÷èëè ñïèñîê ôàéëîâ â êîòîðûõ ìîæåò ñîäåæàòüñÿ èñêîìûé
÷ëåí. Ïàðñèì êàæäûé èç ôàéëîâ
- /// è èùåì â íèõ òèï â êîòîðîì îáúÿâëåí íóæíûé íàì ÷ëåí. Åñëè ÷ëåí è
åñòü òèï, òî çàâåðøàåì îáðàáîòêó
- /// è âîçâðàùàåì ìåñòïîëîæåíèÿ òèïà (òèï ìîæåò áûòü îáÿâëåí áîëåå ÷åì
â îäíîì ôàéëå).
- ///  ïðîòèâíîì ñëó÷àå ïåðåõîäèì ê ñëåäóþùåìó øàãó.
- /// 5. Èùåì â òèïå íàäåíîì íà øàãå 5 ÷ëåí ñ èìåíåì ñîâïàäàþùèì ñ
èñêîìûì (âçÿòûì èç IMember). Åñëè íàéäåíî
- /// áîëåå îäíîãî ÷ëåíà, òî ïðîèçâîäèò îòñåâ íàèáîëåå ïîäõîäÿùåãî. Äëÿ
ýòîãî ïîñëåäîâàòåëüíî ïðîâåðÿåì ñïèñîê
- /// àðãóìåíòîâ, âîçâðàùàåìîå çíà÷åíèå è ò.ï.
+ /// Описание проблемы:
+ /// К сожалению .pdb-файлы не содержат полной информации о
местоположениях тиопов. Местоположения содержатся
+ /// только для методов (так как именно они подвергаются отладке). Нам
же нужно находить не так же типы
+ /// (причем типы могут располагаться более чем в одном файле). Поэтому
поступаем следующим образом...
+ /// 1. Извлекаем тип для которого нужно получить информацию для
перехода. Это может быть или непосредственно
+ /// член на котрый осуществляетя переход, или тип в котором объявлен
этот член (если перход идет на член
+ /// отличный от типа.
+ /// 2. Получаем полный список членов в котором типа полученного на
шаге 1.
+ /// 3. Получаем местоположения членов (вместе с путем к файлу).
Местоположения могут быть не полными. Например,
+ /// может быть задан только путь к файлу, а позиция в файле может быть
не верной (при этом, в колонке
+ /// содержится 0). Если мы нашли местопложение для искомого члена и
оно корректно, то используем его
+ /// (на этом поиск нужно прекратить). В противном случае переходим к
следующему шагу.
+ /// 4. Мы получили список файлов в которых может содежаться искомый
член. Парсим каждый из файлов
+ /// и ищем в них тип в котором объявлен нужный нам член. Если член и
есть тип, то завершаем обработку
+ /// и возвращаем местположения типа (тип может быть обявлен более чем
в одном файле).
+ /// В противном случае переходим к следующему шагу.
+ /// 5. Ищем в типе наденом на шаге 5 член с именем совпадающим с
искомым (взятым из IMember). Если найдено
+ /// более одного члена, то производит отсев наиболее подходящего. Для
этого последовательно проверяем список
+ /// аргументов, возвращаемое значение и т.п.
/// </remarks>
private GotoInfo[] TryFindGotoInfoByDebugInfo(Engine engine, GotoInfo
inf)
{
@@ -369,7 +369,7 @@
var isProp = member is IProperty;

members = td.GetMembers().Where(m => string.Equals(m.Name, name,
StringComparison.OrdinalIgnoreCase)
- // Ìàêðî [Accessor] ìîæåò
èçìåíÿòü èìÿ ñâîéñòâà. Ó÷èòûâàåì ýòî...
+ // Макро [Accessor] может
изменять имя свойства. Учитываем это...
|| (isProp &&
string.Equals(m.Name.Replace("_", ""), name,
StringComparison.OrdinalIgnoreCase))).ToArray();

if (members.Length > 0)
@@ -390,7 +390,7 @@
return FindBastMember(members, member).Select(m => new
GotoInfo(file, m.NameLocation)).ToArray();
}

- return new GotoInfo[0]; // íè÷åãî íå íàøëè
+ return new GotoInfo[0]; // ничего не нашли
}

// ReSharper disable ParameterTypeCanBeEnumerable.Local
@@ -579,7 +579,7 @@
public override void ProcessHiddenRegions(System.Collections.ArrayList
hiddenRegions)
{
// TranslateMe:ss
- //VladD2: Ïðèõîäèòñÿ ïåðåïèñûâàòü ðåàëèçàöèþ îò ÌÑ, òàê êàê îíà
ïðàêòè÷åñêè íå ðàñøèðÿåòñÿ êàê íóæíî íàì.
+ //VladD2: Приходится переписывать реализацию от МС, так как она
практически не расширяется как нужно нам.
throw new NotImplementedException();
}

@@ -611,16 +611,16 @@

//Debug.WriteLine("SetRegions: begin " + timer.Elapsed);
timer.Reset(); timer.Start();

- #region Ïîëó÷àåì ñïèñîê ðåãèîòîâ êîòîðûå óæå åñòü â ðåäàêòîðå.
-
- // Ðåãèîíû â ðåäàêòîðå ìîãóò áûòü
- // ïî äâóì ïðè÷èíàì:
- // 1. Îíà áèëû äîáàâëåíû ïðåäûäóùèì çàïóñêîì ýòîãî ìåòîäà.
- // 2. Îíè áûëè çàãðóæåíû ñàìèì ðåäàêòîðì äëÿ âîñòàíîâëåíèÿ ñîñòîÿíèÿ
ñîñòîÿíèÿ
- // (îòêðûòû / çàêðûòû) ðåãèîíîâ ïîñëå îòêðûòèÿ ôàéëà (îáû÷íî
ñëó÷àåòñÿ òîëüêî
- // åñëè ôàéë îòêðûâàåòñÿ ïðè îòêðûòîì Solution).
- // Ïðè ýòîì ñòóäèÿ íå âîñòàíàâëèâàåò áàííåðû, òàê ÷òî èõ ïðèõîäèòñÿ
îáíîâëÿòü
- // (ñì. êîìåíòàðèé ê âûçîâó region.SetBanner()).
+ #region Получаем список региотов которые уже есть в редакторе.
+
+ // Регионы в редакторе могут быть
+ // по двум причинам:
+ // 1. Она билы добавлены предыдущим запуском этого метода.
+ // 2. Они были загружены самим редакторм для востановления состояния
состояния
+ // (открыты / закрыты) регионов после открытия файла (обычно
случается только
+ // если файл открывается при открытом Solution).
+ // При этом студия не востанавливает баннеры, так что их приходится
обновлять
+ // (см. коментарий к вызову region.SetBanner()).

IVsHiddenTextSession session = GetHiddenTextSession();
var aspan = new TextSpan[1];
@@ -663,11 +663,11 @@

#endregion

- // Îáíîâëÿòü ðåãèîíû íóæíî íà çàáëîêèðîâàííîì äëÿ çàïèñè ðåäàêòîðå,
èíà÷å, åñëè òåêñò
- // èçìåíèòñÿ âî âðåìÿ îáíîâëåíèÿ, òî ìû ïîëó÷èì ðàññèíõðîíèçàöèþ, è êàê
ñëåäñòâèå,
- // íåîïðåäåëåííîå ïîåâåäåíèå. Ïî âîçìîæíîñòè íå ñëåäóåò äîáàâëÿòü
äîëãèå äåéñòâèÿ
- // â áëîê ðàñïîëîæåííûé íèæå, òàê êàê îáíîâëåíèå èäåò â GUI-ïîòîêå è
ìåäëåííàÿ ðàáîòà
- // ìîæåò ïðèâåñòè ê îùóòèìîìó íåóäîáñòâó äëÿ ïîëüçîâàòåëÿ.
+ // Обновлять регионы нужно на заблокированном для записи редакторе,
иначе, если текст
+ // изменится во время обновления, то мы получим рассинхронизацию, и как
следствие,
+ // неопределенное поеведение. По возможности не следует добавлять
долгие действия
+ // в блок расположенный ниже, так как обновление идет в GUI-потоке и
медленная работа
+ // может привести к ощутимому неудобству для пользователя.

// VS fire ViewFilter.OnChangeScrollInfo event vhen we change regions
it lead to many
// calls of Source.TryHighlightBraces() which can take much time.
Prevent it!
@@ -678,7 +678,7 @@
if (CurrentVersion != sourceVersion)
return;

- #region Âû÷èñëÿåì ðåãèîíû êîòîðûõ íåáûëî â ðåäàêòîðå è îáíîâëÿåì
áàííåðû ó ñòàðûõ
+ #region Вычисляем регионы которых небыло в редакторе и обновляем
баннеры у старых

var newRegions = new List<NewHiddenRegion>();

@@ -687,30 +687,30 @@
IVsHiddenRegion region;
if (oldRegionsMap.TryGetValue(rg.tsHiddenText, out region))
{
- // Ðåãèîí ñ òàêèìè æå êîîðäèíàòàìè óæå áûë â ðåäàêòðå...
-
- // Ïîõîæå VS, ïðè çàêðûòèè ôàéëà, çàïîìèíàåò òîëüêî ðàñïîëîæåíèå
ðåãèîíîâ,
- // íî íå èõ áàííåðû. Íàì íóæíî îáíîâèòü áàííåð åñëè îíè íå ñîâïàäàþò.
- // Êðîìå òîãî áàííåðû íóæíî îáíîâëÿòü êîãäà îíè ôèçè÷åñêè ìåíÿþòñÿ
(ïîëüçîâàòåëåì).
+ // Регион с такими же координатами уже был в редактре...
+
+ // Похоже VS, при закрытии файла, запоминает только расположение
регионов,
+ // но не их баннеры. Нам нужно обновить баннер если они не совпадают.
+ // Кроме того баннеры нужно обновлять когда они физически меняются
(пользователем).
string banner;
region.GetBanner(out banner);
if (rg.pszBanner != banner && !(banner == "..." &&
rg.pszBanner.IsNullOrEmpty()))
region.SetBanner(rg.pszBanner);
}
else
- newRegions.Add(rg); // Ðåãèîí íîâûé! Çàïîìèíàåì åãî...
+ newRegions.Add(rg); // Регион новый! Запоминаем его...
}

//Debug.WriteLine("SetRegions: calc new reg & up b " + timer.Elapsed);
timer.Reset(); timer.Start();

#endregion

- #region Âû÷èñëÿåì ñïèñîê óñòàðåâøèõ ðåãèîíîâ è óäàëÿåì èõ
+ #region Вычисляем список устаревших регионов и удаляем их

var newRegiohsMap = new Dictionary<TextSpan,
NewHiddenRegion>(regions.Count);

- // Ôîðìèðóåì "ìàï" íîâûõ ðåãèîíîâ. .ToDictianary() íå ïðèìåíèì, òàê
êàê îí
- // ãåíåðèðóåò èñêëþ÷åíèå ïðè ïîïûòêå äîáàâèòü ýëåìåíò ñ óæå
ñóùåñòâóþùèì êëþ÷åì.
+ // Формируем "мап" новых регионов. .ToDictianary() не применим, так
как он
+ // генерирует исключение при попытке добавить элемент с уже
существующим ключем.
foreach (var rg in regions)
if (newRegiohsMap.ContainsKey(rg.tsHiddenText))
{ }
@@ -719,7 +719,7 @@
foreach (var rg in oldRegionsMap)
{
if (!newRegiohsMap.ContainsKey(rg.Key))
- { // ×òàðûé ðåãèîí íå ñîâïàäàåò ïî ìåñòîïîëîæåíèþ íè ñ îäíèì èç
íîâûõ. Óäàëÿåì åãî!
+ { // Чтарый регион не совпадает по местоположению ни с одним из
новых. Удаляем его!

ErrorHandler.ThrowOnFailure(rg.Value.Invalidate((int)CHANGE_HIDDEN_REGION_FLAGS.chrNonUndoable));
//removed++;
}
@@ -729,7 +729,7 @@

#endregion

- #region Äîáàâëÿåì ðåãèîíû êîòîðûõ íå áûëî â ðåäàêòîðå
+ #region Добавляем регионы которых не было в редакторе

int start = Environment.TickCount;

@@ -990,15 +990,15 @@
switch (cmdId)
{
case MenuCmd.CmdId.ImplementInterface:
- // Ðåàëèçàöèÿ ìåòîäîâ èíòåðôåéñîâ è ïåðåîïðåäåëåíèå ìåòîäîâ
áàçîâîãî òèïà.
- // Ìû íå ìîæåì îáðàùàòüñÿ ê òèïèçèðîâàííîìó ÀÑÒ. Ïîýòìîó ìû äîëæíû
ñôîðìèðîâàòü
- // çàïðîñ íà âû÷èñëåíèå ñïèñêà ÷ëåíîâ êîòîðûå íóæíî ðåàëèçîâàòü.
- // Êîãäà ñïèñîê áóäåò ñôîðìèðîâàí, íóæíî:
- // 1. Ñîôðìèðîâàòü òåêñò ìåòîäîâ.
- // 2. Ñãåíåðèðîâàòü äëÿ íèõ òåêñò.
- // 3. Íàéòè ìåòñî êóäà ìîæíî âñòàâèòü òåêñò.
- // 4. Îïðåäåëèòü îòáèêó è äîáàâèòü åå ê ñãåíåðèðîâàííîìó òåêñòó.
- // 5. Âñòàâ ïîëó÷åíûé òåêñ â ìåñòî íàéäåííîå íà øàãå 3.
+ // Реализация методов интерфейсов и переопределение методов
базового типа.
+ // Мы не можем обращаться к типизированному АСТ. Поэтмоу мы должны
сформировать
+ // запрос на вычисление списка членов которые нужно реализовать.
+ // Когда список будет сформирован, нужно:
+ // 1. Софрмировать текст методов.
+ // 2. Сгенерировать для них текст.
+ // 3. Найти метсо куда можно вставить текст.
+ // 4. Определить отбику и добавить ее к сгенерированному тексту.
+ // 5. Встав полученый текс в место найденное на шаге 3.
{
var engine = GetEngine();
if (!engine.IsDefaultEngine)
@@ -1252,11 +1252,11 @@
foreach (var fileIndex in distinctFilesIndices)
{
var source = ProjectInfo.GetSource(fileIndex) as NemerleSource;
- //VladD2: Ýòîò êîä ðàññ÷èòûâàåò íà òî, ÷òî âñå èñõîäíèêè â êîòîðûõ
ïðîèçâîäÿòñÿ èçìåíåíèÿ îòêðûòû â ðåäàêòîðàõ VS!
- //VladD2: Ýòî íå âåðíîå ïðåäïîëîæåíèå!
- //TODO: Íóæíî ïåðåïèñàòü ýòîò êîä òàê, ÷òîáû îí âûïîëíÿëñÿ áåç
îøèáîê ïðè ëþáîì èñõîäå.
- // Òóò åñòü äâà ïóòè: 1) îòêðûâàòü âñå ôàéëû â ðåäàêòîðàõ, 2)
ñîçäàòü åùå îäíó ðåàëèçàöèþ EditArray êîòîðàÿ óìåëà
- // áû ðàáîòàòü ñ ISource. Ïðè ýòîì íóæíî êàê-òî ïîääåðæèâàòü
Undo/Redo.
+ //VladD2: Этот код рассчитывает на то, что все исходники в которых
производятся изменения открыты в редакторах VS!
+ //VladD2: Это не верное предположение!
+ //TODO: Нужно переписать этот код так, чтобы он выполнялся без
ошибок при любом исходе.
+ // Тут есть два пути: 1) открывать все файлы в редакторах, 2)
создать еще одну реализацию EditArray которая умела
+ // бы работать с ISource. При этом нужно как-то поддерживать
Undo/Redo.
Trace.Assert(source != null);

var mgr = new EditArray(source, null, true, "Renaming");
@@ -1418,9 +1418,9 @@

switch (cm.Kind)
{
- case MessageKind.Error: text.Append("Error: "); break;
- case MessageKind.Hint: text.Append("Hint: "); break;
- case MessageKind.Warning: text.Append("Warning: "); break;
+ case MessageKind.Error: text.Append("<font
color=\"Red\"><b>Error:</b></font> "); break;
+ case MessageKind.Hint: text.Append("<font
color=\"Goldenrod\"><b>Hint:</b></font> "); break;
+ case MessageKind.Warning: text.Append("<font
color=\"DarkCyan\"><b>Warning:</b></font> "); break;
default: break;
}

@@ -1436,17 +1436,17 @@
/// <returns>Token coordinate or span initialised with -1, if no token
intersect with point</returns>
public TextSpan GetTokenSpan(int line, int index)
{
- //VladD2: VS òðåáóåò îò íàñ TextSpan ñîäåðæàùèé êîîðäèíàòû ó÷àñòêà
òåêñòà ê êîòîðîìó îòíîñèòñÿ hint.
- // Â äàëüíåéøåì, åñëè êóðñîð ìûøè íå âûõîäèò çà ýòîò TextSpan, VS íå
ïðåäïðèíèìàåò ïîïûòêè ïîêàçàòü äðóãîé õèíò,
- // äàæå åñëè ñ íàøåé òî÷êè çðåíèÿ òðåáóåòñÿ îòîáðàæàòü äðóãóþ
èíôîðìàöèþ. ×òîáû VS íå "ïîìîãàëà" íàì, âû÷èñëÿåì
- // ëîêåøîí òîêåíà ëåæàùåãî ïîä çàïðàøèâàåìîé òî÷êîé è ïåðåäàåì åãî
ñòóäèè. Ýòî ïðèâåäåò êòîìó, ÷òî VS áóäåò
- // ïîâòîðíî çàïðàøèâàòü hint, åñëè êóðñîð ïîêèíåò ïðåäåëû òåêóùåãî
òîêåíà.
- var token = GetTokenInfo(line, index + 1); // GetTokenInfo() âûäàåò
èíôîðìàöèþ î ïðåäûäóùåì òîêåíå! +1 çàñòàâëÿåò åå áðàòü ñëåäóþùèé
+ //VladD2: VS требует от нас TextSpan содержащий координаты участка
текста к которому относится hint.
+ // В дальнейшем, если курсор мыши не выходит за этот TextSpan, VS не
предпринимает попытки показать другой хинт,
+ // даже если с нашей точки зрения требуется отображать другую
информацию. Чтобы VS не "помогала" нам, вычисляем
+ // локешон токена лежащего под запрашиваемой точкой и передаем его
студии. Это приведет ктому, что VS будет
+ // повторно запрашивать hint, если курсор покинет пределы текущего
токена.
+ var token = GetTokenInfo(line, index + 1); // GetTokenInfo() выдает
информацию о предыдущем токене! +1 заставляет ее брать следующий
if (token == null)
return new TextSpan { iEndIndex = -1, iStartLine = -1, iStartIndex
= -1, iEndLine = -1 };

var start = token.StartIndex;
- var end = token.EndIndex + 1; //VladD2: Íåèçâåñíî èç êàêèõ
ñîîáðàæåíèé GetTokenInfo() âû÷èòàåò åäåíèöó èç EndIndex. Ó÷èòûâàåì ýòî!
+ var end = token.EndIndex + 1; //VladD2: Неизвесно из каких
соображений GetTokenInfo() вычитает еденицу из EndIndex. Учитываем это!
var hintSpan = new TextSpan { iStartLine = line, iStartIndex =
start, iEndLine = line, iEndIndex = end };

return hintSpan;
@@ -1548,20 +1548,22 @@
if (hintText != null)
hintText += Environment.NewLine;

- hintText += "------ Compiler messages ------" +
Environment.NewLine + tasksMsgs.Join(Environment.NewLine);
+ hintText += "<font color=\"Green\"><font face=\"Webdings\"
size=\"22\">!</font> <b>Compiler messages:</b></font>"
+ + Environment.NewLine +
tasksMsgs.Join(Environment.NewLine);
}

- textSpan[0] = hintSpan; // åñëè íå çàäàòü íå ïóñòîé span
ïåðåñåêàþùèéñÿ ñ èñõäíûì, VS íå ïîêàæåò hint.
+ textSpan[0] = hintSpan; // если не задать не пустой span
пересекающийся с исхдным, VS не покажет hint.

//Debug.WriteLine(Utils.LocationFromSpan(FileIndex,
span).ToVsOutputStringFormat() + "result GetDataTipText() text:");
//Debug.WriteLine(hintText);

- view.GetPointOfLineColumn(hintSpan.iStartLine, hintSpan.iStartIndex,
new POINT[1]);
-
+ if (Service.ShowHint(view, hintSpan, hintText))
+ return (int)TipSuccesses2.TIP_S_NODEFAULTTIP;
+
return VSConstants.S_OK;
}

- private bool NeedDebugDataTip(QuickTipInfo quickTipInfo, TextSpan[]
textSpan)
+ private bool NeedDebugDataTip(QuickTipInfo quickTipInfo, TextSpan[]
textSpan)
{
IVsTextLines textLines = GetTextLines();

=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleViewFilter.cs
Wed Oct 28 21:02:28 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleViewFilter.cs
Fri Oct 30 10:58:03 2009
@@ -80,7 +80,6 @@
return Source.GetDataTipText(TextView, aspan, out textValue);
}

- /// <include file='doc\ViewFilter.uex'
path='docs/doc[@for="ViewFilter.GetFullDataTipText"]/*' />
/// <summary>This method checks to see if the IVsDebugger is running,
and if so,
/// calls it to get additional information about the current token and
returns a combined result.
/// You can return an HRESULT here like
TipSuccesses2.TIP_S_NODEFAULTTIP.</summary>
@@ -98,7 +97,7 @@

if (debugger != null && Source.LanguageService.IsDebugging)
{
- TextSpan[] tsdeb = new TextSpan[1] { new TextSpan() };
+ var tsdeb = new TextSpan[1] { new TextSpan() };
if (!TextSpanHelper.IsEmpty(ts))
{
// While debugging we always want to evaluate the expression
user is hovering over
@@ -290,12 +289,7 @@
ShowOptions();
return VSConstants.S_OK;
case MenuCmd.CmdId.AstToolWindow: // AstToolWindow
- {
- //this.CodeWindowManager.LanguageService.
- NemerleSource source = Source as NemerleSource;
- if (source != null)
- source.ProjectInfo.ProjectNode.Package.OnAstToolWindowShow(null,
null);
- }
+ Source.ProjectInfo.ProjectNode.Package.OnAstToolWindowShow(null,
null);
return VSConstants.S_OK;
case MenuCmd.CmdId.AddHighlighting: // cmdIdAddHighlighting
HighlightSymbol();
@@ -303,6 +297,7 @@
case MenuCmd.CmdId.ESC: // ESC
case MenuCmd.CmdId.RemoveLastHighlighting: //
cmdIdRemoveLastHighlighting
RemoveLastHighlighting();
+ Source.Service.Hint.Close();
if(nCmdId == (int)MenuCmd.CmdId.ESC) // ESC
break; // go trocess ESC
return VSConstants.S_OK;
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Nemerle.VisualStudio.csproj
Wed Oct 28 16:13:10 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Nemerle.VisualStudio.csproj
Fri Oct 30 10:58:03 2009
@@ -376,6 +376,7 @@
<Compile Include="LanguageService\ParseReason2.cs">
</Compile>
<Compile Include="LanguageService\SmatrTegs\NemerleSmartTagData.cs" />
+ <Compile Include="NativeMethods.cs" />
<Compile Include="Project\ErrorReporting\NemerleErrorTask.cs" />
<Compile Include="Project\HierarchyHelpers.cs" />
<Compile Include="Project\NemerleDesignPropertyDescriptor.cs" />
@@ -483,6 +484,10 @@
<Project>{DBC77173-9367-485F-B425-74E6D6AB3F82}</Project>
<Name>Nemerle.Compiler.Utils</Name>
</ProjectReference>
+ <ProjectReference Include="GUI\WpfHint\WpfHint.csproj">
+ <Project>{7670DE22-B023-4783-BA19-BB2DB50E1762}</Project>
+ <Name>WpfHint</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ZipProject Include="Templates\Projects\WPF\WPFApplication\App.xaml">
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NemerlePackage.cs Wed
Oct 28 21:02:28 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/NemerlePackage.cs Fri
Oct 30 10:58:03 2009
@@ -216,12 +216,12 @@
return command;
}

- private static void RegisterCommand(OleMenuCommandService service,
CommandID commandId, EventHandler handler)
- {
- var command = new MenuCommand(handler, commandId);
- service.AddCommand(command);
- //Debug.WriteLine(string.Format("Menu command {0} added", command));
- }
+ //private static void RegisterCommand(OleMenuCommandService service,
CommandID commandId, EventHandler handler)
+ //{
+ // var command = new MenuCommand(handler, commandId);
+ // service.AddCommand(command);
+ // //Debug.WriteLine(string.Format("Menu command {0} added",
command));
+ //}

//public IWin32Window TextEditorWindow
//{
Reply all
Reply to author
Forward
0 new messages