Permalink
Browse files

Added connector project to mimics the config for many KO UI component…

…s in C# POCOs. Serialize these from the server using JSON.NET or similar to be able to configure the components easily.
  • Loading branch information...
1 parent 59f2f7b commit 3bb4e3a2053705aa406a00c1ccf3c5c21ea49a83 Ian Mckay committed Aug 8, 2011
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+
+namespace NKnockoutUI.ContextMenu
+{
+ public class ContextMenu
+ {
+ public string Name { get; set; }
+ public int? Width { get; set; }
+
+ public IList<IContextMenuItem> Items { get; protected set; }
+
+ public ContextMenu(string name, int width)
+ {
+ Name = name;
+ Width = width;
+ Items = new List<IContextMenuItem>();
+ }
+
+ public ContextMenu Item(string text, string runFunction)
+ {
+ Items.Add(new ContextMenuItem { Text = text, RunFunction = runFunction });
+ return this;
+ }
+
+ public ContextMenu Item(string text, string iconCssClass, string runFunction)
+ {
+ Items.Add(new ContextMenuItem { Text = text, RunFunction = runFunction, IconCssClass = iconCssClass});
+ return this;
+ }
+
+ public ContextMenu Item(string text, SubContextMenu subContextMenu)
+ {
+ Items.Add(new ContextMenuItem { Text = text, Items = subContextMenu});
+ return this;
+ }
+
+ public ContextMenu Separator()
+ {
+ Items.Add(new ContextMenuSeparator());
+ return this;
+ }
+ }
+}
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json;
+
+namespace NKnockoutUI.ContextMenu
+{
+ public class ContextMenuGroup
+ {
+ public string CssClass { get; set; }
+
+ public IList<ContextMenu> ContextMenus { get; set; }
+ [JsonProperty(PropertyName = "build")]
+ public string BuildFunction { get; set; }
+
+ public ContextMenuGroup(string buildFunction)
+ {
+ ContextMenus = new List<ContextMenu>();
+ BuildFunction = buildFunction;
+ }
+ }
+}
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace NKnockoutUI.ContextMenu
+{
+ public class ContextMenuItem : IContextMenuItem
+ {
+ public string Text { get; set; }
+ [JsonProperty(PropertyName = "run")]
+ public string RunFunction { get; set; }
+ public string IconCssClass { get; set; }
+ public SubContextMenu Items { get; set; }
+ }
+}
@@ -0,0 +1,11 @@
+namespace NKnockoutUI.ContextMenu
+{
+ public class ContextMenuSeparator : IContextMenuItem
+ {
+ public bool Separator { get; protected set; }
+ public ContextMenuSeparator()
+ {
+ Separator = true;
+ }
+ }
+}
@@ -0,0 +1,6 @@
+namespace NKnockoutUI.ContextMenu
+{
+ public interface IContextMenuItem
+ {
+ }
+}
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace NKnockoutUI.ContextMenu
+{
+ public class SubContextMenu : List<IContextMenuItem>
+ {
+ public SubContextMenu Item(string text, string runFunction)
+ {
+ Add(new ContextMenuItem { Text = text, RunFunction = runFunction });
+ return this;
+ }
+
+ public SubContextMenu Item(string text, string iconCssClass, string runFunction)
+ {
+ Add(new ContextMenuItem { Text = text, RunFunction = runFunction, IconCssClass = iconCssClass });
+ return this;
+ }
+
+ public SubContextMenu Item(string text, SubContextMenu subContextMenu)
+ {
+ Add(new ContextMenuItem { Text = text, Items = subContextMenu });
+ return this;
+ }
+
+ public SubContextMenu Separator()
+ {
+ Add(new ContextMenuSeparator());
+ return this;
+ }
+ }
+}
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{80FC1887-D8BB-4CF2-8595-14786F19AE8A}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>NKnockoutUI</RootNamespace>
+ <AssemblyName>NKnockoutUI</AssemblyName>
+ <TargetFrameworkVersion>v4.0</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="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ContextMenu\ContextMenu.cs" />
+ <Compile Include="ContextMenu\ContextMenuGroup.cs" />
+ <Compile Include="ContextMenu\ContextMenuItem.cs" />
+ <Compile Include="ContextMenu\ContextMenuSeparator.cs" />
+ <Compile Include="ContextMenu\IContextMenuItem.cs" />
+ <Compile Include="ContextMenu\SubContextMenu.cs" />
+ <Compile Include="Tabs\Tab.cs" />
+ <Compile Include="Tabs\TabGroup.cs" />
+ <Compile Include="Tree\Behavior.cs" />
+ <Compile Include="Tree\Handlers.cs" />
+ <Compile Include="Tree\Tree.cs" />
+ <Compile Include="Window\Button.cs" />
+ <Compile Include="Tree\Node.cs" />
+ <Compile Include="Window\Window.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <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>
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NKnockoutUI", "NKnockoutUI.csproj", "{80FC1887-D8BB-4CF2-8595-14786F19AE8A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {80FC1887-D8BB-4CF2-8595-14786F19AE8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {80FC1887-D8BB-4CF2-8595-14786F19AE8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {80FC1887-D8BB-4CF2-8595-14786F19AE8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {80FC1887-D8BB-4CF2-8595-14786F19AE8A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -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("NKnockoutUI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("NKnockoutUI")]
+[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("7a084b7f-39ff-4309-a2fc-89c66a535121")]
+
+// 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")]
@@ -0,0 +1,22 @@
+using Newtonsoft.Json;
+
+namespace NKnockoutUI.Tabs
+{
+ public class Tab
+ {
+ public string Name { get; set; }
+ public string CssClass { get; set; }
+ public string IconCssClass { get; set; }
+ public string BodyCssClass { get; set; }
+
+ public bool? IsActive { get; set; }
+
+ public object Contents { get; set; }
+
+ /// <summary>
+ /// This should be the name of function to call to create the window
+ /// </summary>
+ [JsonProperty(PropertyName = "create")]
+ public string CreateFunction { get; set; }
+ }
+}
@@ -0,0 +1,24 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace NKnockoutUI.Tabs
+{
+ public class TabGroup
+ {
+ public string Id { get; set; }
+ public bool? Remember { get; set; }
+ [JsonProperty(PropertyName = "tabs")]
+ public IList<Tab> Members { get; protected set; }
+
+ public void Add(Tab tab)
+ {
+ Members.Add(tab);
+ }
+
+ public TabGroup(string id)
+ {
+ Id = id;
+ Members = new List<Tab>();
+ }
+ }
+}
@@ -0,0 +1,19 @@
+using Newtonsoft.Json;
+
+namespace NKnockoutUI.Tree
+{
+ public class Behavior
+ {
+ public string Name { get; set; }
+ public string ChildType { get; set; }
+ public bool? IsDraggable { get; set; }
+ public bool? IsDropTarget { get; set; }
+ public bool? CanAddChildren { get; set; }
+ public bool? RenameAfterAdd { get; set; }
+ public string ConnectToSortable { get; set; }
+ public object DragCursorAt { get; set; }
+ public string DragCursor { get; set; }
+ [JsonProperty(PropertyName = "~dragHelper")]
+ public string DragHelper { get; set; }
+ }
+}
@@ -0,0 +1,14 @@
+namespace NKnockoutUI.Tree
+{
+ public class Handlers
+ {
+ public string SelectNode { get; set; }
+ public string AddNode { get; set; }
+ public string RenameNode { get; set; }
+ public string DeleteNode { get; set; }
+ public string MoveNode { get; set; }
+ public string DoubleClick { get; set; }
+ public string StartDrag { get; set; }
+ public string EndDrag { get; set; }
+ }
+}
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+
+namespace NKnockoutUI.Tree
+{
+ public class Node
+ {
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public string Type { get; set; }
+ public object Contents { get; set; }
+
+ public string CssClass { get; set; }
+ public bool? IsOpen { get; set; }
+
+ public IList<Node> Children { get; protected set; }
+
+ public Node()
+ {
+ Children = new List<Node>();
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 3bb4e3a

Please sign in to comment.