GlobalSection(MonoDevelopProperties) = preSolution
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.Text = @Copyright (c) ${Year} ${AuthorName} <${AuthorEmail}>\n\nThis code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
$0.DotNetNamingPolicy = $2
$0.TextStylePolicy = $3
$3.EolMarker = Unix
$6.LastFilePostfix = "@:\n "
$6.LineAlign = 0
$6.Wrap = False
- $5.inheritsSet = Mono
description = @C.R.O.W. c# Rapid Open Widgets\n\nCrow is a pure c# widget toolkit with XML definition of interface, bindings, styling...\n
version = 0.8.0
EndGlobalSection
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)netfx.props" />
<PropertyGroup>
- <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
+ <TargetFrameworks>net461;net471;netstandard2.0</TargetFrameworks>
<AssemblyName>Crow</AssemblyName>
<Copyright></Copyright>
- <AssemblyVersion>0.8.1</AssemblyVersion>
+ <AssemblyVersion>0.8.3.2</AssemblyVersion>
<Description>C.R.O.W. is a widget toolkit and rendering engine entirely developed in C# with templates, styles, compositing, and bindings.</Description>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageIconUrl>https://jpbruyere.github.io/Crow/images/crow.png</PackageIconUrl>
<PackageCopyright>Copyright 2013-2019</PackageCopyright>
<PackageReleaseNotes>xcb backend</PackageReleaseNotes>
- <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
+ <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
+
+ <LangVersion>7.2</LangVersion>
<OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
<DefineConstants>DESIGN_MODE</DefineConstants>
- <ReleaseVersion>0.8.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
<DefineConstants>TRACE;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;_DEBUG_FOCUS;_DEBUG_DRAGNDROP;DEBUG;NETFRAMEWORK;NET471</DefineConstants>
- <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+ <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
using System;
using System.IO;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
foreach (Type expT in a.GetExportedTypes ()) {
if (expT.Name != strDataType)
continue;
- knownTypes.Add (strDataType, expT);
+ if (!knownTypes.ContainsKey(strDataType))
+ knownTypes.Add (strDataType, expT);
return expT;
}
}
using System;
using System.Collections.Generic;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
using System;
using System.Collections.Generic;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
using System.Diagnostics;
using System.Xml.Serialization;
-using Cairo;
+using Crow.Cairo;
using System.ComponentModel;
namespace Crow
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Cairo;
+using Crow.Cairo;
using System.Xml.Serialization;
namespace Crow
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;
-using Cairo;
+using Crow.Cairo;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.ComponentModel;
using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Cairo;
+using Crow.Cairo;
using System.Diagnostics;
using System.Xml.Serialization;
using System.ComponentModel;
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
using System.Xml.Serialization;
namespace Crow
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections;
-using Cairo;
+using Crow.Cairo;
namespace Crow
using System.ComponentModel;
using System.IO;
using System.Text;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
using System.Linq;
namespace Crow
using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using Crow.Cairo;
using System.Diagnostics;
using System.Linq;
using System.IO;
using System.Xml;
using System.Reflection;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
// THE SOFTWARE.
using System;
-using System.Xml.Serialization;
-using System.Xml;
-using System.Reflection;
+using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Collections;
-using System.Threading;
using System.Linq;
using Crow.IML;
-using System.Diagnostics;
-using System.IO;
-namespace Crow
-{
+namespace Crow {
public abstract class TemplatedGroup : TemplatedControl
{
#if DESIGN_MODE
public event EventHandler Loaded;
#endregion
- IList data;
+ IEnumerable data;
int _selectedIndex = -1;
Color selBackground, selForeground;
}
}
[XmlIgnore]public virtual object SelectedItem{
- get { return data == null ? null : _selectedIndex < 0 ? data.GetDefaultValue() : data[_selectedIndex]; }
+ get { return data == null ? null : _selectedIndex < 0 ? data.GetDefaultValue() : ((IList)data)?[_selectedIndex]; }
set {
if (data == null) {
SelectedIndex = -1;
if (value == SelectedItem)
return;
- SelectedIndex = data.IndexOf (value);
+ SelectedIndex = (int)((IList)data)?.IndexOf (value);
}
}
[XmlIgnore]public bool HasItems {
get { return Items.Count > 0; }
}
- public IList Data {
+ public IEnumerable Data {
get { return data; }
set {
if (value == data)
if (loadingThread != null)
loadingThread.Cancel ();
}
- void loadPage(IList _data, Group page, string _dataTest)
+ void loadPage(IEnumerable _data, Group page, string _dataTest)
{
#if DEBUG_LOAD
Stopwatch loadingTime = Stopwatch.StartNew ();
// typeof(Wrapper).IsAssignableFrom (items.GetType ())) {
//page = items;
itemPerPage = int.MaxValue;
-// } else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) {
-// GenericStack gs = new GenericStack (items.CurrentInterface);
-// gs.Orientation = (items as GenericStack).Orientation;
-// gs.Width = items.Width;
-// gs.Height = items.Height;
-// gs.VerticalAlignment = items.VerticalAlignment;
-// gs.HorizontalAlignment = items.HorizontalAlignment;
-// page = gs;
-// page.Name = "page" + pageNum;
-// isPaged = true;
-// } else {
-// page = Activator.CreateInstance (items.GetType ()) as Group;
-// page.CurrentInterface = items.CurrentInterface;
-// page.Initialize ();
-// page.Name = "page" + pageNum;
-// isPaged = true;
-// }
-
- for (int i = 0; i < _data.Count; i++) {
- loadItem (_data[i], page, _dataTest);
+ // } else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) {
+ // GenericStack gs = new GenericStack (items.CurrentInterface);
+ // gs.Orientation = (items as GenericStack).Orientation;
+ // gs.Width = items.Width;
+ // gs.Height = items.Height;
+ // gs.VerticalAlignment = items.VerticalAlignment;
+ // gs.HorizontalAlignment = items.HorizontalAlignment;
+ // page = gs;
+ // page.Name = "page" + pageNum;
+ // isPaged = true;
+ // } else {
+ // page = Activator.CreateInstance (items.GetType ()) as Group;
+ // page.CurrentInterface = items.CurrentInterface;
+ // page.Initialize ();
+ // page.Name = "page" + pageNum;
+ // isPaged = true;
+ // }
+
+
+ foreach (object d in _data) {
+ loadItem (d, page, _dataTest);
if (loadingThread.cancelRequested)
break;
}
if (iTemp.Expand != null && g is Expandable) {
Expandable e = g as Expandable;
e.Expand += iTemp.Expand;
- e.GetIsExpandable = iTemp.HasSubItems;
+ if ((o as ICollection) == null)
+ e.GetIsExpandable = new BooleanTestOnInstance((instance) => true);
+ else
+ e.GetIsExpandable = iTemp.HasSubItems;
}
g.DataSource = o;
}
-// protected void _list_LayoutChanged (object sender, LayoutingEventArgs e)
-// {
-// #if DEBUG_LAYOUTING
-// Debug.WriteLine("list_LayoutChanged");
-// #endif
-// if (_gsList.Orientation == Orientation.Horizontal) {
-// if (e.LayoutType == LayoutingType.Width)
-// _gsList.Width = approxSize;
-// } else if (e.LayoutType == LayoutingType.Height)
-// _gsList.Height = approxSize;
-// }
+
+
+ // protected void _list_LayoutChanged (object sender, LayoutingEventArgs e)
+ // {
+ // #if DEBUG_LAYOUTING
+ // Debug.WriteLine("list_LayoutChanged");
+ // #endif
+ // if (_gsList.Orientation == Orientation.Horizontal) {
+ // if (e.LayoutType == LayoutingType.Width)
+ // _gsList.Width = approxSize;
+ // } else if (e.LayoutType == LayoutingType.Height)
+ // _gsList.Height = approxSize;
+ // }
int approxSize
{
get {
return -1;
return page1.Orientation == Orientation.Horizontal ?
- data.Count < itemPerPage ?
+ (data as ICollection)?.Count < itemPerPage ?
-1:
- (int)Math.Ceiling ((double)page1.Slot.Width / (double)itemPerPage * (double)(data.Count+1)):
- data.Count < itemPerPage ?
+ (int)Math.Ceiling ((double)page1.Slot.Width / (double)itemPerPage * (double)((data as ICollection)?.Count+1)):
+ (data as ICollection)?.Count < itemPerPage ?
-1:
- (int)Math.Ceiling ((double)page1.Slot.Height / (double)itemPerPage * (double)(data.Count+1));
+ (int)Math.Ceiling ((double)page1.Slot.Height / (double)itemPerPage * (double)((data as ICollection)?.Count+1));
}
}
internal virtual void itemClick(object sender, MouseButtonEventArgs e){
- SelectedIndex = data.IndexOf((sender as Widget).DataSource);
+ SelectedIndex = (int)((IList)data)?.IndexOf((sender as Widget).DataSource);
}
bool emitHelperIsAlreadyExpanded (Widget go){
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Linq;
using System.Text;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
-using Cairo;
+using Crow.Cairo;
using System.Diagnostics;
using Crow.IML;
using System.Threading;
#if DEBUG_LOG
DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOLockLayouting, this);
#endif
- lock (IFace.LayoutMutex) {
+ lock (IFace.UpdateMutex) {
OnDataSourceChanged (this, dse);
NotifyValueChanged ("DataSource", DataSource);
}
using System.Linq;
using System.Reflection;
using System.Threading;
-using Cairo;
+using Crow.Cairo;
using Crow.IML;
/// The resulting surface (a byte array in the OpenTK renderer) is made available and protected with the
/// RenderMutex of the interface.
/// </remarks>
- public class Interface : ILayoutable, IDisposable ,IValueChange
+ public class Interface : ILayoutable, IDisposable, IValueChange
{
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public virtual void NotifyValueChanged(string MemberName, object _value)
+ public virtual void NotifyValueChanged (string MemberName, object _value)
{
//Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value);
- ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ ValueChanged.Raise (this, new ValueChangeEventArgs (MemberName, _value));
}
#endregion
- internal IBackend backend;
+ protected IBackend backend;
+ protected bool running;
+
#region CTOR
- static Interface(){
+ static Interface () {
/*if (Type.GetType ("Mono.Runtime") == null) {
throw new Exception (@"C.R.O.W. run only on Mono, download latest version at: http://www.mono-project.com/download/stable/");
}*/
CROW_CONFIG_ROOT =
- System.IO.Path.Combine(
- Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ System.IO.Path.Combine (
+ Environment.GetFolderPath (Environment.SpecialFolder.UserProfile),
".config");
CROW_CONFIG_ROOT = System.IO.Path.Combine (CROW_CONFIG_ROOT, "crow");
if (!Directory.Exists (CROW_CONFIG_ROOT))
Directory.CreateDirectory (CROW_CONFIG_ROOT);
//ensure all assemblies are loaded, because IML could contains classes not instanciated in source
- foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")){
+ foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")) {
try {
- Assembly.LoadFrom (af);
+ Assembly.LoadFrom (af);
} catch (Exception ex) {
Console.WriteLine ("{0} not loaded as assembly.", af);
}
FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
}
- public Interface(int width=800, int height=600){
-
+ public Interface(int width=800, int height=600, IBackend _backend = null){
+ CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
+ CurrentInterface = this;
clientRectangle = new Rectangle (0, 0, width, height);
+ backend = _backend;
- Init ();
-
- InitBackend ();
+ Thread t = new Thread (InterfaceThread) {
+ IsBackground = true
+ };
+ t.Start ();
+#if MEASURE_TIME
+ PerfMeasures.Add (updateMeasure);
+ PerfMeasures.Add (drawingMeasure);
+ PerfMeasures.Add (layoutingMeasure);
+ PerfMeasures.Add (clippingMeasure);
+#endif
}
#endregion
- protected bool running;
- protected virtual void InitBackend () {
- if (Environment.OSVersion.Platform == PlatformID.Unix)
- backend = new Crow.XCB.XCBBackend();
- //backend = new Crow.XLib.XLibBackend ();
- else
- backend = new Crow.Win32.Win32Backend();
-
+ public virtual void InterfaceThread ()
+ {
+ if (backend == null) {
+ if (Environment.OSVersion.Platform == PlatformID.Unix)
+ backend = new XCB.XCBBackend ();
+ else
+ backend = new Win32.Win32Backend ();
+ }
+
backend.Init (this);
+ while (!running)
+ Thread.Sleep (2);
+
+ while (running) {
+ Update ();
+ Thread.Sleep (5);
+ }
+ }
+ protected virtual void Startup ()
+ {
+ try {
+ Load ("#main.crow").DataSource = this;
+ } catch { }
+ }
+ public virtual void Run () {
+ loadStyling ();
+
initTooltip ();
initContextMenus ();
running = true;
- Thread t = new Thread (interfaceThread);
- t.IsBackground = true;
- t.Start ();
- }
- public void Run () {
Startup ();
+
while (running) {
ProcessEvents ();
Thread.Sleep(1);
}
}
- protected virtual void Startup ()
- {
- //load default main.crow if present
- try {
- Load ("#main.crow").DataSource = this;
- } catch { }
- }
+
public void ProcessKeyPress (char c)
{
_focusedWidget?.onKeyPress (_focusedWidget, new KeyPressEventArgs(c));
}
-
public void ProcessKeyUp (Key key)
{
_focusedWidget?.onKeyUp (_focusedWidget, new KeyEventArgs(key, false));
// keyboardRepeatThread.IsBackground = true;
// keyboardRepeatThread.Start ();
}
-
public bool Shift {
get { return backend.Shift; }
}
-
public bool Ctrl {
get { return backend.Ctrl; }
}
-
public bool Alt {
get { return backend.Alt; }
}
- void interfaceThread()
- {
- while (running) {
- Update ();
- Thread.Sleep (5);
- }
- }
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
FocusedWidget = w;
break;
}
- w = w.LogicalParent as Widget;
+ w = w.FocusParent;
}
}
- public void Init () {
- CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
-
- CurrentInterface = this;
- //loadCursors ();
- loadStyling ();
-
- #if MEASURE_TIME
- PerfMeasures.Add (updateMeasure);
- PerfMeasures.Add (drawingMeasure);
- PerfMeasures.Add (layoutingMeasure);
- PerfMeasures.Add (clippingMeasure);
- #endif
- }
#region Static and constants
/// <summary>
if (s == null)
s = Assembly.GetAssembly (declaringType).GetManifestResourceStream (resId);
if (s == null)
- throw new Exception ($"Template not found '{path}'");
+ throw new Exception ($"Template ressource not found '{path}'");
} else {
if (!File.Exists (path))
- throw new FileNotFoundException ("Template not found: ", path);
+ throw new FileNotFoundException ($"Template not found: {path}", path);
s = new FileStream (path, FileMode.Open, FileAccess.Read);
}
return s;
throw new Exception ("Resource not found: " + path);
} else {
if (!File.Exists (path))
- throw new FileNotFoundException ("File not found: ", path);
+ throw new FileNotFoundException ($"File not found: {path}", path);
stream = new FileStream (path, FileMode.Open, FileAccess.Read);
}
return stream;
throw new Exception ("Resource not found: " + path);
} else {
if (!File.Exists (path))
- throw new FileNotFoundException ("File not found: ", path);
+ throw new FileNotFoundException ($"File not found: {path}", path);
stream = new FileStream (path, FileMode.Open, FileAccess.Read);
}
return stream;
/// - Drawing
/// Result: the Interface bitmap is drawn in memory (byte[] bmp) and a dirtyRect and bitmap are available
/// </summary>
- public void Update(){
+ public void Update(Context ctx = null){
CrowThread[] tmpThreads;
lock (CrowThreads) {
tmpThreads = new CrowThread[CrowThreads.Count];
clippingRegistration ();
- processDrawing ();
+ if (ctx == null) {
+ using (ctx = new Context (surf)) {
+ processDrawing (ctx);
+ }
+ }else
+ processDrawing (ctx);
- #if MEASURE_TIME
+#if MEASURE_TIME
updateMeasure.StopCycle();
- #endif
+#endif
Monitor.Exit (UpdateMutex);
}
}
/// <summary>Clipping Rectangles drive the drawing process. For compositing, each object under a clip rectangle should be
/// repainted. If it contains also clip rectangles, its cache will be update, or if not cached a full redraw will take place</summary>
- void processDrawing(){
+ void processDrawing(Context ctx){
#if MEASURE_TIME
drawingMeasure.StartCycle();
#endif
if (DragImage != null)
clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight));
//using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
- using (ctx = new Context (surf)){
if (!clipping.IsEmpty) {
IsDirty = true;
backend?.Flush ();
}
- }
+
/*#if DEBUG_LOG
DebugLog.AddEvent (DbgEvtType.IFaceEndDrawing);
#endif*/
/*surf.Dispose ();
surf = new Cairo.XlibSurface (xHandle, xwinHnd, xDefaultVisual, clientRectangle.Width, clientRectangle.Height);*/
- if (surf is XlibSurface)
- (surf as XlibSurface).SetSize (clientRectangle.Width, clientRectangle.Height);
- else if (surf is XcbSurface)
- (surf as XcbSurface).SetSize (clientRectangle.Width, clientRectangle.Height);
-
+ surf.SetSize (clientRectangle.Width, clientRectangle.Height);
foreach (Widget g in GraphicTree)
g.RegisterForLayouting (LayoutingType.All);
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum Antialias
-//
+//
// Cairo.cs - a simplistic binding of the Cairo API to C#.
//
// Authors: Duncan Mak (duncan@ximian.com)
using System;
using System.Runtime.InteropServices;
-namespace Cairo
+namespace Crow.Cairo
{
public static class CairoAPI {
static public int Version {
using System;
-namespace Cairo {
+namespace Crow.Cairo {
static class CairoDebug
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
//[Flags]
-//
+//
// Mono.Cairo.Context.cs
//
// Author:
using System.Text;
using Color = Crow.Color;
-namespace Cairo {
+namespace Crow.Cairo {
[Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")]
public class Graphics : Context {
//
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class DRMDevice : Device
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class DRMSurface : Surface
{
//
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class Device : IDisposable
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class DirectFBSurface : Surface
{
internal DirectFBSurface (IntPtr handle, bool owns) : base (handle, owns)
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Cairo {
+namespace Crow.Cairo {
public struct Distance
{
//
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class EGLDevice : Device
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum Extend
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum FillRule
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum Filter
using System;
using System.Runtime.InteropServices;
-namespace Cairo
+namespace Crow.Cairo
{
[StructLayout (LayoutKind.Sequential)]
public struct FontExtents
//
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class FontFace : IDisposable
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class FontOptions : IDisposable
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum FontSlant
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public enum FontType
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum FontWeight
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum Format
-//
+//
// Mono.Cairo.GLSurface.cs
//
// Authors:
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class GLSurface : Surface
{
//
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class GLXDevice : Device
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class GlitzSurface : Surface
{
internal GlitzSurface (IntPtr handle, bool owns) : base (handle, owns)
using System;
using System.Runtime.InteropServices;
-namespace Cairo
+namespace Crow.Cairo
{
[StructLayout(LayoutKind.Sequential)]
public struct Glyph
using System;
using Color = Crow.Color;
-namespace Cairo {
+namespace Crow.Cairo {
public class Gradient : Pattern
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum HintMetrics
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum HintStyle
-//
+//
// Mono.Cairo.ImageSurface.cs
//
// Authors:
using System;
using System.Runtime.InteropServices;
-namespace Cairo {
+namespace Crow.Cairo {
public class ImageSurface : Surface
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum LineCap
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum LineJoin
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class LinearGradient : Gradient
{
-//
+//
// Mono.Cairo.Matrix.cs
//
// Author: Duncan Mak
using System;
using System.Runtime.InteropServices;
-namespace Cairo {
+namespace Crow.Cairo {
[StructLayout(LayoutKind.Sequential)]
public class Matrix //: ICloneable
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class MeshPattern : Pattern
{
-//
+//
// Cairo.cs - a simplistic binding of the Cairo API to C#.
//
// Authors: Duncan Mak (duncan@ximian.com)
using System;
using System.Runtime.InteropServices;
-namespace Cairo
+namespace Crow.Cairo
{
// sort the functions like in the following page so it is easier to find what is missing
// http://cairographics.org/manual/index-all.html
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum Operator
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class PSSurface : Surface
{
using System;
using System.Runtime.InteropServices;
-using Cairo;
+using Crow.Cairo;
-namespace Cairo {
+namespace Crow.Cairo {
public class Path : IDisposable
{
using System;
using System.Collections;
-namespace Cairo {
+namespace Crow.Cairo {
public class Pattern : IDisposable
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public enum PatternType
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class PdfSurface : Surface
{
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Cairo {
+namespace Crow.Cairo {
public struct Point
{
public Point (int x, int y)
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Cairo {
+namespace Crow.Cairo {
public struct PointD
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class RadialGradient : Gradient
{
using System;
using System.Runtime.InteropServices;
-namespace Cairo
+namespace Crow.Cairo
{
[StructLayout(LayoutKind.Sequential)]
public struct RectangleList {
using System;
using System.Runtime.InteropServices;
-namespace Cairo {
+namespace Crow.Cairo {
public class ScaledFont : IDisposable
{
using System;
using Color = Crow.Color;
-namespace Cairo {
+namespace Crow.Cairo {
public class SolidPattern : Pattern
{
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum Status
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public enum SubpixelOrder
-//
+//
// Mono.Cairo.Surface.cs
//
// Authors:
using System;
using System.Collections;
-namespace Cairo {
+namespace Crow.Cairo {
public class Surface : IDisposable
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class SurfacePattern : Pattern
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public enum SurfaceType
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class SvgSurface : Surface
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public enum SvgVersion
using System;
using System.Runtime.InteropServices;
-namespace Cairo
+namespace Crow.Cairo
{
[StructLayout (LayoutKind.Sequential)]
public struct TextExtents
//
using System;
-namespace Cairo
+namespace Crow.Cairo
{
public class WGLDevice : Device
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class Win32Surface : Surface
{
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class XcbSurface : Surface
{
internal XcbSurface (IntPtr handle, bool owns) : base (handle, owns)
using System;
-namespace Cairo {
+namespace Crow.Cairo {
public class XlibSurface : Surface
{
NativeMethods.cairo_xlib_surface_set_drawable (Handle, drawable, width, height);
}
- public void SetSize (int width, int height)
+ public override void SetSize (int width, int height)
{
NativeMethods.cairo_xlib_surface_set_size (Handle, width, height);
}
using System;
using System.IO;
-using Cairo;
+using Crow.Cairo;
using System.Collections.Generic;
namespace Crow
using System.Xml.Serialization;
using System.Reflection;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
using System;
using System.IO;
-using Cairo;
+using Crow.Cairo;
namespace Crow
{
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
using System.Linq;
namespace Crow
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Cairo;
+using Crow.Cairo;
#if DEBUG_LOG
namespace Crow
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
-//Copyright GPL2
-using Cairo;
+//Copyright GPL2
+using Crow.Cairo;
namespace Rsvg {
[DllImport("rsvg-2")]
static extern void rsvg_handle_render_cairo_sub(IntPtr raw, IntPtr cr, string id);
- public void RenderCairoSub(Cairo.Context cr, string id) {
+ public void RenderCairoSub(Crow.Cairo.Context cr, string id) {
rsvg_handle_render_cairo_sub(Raw, cr == null ? IntPtr.Zero : cr.Handle, id);
}
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)netfx.props" />
<PropertyGroup>
- <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
+ <TargetFramework>net472</TargetFramework>
<OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
<OutputType>Exe</OutputType>
<RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
- <DefineConstants>TRACE;NETSTANDARD2_0;DEBUG;NETCOREAPP2_0</DefineConstants>
+ <DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<LogicalName>Crow.%(Filename).template</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="IDE.style" />
+ <EmbeddedResource Include="IDE.style" />
</ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.Build" Version="16.0.461" />
+ <PackageReference Include="Microsoft.CodeAnalysis" Version="3.3.0-beta3-19401-01" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.3.0-beta3-19401-01" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.0-beta3-19401-01" />
+ <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="3.3.0-beta3-19401-01" />
+ <PackageReference Include="Microsoft.CodeAnalysis.Features" Version="3.3.0-beta3-19401-01" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="3.3.0-beta3-19401-01" />
+ <PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" />
+ </ItemGroup>
<ItemGroup>
<Folder Include="src\msbuild\" />
-Label {
- Foreground="Black";
+//test
+Label {
+ Foreground="White";
}
icon {
Width="14";
Background="RoyalBlue";
}
DockWindow {
- Background="0.98,0.98,0.99,0.9";
+ Background="0.18,0.18,0.18,0.9";
}
{
using (app = new CrowIDE ()) {
MainIFace = app;
-
//app.Keyboard.KeyDown += App_KeyboardKeyDown;
- app.initIde ();
-
- app.reloadWinConfigs ();
-
app.Run ();
app.saveWinConfigs ();
}
}
+ protected override void Startup ()
+ {
+ initIde ();
+ reloadWinConfigs ();
+ }
static void App_KeyboardKeyDown (object sender, KeyEventArgs e)
{
}
Instantiator instFileDlg;
- Solution currentSolution;
+ Workspace currentSolution;
Project currentProject;
DockStack mainDock;
mainDock = go.FindByName ("mainDock") as DockStack;
if (ReopenLastSolution && !string.IsNullOrEmpty (LastOpenSolution)) {
- CurrentSolution = Solution.LoadSolution (LastOpenSolution);
+ CurrentSolution = new Workspace (LastOpenSolution);
//lock(MainIFace.UpdateMutex)
- CurrentSolution.ReopenItemsSavedInUserConfig ();
+ // CurrentSolution.ReopenItemsSavedInUserConfig ();
}
instFileDlg = Instantiator.CreateFromImlFragment
Crow.Configuration.Global.Set ("CurrentDirectory", value);
}
}
- public Solution CurrentSolution {
+ public Workspace CurrentSolution {
get { return currentSolution; }
set {
if (currentSolution == value)
try {
string ext = Path.GetExtension (filePath);
if (string.Equals (ext, ".sln", StringComparison.InvariantCultureIgnoreCase)) {
- CurrentSolution = Solution.LoadSolution (filePath);
+ CurrentSolution = new Workspace (filePath);
LastOpenSolution = filePath;
// }else if (string.Equals (ext, ".csproj", StringComparison.InvariantCultureIgnoreCase)) {
// currentProject = new Project (filePath);
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
-using Cairo;
+using Crow.Cairo;
namespace Crow.Coding
{
public DesignInterface () : base()
{
+ surf = new ImageSurface (Format.Argb32, 100, 100);
+
+ loadStyling ();
}
+ public override void InterfaceThread ()
+ {
- public ProjectFile ProjFile;
+ //running = true;
+ //while (running) {
+ // Update ();
+ // Thread.Sleep (5);
+ //}
+ }
+ public ProjectFile ProjFile;
public override Widget CreateInstance (string path)
throw new Exception ($"In Design File not found: {path}");
}
- protected override void InitBackend ()
- {
- surf = new ImageSurface (Format.Argb32, 100, 100);
- }
+
public override void ProcessResize (Rectangle bounds)
{
if (bounds == clientRectangle)
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections;
-using Cairo;
+using Crow.Cairo;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using System.Xml;
using System.Diagnostics;
-using Cairo;
+using Crow.Cairo;
namespace Crow.Coding
{
using System;
using System.ComponentModel;
-using Cairo;
+using Crow.Cairo;
using System.Collections.Generic;
using System.Diagnostics;
// THE SOFTWARE.
using System;
using System.ComponentModel;
-using Cairo;
+using Crow.Cairo;
namespace Crow.Coding
{
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using Cairo;
+using Crow.Cairo;
namespace Crow.Coding
{
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
-using Cairo;
+using Crow.Cairo;
namespace Crow.Coding
{
return;
FileLocation fl = g.design_style_locations [Name];
ProjectFile pf;
+ /*
if (!mview.ProjectNode.Project.TryGetProjectFileFromPath ("#" + fl.FilePath, out pf))
return;
pf.CurrentLine = fl.Line;
pf.CurrentColumn = fl.Column;
- pf.IsSelected = true;
+ pf.IsSelected = true;*/
}
using System.CodeDom.Compiler;
using Crow;
using System.Text.RegularExpressions;
+using Microsoft.Build.Construction;
namespace Crow.Coding {
public class Project : IValueChange {
#endregion
bool isLoaded = false;
- bool isExpanded;
- XmlDocument xmlDoc;
- XmlNode nodeProject;
- XmlNode nodeProps;
- XmlNodeList nodesItems;
- SolutionProject solutionProject;
- Crow.Command cmdSave, cmdOpen, cmdCompile, cmdSetAsStartProj, cmdNewFile;
+ bool isExpanded;
+ ProjectInSolution solutionProject;
+ Microsoft.Build.Evaluation.Project project;
+
+ Crow.Command cmdSave, cmdOpen, cmdCompile, cmdSetAsStartProj, cmdNewFile;
#region CTOR
- public Project (Solution sol, SolutionProject sp) {
+ public Project (Workspace sol, ProjectInSolution sp) {
solutionProject = sp;
-
solution = sol;
- cmdSave = new Crow.Command (new Action (() => Save ())) { Caption = "Save", Icon = new SvgPicture ("#CrowIDE.icons.save.svg"), CanExecute = true };
+ ProjectRootElement projectRootElt = ProjectRootElement.Open (solutionProject.AbsolutePath);
+ project = new Microsoft.Build.Evaluation.Project (projectRootElt, null, "15.0");
+
+ cmdSave = new Crow.Command (new Action (() => Save ())) { Caption = "Save", Icon = new SvgPicture ("#CrowIDE.icons.save.svg"), CanExecute = true };
cmdOpen = new Crow.Command (new Action (() => Load ())) { Caption = "Open", Icon = new SvgPicture ("#CrowIDE.icons.open.svg"), CanExecute = false };
cmdCompile = new Crow.Command (new Action (() => Compile ())) {
Caption = "Compile",
}
#endregion
- public Solution solution;
+ public Workspace solution;
public List<Crow.Command> Commands;
public CompilerResults CompilationResults;
public List<Project> dependantProjects = new List<Project> ();
public Project ParentProject = null;
- List<ProjectNode> rootItems;
- List<ProjectNode> flattenNodes;
+ List<ProjectNode> rootItems;
public string Name {
get { return solutionProject.ProjectName; }
get { return solution.StartupProject == this; }
}
public string Path {
- get { return System.IO.Path.Combine (solution.SolutionFolder, solutionProject.RelativePath.Replace ('\\', '/')); }
+ get { return System.IO.Path.Combine (project.DirectoryPath.Replace ('\\', '/')); }
}
public string RootDir {
get { return System.IO.Path.GetDirectoryName (Path); }
}
-
-
public List<ProjectNode> RootItems {
get { return rootItems; }
}
-
- void buildTreeNodes () {
- ProjectNode root = new ProjectNode (this, ItemType.VirtualGroup, RootNamespace);
- List<ProjectItem> items = new List<ProjectItem> ();
- foreach (XmlNode i in nodesItems) {
- foreach (XmlNode f in i.ChildNodes) {
- items.Add (new ProjectItem (this, f));
- }
- }
-
- flattenNodes = new List<ProjectNode> ();
-
- ProjectNode refs = new ProjectNode (this, ItemType.ReferenceGroup, "References");
- root.AddChild (refs);
-
- foreach (ProjectItem pn in items) {
- switch (pn.Type) {
- case ItemType.Reference:
- refs.AddChild (pn);
- flattenNodes.Add (pn);
- break;
- case ItemType.ProjectReference:
- ProjectReference pr = new ProjectReference (pn);
- refs.AddChild (pr);
- flattenNodes.Add (pr);
- break;
- case ItemType.Compile:
- case ItemType.None:
- case ItemType.EmbeddedResource:
- ProjectNode curNode = root;
- string[] folds = pn.Path.Split ('/');
- for (int i = 0; i < folds.Length - 1; i++) {
- ProjectNode nextNode = curNode.ChildNodes.FirstOrDefault (n => n.DisplayName == folds[i] && n.Type == ItemType.VirtualGroup);
- if (nextNode == null) {
- nextNode = new ProjectNode (this, ItemType.VirtualGroup, folds[i]);
- curNode.AddChild (nextNode);
- }
- curNode = nextNode;
- }
- ProjectNode f = null;
- switch (pn.Extension) {
- /*case ".cs":
- f = new CSProjectFile (pn);
- break;*/
- case ".crow":
- case ".template":
- case ".goml":
- case ".itemp":
- case ".imtl":
- f = new ImlProjectItem (pn);
- break;
- case ".style":
- f = new StyleProjectItem (pn);
- break;
- default:
- f = new ProjectFile (pn);
- break;
- }
- curNode.AddChild (f);
- flattenNodes.Add (f);
- break;
- }
- }
- root.SortChilds ();
-
- rootItems = root.ChildNodes;
- }
-
+
#region Project properties
public string ToolsVersion {
- get { return nodeProject?.Attributes["ToolsVersion"]?.Value; }
+ get { return project.ToolsVersion; }
}
public string DefaultTargets {
- get { return nodeProject?.Attributes["DefaultTargets"]?.Value; }
+ get { return project.Xml.DefaultTargets; }
}
public string ProjectGuid {
get { return solutionProject.ProjectGuid; }
}
- public string AssemblyName {
- get { return nodeProps["AssemblyName"]?.InnerText; }
- }
- public string OutputType {
- get { return nodeProps["OutputType"]?.InnerText; }
- }
- public string RootNamespace {
- get { return nodeProps["RootNamespace"]?.InnerText; }
- }
+ public string AssemblyName => project.AllEvaluatedProperties.Where(p=>p.Name =="AssemblyName").FirstOrDefault().EvaluatedValue;
+ public string OutputType => project.AllEvaluatedProperties.Where (p => p.Name == "OutputType").FirstOrDefault ().EvaluatedValue;
+ public string RootNamespace => project.AllEvaluatedProperties.Where (p => p.Name == "RootNamespace").FirstOrDefault ().EvaluatedValue;
public bool AllowUnsafeBlocks {
get {
- return nodeProps["AllowUnsafeBlocks"] == null ? false :
- bool.Parse (nodeProps["AllowUnsafeBlocks"]?.InnerText);
+ return false;
+ /*return nodeProps["AllowUnsafeBlocks"] == null ? false :
+ bool.Parse (nodeProps["AllowUnsafeBlocks"]?.InnerText);*/
}
}
public bool NoStdLib {
get {
- return nodeProps["NoStdLib"] == null ? false :
- bool.Parse (nodeProps["NoStdLib"]?.InnerText);
+ return false;
+ /*return nodeProps["NoStdLib"] == null ? false :
+ bool.Parse (nodeProps["NoStdLib"]?.InnerText);*/
}
}
public bool TreatWarningsAsErrors {
get {
- return nodeProps["TreatWarningsAsErrors"] == null ? false :
- bool.Parse (nodeProps["TreatWarningsAsErrors"]?.InnerText);
+ return false;
+ /*return nodeProps["TreatWarningsAsErrors"] == null ? false :
+ bool.Parse (nodeProps["TreatWarningsAsErrors"]?.InnerText);*/
}
}
public bool SignAssembly {
- get { return bool.Parse (nodeProps["SignAssembly"]?.InnerText); }
- }
- public string TargetFrameworkVersion {
- get { return nodeProps["TargetFrameworkVersion"]?.InnerText; }
- }
- public string Description {
- get { return nodeProps["Description"]?.InnerText; }
- }
- public string OutputPath {
- get { return nodeProps["OutputPath"]?.InnerText; }
- }
- public string IntermediateOutputPath {
- get { return nodeProps["IntermediateOutputPath"]?.InnerText; }
- }
- public string StartupObject {
- get { return nodeProps["StartupObject"]?.InnerText; }
- }
- public bool DebugSymbols {
- get { return nodeProps["DebugSymbols"] == null ? false : bool.Parse (nodeProps["DebugSymbols"]?.InnerText); }
- }
- public int WarningLevel {
- get { return nodeProps["WarningLevel"] == null ? 0 : int.Parse (nodeProps["WarningLevel"]?.InnerText); }
- }
-
+ get { return false; }// projectRootElt.Properties.Where (p => p.Name == "SignAssembly").FirstOrDefault ().Value; }
+ }
+ public string TargetFrameworkVersion => project.AllEvaluatedProperties.Where (p => p.Name == "TargetFrameworkVersion").FirstOrDefault ().EvaluatedValue;
+ public string Description => project.AllEvaluatedProperties.Where (p => p.Name == "Description").FirstOrDefault ().EvaluatedValue;
+ public string OutputPath => project.AllEvaluatedProperties.Where (p => p.Name == "OutputPath").FirstOrDefault ().EvaluatedValue;
+ public string IntermediateOutputPath => project.AllEvaluatedProperties.Where (p => p.Name == "IntermediateOutputPath").FirstOrDefault ().EvaluatedValue;
+ public string StartupObject => project.AllEvaluatedProperties.Where (p => p.Name == "StartupObject").FirstOrDefault ().EvaluatedValue;
+ public bool DebugSymbols => false;// nodeProps["DebugSymbols"] == null ? false : bool.Parse (nodeProps["DebugSymbols"]?.InnerText); }
+ public int WarningLevel => 0;
#endregion
public void Load () {
- xmlDoc = new XmlDocument ();
- using (Stream ins = new FileStream (this.Path, FileMode.Open)) {
- xmlDoc.Load (new XmlTextReader (ins) { Namespaces = false });
- }
-
- nodeProject = xmlDoc.SelectSingleNode ("Project");
- XmlNodeList nodesProps = xmlDoc.SelectNodes ("/Project/PropertyGroup");
-
- foreach (XmlNode n in nodesProps) {
- if (n.Attributes["Condition"] == null)
- nodeProps = n;
- }
- nodesItems = xmlDoc.SelectNodes ("/Project/ItemGroup");
-
- if (ProjectGuid != solutionProject.ProjectGuid)
- throw new Exception ("Project GUID not matching with solution");
-
- buildTreeNodes ();
-
- IsLoaded = true;
+ ProjectNode root = new ProjectNode (this, ItemType.VirtualGroup, RootNamespace);
+ ProjectNode refs = new ProjectNode (this, ItemType.ReferenceGroup, "References");
+ root.AddChild (refs);
+
+ foreach (Microsoft.Build.Evaluation.ProjectItem pn in project.AllEvaluatedItems) {
+ switch (pn.ItemType) {
+ case "Reference":
+ refs.AddChild (new ProjectItem(this, pn));
+ break;
+ case "ProjectReference":
+ ProjectReference pr = new ProjectReference (this, pn);
+ refs.AddChild (pr);
+ break;
+ case "Compile":
+ case "None":
+ case "EmbeddedResource":
+
+ ProjectNode curNode = root;
+ try {
+ string file = pn.EvaluatedInclude.Replace ('\\', '/');
+ string [] folds = file.Split ('/');
+ for (int i = 0; i < folds.Length - 1; i++) {
+ ProjectNode nextNode = curNode.ChildNodes.FirstOrDefault (n => n.DisplayName == folds [i] && n.Type == ItemType.VirtualGroup);
+ if (nextNode == null) {
+ nextNode = new ProjectNode (this, ItemType.VirtualGroup, folds [i]);
+ curNode.AddChild (nextNode);
+ }
+ curNode = nextNode;
+ }
+ ProjectItem pi = new ProjectItem (this, pn);
+
+ switch (System.IO.Path.GetExtension (file)) {
+ /*case ".cs":
+ f = new CSProjectFile (pn);
+ break;*/
+ case ".crow":
+ case ".template":
+ case ".goml":
+ case ".itemp":
+ case ".imtl":
+ pi = new ImlProjectItem (pi);
+ break;
+ case ".style":
+ pi = new StyleProjectItem (pi);
+ break;
+ default:
+ pi = new ProjectFile (pi);
+ break;
+ }
+ curNode.AddChild (pi);
+
+ } catch (Exception ex) {
+
+ }
+
+ break;
+ }
+ }
+ root.SortChilds ();
+ rootItems = root.ChildNodes;
+ IsLoaded = true;
}
public void Save () {
return tmp;
}
public string Compile () {
- if (ParentProject != null)
- ParentProject.Compile ();
-
- CSharpCodeProvider cp = new CSharpCodeProvider ();
- CompilerParameters parameters = new CompilerParameters ();
-
- foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
- Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID);
- if (p == null)
- throw new Exception ("referenced project not found");
- parameters.ReferencedAssemblies.Add (p.Compile ());
- }
-
- string outputDir = getDirectoryWithTokens (this.OutputPath);
- string objDir = getDirectoryWithTokens (this.IntermediateOutputPath);
-
- Directory.CreateDirectory (outputDir);
- Directory.CreateDirectory (objDir);
-
- parameters.OutputAssembly = System.IO.Path.Combine (outputDir, this.AssemblyName);
-
- // True - exe file generation, false - dll file generation
- if (this.OutputType == "Library") {
- parameters.GenerateExecutable = false;
- parameters.CompilerOptions += " /target:library";
- parameters.OutputAssembly += ".dll";
- } else {
- parameters.GenerateExecutable = true;
- parameters.CompilerOptions += " /target:exe";
- parameters.OutputAssembly += ".exe";
- parameters.MainClass = this.StartupObject;
- }
-
- parameters.GenerateInMemory = false;
- parameters.IncludeDebugInformation = this.DebugSymbols;
- parameters.TreatWarningsAsErrors = this.TreatWarningsAsErrors;
- parameters.WarningLevel = this.WarningLevel;
- parameters.CompilerOptions += " /noconfig";
- if (this.AllowUnsafeBlocks)
- parameters.CompilerOptions += " /unsafe";
- parameters.CompilerOptions += " /delaysign+";
- parameters.CompilerOptions += " /debug:full /debug+";
- parameters.CompilerOptions += " /optimize-";
- parameters.CompilerOptions += " /define:\"DEBUG;TRACE\"";
- parameters.CompilerOptions += " /nostdlib";
-
-
-
- foreach (ProjectItem pi in flattenNodes.Where (p => p.Type == ItemType.Reference)) {
-
- if (string.IsNullOrEmpty (pi.HintPath)) {
- parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/" + pi.Path + ".dll";
- continue;
- }
- parameters.ReferencedAssemblies.Add (pi.Path);
- string fullHintPath = System.IO.Path.GetFullPath (System.IO.Path.Combine (RootDir, pi.HintPath.Replace ('\\', '/')));
- if (File.Exists (fullHintPath)) {
- string outPath = System.IO.Path.Combine (outputDir, System.IO.Path.GetFileName (fullHintPath));
- if (!File.Exists (outPath))
- File.Copy (fullHintPath, outPath);
- }
- }
- parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/System.Core.dll";
- parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/mscorlib.dll";
- //parameters.ReferencedAssemblies.Add ("System.Core");
- //parameters.ReferencedAssemblies.Add ("mscorlib.dll");
-
-
- IEnumerable<ProjectFile> pfs = flattenNodes.OfType<ProjectFile> ();
-
- foreach (ProjectFile pi in pfs.Where (p => p.Type == ItemType.EmbeddedResource)) {
-
- string absPath = pi.AbsolutePath;
- string logicName = pi.LogicalName;
- if (string.IsNullOrEmpty (logicName))
- parameters.CompilerOptions += string.Format (" /resource:{0},{1}", absPath, this.Name + "." + pi.Path.Replace ('/', '.'));
- else
- parameters.CompilerOptions += string.Format (" /resource:{0},{1}", absPath, logicName);
- }
- foreach (ProjectFile pi in pfs.Where (p => p.Type == ItemType.None)) {
- if (pi.CopyToOutputDirectory == CopyToOutputState.Never)
- continue;
- string source = pi.AbsolutePath;
- string target = System.IO.Path.Combine (outputDir, pi.Path);
- Directory.CreateDirectory (System.IO.Path.GetDirectoryName (target));
-
- if (File.Exists (target)) {
- if (pi.CopyToOutputDirectory == CopyToOutputState.PreserveNewest) {
- if (DateTime.Compare (
- System.IO.File.GetLastWriteTime (source),
- System.IO.File.GetLastWriteTime (target)) < 0)
- continue;
- }
- File.Delete (target);
- }
- System.Diagnostics.Debug.WriteLine ("copy " + source + " to " + target);
- File.Copy (source, target);
- }
- string[] files = pfs.Where (p => p.Type == ItemType.Compile).Select (p => p.AbsolutePath).ToArray ();
-
- System.Diagnostics.Debug.WriteLine ("---- start compilation of :" + parameters.OutputAssembly);
- System.Diagnostics.Debug.WriteLine (parameters.CompilerOptions);
-
- CompilationResults = cp.CompileAssemblyFromFile (parameters, files);
-
- solution.UpdateErrorList ();
-
- return parameters.OutputAssembly;
- }
-
- public bool TryGetProjectFileFromAbsolutePath (string absolutePath, out ProjectFile pi) {
- pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault
- (pp => pp.AbsolutePath == absolutePath);
- return pi != null;
- }
- public bool TryGetProjectFileFromPath (string path, out ProjectFile pi) {
- if (path.StartsWith ("#", StringComparison.Ordinal))
- pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault
- (pp => pp.Type == ItemType.EmbeddedResource && pp.ResourceID == path.Substring (1));
- else
- pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault (pp => pp.Path == path);
-
- if (pi != null)
- return true;
-
- foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
- Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID);
- if (p == null)
- throw new Exception ("referenced project not found");
- if (p.TryGetProjectFileFromPath (path, out pi))
- return true;
- }
- //TODO: search referenced assemblies
- return false;
+ // if (ParentProject != null)
+ // ParentProject.Compile ();
+
+ // CSharpCodeProvider cp = new CSharpCodeProvider ();
+ // CompilerParameters parameters = new CompilerParameters ();
+
+ // foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
+ // Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID);
+ // if (p == null)
+ // throw new Exception ("referenced project not found");
+ // parameters.ReferencedAssemblies.Add (p.Compile ());
+ // }
+
+ // string outputDir = getDirectoryWithTokens (this.OutputPath);
+ // string objDir = getDirectoryWithTokens (this.IntermediateOutputPath);
+
+ // Directory.CreateDirectory (outputDir);
+ // Directory.CreateDirectory (objDir);
+
+ // parameters.OutputAssembly = System.IO.Path.Combine (outputDir, this.AssemblyName);
+
+ // // True - exe file generation, false - dll file generation
+ // if (this.OutputType == "Library") {
+ // parameters.GenerateExecutable = false;
+ // parameters.CompilerOptions += " /target:library";
+ // parameters.OutputAssembly += ".dll";
+ // } else {
+ // parameters.GenerateExecutable = true;
+ // parameters.CompilerOptions += " /target:exe";
+ // parameters.OutputAssembly += ".exe";
+ // parameters.MainClass = this.StartupObject;
+ // }
+
+ // parameters.GenerateInMemory = false;
+ // parameters.IncludeDebugInformation = this.DebugSymbols;
+ // parameters.TreatWarningsAsErrors = this.TreatWarningsAsErrors;
+ // parameters.WarningLevel = this.WarningLevel;
+ // parameters.CompilerOptions += " /noconfig";
+ // if (this.AllowUnsafeBlocks)
+ // parameters.CompilerOptions += " /unsafe";
+ // parameters.CompilerOptions += " /delaysign+";
+ // parameters.CompilerOptions += " /debug:full /debug+";
+ // parameters.CompilerOptions += " /optimize-";
+ // parameters.CompilerOptions += " /define:\"DEBUG;TRACE\"";
+ // parameters.CompilerOptions += " /nostdlib";
+
+
+
+ // foreach (ProjectItem pi in flattenNodes.Where (p => p.Type == ItemType.Reference)) {
+
+ // if (string.IsNullOrEmpty (pi.HintPath)) {
+ // parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/" + pi.Path + ".dll";
+ // continue;
+ // }
+ // parameters.ReferencedAssemblies.Add (pi.Path);
+ // string fullHintPath = System.IO.Path.GetFullPath (System.IO.Path.Combine (RootDir, pi.HintPath.Replace ('\\', '/')));
+ // if (File.Exists (fullHintPath)) {
+ // string outPath = System.IO.Path.Combine (outputDir, System.IO.Path.GetFileName (fullHintPath));
+ // if (!File.Exists (outPath))
+ // File.Copy (fullHintPath, outPath);
+ // }
+ // }
+ // parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/System.Core.dll";
+ // parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/mscorlib.dll";
+ // //parameters.ReferencedAssemblies.Add ("System.Core");
+ // //parameters.ReferencedAssemblies.Add ("mscorlib.dll");
+
+
+ // IEnumerable<ProjectFile> pfs = flattenNodes.OfType<ProjectFile> ();
+
+ // foreach (ProjectFile pi in pfs.Where (p => p.Type == ItemType.EmbeddedResource)) {
+
+ // string absPath = pi.AbsolutePath;
+ // string logicName = pi.LogicalName;
+ // if (string.IsNullOrEmpty (logicName))
+ // parameters.CompilerOptions += string.Format (" /resource:{0},{1}", absPath, this.Name + "." + pi.Path.Replace ('/', '.'));
+ // else
+ // parameters.CompilerOptions += string.Format (" /resource:{0},{1}", absPath, logicName);
+ // }
+ // foreach (ProjectFile pi in pfs.Where (p => p.Type == ItemType.None)) {
+ // if (pi.CopyToOutputDirectory == CopyToOutputState.Never)
+ // continue;
+ // string source = pi.AbsolutePath;
+ // string target = System.IO.Path.Combine (outputDir, pi.Path);
+ // Directory.CreateDirectory (System.IO.Path.GetDirectoryName (target));
+
+ // if (File.Exists (target)) {
+ // if (pi.CopyToOutputDirectory == CopyToOutputState.PreserveNewest) {
+ // if (DateTime.Compare (
+ // System.IO.File.GetLastWriteTime (source),
+ // System.IO.File.GetLastWriteTime (target)) < 0)
+ // continue;
+ // }
+ // File.Delete (target);
+ // }
+ // System.Diagnostics.Debug.WriteLine ("copy " + source + " to " + target);
+ // File.Copy (source, target);
+ // }
+ // string[] files = pfs.Where (p => p.Type == ItemType.Compile).Select (p => p.AbsolutePath).ToArray ();
+
+ // System.Diagnostics.Debug.WriteLine ("---- start compilation of :" + parameters.OutputAssembly);
+ // System.Diagnostics.Debug.WriteLine (parameters.CompilerOptions);
+
+ // CompilationResults = cp.CompileAssemblyFromFile (parameters, files);
+
+ // solution.UpdateErrorList ();
+
+ // return parameters.OutputAssembly;
+ //}
+
+ //public bool TryGetProjectFileFromAbsolutePath (string absolutePath, out ProjectFile pi) {
+ // pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault
+ // (pp => pp.AbsolutePath == absolutePath);
+ // return pi != null;
+ //}
+ //public bool TryGetProjectFileFromPath (string path, out ProjectFile pi) {
+ //if (path.StartsWith ("#", StringComparison.Ordinal))
+ // pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault
+ // (pp => pp.Type == ItemType.EmbeddedResource && pp.ResourceID == path.Substring (1));
+ //else
+ // pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault (pp => pp.Path == path);
+
+ //if (pi != null)
+ // return true;
+
+ //foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
+ // Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID);
+ // if (p == null)
+ // throw new Exception ("referenced project not found");
+ // if (p.TryGetProjectFileFromPath (path, out pi))
+ // return true;
+ //}
+ ////TODO: search referenced assemblies
+ return "";
}
public void GetDefaultTemplates () {
- IEnumerable<ProjectFile> tmpFiles =
- flattenNodes.OfType<ProjectFile> ().Where (pp => pp.Extension == ".template");
-
- foreach (ProjectFile pi in tmpFiles.Where (
- pp => pp.Type == ItemType.None && pp.CopyToOutputDirectory != CopyToOutputState.Never)) {
-
- string clsName = System.IO.Path.GetFileNameWithoutExtension (pi.Path);
- if (solution.DefaultTemplates.ContainsKey (clsName))
- continue;
- solution.DefaultTemplates[clsName] = pi.AbsolutePath;
- }
- foreach (ProjectFile pi in tmpFiles.Where (pp => pp.Type == ItemType.EmbeddedResource)) {
- string resId = pi.ResourceID;
- string clsName = resId.Substring (0, resId.Length - 9);
- if (solution.DefaultTemplates.ContainsKey (clsName))
- continue;
- solution.DefaultTemplates[clsName] = pi.Path;
- }
-
- foreach (Project p in ReferencedProjects)
- p.GetDefaultTemplates ();
+ //IEnumerable<ProjectFile> tmpFiles =
+ // flattenNodes.OfType<ProjectFile> ().Where (pp => pp.Extension == ".template");
+
+ //foreach (ProjectFile pi in tmpFiles.Where (
+ // pp => pp.Type == ItemType.None && pp.CopyToOutputDirectory != CopyToOutputState.Never)) {
+
+ // string clsName = System.IO.Path.GetFileNameWithoutExtension (pi.Path);
+ // if (solution.DefaultTemplates.ContainsKey (clsName))
+ // continue;
+ // solution.DefaultTemplates[clsName] = pi.AbsolutePath;
+ //}
+ //foreach (ProjectFile pi in tmpFiles.Where (pp => pp.Type == ItemType.EmbeddedResource)) {
+ // string resId = pi.ResourceID;
+ // string clsName = resId.Substring (0, resId.Length - 9);
+ // if (solution.DefaultTemplates.ContainsKey (clsName))
+ // continue;
+ // solution.DefaultTemplates[clsName] = pi.Path;
+ //}
+
+ //foreach (Project p in ReferencedProjects)
+ //p.GetDefaultTemplates ();
}
// void searchTemplatesIn(Assembly assembly){
// if (assembly == null)
public List<Project> ReferencedProjects {
get {
List<Project> tmp = new List<Project> ();
- foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
+ /*foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID);
if (p != null)
tmp.Add (p);
- }
+ }*/
return tmp;
}
}
public void GetStyling () {
- try {
+ /*try {
foreach (ProjectFile pi in flattenNodes.OfType<ProjectFile> ().Where (pp => pp.Type == ItemType.EmbeddedResource && pp.Extension == ".style")) {
using (Stream s = new MemoryStream (System.Text.Encoding.UTF8.GetBytes (pi.Source))) {
new StyleReader (solution.Styling, s, pi.ResourceID);
if (p != null)
//throw new Exception ("referenced project not found");
p.GetStyling ();
- }
+ }*/
//TODO:get styling from referenced assemblies
}
}
public string ResourceID {
- get {
- return Type != ItemType.EmbeddedResource ? null :
+ get {
+ return "todo";/* Type != ItemType.EmbeddedResource ? null :
node.SelectSingleNode ("LogicalName") == null ?
Project.Name + "." + Path.Replace ('/', '.') :
- LogicalName;
+ LogicalName;*/
}
}
public string LogicalName {
get {
- return node.SelectSingleNode ("LogicalName")?.InnerText;
+ return "todo";// node.SelectSingleNode ("LogicalName")?.InnerText;
}
}
public bool IsOpened {
public CopyToOutputState CopyToOutputDirectory {
get {
- XmlNode xn = node.SelectSingleNode ("CopyToOutputDirectory");
+ return CopyToOutputState.Never;
+ /*XmlNode xn = node.SelectSingleNode ("CopyToOutputDirectory");
return xn == null ? CopyToOutputState.Never :
- (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
+ (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);*/
}
}
using System.IO;
using Crow;
using System.Threading;
+using Microsoft.Build.Construction;
namespace Crow.Coding
{
public class ProjectItem : ProjectNode {
#region CTOR
public ProjectItem() {}
- public ProjectItem (Project project, XmlNode _node) : base (project){
+ public ProjectItem (Project project, Microsoft.Build.Evaluation.ProjectItem _node) : base (project){
node = _node;
}
#endregion
- public XmlNode node;
+ public Microsoft.Build.Evaluation.ProjectItem node;
public override Picture Icon {
get {
}
public string Path {
get {
- return node.Attributes["Include"]?.Value.Replace('\\','/');
+ return node.EvaluatedInclude?.Replace('\\','/');
}
}
public string AbsolutePath {
get {
- return System.IO.Path.Combine (Project.RootDir, Path);
+ return System.IO.Path.Combine (Project.Path, Path);
}
}
public override ItemType Type {
get {
- return (ItemType)Enum.Parse (typeof(ItemType), node.Name, true);
+ return (ItemType)Enum.Parse (typeof(ItemType), node.ItemType, true);
}
}
public override string DisplayName {
}
}
public string HintPath {
- get { return node.SelectSingleNode ("HintPath")?.InnerText; }
+ get { return "HintPath?"; }
}
public override bool IsSelected {
using System.IO;
using Crow;
using System.Threading;
+using Microsoft.Build.Construction;
namespace Crow.Coding
{
public class ProjectReference : ProjectItem {
- public ProjectReference (ProjectItem pi) : base (pi.Project, pi.node){
+ public ProjectReference (Project proj, Microsoft.Build.Evaluation.ProjectItem pi) : base (proj, pi){
}
public string ProjectGUID {
get {
- return node.SelectSingleNode ("Project")?.InnerText;
+ return "todo"; //node.SelectSingleNode ("Project")?.InnerText;
}
}
public override string DisplayName {
get {
- return node.SelectSingleNode ("Name").InnerText;
+ return "project Ref"; // node.SelectSingleNode ("Name").InnerText;
}
}
}
+++ /dev/null
-//
-// Solution.cs
-//
-//code taken in project https://sourceforge.net/projects/syncproj/
-// no licence info was included, I took the liberty to modify it.
-// Author:
-// tarmopikaro
-// 2018 Jean-Philippe Bruyère
-//MIT-licenced
-
-using Microsoft.Win32;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Xml.Serialization;
-using Crow;
-
-namespace Crow.Coding{
- public class SolutionProject {
- public string ProjectHostGuid;
- public string ProjectName;
- public string RelativePath;
- public string ProjectGuid;
- }
- public class StyleItemContainer {
- public object Value;
- public string Name;
- public StyleItemContainer(string name, object _value){
- Name = name;
- Value = _value;
- }
- }
- public class StyleContainer : IValueChange {
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public virtual void NotifyValueChanged(string MemberName, object _value)
- {
- ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
- }
- #endregion
-
- Style style;
- bool isExpanded;
-
- public string Name;
- public List<StyleItemContainer> Items;
- public bool IsExpanded
- {
- get { return isExpanded; }
- set
- {
- if (value == isExpanded)
- return;
- isExpanded = value;
- NotifyValueChanged ("IsExpanded", isExpanded);
- }
- }
- public StyleContainer(string name, Style _style){
- Name = name;
- style = _style;
-
- Items = new List<StyleItemContainer> ();
- foreach (string k in style.Keys) {
- Items.Add(new StyleItemContainer(k, style[k]));
- }
- }
- }
-
-
- /// <summary>
-/// .sln loaded into class.
-/// </summary>
- public class Solution: IValueChange
- {
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public virtual void NotifyValueChanged(string MemberName, object _value)
- {
- ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
- }
- #endregion
-
- ProjectItem selectedItem = null;
- object selectedItemElement = null;
- ObservableList<ProjectItem> openedItems = new ObservableList<ProjectItem>();
- ObservableList<GraphicObjectDesignContainer> toolboxItems;
-
- public Dictionary<string, Style> Styling;
- public Dictionary<string, string> DefaultTemplates;
-
- public List<Style> Styles { get { return Styling.Values.ToList(); }}
- public List<StyleContainer> StylingContainers;
- //TODO: check project dependencies if no startup proj
-
- public void ReloadStyling () {
- Styling = new Dictionary<string, Style> ();
- if (StartupProject != null)
- StartupProject.GetStyling ();
- StylingContainers = new List<StyleContainer> ();
- foreach (string k in Styling.Keys)
- StylingContainers.Add (new StyleContainer (k, Styling [k]));
- foreach (ImlProjectItem pf in openedItems.OfType<ImlProjectItem>()) {
- pf.SignalEditorOfType<ImlVisualEditor> ();
- }
- }
- public string[] AvailaibleStyles {
- get { return Styling == null ? new string[] {} : Styling.Keys.ToArray();}
- }
- public void ReloadDefaultTemplates () {
- DefaultTemplates = new Dictionary<string, string>();
- if (StartupProject != null)
- StartupProject.GetDefaultTemplates ();
- }
- public void updateToolboxItems () {
- Type[] crowItems = AppDomain.CurrentDomain.GetAssemblies ()
- .SelectMany (t => t.GetTypes ())
- .Where (t => t.IsClass && !t.IsAbstract && t.IsPublic &&
- t.Namespace == "Crow" && t.IsSubclassOf(typeof(Widget)) &&
- t.GetCustomAttribute<DesignIgnore>(false) == null).ToArray ();
- ToolboxItems = new ObservableList<GraphicObjectDesignContainer> ();
- foreach (Type ci in crowItems) {
- toolboxItems.AddElement(new GraphicObjectDesignContainer(ci));
- }
- }
- public bool GetProjectFileFromPath (string path, out ProjectFile pi){
- pi = null;
- return StartupProject == null ? false :
- StartupProject.TryGetProjectFileFromPath (path, out pi);
- }
-
- public ObservableList<ProjectItem> OpenedItems {
- get { return openedItems; }
- set {
- if (openedItems == value)
- return;
- openedItems = value;
- NotifyValueChanged ("OpenedItems", openedItems);
- }
- }
-
- public ObservableList<GraphicObjectDesignContainer> ToolboxItems {
- get { return toolboxItems; }
- set {
- if (toolboxItems == value)
- return;
- toolboxItems = value;
- NotifyValueChanged ("ToolboxItems", toolboxItems);
- }
- }
- public ProjectItem SelectedItem {
- get { return selectedItem; }
- set {
- if (selectedItem == value)
- return;
- if (SelectedItem != null)
- SelectedItem.IsSelected = false;
- selectedItem = value;
- if (SelectedItem != null)
- SelectedItem.IsSelected = true;
-
- UserConfig.Set ("SelectedProjItems", SelectedItem?.AbsolutePath);
-
- NotifyValueChanged ("SelectedItem", selectedItem);
- }
- }
- public object SelectedItemElement {
- get { return selectedItemElement; }
- set {
- if (selectedItemElement == value)
- return;
- selectedItemElement = value;
- NotifyValueChanged ("SelectedItemElement", selectedItemElement);
- }
- }
- public string DisplayName {
- get { return name; }
- }
- /// <summary>
- /// Gets solution path
- /// </summary>
- public String SolutionFolder
- {
- get { return Path.GetDirectoryName (path); }
- }
-
-// public System.CodeDom.Compiler.CompilerErrorCollection CompilationErrors {
-// get {
-// System.CodeDom.Compiler.CompilerErrorCollection tmp = Projects.SelectMany<Project>
-// (p => p.CompilationResults.Errors);
-// return tmp;
-// }
-// }
- public List<System.CodeDom.Compiler.CompilerError> CompilerErrors {
- get {
- int errCount = 0;
- for (int i = 0; i < Projects.Count; i++) {
- if (Projects [i].CompilationResults != null)
- errCount += Projects [i].CompilationResults.Errors.Count;
- }
- System.CodeDom.Compiler.CompilerError[] tmp = new System.CodeDom.Compiler.CompilerError[errCount];
-
- int ptr = 0;
- for (int i = 0; i < Projects.Count; i++) {
- if (Projects [i].CompilationResults == null)
- continue;
- Projects [i].CompilationResults.Errors.CopyTo (tmp,ptr);
- ptr += Projects [i].CompilationResults.Errors.Count;
- }
- return new List<System.CodeDom.Compiler.CompilerError>(tmp);
- }
- }
-
- public void UpdateErrorList () {
- NotifyValueChanged ("CompilerErrors", CompilerErrors);
- }
-
- void saveOpenedItemsInUserConfig (){
- if (openedItems.Count == 0)
- UserConfig.Set ("OpenedItems", "");
- else
- UserConfig.Set ("OpenedItems", openedItems.Select(o => o.AbsolutePath).Aggregate((a,b)=>a + ";" + b));
- }
- public void ReopenItemsSavedInUserConfig () {
- string tmp = UserConfig.Get<string> ("OpenedItems");
- string sel = UserConfig.Get<string> ("SelectedProjItems");
- ProjectFile selItem = null;
- if (string.IsNullOrEmpty (tmp))
- return;
- foreach (string f in tmp.Split(';')) {
- foreach (Project p in Projects) {
- ProjectFile pi;
- if (p.TryGetProjectFileFromAbsolutePath (f, out pi)) {
- pi.Open ();
- if (pi.AbsolutePath == sel)
- selItem = pi;
- break;
- }
- }
- }
- if (selItem == null)
- return;
- selItem.IsSelected = true;
- }
-
- /*void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
- SelectedItem = e.NewValue as ProjectItem;
- UserConfig.Set ("SelectedProjItems", SelectedItem?.AbsolutePath);
- }*/
-
- public void OpenItem (ProjectItem pi) {
- if (!openedItems.Contains (pi)) {
- openedItems.AddElement (pi);
- saveOpenedItemsInUserConfig ();
- }
- }
- public void CloseItem (ProjectItem pi) {
- openedItems.RemoveElement (pi);
- saveOpenedItemsInUserConfig ();
- }
-
- public void CloseSolution () {
- while (openedItems.Count > 0) {
- openedItems.RemoveElement (openedItems [0]);
- }
- while (toolboxItems.Count > 0) {
- toolboxItems.RemoveElement (toolboxItems [0]);
- }
- NotifyValueChanged ("Projects", null);
- }
- /// <summary>
- /// Solution name
- /// </summary>
- String name;
- /// <summary>
- /// File path from where solution was loaded.
- /// </summary>
- [XmlIgnore]
- String path;
-
- /// <summary>
- /// Solution name for debugger.
- /// </summary>
- [ExcludeFromCodeCoverage]
- public override string ToString()
- {
- return "Solution: " + name;
- }
-
- #region Solution properties
- double slnVer; // 11.00 - vs2010, 12.00 - vs2015
-
- /// <summary>
- /// Visual studio version information used for generation, for example 2010, 2012, 2015 and so on...
- /// </summary>
- public int fileFormatVersion;
-
- /// <summary>
- /// null for old visual studio's
- /// </summary>
- public String VisualStudioVersion;
-
- /// <summary>
- /// null for old visual studio's
- /// </summary>
- public String MinimumVisualStudioVersion;
-
- /// <summary>
- /// List of project included into solution.
- /// </summary>
- public List<Project> Projects = new List<Project>();
-
- /// <summary>
- /// List of configuration list, in form "{Configuration}|{Platform}", for example "Release|Win32".
- /// To extract individual platforms / configuration list, use following functions.
- /// </summary>
- public List<String> configurations = new List<string>();
-
- /// <summary>
- /// Extracts platfroms supported by solution
- /// </summary>
- public IEnumerable<String> getPlatforms()
- {
- return configurations.Select(x => x.Split('|')[1]).Distinct();
- }
-
- /// <summary>
- /// Extracts configuration names supported by solution
- /// </summary>
- public IEnumerable<String> getConfigurations()
- {
- return configurations.Select(x => x.Split('|')[0]).Distinct();
- }
- #endregion
-
- public Configuration UserConfig;
-
- public Project StartupProject {
- get { return Projects?.FirstOrDefault (p => p.ProjectGuid == UserConfig.Get<string> ("StartupProject")); }
- set {
- if (value == StartupProject)
- return;
- if (value == null)
- UserConfig.Set ("StartupProject", "");
- else {
- UserConfig.Set ("StartupProject", value.ProjectGuid);
- value.NotifyValueChanged("IsStartupProject", true);
- }
- NotifyValueChanged ("StartupProject", StartupProject);
- ReloadStyling ();
- ReloadDefaultTemplates ();
- }
- }
-
- #region CTOR
- /// <summary>
- /// Creates new solution.
- /// </summary>
- public Solution() {
- }
-
- #endregion
-
-
- #region Loading from SLN file
- /// <summary>
- /// Loads visual studio .sln solution
- /// </summary>
- /// <exception cref="System.IO.FileNotFoundException">The file specified in path was not found.</exception>
- static public Solution LoadSolution(string path)
- {
- Solution s = new Solution();
- s.path = path;
-
- String slnTxt = File.ReadAllText(path);
- //
- // Extra line feed is used by Visual studio, cmake does not generate extra line feed.
- //
- s.slnVer = Double.Parse(Regex.Match(slnTxt, "[\r\n]?Microsoft Visual Studio Solution File, Format Version ([0-9.]+)", RegexOptions.Multiline).Groups[1].Value, CultureInfo.InvariantCulture);
-
- int vsNumber = Int32.Parse(Regex.Match(slnTxt, "^\\# Visual Studio (Express )?([0-9]+)", RegexOptions.Multiline).Groups[2].Value);
- if (vsNumber > 2000)
- s.fileFormatVersion = vsNumber;
- else
- s.fileFormatVersion = vsNumber - 14 + 2015; // Visual Studio 14 => vs2015, formula might not be applicable for future vs versions.
-
- foreach (String line in new String[] { "VisualStudioVersion", "MinimumVisualStudioVersion" })
- {
- var m = Regex.Match(slnTxt, "^" + line + " = ([0-9.]+)", RegexOptions.Multiline);
- String v = null;
- if (m.Success)
- v = m.Groups[1].Value;
-
- s.GetType().GetField(line).SetValue(s, v);
- }
-
- Regex reProjects = new Regex(
- "Project\\(\"(?<ProjectHostGuid>{[A-F0-9-]+})\"\\) = \"(?<ProjectName>.*?)\", \"(?<RelativePath>.*?)\", \"(?<ProjectGuid>{[A-F0-9-]+})\"[\r\n]*(?<dependencies>.*?)EndProject[\r\n]+",
- RegexOptions.Singleline);
-
-
- reProjects.Replace(slnTxt, new MatchEvaluator(m =>
- {
- SolutionProject p = new SolutionProject ();
-
- foreach (String g in reProjects.GetGroupNames())
- {
- if (g == "0") //"0" - RegEx special kind of group
- continue;
-
- //
- // ProjectHostGuid, ProjectName, RelativePath, ProjectGuid fields/properties are set here.
- //
- String v = m.Groups[g].ToString();
- if (g != "dependencies")
- {
- FieldInfo fi = p.GetType().GetField(g);
- if (fi != null)
- {
- fi.SetValue(p, v);
- }
- else
- {
- p.GetType().GetProperty(g).SetValue(p, v);
- }
- continue;
- }
-
- if (v == "") // No dependencies set
- continue;
-
- String depsv = new Regex("ProjectSection\\(ProjectDependencies\\)[^\r\n]*?[\r\n]+" + "(.*?)" + "EndProjectSection", RegexOptions.Singleline).Match(v).Groups[1].Value;
-
- //
- // key is always equal to it's value.
- // http://stackoverflow.com/questions/5629981/question-about-visual-studio-sln-file-format
- //
- var ProjectDependencies = new Regex("\\s*?({[A-F0-9-]+}) = ({[A-F0-9-]+})[\r\n]+", RegexOptions.Multiline).Matches(depsv).Cast<Match>().Select(x => x.Groups[1].Value).ToList();
- } //foreach
- s.Projects.Add(new Project (s, p));
- return "";
- }
- )
- );
-
- new Regex("GlobalSection\\(SolutionConfigurationPlatforms\\).*?[\r\n]+(.*?)EndGlobalSection[\r\n]+", RegexOptions.Singleline).Replace(slnTxt, new MatchEvaluator(m2 =>
- {
- s.configurations = new Regex("\\s*(.*)\\s+=").Matches(m2.Groups[1].ToString()).Cast<Match>().Select(x => x.Groups[1].Value).ToList();
- return "";
- }
- ));
-
- Console.WriteLine ("******** CONFIG ***************");
-
- new Regex("GlobalSection\\(ProjectConfigurationPlatforms\\).*?[\r\n]+(.*?)EndGlobalSection[\r\n]+", RegexOptions.Singleline).Replace(slnTxt, new MatchEvaluator(m2 =>
- {
- foreach (Match m3 in new Regex("\\s*({[A-F0-9-]+})\\.(.*?)\\.(.*?)\\s+=\\s+(.*?)[\r\n]+").Matches(m2.Groups[1].ToString()))
- {
- String guid = m3.Groups[1].Value;
- String solutionConfig = m3.Groups[2].Value;
- String action = m3.Groups[3].Value;
- String projectConfig = m3.Groups[4].Value;
-
- Project p = s.Projects.Where(x => x.ProjectGuid == guid).FirstOrDefault();
- if (p == null)
- continue;
-
- Console.WriteLine ("{0},{1},{2},{3}",guid,solutionConfig,action,projectConfig);
-
- int iConfigIndex = s.configurations.IndexOf(solutionConfig);
- if (iConfigIndex == -1)
- continue;
-
-// while (p.slnConfigurations.Count < s.configurations.Count)
-// {
-// p.slnConfigurations.Add(null);
-// p.slnBuildProject.Add(false);
-// }
-//
-// if (action == "ActiveCfg")
-// {
-// p.slnConfigurations[iConfigIndex] = projectConfig;
-// }
-// else
-// {
-// if (action.StartsWith("Build"))
-// {
-// p.slnBuildProject[iConfigIndex] = true;
-// }
-// else
-// {
-// if (action.StartsWith("Deploy"))
-// {
-// if (p.slnDeployProject == null) p.slnDeployProject = new List<bool?>();
-//
-// while (p.slnDeployProject.Count < s.configurations.Count)
-// p.slnDeployProject.Add(null);
-//
-// p.slnDeployProject[iConfigIndex] = true;
-// }
-// }
-// } //if-esle
- }
- return "";
- }
- ));
-
- //
- // Initializes parent-child relationship.
- //
- new Regex("GlobalSection\\(NestedProjects\\).*?[\r\n]+(.*?)EndGlobalSection[\r\n]+", RegexOptions.Singleline).Replace(slnTxt, new MatchEvaluator(m4 =>
- {
- String v = m4.Groups[1].Value;
- new Regex("\\s*?({[A-F0-9-]+}) = ({[A-F0-9-]+})[\r\n]+", RegexOptions.Multiline).Replace(v, new MatchEvaluator(m5 =>
- {
- String[] args = m5.Groups.Cast<System.Text.RegularExpressions.Group>().Skip(1).Select(x => x.Value).ToArray();
- Project child = s.Projects.Where(x => args[0] == x.ProjectGuid).FirstOrDefault();
- Project parent = s.Projects.Where(x => args[1] == x.ProjectGuid).FirstOrDefault();
- parent.dependantProjects.Add(child);
- child.ParentProject = parent;
- return "";
- }));
- return "";
- }
- ));
-
- s.UserConfig = new Configuration (s.path + ".user");
- s.ReloadStyling ();
- s.ReloadDefaultTemplates ();
- s.updateToolboxItems ();
- return s;
- } //LoadSolution
- #endregion
- }
-}
--- /dev/null
+//
+// Solution.cs
+//
+//code taken in project https://sourceforge.net/projects/syncproj/
+// no licence info was included, I took the liberty to modify it.
+// Author:
+// tarmopikaro
+// 2018 Jean-Philippe Bruyère
+//MIT-licenced
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using Microsoft.Build.Construction;
+
+namespace Crow.Coding
+{
+ public class StyleItemContainer {
+ public object Value;
+ public string Name;
+ public StyleItemContainer(string name, object _value){
+ Name = name;
+ Value = _value;
+ }
+ }
+ public class StyleContainer : IValueChange {
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
+ Style style;
+ bool isExpanded;
+
+ public string Name;
+ public List<StyleItemContainer> Items;
+ public bool IsExpanded
+ {
+ get { return isExpanded; }
+ set
+ {
+ if (value == isExpanded)
+ return;
+ isExpanded = value;
+ NotifyValueChanged ("IsExpanded", isExpanded);
+ }
+ }
+ public StyleContainer(string name, Style _style){
+ Name = name;
+ style = _style;
+
+ Items = new List<StyleItemContainer> ();
+ foreach (string k in style.Keys) {
+ Items.Add(new StyleItemContainer(k, style[k]));
+ }
+ }
+ }
+
+
+ /// <summary>
+/// .sln loaded into class.
+/// </summary>
+ public class Workspace: IValueChange
+ {
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
+ SolutionFile solutionFile;
+
+ ProjectItem selectedItem = null;
+ object selectedItemElement = null;
+ ObservableList<ProjectItem> openedItems = new ObservableList<ProjectItem>();
+ ObservableList<GraphicObjectDesignContainer> toolboxItems;
+
+ public Dictionary<string, Style> Styling;
+ public Dictionary<string, string> DefaultTemplates;
+
+ public List<Style> Styles { get { return Styling.Values.ToList(); }}
+ public List<StyleContainer> StylingContainers;
+ //TODO: check project dependencies if no startup proj
+
+ public void ReloadStyling () {
+ Styling = new Dictionary<string, Style> ();
+ if (StartupProject != null)
+ StartupProject.GetStyling ();
+ StylingContainers = new List<StyleContainer> ();
+ foreach (string k in Styling.Keys)
+ StylingContainers.Add (new StyleContainer (k, Styling [k]));
+ foreach (ImlProjectItem pf in openedItems.OfType<ImlProjectItem>()) {
+ pf.SignalEditorOfType<ImlVisualEditor> ();
+ }
+ }
+ public string[] AvailaibleStyles {
+ get { return Styling == null ? new string[] {} : Styling.Keys.ToArray();}
+ }
+ public void ReloadDefaultTemplates () {
+ DefaultTemplates = new Dictionary<string, string>();
+ if (StartupProject != null)
+ StartupProject.GetDefaultTemplates ();
+ }
+ public void updateToolboxItems () {
+ Type[] crowItems = AppDomain.CurrentDomain.GetAssemblies ()
+ .SelectMany (t => t.GetTypes ())
+ .Where (t => t.IsClass && !t.IsAbstract && t.IsPublic &&
+ t.Namespace == "Crow" && t.IsSubclassOf(typeof(Widget)) &&
+ t.GetCustomAttribute<DesignIgnore>(false) == null).ToArray ();
+ ToolboxItems = new ObservableList<GraphicObjectDesignContainer> ();
+ foreach (Type ci in crowItems) {
+ toolboxItems.AddElement(new GraphicObjectDesignContainer(ci));
+ }
+ }
+ public bool GetProjectFileFromPath (string path, out ProjectFile pi){
+ pi = null;
+ return false;/* StartupProject == null ? false :
+ StartupProject.TryGetProjectFileFromPath (path, out pi);*/
+ }
+
+ public ObservableList<ProjectItem> OpenedItems {
+ get { return openedItems; }
+ set {
+ if (openedItems == value)
+ return;
+ openedItems = value;
+ NotifyValueChanged ("OpenedItems", openedItems);
+ }
+ }
+
+ public ObservableList<GraphicObjectDesignContainer> ToolboxItems {
+ get { return toolboxItems; }
+ set {
+ if (toolboxItems == value)
+ return;
+ toolboxItems = value;
+ NotifyValueChanged ("ToolboxItems", toolboxItems);
+ }
+ }
+ public ProjectItem SelectedItem {
+ get { return selectedItem; }
+ set {
+ if (selectedItem == value)
+ return;
+ if (SelectedItem != null)
+ SelectedItem.IsSelected = false;
+ selectedItem = value;
+ if (SelectedItem != null)
+ SelectedItem.IsSelected = true;
+
+ //UserConfig.Set ("SelectedProjItems", SelectedItem?.AbsolutePath);
+
+ NotifyValueChanged ("SelectedItem", selectedItem);
+ }
+ }
+ public object SelectedItemElement {
+ get { return selectedItemElement; }
+ set {
+ if (selectedItemElement == value)
+ return;
+ selectedItemElement = value;
+ NotifyValueChanged ("SelectedItemElement", selectedItemElement);
+ }
+ }
+ public string DisplayName {
+ get { return name; }
+ }
+ /// <summary>
+ /// Gets solution path
+ /// </summary>
+ public String SolutionFolder
+ {
+ get { return Path.GetDirectoryName (path); }
+ }
+
+// public System.CodeDom.Compiler.CompilerErrorCollection CompilationErrors {
+// get {
+// System.CodeDom.Compiler.CompilerErrorCollection tmp = Projects.SelectMany<Project>
+// (p => p.CompilationResults.Errors);
+// return tmp;
+// }
+// }
+ public List<System.CodeDom.Compiler.CompilerError> CompilerErrors {
+ get {
+ int errCount = 0;
+ for (int i = 0; i < Projects.Count; i++) {
+ if (Projects [i].CompilationResults != null)
+ errCount += Projects [i].CompilationResults.Errors.Count;
+ }
+ System.CodeDom.Compiler.CompilerError[] tmp = new System.CodeDom.Compiler.CompilerError[errCount];
+
+ int ptr = 0;
+ for (int i = 0; i < Projects.Count; i++) {
+ if (Projects [i].CompilationResults == null)
+ continue;
+ Projects [i].CompilationResults.Errors.CopyTo (tmp,ptr);
+ ptr += Projects [i].CompilationResults.Errors.Count;
+ }
+ return new List<System.CodeDom.Compiler.CompilerError>(tmp);
+ }
+ }
+
+ public void UpdateErrorList () {
+ NotifyValueChanged ("CompilerErrors", CompilerErrors);
+ }
+
+ void saveOpenedItemsInUserConfig (){
+ if (openedItems.Count == 0)
+ UserConfig.Set ("OpenedItems", "");
+ else
+ UserConfig.Set ("OpenedItems", openedItems.Select(o => o.AbsolutePath).Aggregate((a,b)=>a + ";" + b));
+ }
+ public void ReopenItemsSavedInUserConfig () {
+ string tmp = UserConfig.Get<string> ("OpenedItems");
+ string sel = UserConfig.Get<string> ("SelectedProjItems");
+ ProjectFile selItem = null;
+ if (string.IsNullOrEmpty (tmp))
+ return;
+ foreach (string f in tmp.Split(';')) {
+ foreach (Project p in Projects) {
+ ProjectFile pi;
+ /*if (p.TryGetProjectFileFromAbsolutePath (f, out pi)) {
+ pi.Open ();
+ if (pi.AbsolutePath == sel)
+ selItem = pi;
+ break;
+ }*/
+ }
+ }
+ if (selItem == null)
+ return;
+ selItem.IsSelected = true;
+ }
+
+ /*void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
+ SelectedItem = e.NewValue as ProjectItem;
+ UserConfig.Set ("SelectedProjItems", SelectedItem?.AbsolutePath);
+ }*/
+
+ public void OpenItem (ProjectItem pi) {
+ if (!openedItems.Contains (pi)) {
+ openedItems.AddElement (pi);
+ saveOpenedItemsInUserConfig ();
+ }
+ }
+ public void CloseItem (ProjectItem pi) {
+ openedItems.RemoveElement (pi);
+ saveOpenedItemsInUserConfig ();
+ }
+
+ public void CloseSolution () {
+ while (openedItems.Count > 0) {
+ openedItems.RemoveElement (openedItems [0]);
+ }
+ while (toolboxItems?.Count > 0) {
+ toolboxItems.RemoveElement (toolboxItems [0]);
+ }
+ NotifyValueChanged ("Projects", null);
+ }
+ /// <summary>
+ /// Solution name
+ /// </summary>
+ String name;
+ /// <summary>
+ /// File path from where solution was loaded.
+ /// </summary>
+ [XmlIgnore]
+ String path;
+
+ /// <summary>
+ /// Solution name for debugger.
+ /// </summary>
+ [ExcludeFromCodeCoverage]
+ public override string ToString()
+ {
+ return "Solution: " + name;
+ }
+
+ #region Solution properties
+ double slnVer; // 11.00 - vs2010, 12.00 - vs2015
+
+ /// <summary>
+ /// Visual studio version information used for generation, for example 2010, 2012, 2015 and so on...
+ /// </summary>
+ public int fileFormatVersion;
+
+ /// <summary>
+ /// null for old visual studio's
+ /// </summary>
+ public String VisualStudioVersion;
+
+ /// <summary>
+ /// null for old visual studio's
+ /// </summary>
+ public String MinimumVisualStudioVersion;
+
+ /// <summary>
+ /// List of project included into solution.
+ /// </summary>
+ public List<Project> Projects = new List<Project>();
+
+ /// <summary>
+ /// List of configuration list, in form "{Configuration}|{Platform}", for example "Release|Win32".
+ /// To extract individual platforms / configuration list, use following functions.
+ /// </summary>
+ public List<String> configurations = new List<string>();
+
+ /// <summary>
+ /// Extracts platfroms supported by solution
+ /// </summary>
+ public IEnumerable<String> getPlatforms()
+ {
+ return configurations.Select(x => x.Split('|')[1]).Distinct();
+ }
+
+ /// <summary>
+ /// Extracts configuration names supported by solution
+ /// </summary>
+ public IEnumerable<String> getConfigurations()
+ {
+ return configurations.Select(x => x.Split('|')[0]).Distinct();
+ }
+ #endregion
+
+ public Configuration UserConfig;
+
+ public Project StartupProject {
+ get { return null; }// Projects?.FirstOrDefault (p => p.ProjectGuid == UserConfig.Get<string> ("StartupProject")); }
+ set {
+ if (value == StartupProject)
+ return;
+ if (value == null)
+ UserConfig.Set ("StartupProject", "");
+ else {
+ UserConfig.Set ("StartupProject", value.ProjectGuid);
+ value.NotifyValueChanged("IsStartupProject", true);
+ }
+ NotifyValueChanged ("StartupProject", StartupProject);
+ ReloadStyling ();
+ ReloadDefaultTemplates ();
+ }
+ }
+
+ #region CTOR
+ /// <summary>
+ /// Creates new solution.
+ /// </summary>
+ public Workspace (string path)
+ {
+ this.path = path;
+ solutionFile = SolutionFile.Parse (path);
+ UserConfig = new Configuration (path + ".user");
+
+ foreach (ProjectInSolution pis in solutionFile.ProjectsInOrder) {
+ switch (pis.ProjectType) {
+ case SolutionProjectType.Unknown:
+ break;
+ case SolutionProjectType.KnownToBeMSBuildFormat:
+ Projects.Add (new Project (this, pis));
+ break;
+ case SolutionProjectType.SolutionFolder:
+ break;
+ case SolutionProjectType.WebProject:
+ break;
+ case SolutionProjectType.WebDeploymentProject:
+ break;
+ case SolutionProjectType.EtpSubProject:
+ break;
+ case SolutionProjectType.SharedProject:
+ break;
+ }
+ }
+ }
+ #endregion
+ }
+}
-using Crow;
+using System;
+using Crow;
namespace HelloWorld
{
class Program : Interface {
+ Command CMDQuit;
static void Main (string[] args) {
using (Program vke = new Program ()) {
- vke.Load ("#HelloWorld.helloworld.crow");
vke.Run ();
}
}
+ protected override void Startup ()
+ {
+ CMDQuit = new Command (new Action (() => running = false)) { Caption = "Quit", Icon = new SvgPicture ("#Crow.Icons.exit-symbol.svg") };
+
+ Widget w = Load ("#HelloWorld.helloworld.crow");
+ w.KeyPress += W_KeyPress;
+ w.DataSource = this;
+ }
+
+ Color [] colors = { Color.Blue, Color.DarkGoldenRod, Color.Red, Color.Azure, Color.Brown, Color.Black, Color.White, Color.Pink };
+ int ptr = 0;
+
+ void W_KeyPress (object sender, KeyPressEventArgs e)
+ {
+ switch (e.KeyChar) {
+ case 'w':
+ LoadIMLFragment ($"<DockWindow Name='win{ptr}' Left='450' Top='450' Width='150' Height='150' Background='{colors [ptr]}'/>");
+ break;
+ case 'x':
+ LoadIMLFragment ($"<Window Name='win{ptr}' Left='450' Top='450' Width='150' Height='150' Background='{colors [ptr]}'/>");
+ break;
+ }
+
+ ptr++;
+ if (ptr == colors.Length)
+ ptr = 0;
+ }
+
}
}
using (Showcase app = new Showcase ()) {
//app.Keyboard.KeyDown += App_KeyboardKeyDown;
- Widget g = app.Load ("#ShowCase.showcase.crow");
- g.DataSource = app;
- app.crowContainer = g.FindByName ("CrowContainer") as Container;
- //I set an empty object as datasource at this level to force update when new
- //widgets are added to the interface
- app.crowContainer.DataSource = new object ();
- app.hideError ();
app.Run ();
}
}
+ protected override void Startup ()
+ {
+ Widget g = Load ("#ShowCase.showcase.crow");
+ g.DataSource = this;
+ crowContainer = g.FindByName ("CrowContainer") as Container;
+ //I set an empty object as datasource at this level to force update when new
+ //widgets are added to the interface
+ crowContainer.DataSource = new object ();
+ hideError ();
+ }
+
static void App_KeyboardKeyDown (object sender, KeyEventArgs e)
{
#if DEBUG_LOG
<?xml version="1.0"?>
-<Container Background="Yellow" Margin="10" Width="90%" Height="90%">
- <Widget Margin="10" Width="50%" Height="50%" Background="Yellow"
+<Container Background="Blue" Margin="1" Width="90%" Height="90%">
+ <Widget Margin="1" Width="50%" Height="50%" Background="Red"
MinimumSize="50,50"/>
</Container>
\ No newline at end of file
<?xml version="1.0"?>
-<Container Background="DimGrey" Margin="10" Fit="true">
- <Label Text="{fps}" Margin="10" Fit="true" Background="SeaGreen"/>
+<Container Background="Blue" Margin="10" Fit="true">
+ <Label Text="tes" Margin="10" Fit="true" Background="SeaGreen"/>
</Container>
\ No newline at end of file
<?xml version="1.0"?>
<VerticalStack Fit="true">
<TextBox Text="{Datas}" Width="100" />
- <Button Text="Set Text to Null" MouseClick="onSetDataToNull"/>
+ <Button Caption="Set Text to Null" MouseClick="onSetDataToNull"/>
</VerticalStack>
\ No newline at end of file
<Label Text="{Hover}" Background="DarkGreen"/>
<Button Caption="Clear" Width="Stretched" MouseClick="OnClear"/>
<ListBox Name="ColorList" Data="{TestList}" Width="200" Height="200"
- ItemTemplate="#Tests.Interfaces.colorItem.crow">
+ ItemTemplate="Interfaces/colorItem.crow">
</ListBox>
<Button Caption="Load list" Width="Stretched" MouseClick="OnLoadList"/>
</VerticalStack>
<?xml version="1.0"?>
<Container Background="DimGrey" Width="300">
- <ComboBox Data="{TestList}" ItemTemplate="#Tests.Interfaces.colorItem.crow"/>
+ <ComboBox Data="{TestList}" ItemTemplate="Interfaces/colorItem.crow"/>
</Container>
\ No newline at end of file