OSDN Git Service

Added sample plugin that demonstrates how to add GUI tab to Radegast via plugin
authorLatif Khalifa <latifer@streamgrid.net>
Fri, 22 Jul 2011 03:49:33 +0000 (03:49 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Fri, 22 Jul 2011 03:49:33 +0000 (03:49 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@1000 f7a694da-4d33-11de-9ad6-1127a62b9fcd

plugins/Radegast.Plugin.DemoTab/DemoTab.Designer.cs [new file with mode: 0644]
plugins/Radegast.Plugin.DemoTab/DemoTab.cs [new file with mode: 0644]
plugins/Radegast.Plugin.DemoTab/DemoTab.resx [new file with mode: 0644]
plugins/Radegast.Plugin.DemoTab/Properties/AssemblyInfo.cs [new file with mode: 0644]
plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj [new file with mode: 0644]

diff --git a/plugins/Radegast.Plugin.DemoTab/DemoTab.Designer.cs b/plugins/Radegast.Plugin.DemoTab/DemoTab.Designer.cs
new file mode 100644 (file)
index 0000000..77fe570
--- /dev/null
@@ -0,0 +1,82 @@
+namespace DemoTab
+{
+    partial class DemoTab
+    {
+        /// <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 Component Designer generated code
+
+        /// <summary> 
+        /// Required method for Designer support - do not modify 
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.btnSaySomething = new System.Windows.Forms.Button();
+            this.label1 = new System.Windows.Forms.Label();
+            this.txtChat = new System.Windows.Forms.TextBox();
+            this.SuspendLayout();
+            // 
+            // btnSaySomething
+            // 
+            this.btnSaySomething.Location = new System.Drawing.Point(18, 23);
+            this.btnSaySomething.Name = "btnSaySomething";
+            this.btnSaySomething.Size = new System.Drawing.Size(159, 23);
+            this.btnSaySomething.TabIndex = 0;
+            this.btnSaySomething.Text = "Say Something";
+            this.btnSaySomething.UseVisualStyleBackColor = true;
+            this.btnSaySomething.Click += new System.EventHandler(this.btnSaySomething_Click);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(15, 62);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(73, 13);
+            this.label1.TabIndex = 1;
+            this.label1.Text = "Last chat line:";
+            // 
+            // txtChat
+            // 
+            this.txtChat.Location = new System.Drawing.Point(94, 59);
+            this.txtChat.Name = "txtChat";
+            this.txtChat.Size = new System.Drawing.Size(247, 20);
+            this.txtChat.TabIndex = 2;
+            // 
+            // DemoTab
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.txtChat);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.btnSaySomething);
+            this.Name = "DemoTab";
+            this.Size = new System.Drawing.Size(458, 290);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Button btnSaySomething;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.TextBox txtChat;
+    }
+}
diff --git a/plugins/Radegast.Plugin.DemoTab/DemoTab.cs b/plugins/Radegast.Plugin.DemoTab/DemoTab.cs
new file mode 100644 (file)
index 0000000..f089caa
--- /dev/null
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using Radegast;
+using OpenMetaverse;
+
+namespace DemoTab
+{
+    [Radegast.Plugin(Name = "Demo Tab", Description = "Demonstration of how to add a new tab via plugin", Version = "1.0")]
+    public partial class DemoTab : RadegastTabControl, IRadegastPlugin
+    {
+        ToolStripMenuItem ActivateTabButton;
+
+        public DemoTab()
+        {
+            InitializeComponent();
+        }
+
+        public void StartPlugin(RadegastInstance inst)
+        {
+            this.instance = inst;
+            ActivateTabButton = new ToolStripMenuItem("Demo Tab", null, MenuButtonClicked);
+            instance.MainForm.PluginsMenu.DropDownItems.Add(ActivateTabButton);
+            instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(instance_ClientChanged);
+            RegisterClientEvents(client);
+        }
+
+        public void StopPlugin(RadegastInstance inst)
+        {
+            ActivateTabButton.Dispose();
+            instance.TabConsole.RemoveTab("demo_tab");
+            UnregisterClientEvents(client);
+        }
+
+        void instance_ClientChanged(object sender, ClientChangedEventArgs e)
+        {
+            UnregisterClientEvents(e.OldClient);
+            RegisterClientEvents(e.Client);
+        }
+
+
+        void RegisterClientEvents(GridClient client)
+        {
+            client.Self.ChatFromSimulator += new EventHandler<ChatEventArgs>(Self_ChatFromSimulator);
+        }
+
+        void UnregisterClientEvents(GridClient client)
+        {
+            if (client == null) return;
+            client.Self.ChatFromSimulator -= new EventHandler<ChatEventArgs>(Self_ChatFromSimulator);
+        }
+
+        void Self_ChatFromSimulator(object sender, ChatEventArgs e)
+        {
+            // Boilerplate, make sure to be on the GUI thread
+            if (InvokeRequired)
+            {
+                BeginInvoke(new MethodInvoker(() => Self_ChatFromSimulator(sender, e)));
+                return;
+            }
+
+            txtChat.Text = e.Message;
+        }
+
+
+        void MenuButtonClicked(object sender, EventArgs e)
+        {
+            if (instance.TabConsole.TabExists("demo_tab"))
+            {
+                instance.TabConsole.Tabs["demo_tab"].Select();
+            }
+            else
+            {
+                instance.TabConsole.AddTab("demo_tab", "Demo Tab", this);
+                instance.TabConsole.Tabs["demo_tab"].Select();
+            }
+        }
+
+        private void btnSaySomething_Click(object sender, EventArgs e)
+        {
+            client.Self.Chat("Something", 0, ChatType.Normal);
+        }
+
+    }
+}
diff --git a/plugins/Radegast.Plugin.DemoTab/DemoTab.resx b/plugins/Radegast.Plugin.DemoTab/DemoTab.resx
new file mode 100644 (file)
index 0000000..ff31a6d
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file
diff --git a/plugins/Radegast.Plugin.DemoTab/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.DemoTab/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..de82004
--- /dev/null
@@ -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("DemoTab.cs")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("DemoTab.cs")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[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("792f0d36-219d-4511-b366-82de85d764db")]
+
+// 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")]
diff --git a/plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj b/plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj
new file mode 100644 (file)
index 0000000..7c1d62e
--- /dev/null
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.30729</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{07A067A9-C029-472E-82BA-839443527BA7}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>DemoTab</RootNamespace>\r
+    <AssemblyName>Radegast.Plugin.DemoTab</AssemblyName>\r
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <OutputPath>..\..\bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <DebugType>full</DebugType>\r
+    <PlatformTarget>x86</PlatformTarget>\r
+    <ErrorReport>prompt</ErrorReport>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">\r
+    <OutputPath>..\..\bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <Optimize>true</Optimize>\r
+    <DebugType>pdbonly</DebugType>\r
+    <PlatformTarget>x86</PlatformTarget>\r
+    <ErrorReport>prompt</ErrorReport>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Drawing" />\r
+    <Reference Include="System.Windows.Forms" />\r
+    <Reference Include="System.Xml.Linq">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data.DataSetExtensions">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="DemoTab.cs">\r
+      <SubType>UserControl</SubType>\r
+    </Compile>\r
+    <Compile Include="DemoTab.Designer.cs">\r
+      <DependentUpon>DemoTab.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <EmbeddedResource Include="DemoTab.resx">\r
+      <DependentUpon>DemoTab.cs</DependentUpon>\r
+    </EmbeddedResource>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ProjectReference Include="..\..\..\libopenmetaverse\OpenMetaverse.StructuredData\OpenMetaverse.StructuredData.csproj">\r
+      <Project>{E63618CF-B21B-44CD-BBDE-BCE26CF6AF0D}</Project>\r
+      <Name>OpenMetaverse.StructuredData</Name>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\..\libopenmetaverse\OpenMetaverseTypes\OpenMetaverseTypes.csproj">\r
+      <Project>{1A303634-82F1-4C91-9E1C-C96B8B03D10A}</Project>\r
+      <Name>OpenMetaverseTypes</Name>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\..\libopenmetaverse\OpenMetaverse\OpenMetaverse.csproj">\r
+      <Project>{30D9F2AE-42FE-4ACD-9E52-A819CB36EE05}</Project>\r
+      <Name>OpenMetaverse</Name>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\Radegast\Radegast.csproj">\r
+      <Project>{A6D955CD-1F55-459F-A7AD-01E591404989}</Project>\r
+      <Name>Radegast</Name>\r
+    </ProjectReference>\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file