ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin));
}
#endif
- if (frameCpt % 3 == 0) {
+ if (frameCpt % 20 == 0) {
ValueChanged.Raise (this, new ValueChangeEventArgs ("fps", _fps));
#if MEASURE_TIME
foreach (PerformanceMeasure m in ifaceControl[0].PerfMeasures)
thread = new Thread (start);
thread.IsBackground = true;
Host = host;
- lock (Host.CurrentInterface.CrowThreads)
- Host.CurrentInterface.CrowThreads.Add (this);
+ lock (Host.currentInterface.CrowThreads)
+ Host.currentInterface.CrowThreads.Add (this);
}
public void CheckState(){
if (thread.ThreadState != ThreadState.Stopped)
return;
Finished.Raise (Host, null);
- lock (Host.CurrentInterface.CrowThreads)
- Host.CurrentInterface.CrowThreads.Remove (this);
+ lock (Host.currentInterface.CrowThreads)
+ Host.currentInterface.CrowThreads.Remove (this);
}
public void Start() { thread.Start();}
public void Cancel(){
thread.Join ();
//cancelLoading = false;
}
- lock (Host.CurrentInterface.CrowThreads)
- Host.CurrentInterface.CrowThreads.Remove (this);
+ lock (Host.currentInterface.CrowThreads)
+ Host.currentInterface.CrowThreads.Remove (this);
}
}
}
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
- if (CurrentInterface.Mouse.LeftButton == ButtonState.Released)
+ if (currentInterface.Mouse.LeftButton == ButtonState.Released)
return;
updateMouseLocalPos (e.Position);
}
CurrentDirectory = SelectedDirectory;
else {
OkClicked.Raise (this, null);
- unloadDialog ((sender as GraphicObject).CurrentInterface);
+ unloadDialog ((sender as GraphicObject).currentInterface);
}
}
void onCancel(object sender, MouseButtonEventArgs e){
- unloadDialog ((sender as GraphicObject).CurrentInterface);
+ unloadDialog ((sender as GraphicObject).currentInterface);
}
void unloadDialog(Interface host){
host.DeleteWidget (this);
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && IsDirty)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
return true;
}
internal static ulong currentUid = 0;
internal ulong uid = 0;
- Interface currentInterface = null;
-
- [XmlIgnore]public Interface CurrentInterface {
- get {
- if (currentInterface == null) {
- currentInterface = Interface.CurrentInterface;
- Initialize ();
- }
- return currentInterface;
- }
- set {
- currentInterface = value;
- }
- }
+ internal Interface currentInterface = null;
public Region Clipping;
#region CTOR
public GraphicObject ()
{
- Clipping = new Region ();
#if DEBUG
uid = currentUid;
currentUid++;
#endif
}
#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(){
- if (currentInterface == null)
- currentInterface = Interface.CurrentInterface;
- loadDefaultValues ();
- initialized = true;
- }
#region private fields
LayoutingType registeredLayoutings = LayoutingType.All;
ILayoutable logicalParent;
Debug.WriteLine ("LoadDefValues for " + this.ToString ());
#endif
+ Clipping = new Region ();
+
Type thisType = this.GetType ();
if (!string.IsNullOrEmpty (Style)) {
if (Width.IsFit || Height.IsFit)
RegisterForLayouting (LayoutingType.Sizing);
else if (RegisteredLayoutings == LayoutingType.None)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
}
/// <summary> query an update of the content, a redraw </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
{
IsDirty = true;
if (RegisteredLayoutings == LayoutingType.None)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
}
#endregion
contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
}
/// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
- public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
- }
+ public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){}
public virtual bool ArrangeChildren { get { return false; } }
public virtual void RegisterForLayouting(LayoutingType layoutType){
if (Parent == null)
return;
- lock (CurrentInterface.LayoutMutex) {
+ lock (currentInterface.LayoutMutex) {
//prevent queueing same LayoutingType for this
layoutType &= (~RegisteredLayoutings);
if (Parent is GraphicObject)
(Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
-// //prevent queueing same LayoutingType for this
-// layoutType &= (~RegisteredLayoutings);
-
if (layoutType == LayoutingType.None)
return;
//enqueue LQI LayoutingTypes separately
if (layoutType.HasFlag (LayoutingType.Width))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+ currentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
if (layoutType.HasFlag (LayoutingType.Height))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+ currentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
if (layoutType.HasFlag (LayoutingType.X))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+ currentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
if (layoutType.HasFlag (LayoutingType.Y))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+ currentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+ currentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
}
}
//if no layouting remains in queue for item, registre for redraw
if (this.registeredLayoutings == LayoutingType.None && IsDirty)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
return true;
}
}
public virtual void checkHoverWidget(MouseMoveEventArgs e)
{
- if (CurrentInterface.HoverWidget != this) {
- CurrentInterface.HoverWidget = this;
+ if (currentInterface.HoverWidget != this) {
+ currentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
MouseMove.Raise (this, e);
}
public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
- if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
+ if (currentInterface.eligibleForDoubleClick == this && currentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
onMouseDoubleClick (this, e);
else
currentInterface.clickTimer.Restart();
- CurrentInterface.eligibleForDoubleClick = null;
+ currentInterface.eligibleForDoubleClick = null;
- if (CurrentInterface.ActiveWidget == null)
- CurrentInterface.ActiveWidget = this;
+ if (currentInterface.ActiveWidget == null)
+ currentInterface.ActiveWidget = this;
if (this.Focusable && !Interface.FocusOnHover) {
BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
if (be.Focused == null) {
be.Focused = this;
- CurrentInterface.FocusedWidget = this;
+ currentInterface.FocusedWidget = this;
}
}
//bubble event to the top
MouseUp.Raise (this, e);
if (MouseIsIn (e.Position) && IsActive) {
- if (CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
- CurrentInterface.eligibleForDoubleClick = this;
+ if (currentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
+ currentInterface.eligibleForDoubleClick = this;
onMouseClick (this, e);
}
}
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && IsDirty)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
return true;
}
//child.Parent = null;
//check if HoverWidget is removed from Tree
- if (CurrentInterface.HoverWidget != null) {
- if (this.Contains (CurrentInterface.HoverWidget))
- CurrentInterface.HoverWidget = null;
+ if (currentInterface.HoverWidget != null) {
+ if (this.Contains (currentInterface.HoverWidget))
+ currentInterface.HoverWidget = null;
}
lock (children)
#region Mouse handling
public override void checkHoverWidget (MouseMoveEventArgs e)
{
- if (CurrentInterface.HoverWidget != this) {
- CurrentInterface.HoverWidget = this;
+ if (currentInterface.HoverWidget != this) {
+ currentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
for (int i = Children.Count - 1; i >= 0; i--) {
if (string.IsNullOrEmpty(value))
Picture = null;
else {
- lock(CurrentInterface.LayoutMutex){
+ lock(currentInterface.LayoutMutex){
LoadImage (value);
}
}
{
base.onMouseEnter (sender, e);
if (Selectable)
- CurrentInterface.MouseCursor = XCursor.Text;
+ currentInterface.MouseCursor = XCursor.Text;
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- CurrentInterface.MouseCursor = XCursor.Default;
+ currentInterface.MouseCursor = XCursor.Default;
}
protected override void onFocused (object sender, EventArgs e)
{
public static MessageBox Show (Type msgBoxType, string message, string okMsg = "", string cancelMsg = ""){
lock (Interface.CurrentInterface.UpdateMutex) {
MessageBox mb = new MessageBox ();
- mb.Initialize ();
- mb.CurrentInterface.AddWidget (mb);
+ mb.loadDefaultValues ();
+ mb.currentInterface.AddWidget (mb);
mb.MsgType = msgBoxType;
mb.Message = message;
if (!string.IsNullOrEmpty(okMsg))
}
public override void checkHoverWidget (MouseMoveEventArgs e)
{
- if (CurrentInterface.HoverWidget != this) {
- CurrentInterface.HoverWidget = this;
+ if (currentInterface.HoverWidget != this) {
+ currentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
if (Content != null){
if (Content != null) {
Content.Visible = true;
if (Content.Parent == null)
- CurrentInterface.AddWidget (Content, true);
+ currentInterface.AddWidget (Content, true);
if (Content.LogicalParent != this)
Content.LogicalParent = this;
- CurrentInterface.PutOnTop (Content, true);
+ currentInterface.PutOnTop (Content, true);
_content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
}
Popped.Raise (this, e);
if (child != null) {
//check if HoverWidget is removed from Tree
- if (CurrentInterface.HoverWidget != null) {
- if (this.Contains (CurrentInterface.HoverWidget))
- CurrentInterface.HoverWidget = null;
+ if (currentInterface.HoverWidget != null) {
+ if (this.Contains (currentInterface.HoverWidget))
+ currentInterface.HoverWidget = null;
}
contentSize = new Size (0, 0);
child.LayoutChanged -= OnChildLayoutChanges;
public override void onMouseWheel (object sender, MouseWheelEventArgs e)
{
base.onMouseWheel (sender, e);
- if (CurrentInterface.Keyboard.IsKeyDown (Key.ShiftLeft))
+ if (currentInterface.Keyboard.IsKeyDown (Key.ShiftLeft))
ScrollY += e.Delta * MouseWheelSpeed;
else
ScrollX += e.Delta * MouseWheelSpeed;
{
base.onMouseEnter (sender, e);
if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
- CurrentInterface.MouseCursor = XCursor.H;
+ currentInterface.MouseCursor = XCursor.H;
else
- CurrentInterface.MouseCursor = XCursor.V;
+ currentInterface.MouseCursor = XCursor.V;
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- CurrentInterface.MouseCursor = XCursor.Default;
+ currentInterface.MouseCursor = XCursor.Default;
}
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && IsDirty)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
return true;
}
#region Mouse handling
public override void checkHoverWidget (MouseMoveEventArgs e)
{
- if (CurrentInterface.HoverWidget != this) {
- CurrentInterface.HoverWidget = this;
+ if (currentInterface.HoverWidget != this) {
+ currentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
if (string.IsNullOrEmpty(_template))
loadTemplate ();
else
- loadTemplate (CurrentInterface.Load (_template));
+ loadTemplate (currentInterface.Load (_template));
}
}
[XmlAttributeAttribute()][DefaultValue("Templated Control")]
}
}
#region GraphicObject overrides
- public override void Initialize ()
- {
- loadTemplate ();
- base.Initialize ();
- }
public override GraphicObject FindByName (string nameToFind)
{
//prevent name searching in template
if (template == null) {
if (!Interface.DefaultTemplates.ContainsKey (this.GetType ().FullName))
throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName));
- this.SetChild (CurrentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
+ this.SetChild (currentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
}else
this.SetChild (template);
}
NotifyValueChanged ("Data", data);
- lock (CurrentInterface.LayoutMutex)
+ lock (currentInterface.LayoutMutex)
ClearItems ();
if (data == null)
itemPerPage = int.MaxValue;
} else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) {
GenericStack gs = new GenericStack ();
- gs.CurrentInterface = items.CurrentInterface;
- gs.Initialize ();
+ gs.currentInterface = items.currentInterface;
+ gs.loadDefaultValues ();
gs.Orientation = (items as GenericStack).Orientation;
gs.Width = items.Width;
gs.Height = items.Height;
if (page == items)
return;
- lock (CurrentInterface.LayoutMutex)
+ lock (currentInterface.LayoutMutex)
items.AddChild (page);
#if DEBUG_LOAD
iTemp = ItemTemplates ["default"];
}
- lock (CurrentInterface.LayoutMutex) {
- g = iTemp.CreateInstance(CurrentInterface);
+ lock (currentInterface.LayoutMutex) {
+ g = iTemp.CreateInstance(currentInterface);
page.AddChild (g);
//g.LogicalParent = this;
registerItemClick (g);
if (!MoveRight ())
return;
}else if (e.Shift)
- CurrentInterface.Clipboard = this.SelectedText;
+ currentInterface.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
case Key.Enter:
break;
case Key.Insert:
if (e.Shift)
- this.Insert (CurrentInterface.Clipboard);
+ this.Insert (currentInterface.Clipboard);
else if (e.Control && !selectionIsEmpty)
- CurrentInterface.Clipboard = this.SelectedText;
+ currentInterface.Clipboard = this.SelectedText;
break;
case Key.Left:
if (e.Shift) {
alwaysOnTop = value;
if (alwaysOnTop && Parent != null)
- CurrentInterface.PutOnTop (this);
+ currentInterface.PutOnTop (this);
NotifyValueChanged ("AlwaysOnTop", alwaysOnTop);
}
{
base.onMouseMove (sender, e);
- Interface otkgw = CurrentInterface;
+ Interface otkgw = currentInterface;
if (!hoverBorder) {
currentDirection = Direction.None;
- CurrentInterface.MouseCursor = XCursor.Default;
+ currentInterface.MouseCursor = XCursor.Default;
return;
}
#endregion
protected void onMaximized (object sender, EventArgs e){
- lock (CurrentInterface.LayoutMutex) {
+ lock (currentInterface.LayoutMutex) {
if (!IsMinimized)
savedBounds = this.LastPaintedSlot;
this.Left = this.Top = 0;
}
protected void onUnmaximized (object sender, EventArgs e){
- lock (CurrentInterface.LayoutMutex) {
+ lock (currentInterface.LayoutMutex) {
this.Left = savedBounds.Left;
this.Top = savedBounds.Top;
this.Width = savedBounds.Width;
Unmaximized.Raise (sender, e);
}
protected void onMinimized (object sender, EventArgs e){
- lock (CurrentInterface.LayoutMutex) {
+ lock (currentInterface.LayoutMutex) {
if (IsNormal)
savedBounds = this.LastPaintedSlot;
Width = 200;
{
hoverBorder = false;
currentDirection = Direction.None;
- CurrentInterface.MouseCursor = XCursor.Default;
+ currentInterface.MouseCursor = XCursor.Default;
}
protected void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
{
protected void butQuitPress (object sender, MouseButtonEventArgs e)
{
- CurrentInterface.MouseCursor = XCursor.Default;
+ currentInterface.MouseCursor = XCursor.Default;
close ();
}
protected void close(){
Closing.Raise (this, null);
- CurrentInterface.DeleteWidget (this);
+ currentInterface.DeleteWidget (this);
}
}
}
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && IsDirty)
- CurrentInterface.EnqueueForRepaint (this);
+ currentInterface.EnqueueForRepaint (this);
return true;
}
#endif
if (LayoutingTries < Interface.MaxLayoutingTries) {
Layoutable.RegisteredLayoutings |= LayoutType;
- (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this);
+ (Layoutable as GraphicObject).currentInterface.LayoutingQueue.Enqueue (this);
} else if (DiscardCount < Interface.MaxDiscardCount) {
#if DEBUG_LAYOUTING
Debug.WriteLine ("\t\tDiscarded");
LayoutingTries = 0;
DiscardCount++;
Layoutable.RegisteredLayoutings |= LayoutType;
- (Layoutable as GraphicObject).CurrentInterface.DiscardQueue.Enqueue (this);
+ (Layoutable as GraphicObject).currentInterface.DiscardQueue.Enqueue (this);
}
#if DEBUG_LAYOUTING
else