Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions src.csharp/AlphaTab.Windows/WinForms/ControlContainer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Drawing;
using System.Windows.Forms;
using AlphaTab.Platform;
using AlphaTab.Rendering.Utils;

namespace AlphaTab.WinForms
{
Expand Down Expand Up @@ -42,18 +43,6 @@ public ControlContainer(Control control)
);
}

public double Top
{
get => Control.Top;
set => Control.Top = (int)value;
}

public double Left
{
get => Control.Left;
set => Control.Left = (int)value;
}

public double Width
{
get => Control.ClientSize.Width - Control.Padding.Horizontal;
Expand Down Expand Up @@ -116,6 +105,41 @@ public void Clear()
Control.Controls.Clear();
}

private readonly Bounds _lastBounds = new Bounds();

public Bounds GetBounds()
{
return _lastBounds;
}

public void SetBounds(double x, double y, double w, double h)
{
if (double.IsNaN(x))
{
x = _lastBounds.X;
}
if (double.IsNaN(y))
{
y = _lastBounds.Y;
}
if (double.IsNaN(w))
{
w = _lastBounds.W;
}
if (double.IsNaN(h))
{
h = _lastBounds.H;
}
Control.Left = (int)x;
Control.Top = (int)y;
Control.Width = (int)w;
Control.Height = (int)h;
_lastBounds.X = x;
_lastBounds.Y = y;
_lastBounds.W = w;
_lastBounds.H = h;
}

public IEventEmitter Resize { get; set; }
public IEventEmitterOfT<IMouseEventArgs> MouseDown { get; set; }
public IEventEmitterOfT<IMouseEventArgs> MouseMove { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src.csharp/AlphaTab.Windows/WinForms/WinFormsUiFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public override void RemoveHighlights()
{
}

public override void HighlightElements(string groupId)
public override void HighlightElements(string groupId, double masterBarIndex)
{
}

Expand Down
50 changes: 37 additions & 13 deletions src.csharp/AlphaTab.Windows/Wpf/FrameworkElementContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Controls;
using System.Windows.Media.Animation;
using AlphaTab.Platform;
using AlphaTab.Rendering.Utils;

namespace AlphaTab.Wpf
{
Expand Down Expand Up @@ -44,18 +45,6 @@ public FrameworkElementContainer(FrameworkElement control)
);
}

public double Top
{
get => (float) Canvas.GetTop(Control);
set => Canvas.SetTop(Control, value);
}

public double Left
{
get => (float) Canvas.GetLeft(Control);
set => Canvas.SetLeft(Control, value);
}

public double Width
{
get => (float) Control.ActualWidth;
Expand Down Expand Up @@ -133,7 +122,6 @@ public void TransitionToX(double duration, double x)
new DoubleAnimation(x, new Duration(TimeSpan.FromMilliseconds(duration))));
}


public void Clear()
{
if (Control is Panel p)
Expand All @@ -142,6 +130,42 @@ public void Clear()
}
}

private readonly Bounds _lastBounds = new Bounds();

public Bounds GetBounds()
{
return _lastBounds;
}

public void SetBounds(double x, double y, double w, double h)
{
if (double.IsNaN(x))
{
x = _lastBounds.X;
}
if (double.IsNaN(y))
{
y = _lastBounds.Y;
}
if (double.IsNaN(w))
{
w = _lastBounds.W;
}
if (double.IsNaN(h))
{
h = _lastBounds.H;
}

Canvas.SetLeft(Control, x);
Canvas.SetTop(Control, y);
Control.Width = w;
Control.Height = h;
_lastBounds.X = x;
_lastBounds.Y = y;
_lastBounds.W = w;
_lastBounds.H = h;
}

public IEventEmitter Resize { get; set; }
public IEventEmitterOfT<IMouseEventArgs> MouseDown { get; set; }
public IEventEmitterOfT<IMouseEventArgs> MouseMove { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src.csharp/AlphaTab.Windows/Wpf/WpfUiFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public override void RemoveHighlights()
{
}

public override void HighlightElements(string groupId)
public override void HighlightElements(string groupId, double masterBarIndex)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src.csharp/AlphaTab/Platform/CSharp/ManagedUiFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public virtual void InitialRender()
public abstract Cursors? CreateCursors();
public abstract void BeginInvoke(Action action);
public abstract void RemoveHighlights();
public abstract void HighlightElements(string groupId);
public abstract void HighlightElements(string groupId, double masterBarIndex);
public abstract IContainer? CreateSelectionElement();
public abstract IContainer GetScrollContainer();
public abstract Bounds GetOffset(IContainer? scrollElement, IContainer container);
Expand Down
Loading