{75BDE4C7-4BAF-4A03-B697-5D1370775E20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75BDE4C7-4BAF-4A03-B697-5D1370775E20}.Release|Any CPU.Build.0 = Release|Any CPU
{28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x64.ActiveCfg = Debug|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x64.Build.0 = Debug|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x86.ActiveCfg = Debug|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x86.Build.0 = Debug|Any CPU
{28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|Any CPU.Build.0 = Release|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x64.ActiveCfg = Release|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x64.Build.0 = Release|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x86.ActiveCfg = Release|Any CPU
- {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x86.Build.0 = Release|Any CPU
{A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x64.ActiveCfg = Debug|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x64.Build.0 = Debug|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x86.ActiveCfg = Debug|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x86.Build.0 = Debug|Any CPU
{A01B3151-BC81-437C-B526-CC8DBB808638}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A01B3151-BC81-437C-B526-CC8DBB808638}.Release|Any CPU.Build.0 = Release|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x64.ActiveCfg = Release|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x64.Build.0 = Release|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x86.ActiveCfg = Release|Any CPU
- {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Policies = $0
$0.StandardHeader = $1
$1.Text = @\n${FileName}\n \nAuthor:\n ${AuthorName} <${AuthorEmail}>\n\nCopyright (c) 2013-2017 Jean-Philippe Bruyère\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.
- $1.IncludeInNewFiles = True
$0.DotNetNamingPolicy = $2
- $2.DirectoryNamespaceAssociation = None
- $2.ResourceNamePolicy = FileFormatDefault
$0.TextStylePolicy = $3
- $3.FileWidth = 120
- $3.TabsToSpaces = False
$3.EolMarker = Unix
- $3.inheritsSet = VisualStudio
- $3.inheritsScope = text/plain
$3.scope = text/x-csharp
$0.CSharpFormattingPolicy = $4
$4.AfterDelegateDeclarationParameterComma = True
- $4.inheritsSet = Mono
- $4.inheritsScope = text/x-csharp
$4.scope = text/x-csharp
+ $4.IndentSwitchSection = False
+ $4.NewLinesForBracesInProperties = False
+ $4.NewLinesForBracesInAccessors = False
+ $4.NewLinesForBracesInAnonymousMethods = False
+ $4.NewLinesForBracesInControlBlocks = False
+ $4.NewLinesForBracesInAnonymousTypes = False
+ $4.NewLinesForBracesInObjectCollectionArrayInitializers = False
+ $4.NewLinesForBracesInLambdaExpressionBody = False
+ $4.NewLineForElse = False
+ $4.NewLineForCatch = False
+ $4.NewLineForFinally = False
+ $4.NewLineForMembersInObjectInit = False
+ $4.NewLineForMembersInAnonymousTypes = False
+ $4.NewLineForClausesInQuery = False
+ $4.SpacingAfterMethodDeclarationName = True
+ $4.SpaceAfterMethodCallName = True
+ $4.SpaceBeforeOpenSquareBracket = True
$0.VersionControlPolicy = $5
$5.CommitMessageStyle = $6
$6.Indent = @\t
<Target Name="AfterBuild">
</Target>
-->
- <ItemGroup />
<ItemGroup>
<Folder Include="src\GraphicObjects\" />
<Folder Include="src\Cairo\" />
<None Include="Crow.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <EmbeddedResource Include="Images\Icons\Cursors\arrow" />
+ <EmbeddedResource Include="Images\Icons\Cursors\bottom_left_corner" />
+ <EmbeddedResource Include="Images\Icons\Cursors\bottom_right_corner" />
+ <EmbeddedResource Include="Images\Icons\Cursors\cross" />
+ <EmbeddedResource Include="Images\Icons\Cursors\hand" />
+ <EmbeddedResource Include="Images\Icons\Cursors\help" />
+ <EmbeddedResource Include="Images\Icons\Cursors\move" />
+ <EmbeddedResource Include="Images\Icons\Cursors\sb_h_double_arrow" />
+ <EmbeddedResource Include="Images\Icons\Cursors\sb_v_double_arrow" />
+ <EmbeddedResource Include="Images\Icons\Cursors\top_left_corner" />
+ <EmbeddedResource Include="Images\Icons\Cursors\top_right_corner" />
</ItemGroup>
</Project>
using System.Runtime.CompilerServices;
using System.Xml;
using Crow.IML;
-
+using System.Text;
namespace Crow.IML
{
public static class CompilerServices
{
+ /// <summary>
+ /// known types cache, prevent rewalking all the assemblies of the domain
+ /// the key is the type simple name
+ /// </summary>
+ internal static Dictionary<string, Type> knownTypes = new Dictionary<string, Type> ();
+ /// <summary>
+ /// known extension methods.
+ /// key is type dot memberName.
+ /// </summary>
+ internal static Dictionary<string, MethodInfo> knownExtMethods = new Dictionary<string, MethodInfo> ();
+
internal static Type TObject = typeof(object);
internal static MethodInfo stringEquals = typeof (string).GetMethod("Equals", new Type [3] { typeof (string), typeof (string), typeof (StringComparison) });
internal static MethodInfo miObjToString = typeof(object).GetMethod("ToString");
return query;
}
/// <summary>
- /// search for extentions method in entry assembly then in crow assembly
+ /// search for extentions method in entry assembly then in assembly where the type is defined
/// </summary>
/// <returns>Extention MethodInfo</returns>
/// <param name="t">Extended type</param>
/// <param name="methodName">Extention method name</param>
- internal static MethodInfo SearchExtMethod(Type t, string methodName){
+ //internal static MethodInfo SearchExtMethod(Type t, string methodName){
+ // MethodInfo mi = null;
+ // mi = GetExtensionMethods (Assembly.GetEntryAssembly(), t)
+ // .Where (em => em.Name == methodName).FirstOrDefault ();
+ // if (mi != null)
+ // return mi;
+
+ // return GetExtensionMethods (t.Module.Assembly, t)
+ // .Where (em => em.Name == methodName).FirstOrDefault ();
+ //}
+ internal static MethodInfo SearchExtMethod (Type t, string methodName)
+ {
+ string key = t.Name + "." + methodName;
+ if (knownExtMethods.ContainsKey (key))
+ return knownExtMethods [key];
+
+ //Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}");
+
MethodInfo mi = null;
- mi = GetExtensionMethods (Assembly.GetEntryAssembly(), t)
- .Where (em => em.Name == methodName).FirstOrDefault ();
- if (mi != null)
- return mi;
+ mi = GetExtensionMethods2 (Assembly.GetEntryAssembly (), t, methodName);
+ if (mi == null)
+ mi = GetExtensionMethods2 (t.Module.Assembly, t, methodName);
- return GetExtensionMethods (Assembly.GetExecutingAssembly(), t)
- .Where (em => em.Name == methodName).FirstOrDefault ();
+ //add key even if mi is null to prevent searching again and again for propertyless bindings
+ knownExtMethods.Add (key, mi);
+ return mi;
+ }
+
+ static MethodInfo GetExtensionMethods2 (Assembly assembly, Type extendedType, string methodName)
+ {
+ foreach (Type t in assembly.GetTypes ().Where
+ (ty => ty.IsDefined (typeof (ExtensionAttribute), false))) {
+ foreach (MethodInfo mi in t.GetMethods
+ (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where
+ (m=> m.Name == methodName && m.IsDefined (typeof (ExtensionAttribute), false) &&
+ m.GetParameters ().Length == 1)) {
+ Type curType = extendedType;
+ while (curType != null) {
+ if (mi.GetParameters () [0].ParameterType == curType)
+ return mi;
+ curType = curType.BaseType;
+ }
+ }
+
+ }
+ return null;
}
/// <summary>
/// retrieve event handler in class or ancestors
/// </summary>
/// <returns>the corresponding type object if found</returns>
/// <param name="strDataType">type name</param>
- internal static Type tryGetType (string strDataType){
+ internal static Type getTypeFromName (string strDataType){
+ if (knownTypes.ContainsKey (strDataType))
+ return knownTypes [strDataType];
Type dataType = Type.GetType(strDataType);
- if (dataType != null)
+ if (dataType != null) {
+ knownTypes.Add (strDataType, dataType);
return dataType;
- Assembly a = Assembly.GetEntryAssembly ();
- foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == strDataType)
- return dataType;
}
+ foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
+ if (a.IsDynamic)
+ continue;
+ foreach (Type expT in a.GetExportedTypes ()) {
+ if (expT.Name != strDataType)
+ continue;
+ knownTypes.Add (strDataType, expT);
+ return expT;
+ }
+ }
+ knownTypes.Add (strDataType, null);
return null;
}
+ //get value from member of object
internal static object getDataTypeAndFetch (object data, string fetchMethod){
Type dataType = data.GetType();
+ //Console.WriteLine ($"get data type and fetch {data}.{fetchMethod}");
MethodInfo miGetDatas = dataType.GetMethod (fetchMethod, new Type[] {});
if (miGetDatas == null)
miGetDatas = CompilerServices.SearchExtMethod (dataType, fetchMethod);
if (miGetDatas == null)
throw new Exception ("Read only property for fetching data in ItemTemplate: " + fetchMethod);
}
- object tmp = miGetDatas.Invoke (data, null);
- return tmp;
+ return miGetDatas.IsStatic ?
+ miGetDatas.Invoke (null, new object [] { data }) : miGetDatas.Invoke (data, null);
+ }
+ //TODO:memberinfo found here must be cached
+ internal static object getValue (Type dataType, object data, string member)
+ {
+ //Console.WriteLine ($"get value: {dataType} ; {data} ; {member}");
+
+ MethodInfo miGetDatas = dataType.GetMethod (member, new Type [] { });
+ if (miGetDatas != null)
+ return miGetDatas.Invoke (data, null);
+ MemberInfo mbi = dataType.GetMember (member).FirstOrDefault ();
+ if (mbi == null) {
+ MethodInfo miExt = CompilerServices.SearchExtMethod (dataType, member);
+ if (miExt == null)//and among fields
+ throw new Exception ($"member {member} not found in {dataType}");
+ return miExt.Invoke (null, new object [] { data });
+ }
+ if (mbi.MemberType == MemberTypes.Property) {
+ miGetDatas = (mbi as PropertyInfo)?.GetGetMethod ();
+ if (miGetDatas == null)
+ throw new Exception ($"no getter found for property {member} in {dataType}");
+ return miGetDatas.Invoke (data, null);
+ }
+
+ FieldInfo fi = mbi as FieldInfo;
+ if (fi == null)
+ throw new Exception ($"member {member} not found in {dataType}");
+
+ return fi.GetValue (data);
}
}
}
}
}
return di;
- }
+ }
+ public string DesignName {
+ get { return GetType ().Name + design_id; }
+ }
#endif
#region IDisposable implementation
loadingTime.ElapsedMilliseconds, this.ToString());
#endif
}
- string getItempKey(Type dataType, object o, string propertyName){
- try {
- return dataType.GetProperty (propertyName).GetGetMethod ().Invoke (o, null)?.ToString();
- } catch {
- return dataType.FullName;
- }
- }
+
protected void loadItem(object o, Group page, string _dataTest){
if (o == null)//TODO:surely a threading sync problem
return;
Type dataType = o.GetType ();
string itempKey = dataType.FullName;
- if (_dataTest != "TypeOf")
- itempKey = getItempKey (dataType, o, _dataTest);
+ //if item template selection is not done depending on the type of item
+ //dataTest must contains a member name of the item
+ if (_dataTest != "TypeOf") {
+ try {
+ itempKey = CompilerServices.getValue (dataType, o, _dataTest)?.ToString ();
+ } catch {
+ itempKey = dataType.FullName;
+ }
+ }
if (ItemTemplates.ContainsKey (itempKey))
iTemp = ItemTemplates [itempKey];
else {
foreach (string it in ItemTemplates.Keys) {
- Type t = CompilerServices.tryGetType (it);
+ if (it == "default")
+ continue;
+ Type t = CompilerServices.getTypeFromName (it);
if (t == null)
continue;
if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached
}
#endregion
+ internal static Dictionary<string, Type> knownGOTypes = new Dictionary<string, Type> ();
+
public Type RootType;
InstanciatorInvoker loader;
protected Interface iface;
/// <returns>the corresponding type object</returns>
/// <param name="typeName">graphic object type name without its namespace</param>
Type tryGetGOType (string typeName){
+ if (knownGOTypes.ContainsKey (typeName))
+ return knownGOTypes [typeName];
Type t = Type.GetType ("Crow." + typeName);
- if (t != null)
- return t;
+ if (t != null) {
+ knownGOTypes.Add (typeName, t);
+ return t;
+ }
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) {
if (a.IsDynamic)
continue;
foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == typeName)
- return expT;
+ if (expT.Name != typeName)
+ continue;
+ knownGOTypes.Add (typeName, expT);
+ return expT;
}
}
return null;
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Globalization;
using Crow.IML;
using System.Runtime.InteropServices;
-
+using System;
+using System.IO;
+using System.Diagnostics;
+using System.Collections.Generic;
namespace Crow
}
}
- void loadCursors(){
- //Load cursors
- XCursor.Cross = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.cross").Cursors[0];
- XCursor.Default = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.arrow").Cursors[0];
- XCursor.NW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0];
- XCursor.NE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0];
- XCursor.SW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0];
- XCursor.SE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0];
- XCursor.H = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0];
- XCursor.V = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0];
- XCursor.Text = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.ibeam").Cursors[0];
- }
+
#endregion
#region Templates
string resId = path.Substring (1);
//try/catch added to prevent nunit error
try {
- stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
+ stream = Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
} catch{}
if (stream == null)//try to find ressource in Crow assembly
- stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId);
+ stream = Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId);
if (stream == null)
throw new Exception("Resource not found: " + path);
/// </summary>
/// <param name="host">Host.</param>
public void CreateExpandDelegate (TemplatedGroup host){
- Type dataType = null;
- //if (host.DataTest == "TypeOf"){
- dataType = CompilerServices.tryGetType(strDataType);
-// if (dataType == null) {
-// Debug.WriteLine ("ItemTemplate error: DataType not found: {0}.", strDataType);
-// return;
-// }
-// }
+ Type dataType = CompilerServices.getTypeFromName(strDataType);
Type tmpGrpType = typeof(TemplatedGroup);
Type evtType = typeof(EventHandler);
- //PropertyInfo piData = tmpGrpType.GetProperty ("Data");
-
MethodInfo evtInvoke = evtType.GetMethod ("Invoke");
ParameterInfo [] evtParams = evtInvoke.GetParameters ();
Type handlerArgsType = evtParams [1].ParameterType;
il.Emit (OpCodes.Ldarg_1);
il.Emit (OpCodes.Call, CompilerServices.miIsAlreadyExpanded);
il.Emit (OpCodes.Brtrue, gotoEnd);
-// il.Emit (OpCodes.Ldloc_0);
-// il.Emit (OpCodes.Callvirt, piData.GetGetMethod ());
-// il.Emit (OpCodes.Brfalse, ifDataIsNull);
-// il.Emit (OpCodes.Br, gotoEnd);
-
-// il.MarkLabel(ifDataIsNull);
-
- //copy the ref of ItemTemplates list TODO: maybe find another way to share it among the nodes?
-// FieldInfo fiTemplates = tmpGrpType.GetField("ItemTemplates");
-// il.Emit (OpCodes.Ldloc_0);
-// il.Emit (OpCodes.Ldarg_0);
-// il.Emit (OpCodes.Ldfld, fiTemplates);
-// il.Emit (OpCodes.Stfld, fiTemplates);
-
- //call 'fetchMethodName' from the dataSource to build the sub nodes list
- //il.Emit (OpCodes.Ldarg_0);//load root templatedGroop
+ //get the dataSource of the sender
il.Emit (OpCodes.Ldarg_0);//push root TemplatedGroup into the stack
il.Emit (OpCodes.Ldarg_1);//load sender node of expand
- il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataSource);//get the dataSource of the sender
-
-
+ il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataSource);
if (fetchMethodName != "self") {//special keyword self allows the use of recurent list<<<
if (dataType == null) {
if (miGetDatas == null)
throw new Exception ("Write only property for fetching data in ItemTemplate: " + fetchMethodName);
}
-
- il.Emit (OpCodes.Callvirt, miGetDatas);
- }
+ if (miGetDatas.IsStatic)
+ il.Emit (OpCodes.Call, miGetDatas);
+ else
+ il.Emit (OpCodes.Callvirt, miGetDatas);
+ }
+++ /dev/null
-//
-// XCursor.cs
-//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Diagnostics;
-using System.Collections.Generic;
-
-namespace Crow
-{
- public class XCursorFile
- {
- const uint XC_TYPE_IMG = 0xfffd0002;
-
- class toc
- {
- public uint type;
- public uint subtype;
- public uint pos;
-
- public toc(BinaryReader sr)
- {
- type = sr.ReadUInt32();
- subtype = sr.ReadUInt32();
- pos = sr.ReadUInt32();
- }
- }
-
- public List<XCursor> Cursors = new List<XCursor>();
-
-
- static XCursorFile loadFromStream(Stream s)
- {
- List<toc> tocList = new List<toc> ();
- XCursorFile tmp = new XCursorFile ();
-
- using (BinaryReader sr = new BinaryReader (s)) {
- byte[] data;
- //magic: CARD32 ’Xcur’ (0x58, 0x63, 0x75, 0x72)
- if (new string (sr.ReadChars (4)) != "Xcur") {
- Debug.WriteLine ("XCursor Load error: Wrong magic");
- return null;
- }
- //header: CARD32 bytes in this header
- uint headerLength = sr.ReadUInt32 ();
- //version: CARD32 file version number
- uint version = sr.ReadUInt32 ();
- //ntoc: CARD32 number of toc entries
- uint nbToc = sr.ReadUInt32 ();
- //toc: LISTofTOC table of contents
- for (uint i = 0; i < nbToc; i++) {
- tocList.Add (new toc (sr));
- }
-
- foreach (toc t in tocList) {
- if (t.type != XC_TYPE_IMG)
- continue;
-
- sr.BaseStream.Seek (t.pos, SeekOrigin.Begin);
- tmp.Cursors.Add(imageLoad (sr));
- }
- }
- return tmp;
- }
-
- public static XCursorFile Load(Interface iface, string path)
- {
- return loadFromStream (iface.GetStreamFromPath (path));
- }
-
- static XCursor imageLoad(BinaryReader sr)
- {
- XCursor tmp = new XCursor();
- // header: 36 Image headers are 36 bytes
- uint header = sr.ReadUInt32();
- // type: 0xfffd0002 Image type is 0xfffd0002
- uint type = sr.ReadUInt32();
- // subtype: CARD32 Image subtype is the nominal size
- uint subtype = sr.ReadUInt32();
- // version: 1
- uint version = sr.ReadUInt32();
- // width: CARD32 Must be less than or equal to 0x7fff
- tmp.Width = sr.ReadUInt32();
- // height: CARD32 Must be less than or equal to 0x7fff
- tmp.Height = sr.ReadUInt32();
- // xhot: CARD32 Must be less than or equal to width
- tmp.Xhot = sr.ReadUInt32();
- // yhot: CARD32 Must be less than or equal to height
- tmp.Yhot = sr.ReadUInt32();
- // delay: CARD32 Delay between animation frames in milliseconds
- tmp.Delay = sr.ReadUInt32();
- // pixels: LISTofCARD32 Packed ARGB format pixels
- tmp.data = sr.ReadBytes((int)(tmp.Width * tmp.Height * 4));
- return tmp;
- }
- }
- public class XCursor
- {
- public static XCursor Default;
- public static XCursor Cross;
- public static XCursor Arrow;
- public static XCursor Text;
- public static XCursor SW;
- public static XCursor SE;
- public static XCursor NW;
- public static XCursor NE;
- public static XCursor N;
- public static XCursor S;
- public static XCursor V;
- public static XCursor H;
-
- public uint Width;
- public uint Height;
- public uint Xhot;
- public uint Yhot;
- public uint Delay;
- public byte[] data;
-
- public XCursor ()
- {
- }
-// public static implicit operator MouseCursor(XCursor xc)
-// {
-// return new MouseCursor((int)xc.Xhot, (int)xc.Yhot, (int)xc.Width, (int)xc.Height,xc.data);
-// }
- }
-}
-
xcb_flush (conn);
- IntPtr visual = findVisual (scr_it, scr.root_visual);
+ IntPtr visual = findVisual (scr_it, scr.root_visual);
+ //loadCursors ();
iFace.surf = new Cairo.XcbSurface (conn, win, visual, iFace.ClientRectangle.Width, iFace.ClientRectangle.Height);
}
}
#endregion
+ void loadCursors ()
+ {
+ //Load cursors
+ XCursor.Cross = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.cross").Cursors [0];
+ XCursor.Default = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.arrow").Cursors [0];
+ XCursor.NW = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.top_left_corner").Cursors [0];
+ XCursor.NE = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.top_right_corner").Cursors [0];
+ XCursor.SW = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors [0];
+ XCursor.SE = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors [0];
+ XCursor.H = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors [0];
+ XCursor.V = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors [0];
+ XCursor.Text = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.ibeam").Cursors [0];
+ }
+
static IntPtr findVisual (xcb_iterator_t scr_it, xcb_visualid_t visualId){
for (; scr_it.rem > 0; xcb_screen_next (ref scr_it)) {
xcb_iterator_t depth_it = xcb_screen_allowed_depths_iterator (scr_it.data);
--- /dev/null
+//
+// XCursor.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Diagnostics;
+using System.Collections.Generic;
+
+namespace Crow
+{
+ public class XCursorFile
+ {
+ const uint XC_TYPE_IMG = 0xfffd0002;
+
+ class toc
+ {
+ public uint type;
+ public uint subtype;
+ public uint pos;
+
+ public toc(BinaryReader sr)
+ {
+ type = sr.ReadUInt32();
+ subtype = sr.ReadUInt32();
+ pos = sr.ReadUInt32();
+ }
+ }
+
+ public List<XCursor> Cursors = new List<XCursor>();
+
+
+ static XCursorFile loadFromStream(Stream s)
+ {
+ List<toc> tocList = new List<toc> ();
+ XCursorFile tmp = new XCursorFile ();
+
+ using (BinaryReader sr = new BinaryReader (s)) {
+ byte[] data;
+ //magic: CARD32 ’Xcur’ (0x58, 0x63, 0x75, 0x72)
+ if (new string (sr.ReadChars (4)) != "Xcur") {
+ Debug.WriteLine ("XCursor Load error: Wrong magic");
+ return null;
+ }
+ //header: CARD32 bytes in this header
+ uint headerLength = sr.ReadUInt32 ();
+ //version: CARD32 file version number
+ uint version = sr.ReadUInt32 ();
+ //ntoc: CARD32 number of toc entries
+ uint nbToc = sr.ReadUInt32 ();
+ //toc: LISTofTOC table of contents
+ for (uint i = 0; i < nbToc; i++) {
+ tocList.Add (new toc (sr));
+ }
+
+ foreach (toc t in tocList) {
+ if (t.type != XC_TYPE_IMG)
+ continue;
+
+ sr.BaseStream.Seek (t.pos, SeekOrigin.Begin);
+ tmp.Cursors.Add(imageLoad (sr));
+ }
+ }
+ return tmp;
+ }
+
+ public static XCursorFile Load(Interface iface, string path)
+ {
+ return loadFromStream (iface.GetStreamFromPath (path));
+ }
+
+ static XCursor imageLoad(BinaryReader sr)
+ {
+ XCursor tmp = new XCursor();
+ // header: 36 Image headers are 36 bytes
+ uint header = sr.ReadUInt32();
+ // type: 0xfffd0002 Image type is 0xfffd0002
+ uint type = sr.ReadUInt32();
+ // subtype: CARD32 Image subtype is the nominal size
+ uint subtype = sr.ReadUInt32();
+ // version: 1
+ uint version = sr.ReadUInt32();
+ // width: CARD32 Must be less than or equal to 0x7fff
+ tmp.Width = sr.ReadUInt32();
+ // height: CARD32 Must be less than or equal to 0x7fff
+ tmp.Height = sr.ReadUInt32();
+ // xhot: CARD32 Must be less than or equal to width
+ tmp.Xhot = sr.ReadUInt32();
+ // yhot: CARD32 Must be less than or equal to height
+ tmp.Yhot = sr.ReadUInt32();
+ // delay: CARD32 Delay between animation frames in milliseconds
+ tmp.Delay = sr.ReadUInt32();
+ // pixels: LISTofCARD32 Packed ARGB format pixels
+ tmp.data = sr.ReadBytes((int)(tmp.Width * tmp.Height * 4));
+ return tmp;
+ }
+ }
+ public class XCursor
+ {
+ public static XCursor Default;
+ public static XCursor Cross;
+ public static XCursor Arrow;
+ public static XCursor Text;
+ public static XCursor SW;
+ public static XCursor SE;
+ public static XCursor NW;
+ public static XCursor NE;
+ public static XCursor N;
+ public static XCursor S;
+ public static XCursor V;
+ public static XCursor H;
+
+ public uint Width;
+ public uint Height;
+ public uint Xhot;
+ public uint Yhot;
+ public uint Delay;
+ public byte[] data;
+
+ public XCursor ()
+ {
+ }
+// public static implicit operator MouseCursor(XCursor xc)
+// {
+// return new MouseCursor((int)xc.Xhot, (int)xc.Yhot, (int)xc.Width, (int)xc.Height,xc.data);
+// }
+ }
+}
+
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup>
- <Compile Include="*.cs" />
+ <Compile Include="*.cs" Exclude="testClass.cs" />
<ProjectReference Include="..\Crow\Crow.NetStd.csproj" />
</None>
</ItemGroup>
+<!-- <ItemGroup>
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
+ </ItemGroup>-->
</Project>
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>tests.Showcase</StartupObject>
+ <StartupObject>tests.MainClass</StartupObject>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReleaseVersion>0.8.0</ReleaseVersion>
<OutputPath>$(SolutionDir)build/$(Configuration)</OutputPath>
<IntermediateOutputPath>$(SolutionDir)build/obj/$(Configuration)</IntermediateOutputPath>
- <CustomCommands>
- <CustomCommands>
- <Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
- </CustomCommands>
- </CustomCommands>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
<OutputPath>$(SolutionDir)build\Release</OutputPath>
</PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
- <StartAction>Program</StartAction>
- <StartProgram>%24{TargetName}</StartProgram>
- <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
+
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Drawing" />
<Reference Include="Mono.Posix" />
+ <Reference Include="System.AppContext">
+ <HintPath>..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
+ </Reference>
+ <Reference Include="mscorlib" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Collections.Immutable">
+ <HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Console">
+ <HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.FileVersionInfo">
+ <HintPath>..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.StackTrace">
+ <HintPath>..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.Compression">
+ <HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem.Primitives">
+ <HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem">
+ <HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reflection.Metadata">
+ <HintPath>..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.Composition" />
+ <Reference Include="System.Numerics" />
+ <Reference Include="System.Security.Cryptography.Encoding">
+ <HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Primitives">
+ <HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Algorithms">
+ <HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.X509Certificates">
+ <HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Text.Encoding.CodePages">
+ <HintPath>..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Tasks.Extensions">
+ <HintPath>..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Thread">
+ <HintPath>..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ValueTuple">
+ <HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.ReaderWriter">
+ <HintPath>..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Xml.XmlDocument">
+ <HintPath>..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.XPath">
+ <HintPath>..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.XPath.XDocument">
+ <HintPath>..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.CodeAnalysis">
+ <HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.CodeAnalysis.CSharp">
+ <HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
+ </Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<None Include="Interfaces\CheckBox2.imlt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="testClass.cs">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
<EmbeddedResource Include="Interfaces\colorItem2.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
+ <EmbeddedResource Include="ui\TreeExpandable.template" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Crow\Crow.csproj">
--- /dev/null
+
+using System;
+
+/* this is a block comment
+ * on several lines
+ */
+
+namespace testRoslyn {
+ public class testClass {
+ public testClass self;
+ int a = 0;
+ int b;
+ public string str = "this is a test string"
+
+ [XmlIgnore]
+ public string Str {
+ get { return str; }
+ set { str = value; }
+ }
+ [SecuritySafeCritical]
+ public testClass (int _a, int _b) {
+ a = _a;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack>
+ <Border Style="TreeItemBorder" >
+ <HorizontalStack Spacing="5" Focusable="true" MouseDoubleClick="./onClickForExpand">
+ <Image Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
+ Path="{./Image}"
+ Visible="{./IsExpandable}"
+ SvgSub="{./IsExpanded}"
+ MouseEnter="{Background=LightGrey}"
+ MouseLeave="{Background=Transparent}"/>
+ <Label Text="{Kind}" Width="Fit" Margin="2" Background="Onyx"/>
+ <Label Multiline="true" Text="{ToFullString}" Foreground="White" Background="Blue" Margin="2"/>
+ <ListBox Data="{GetToks}" Height="Fit" Width="Fit" DataTest="GetKind">
+ <Template>
+ <HorizontalStack Name="ItemsContainer"/>
+ </Template>
+ <ItemTemplate DataType="OpenBraceToken">
+ <Label Text="{ToFullString}" Foreground="White" Background="Red"/>
+ </ItemTemplate>
+ <ItemTemplate DataType="OpenParenToken">
+ <Label Text="{ToFullString}" Foreground="Red" />
+ </ItemTemplate>
+ <ItemTemplate>
+ <Label Text="{ToFullString}" Foreground="Black"/>
+ </ItemTemplate>
+ </ListBox>
+ </HorizontalStack>
+ </Border>
+ <Container Name="Content" Visible="false"/>
+</VerticalStack>