}
void initIcons () {
- icoMove = new SvgPicture ();
- icoMove.Load (IFace, "#Crow.Coding.icons.move-arrows.svg");
+ icoMove = new SvgPicture ("#Crow.Coding.icons.move-arrows.svg");
+ icoMove.Load (IFace);
// icoStyle = new SvgPicture ();
// icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg");
}
lock (go.IFace.UpdateMutex) {
go.IFace.DragImageHeight = dragIconSize;
go.IFace.DragImageWidth = dragIconSize;
- SvgPicture pic = new SvgPicture ();
- pic.Load (go.IFace, IconPath);
+ SvgPicture pic = new SvgPicture (IconPath);
+ pic.Load (go.IFace);
ImageSurface img = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize);
using (Context ctx = new Context (img)) {
Rectangle r = new Rectangle (0, 0, dragIconSize, dragIconSize);
</VerticalStack>
<Splitter/>
<IMLContainer Path="#Crow.Coding.ui.SourceEditor.crow"/>
-<!-- <Label DataSource="{../editor.Error}" Text="{}"
- Visible="{../editor.HasError}"
- Height="Fit" Width="Stretched" Background="DarkRed" Foreground="White"
- TextAlignment="TopLeft" Multiline="true"/>-->
</VerticalStack>
</TabItem>
this.KeyDown += KeyboardKeyDown1;
//testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" };
- testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
+ //testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
//testFiles = new string [] { @"Interfaces/Divers/0.crow" };
+ //testFiles = new string [] { @"Interfaces/Divers/testIMLContainer.crow" };
+ testFiles = new string [] { @"Interfaces/TemplatedContainer/testTabView.crow" };
//testFiles = new string [] { @"Interfaces/TemplatedContainer/testTreeView.crow" };
//testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
// testFiles = new string[] { @"Interfaces/TemplatedControl/testItemTemplateTag.crow" };
<Slider Orientation="Vertical" Height="Stretched" Width="20" Background="DimGray"/>
<Label Name="ShowTarget" Background="DarkBlue"/>
</VerticalStack>-->
-<Slider Orientation="Horizontal" Height="10" Width="100" Background="DimGray"/>
\ No newline at end of file
+<Popper >
+ <Label/>
+</Popper>
\ No newline at end of file
/// load the image for rendering from the path given as argument
/// </summary>
/// <param name="path">image path, may be embedded</param>
- public override void Load (Interface iface, string path)
+ public override void Load (Interface iface)
{
- Path = path;
- if (sharedResources.ContainsKey (path)) {
- sharedPicture sp = sharedResources [path];
+ Loaded = false;
+ if (iface == null)
+ return;
+
+ if (sharedResources.ContainsKey (Path)) {
+ sharedPicture sp = sharedResources [Path];
image = (byte[])sp.Data;
Dimensions = sp.Dims;
} else {
- using (Stream stream = iface.GetStreamFromPath (path)) {
+ using (Stream stream = iface.GetStreamFromPath (Path)) {
loadBitmap (new System.Drawing.Bitmap (stream));
}
- sharedResources [path] = new sharedPicture (image, Dimensions);
+ sharedResources [Path] = new sharedPicture (image, Dimensions);
}
Loaded = true;
}
throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString());
#endif
- if (IFace.HoverWidget != null) {
- if (IFace.HoverWidget.IsOrIsInside(this))
- IFace.HoverWidget = null;
- }
- if (IFace.ActiveWidget != null) {
- if (IFace.ActiveWidget.IsOrIsInside (this))
- IFace.ActiveWidget = null;
- }
- if (IFace.FocusedWidget != null) {
- if (IFace.FocusedWidget.IsOrIsInside (this))
- IFace.FocusedWidget = null;
- }
- if (!localDataSourceIsNull)
- DataSource = null;
-
- parentRWLock.EnterWriteLock();
- parent = null;
- parentRWLock.ExitWriteLock();
+// if (IFace.HoverWidget != null) {
+// if (IFace.HoverWidget.IsOrIsInside(this))
+// IFace.HoverWidget = null;
+// }
+// if (IFace.ActiveWidget != null) {
+// if (IFace.ActiveWidget.IsOrIsInside (this))
+// IFace.ActiveWidget = null;
+// }
+// if (IFace.FocusedWidget != null) {
+// if (IFace.FocusedWidget.IsOrIsInside (this))
+// IFace.FocusedWidget = null;
+// }
+// if (!localDataSourceIsNull)
+// DataSource = null;
+
+ //parentRWLock.EnterWriteLock();
+ Parent = null;
+ //parentRWLock.ExitWriteLock();
} else
Debug.WriteLine ("!!! Finalized by GC: {0}", this.ToString ());
Clipping?.Dispose ();
/// <summary>
/// interface this widget is bound to, this should not be changed once the instance is created
/// </summary>
- public Interface IFace = null;
-
+ public Interface IFace { get { return parent?.IFace; }}
/// <summary>
/// contains the dirty rectangles in the coordinate system of the cache. those dirty zones
/// are repeated at each cached levels of the tree with correspondig coordinate system. This is done
/// <param name="iface">Iface.</param>
public GraphicObject (Interface iface) : this()
{
- IFace = iface;
- Initialize ();
+ //IFace = iface;
+ Initialize (iface);
}
#endregion
//internal bool initialized = false;
/// <summary>
/// Initialize this Graphic object instance by setting style and default values and loading template if required
/// </summary>
- public virtual void Initialize(){
- loadDefaultValues ();
+ public virtual void Initialize(Interface iFace){
+ loadDefaultValues (iFace);
//initialized = true;
}
#region private fields
#region Default and Style Values loading
/// <summary> Loads the default values from XML attributes default </summary>
- public void loadDefaultValues()
+ public void loadDefaultValues(Interface iFace)
{
// #if DEBUG_LOAD
// Debug.WriteLine ("LoadDefValues for " + this.ToString ());
Type thisType = this.GetType ();
if (!string.IsNullOrEmpty (Style)) {
- if (IFace.DefaultValuesLoader.ContainsKey (Style)) {
- IFace.DefaultValuesLoader [Style] (this);
+ if (iFace.DefaultValuesLoader.ContainsKey (Style)) {
+ iFace.DefaultValuesLoader [Style] (this);
onInitialized (this, null);
return;
}
- } else if (IFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
- IFace.DefaultValuesLoader [thisType.FullName] (this);
+ } else if (iFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
+ iFace.DefaultValuesLoader [thisType.FullName] (this);
onInitialized (this, null);
return;
- } else if (IFace.DefaultValuesLoader.ContainsKey (thisType.Name)) {
- IFace.DefaultValuesLoader [thisType.Name] (this);
+ } else if (iFace.DefaultValuesLoader.ContainsKey (thisType.Name)) {
+ iFace.DefaultValuesLoader [thisType.Name] (this);
onInitialized (this, null);
return;
}
// those files being placed in a Styles folder
string styleKey = Style;
if (!string.IsNullOrEmpty (Style)) {
- if (IFace.Styling.ContainsKey (Style)) {
- styling.Add (IFace.Styling [Style]);
+ if (iFace.Styling.ContainsKey (Style)) {
+ styling.Add (iFace.Styling [Style]);
}
}
- if (IFace.Styling.ContainsKey (thisType.FullName)) {
- styling.Add (IFace.Styling [thisType.FullName]);
+ if (iFace.Styling.ContainsKey (thisType.FullName)) {
+ styling.Add (iFace.Styling [thisType.FullName]);
if (string.IsNullOrEmpty (styleKey))
styleKey = thisType.FullName;
}
- if (IFace.Styling.ContainsKey (thisType.Name)) {
- styling.Add (IFace.Styling [thisType.Name]);
+ if (iFace.Styling.ContainsKey (thisType.Name)) {
+ styling.Add (iFace.Styling [thisType.Name]);
if (string.IsNullOrEmpty (styleKey))
styleKey = thisType.Name;
}
#endregion
try {
- IFace.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
- IFace.DefaultValuesLoader[styleKey] (this);
+ iFace.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
+ iFace.DefaultValuesLoader[styleKey] (this);
} catch (Exception ex) {
throw new Exception ("Error applying style <" + styleKey + ">:", ex);
}
IsDirty = true;
EnqueueForRepaint ();
}
- protected void EnqueueForRepaint (){
+ protected virtual void EnqueueForRepaint (){
//if no layouting remains in queue for item, registre for redraw
if (requestedLayoutings != LayoutingType.None)
RegisterForLayouting ();
- else if (RegisteredLayoutings == LayoutingType.None && IsDirty)
- IFace.EnqueueForRepaint (this);
+ else if (RegisteredLayoutings == LayoutingType.None && IsDirty) {
+ Interface iface = IFace;
+ if (iface != null)
+ IFace.EnqueueForRepaint (this);
+ }
}
#endregion
public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
}
public virtual bool ArrangeChildren { get { return false; } }
+
public virtual void RegisterForLayouting(LayoutingType layoutType = LayoutingType.None){
- if (Parent == null || !Monitor.TryEnter(IFace.LayoutMutex)) {
+ Interface iface = IFace;
+ if (iface == null || !Monitor.TryEnter(IFace.LayoutMutex)) {
requestedLayoutings |= layoutType;
-// if (registeredLayoutings != LayoutingType.None)
-// Debugger.Break ();
return;
}
layoutType |= requestedLayoutings;
if (Parent is GraphicObject)
(Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
-// //prevent queueing same LayoutingType for this
-// layoutType &= (~RegisteredLayoutings);
-
if (layoutType == LayoutingType.None) {
Monitor.Exit (IFace.LayoutMutex);
return;
//enqueue LQI LayoutingTypes separately
if (layoutType.HasFlag (LayoutingType.Width))
- IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+ iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
if (layoutType.HasFlag (LayoutingType.Height))
- IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+ iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
if (layoutType.HasFlag (LayoutingType.X))
- IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+ iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
if (layoutType.HasFlag (LayoutingType.Y))
- IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+ iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
- IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+ iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
Monitor.Exit (IFace.LayoutMutex);
}
/// to the parent in the graphic tree </summary>
ILayoutable LogicalParent { get; set; }
+ Interface IFace { get; }
+
Rectangle ClientRectangle { get; }
Rectangle getSlot();
}
string path;
+ bool loaded = true;
public string Path {
get { return path; }
if (path == value)
return;
path = value;
- this.SetChild (IFace.Load (path));
+
+ if (path == null)
+ this.SetChild (null);
+ else
+ loaded = false;
+
NotifyValueChanged ("Path", path);
}
}
+ protected override void EnqueueForRepaint ()
+ {
+ if (!loaded) {
+ Interface iface = IFace;
+ if (iface != null) {
+ this.SetChild (iface.Load (path));
+ loaded = true;
+ RegisterForGraphicUpdate ();
+ return;
+ }
+ }
+ base.EnqueueForRepaint ();
+ }
+ protected override void SetChild (GraphicObject _child)
+ {
+ base.SetChild (_child);
+ if (_child != null) {
+ if (_child.localDataSourceIsNull) {
+ object ds = DataSource;
+ if (ds != null)
+ OnDataSourceChanged (this, new DataSourceChangeEventArgs (null, ds));
+ }
+ }
+ }
}
}
set {
if (value == Path)
return;
- try {
- if (string.IsNullOrEmpty(value))
- Picture = null;
- else {
- //lock(IFace.LayoutMutex){
- LoadImage (value);
- //}
- }
- } catch (Exception ex) {
- Debug.WriteLine (ex.Message);
+ if (string.IsNullOrEmpty (value))
_pic = null;
+ else {
+ if (value.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
+ _pic = new SvgPicture (value);
+ else
+ _pic = new BmpPicture (value);
+ _pic.Scaled = scaled;
+ _pic.KeepProportions = keepProps;
}
NotifyValueChanged ("Path", Path);
+ RegisterForGraphicUpdate ();
}
}
/// <summary>
_pic = value;
if (_pic!=null){
if (!_pic.Loaded)
- _pic.Load (IFace, _pic.Path);
+ _pic.Load (IFace);
Scaled = _pic.Scaled;
KeepProportions = _pic.KeepProportions;
}
}
#endregion
- #region Image Loading
- public void LoadImage (string path)
- {
- Picture pic;
- if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
- pic = new SvgPicture (path);
- else
- pic = new BmpPicture (path);
-
- pic.Load (IFace, path);
- pic.Scaled = scaled;
- pic.KeepProportions = keepProps;
-
- Picture = pic;
- }
- #endregion
#region GraphicObject overrides
+ protected override void EnqueueForRepaint ()
+ {
+ if (_pic != null) {
+ if (!_pic.Loaded) {
+ Interface iface = IFace;
+ if (iface != null) {
+ _pic.Load (iface);
+ RegisterForGraphicUpdate ();
+ }
+ return;
+ }
+ }
+ base.EnqueueForRepaint ();
+ }
public override int measureRawSize (LayoutingType lt)
{
if (_pic == null)
return 2 * Margin;
//_pic = "#Crow.Images.Icons.IconAlerte.svg";
+
+ if (!_pic.Loaded)
+ _pic.Load (IFace);
+
//TODO:take scalling in account
if (lt == LayoutingType.Width)
return _pic.Dimensions.Width + 2 * Margin;
base.onDraw (gr);
if (_pic == null)
- return;
+ return;
_pic.Paint (gr, ClientRectangle, _svgSub);
}
- protected override void loadTemplate (GraphicObject template)
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null)
{
- base.loadTemplate (template);
+ base.loadTemplate (iFace, template);
NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg");
}
string message, okMessage, cancelMessage, noMessage;
}
public virtual void onUnpop(object sender, EventArgs e)
{
- if (Content != null) {
+ if (Content != null)
Content.Visible = false;
- }
+
Unpoped.Raise (this, e);
}
public ProgressBar(Interface iface) : base(iface){}
#endregion
- protected override void loadTemplate (GraphicObject template)
- {
-
- }
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null){}
#region GraphicObject overrides
protected override void onDraw (Context gr)
#region implemented abstract members of TemplatedControl
- protected override void loadTemplate (GraphicObject template = null)
- {
-
- }
-
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null){}
#endregion
#region private fields
value.LogicalParent = this;
}
}
- protected override void loadTemplate(GraphicObject template = null)
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null)
{
- base.loadTemplate (template);
+ base.loadTemplate (iFace, template);
titleWidget = this.child.FindByName ("TabTitle");
}
set {
base.Parent = value;
if (value != null) {
- dragStartPoint = IFace.Mouse.Position;
+ //dragStartPoint = IFace.Mouse.Position;
savedParent = value as TabView;
}
}
get { return _contentContainer?.Child != null; }
}
//TODO: move loadTemplate and ResolveBinding in TemplatedContainer
- protected override void loadTemplate(GraphicObject template = null)
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null)
{
- base.loadTemplate (template);
+ base.loadTemplate (iFace, template);
_contentContainer = this.child.FindByName ("Content") as Container;
}
public TemplatedControl (Interface iface) : base(iface){}
#endregion
- string _template;
+ string templatePath;
string caption;
/// <summary>
//TODO: this property should be renamed 'TemplatePath'
[XmlAttributeAttribute][DefaultValue(null)]
public string Template {
- get { return _template; }
+ get { return templatePath; }
set {
if (Template == value)
return;
- _template = value;
+ templatePath = value;
- if (string.IsNullOrEmpty(_template))
- loadTemplate ();
- else
- loadTemplate (IFace.Load (_template));
+// if (string.IsNullOrEmpty(templatePath))
+// loadTemplate ();
+// else
+// loadTemplate (IFace.Load (templatePath));
}
}
/// <summary>
#region GraphicObject overrides
- public override void Initialize ()
+ public override void Initialize (Interface iFace)
{
- loadTemplate ();
- base.Initialize ();
+ loadTemplate (iFace);
+ base.Initialize (iFace);
}
/// <summary>
/// override search method from GraphicObject to prevent
/// Loads the template.
/// </summary>
/// <param name="template">Optional template instance</param>
- protected virtual void loadTemplate(GraphicObject template = null)
+ protected virtual void loadTemplate(Interface iFace, GraphicObject template = null)
{
if (this.child != null)//template change, bindings has to be reset
this.ClearTemplateBinding();
if (template == null) {
- if (!IFace.DefaultTemplates.ContainsKey (this.GetType ().FullName))
+ if (!iFace.DefaultTemplates.ContainsKey (this.GetType ().FullName))
throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName));
- this.SetChild (IFace.Load (IFace.DefaultTemplates[this.GetType ().FullName]));
+ this.SetChild (iFace.Load (iFace.DefaultTemplates[this.GetType ().FullName]));
}else
this.SetChild (template);
}
NotifyValueChanged("ItemTemplate", _itemTemplate);
}
}
- protected override void loadTemplate(GraphicObject template = null)
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null)
{
- base.loadTemplate (template);
+ base.loadTemplate (iFace, template);
items = this.child.FindByName ("ItemsContainer") as Group;
if (items == null)
#endregion
#region TemplatedContainer overrides
- protected override void loadTemplate(GraphicObject template = null)
+ protected override void loadTemplate(Interface iFace, GraphicObject template = null)
{
- base.loadTemplate (template);
+ base.loadTemplate (iFace, template);
NotifyValueChanged ("ShowNormal", false);
NotifyValueChanged ("ShowMinimize", true);
protected void butQuitPress (object sender, MouseButtonEventArgs e)
{
- IFace.MouseCursor = XCursor.Default;
+ //IFace.MouseCursor = XCursor.Default;
close ();
}
throw new Exception ("No default parameterless constructor found in " + rootType.Name);
il.Emit (OpCodes.Newobj, ci);
il.Emit (OpCodes.Stloc_0);
- CompilerServices.emitSetCurInterface (il);
+ //CompilerServices.emitSetCurInterface (il);
}
public NodeAddress CurrentNodeAddress {
if (!inlineTemplate) {//load from path or default template
ctx.il.Emit (OpCodes.Ldloc_0);//Load current templatedControl ref
+ ctx.il.Emit (OpCodes.Ldarg_1);//load currentInterface
if (string.IsNullOrEmpty (templatePath)) {
ctx.il.Emit (OpCodes.Ldnull);//default template loading
} else {
}
}
ctx.il.Emit (OpCodes.Ldloc_0);
+ ctx.il.Emit (OpCodes.Ldarg_1);//load currentInterface
ctx.il.Emit (OpCodes.Callvirt, CompilerServices.miLoadDefaultVals);
#endregion
throw new Exception (reader.Name + " type not found");
ConstructorInfo ci = t.GetConstructor (
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
- null, Type.EmptyTypes, null);
+ null, Type.EmptyTypes, null);
if (ci == null)
throw new Exception ("No default parameterless constructor found in " + t.Name);
ctx.il.Emit (OpCodes.Newobj, ci);
ctx.il.Emit (OpCodes.Stloc_0);//child is now loc_0
- CompilerServices.emitSetCurInterface (ctx.il);
+ //CompilerServices.emitSetCurInterface (ctx.il);
ctx.nodesStack.Push (new Node (t, nodeIdx));
emitLoader (reader, ctx);
ctx.nodesStack.Pop ();
+ MethodInfo miAdd = ctx.nodesStack.Peek ().GetAddMethod (nodeIdx);
+ if (miAdd == CompilerServices.miLoadTmp)
+ ctx.il.Emit (OpCodes.Ldarg_1);//push cur iface if tmp load
ctx.il.Emit (OpCodes.Ldloc_0);//load child on stack for parenting
- ctx.il.Emit (OpCodes.Callvirt, ctx.nodesStack.Peek().GetAddMethod(nodeIdx));
+ ctx.il.Emit (OpCodes.Callvirt, miAdd);
ctx.il.Emit (OpCodes.Stloc_0); //reset local to current go
nodeIdx++;
loadCursors ();
loadStyling ();
findAvailableTemplates ();
- initTooltip ();
- initContextMenus ();
+// initTooltip ();
+// initContextMenus ();
}
#region Static and constants
#endregion
#region ILayoutable implementation
+ /// </summary>
+ public Interface IFace { get { return this; }}
+
public virtual bool PointIsIn(ref Point m)
{
return true;
/// load the image for rendering from the stream given as argument
/// </summary>
/// <param name="stream">picture stream</param>
- public abstract void Load(Interface iface, string path);
+ public abstract void Load(Interface iface);
#endregion
/// <summary>
{}
#endregion
- public override void Load (Interface iface, string path)
- {
- Path = path;
- if (sharedResources.ContainsKey (path)) {
- sharedPicture sp = sharedResources [path];
+ public override void Load (Interface iface)
+ {
+ Loaded = false;
+ if (iface == null)
+ return;
+ if (sharedResources.ContainsKey (Path)) {
+ sharedPicture sp = sharedResources [Path];
hSVG = (Rsvg.Handle)sp.Data;
Dimensions = sp.Dims;
} else {
- using (Stream stream = iface.GetStreamFromPath (path)) {
- using (MemoryStream ms = new MemoryStream ()) {
- stream.CopyTo (ms);
-
- hSVG = new Rsvg.Handle (ms.ToArray ());
- Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+ try {
+ using (Stream stream = iface.GetStreamFromPath (Path)) {
+ using (MemoryStream ms = new MemoryStream ()) {
+ stream.CopyTo (ms);
+
+ hSVG = new Rsvg.Handle (ms.ToArray ());
+ Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+ }
}
+ sharedResources [Path] = new sharedPicture (hSVG, Dimensions);
+ } catch (Exception ex) {
+
}
- sharedResources [path] = new sharedPicture (hSVG, Dimensions);
}
Loaded = true;
}