Track api changes in WPF backend
This commit is contained in:
Родитель
d1a1d59d23
Коммит
a525df7145
|
@ -41,7 +41,7 @@ namespace Xwt.WPFBackend.Utilities
|
|||
if (image == null)
|
||||
return null;
|
||||
|
||||
return DataConverter.AsImageSource (WidgetRegistry.GetBackend (image));
|
||||
return DataConverter.AsImageSource (Toolkit.GetBackend (image));
|
||||
}
|
||||
|
||||
public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Xwt.WPFBackend
|
|||
message.SecondaryText = String.Empty;
|
||||
}
|
||||
|
||||
var wb = (WindowFrameBackend)WidgetRegistry.GetBackend (transientFor);
|
||||
var wb = (WindowFrameBackend)Toolkit.GetBackend (transientFor);
|
||||
if (wb != null) {
|
||||
this.dialogResult = MessageBox.Show (wb.Window, message.Text,message.SecondaryText,
|
||||
this.buttons, this.icon, this.defaultResult, this.options);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using Xwt.Backends;
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public abstract class Backend
|
||||
|
@ -31,9 +32,10 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
protected object frontend;
|
||||
|
||||
void IBackend.InitializeBackend (object frontend)
|
||||
public virtual void InitializeBackend (object frontend, ApplicationContext context)
|
||||
{
|
||||
this.frontend = frontend;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public virtual void EnableEvent (object eventId)
|
||||
|
@ -47,5 +49,7 @@ namespace Xwt.WPFBackend
|
|||
public object Frontend {
|
||||
get { return frontend; }
|
||||
}
|
||||
|
||||
public ApplicationContext Context { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
void HandleWidgetClicked (object sender, EventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (EventSink.OnClicked);
|
||||
Context.InvokeUserCode (EventSink.OnClicked);
|
||||
}
|
||||
|
||||
private static ResourceDictionary buttonsDictionary;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Xwt.WPFBackend
|
|||
this.fullRedraw = true;
|
||||
|
||||
if (!this.queued) {
|
||||
Toolkit.QueueExitAction (Render);
|
||||
Application.MainLoop.QueueExitAction (Render);
|
||||
this.queued = true;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace Xwt.WPFBackend
|
|||
this.dirtyRects.Add (rect.ToInt32Rect());
|
||||
|
||||
if (!this.queued) {
|
||||
Toolkit.QueueExitAction (Render);
|
||||
Application.MainLoop.QueueExitAction (Render);
|
||||
this.queued = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,12 +112,12 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnChecked (object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (CheckBoxEventSink.OnToggled);
|
||||
Context.InvokeUserCode (CheckBoxEventSink.OnToggled);
|
||||
}
|
||||
|
||||
private void OnClicked (object sender, RoutedEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (CheckBoxEventSink.OnClicked);
|
||||
Context.InvokeUserCode (CheckBoxEventSink.OnClicked);
|
||||
}
|
||||
|
||||
protected ICheckBoxEventSink CheckBoxEventSink
|
||||
|
|
|
@ -32,15 +32,15 @@ using WindowsClipboard = System.Windows.Clipboard;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class ClipboardBackend
|
||||
public class WpfClipboardBackend
|
||||
: ClipboardBackend
|
||||
{
|
||||
public void Clear ()
|
||||
public override void Clear ()
|
||||
{
|
||||
WindowsClipboard.Clear();
|
||||
}
|
||||
|
||||
public void SetData (TransferDataType type, Func<object> dataSource)
|
||||
public override void SetData (TransferDataType type, Func<object> dataSource)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
@ -50,7 +50,7 @@ namespace Xwt.WPFBackend
|
|||
WindowsClipboard.SetData (type.ToWpfDataFormat (), dataSource ());
|
||||
}
|
||||
|
||||
public bool IsTypeAvailable (TransferDataType type)
|
||||
public override bool IsTypeAvailable (TransferDataType type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
@ -58,7 +58,7 @@ namespace Xwt.WPFBackend
|
|||
return WindowsClipboard.ContainsData (type.ToWpfDataFormat ());
|
||||
}
|
||||
|
||||
public object GetData (TransferDataType type)
|
||||
public override object GetData (TransferDataType type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
@ -69,7 +69,7 @@ namespace Xwt.WPFBackend
|
|||
return WindowsClipboard.GetData (type.ToWpfDataFormat ());
|
||||
}
|
||||
|
||||
public IAsyncResult BeginGetData (TransferDataType type, AsyncCallback callback, object state)
|
||||
public override IAsyncResult BeginGetData (TransferDataType type, AsyncCallback callback, object state)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
@ -80,7 +80,7 @@ namespace Xwt.WPFBackend
|
|||
.ContinueWith (t => callback (t));
|
||||
}
|
||||
|
||||
public object EndGetData (IAsyncResult ares)
|
||||
public override object EndGetData (IAsyncResult ares)
|
||||
{
|
||||
if (ares == null)
|
||||
throw new ArgumentNullException ("ares");
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnSelectionChanged (object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Xwt.Engine.ApplicationContext.InvokeUserCode (ComboBoxEventSink.OnSelectionChanged);
|
||||
Context.InvokeUserCode (ComboBoxEventSink.OnSelectionChanged);
|
||||
}
|
||||
|
||||
private DataTemplate GetDataTemplate (IList<CellView> views)
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnTextChanged (object sender, EventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (TextEntryEventSink.OnChanged);
|
||||
Context.InvokeUserCode (TextEntryEventSink.OnChanged);
|
||||
}
|
||||
|
||||
private void UpdatePlaceholder (string newPlaceholder, bool focused)
|
||||
|
|
|
@ -42,27 +42,27 @@ using Font = Xwt.Drawing.Font;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class ContextBackendHandler
|
||||
: Backend, ContextBackendHandler
|
||||
public class WpfContextBackendHandler
|
||||
: ContextBackendHandler
|
||||
{
|
||||
public void Save (object backend)
|
||||
public override void Save (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Save();
|
||||
}
|
||||
|
||||
public void Restore (object backend)
|
||||
public override void Restore (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Restore();
|
||||
}
|
||||
|
||||
public void SetGlobalAlpha (object backend, double alpha)
|
||||
public override void SetGlobalAlpha (object backend, double alpha)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void Arc (object backend, double xc, double yc, double radius, double angle1, double angle2)
|
||||
public override void Arc (object backend, double xc, double yc, double radius, double angle1, double angle2)
|
||||
{
|
||||
// ensure sweep angle is always positive
|
||||
if (angle2 < angle1)
|
||||
|
@ -70,7 +70,7 @@ namespace Xwt.WPFBackend
|
|||
ArcInternal (backend, xc, yc, radius, angle1, angle2);
|
||||
}
|
||||
|
||||
public void ArcNegative (object backend, double xc, double yc, double radius, double angle1, double angle2)
|
||||
public override void ArcNegative (object backend, double xc, double yc, double radius, double angle1, double angle2)
|
||||
{
|
||||
// ensure sweep angle is always negative
|
||||
if (angle1 < angle2)
|
||||
|
@ -89,32 +89,32 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = current.Y;
|
||||
}
|
||||
|
||||
public void Clip (object backend)
|
||||
public override void Clip (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.SetClip (c.Path);
|
||||
c.Path.Reset ();
|
||||
}
|
||||
|
||||
public void ClipPreserve (object backend)
|
||||
public override void ClipPreserve (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.SetClip (c.Path);
|
||||
}
|
||||
|
||||
public void ResetClip (object backend)
|
||||
public override void ResetClip (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.ResetClip ();
|
||||
}
|
||||
|
||||
public void ClosePath (object backend)
|
||||
public override void ClosePath (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Path.CloseFigure();
|
||||
}
|
||||
|
||||
public void CurveTo (object backend, double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
public override void CurveTo (object backend, double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
c.Path.AddBezier (c.CurrentX, c.CurrentY,
|
||||
|
@ -125,7 +125,7 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = (float)y3;
|
||||
}
|
||||
|
||||
public void Fill (object backend)
|
||||
public override void Fill (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.FillPath (c.Brush, c.Path);
|
||||
|
@ -134,13 +134,13 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = 0;
|
||||
}
|
||||
|
||||
public void FillPreserve (object backend)
|
||||
public override void FillPreserve (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.FillPath (c.Brush, c.Path);
|
||||
}
|
||||
|
||||
public void LineTo (object backend, double x, double y)
|
||||
public override void LineTo (object backend, double x, double y)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = (float) y;
|
||||
}
|
||||
|
||||
public void MoveTo (object backend, double x, double y)
|
||||
public override void MoveTo (object backend, double x, double y)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
if (c.CurrentX != x || c.CurrentY != y) {
|
||||
|
@ -159,7 +159,7 @@ namespace Xwt.WPFBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void NewPath (object backend)
|
||||
public override void NewPath (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Path.Reset();
|
||||
|
@ -167,7 +167,7 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = 0;
|
||||
}
|
||||
|
||||
public void Rectangle (object backend, double x, double y, double width, double height)
|
||||
public override void Rectangle (object backend, double x, double y, double width, double height)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
if (c.CurrentX != x || c.CurrentY != y)
|
||||
|
@ -177,7 +177,7 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = (float)y;
|
||||
}
|
||||
|
||||
public void RelCurveTo (object backend, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
|
||||
public override void RelCurveTo (object backend, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
c.Path.AddBezier (c.CurrentX, c.CurrentY,
|
||||
|
@ -188,7 +188,7 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = (float)(c.CurrentX + dy3);
|
||||
}
|
||||
|
||||
public void RelLineTo (object backend, double dx, double dy)
|
||||
public override void RelLineTo (object backend, double dx, double dy)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -200,7 +200,7 @@ namespace Xwt.WPFBackend
|
|||
c.Path.AddLine (x, y, c.CurrentX, c.CurrentY);
|
||||
}
|
||||
|
||||
public void RelMoveTo (object backend, double dx, double dy)
|
||||
public override void RelMoveTo (object backend, double dx, double dy)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Path.StartFigure ();
|
||||
|
@ -208,7 +208,7 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY += (float)dy;
|
||||
}
|
||||
|
||||
public void Stroke (object backend)
|
||||
public override void Stroke (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.DrawPath (c.Pen, c.Path);
|
||||
|
@ -217,13 +217,13 @@ namespace Xwt.WPFBackend
|
|||
c.CurrentY = 0;
|
||||
}
|
||||
|
||||
public void StrokePreserve (object backend)
|
||||
public override void StrokePreserve (object backend)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Graphics.DrawPath (c.Pen, c.Path);
|
||||
}
|
||||
|
||||
public void SetColor (object backend, Color color)
|
||||
public override void SetColor (object backend, Color color)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -231,13 +231,13 @@ namespace Xwt.WPFBackend
|
|||
c.SetColor (dc);
|
||||
}
|
||||
|
||||
public void SetLineWidth (object backend, double width)
|
||||
public override void SetLineWidth (object backend, double width)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.SetWidth ((float) width);
|
||||
}
|
||||
|
||||
public void SetLineDash (object backend, double offset, params double[] pattern)
|
||||
public override void SetLineDash (object backend, double offset, params double[] pattern)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -253,7 +253,7 @@ namespace Xwt.WPFBackend
|
|||
c.Pen.DashStyle = DashStyle.Solid;
|
||||
}
|
||||
|
||||
public void SetPattern (object backend, object p)
|
||||
public override void SetPattern (object backend, object p)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -265,14 +265,14 @@ namespace Xwt.WPFBackend
|
|||
c.Brush = (Brush) p;
|
||||
}
|
||||
|
||||
public void SetFont (object backend, Font font)
|
||||
public override void SetFont (object backend, Font font)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
c.Font.Dispose();
|
||||
c.Font = font.ToDrawingFont ();
|
||||
}
|
||||
|
||||
public void DrawTextLayout (object backend, TextLayout layout, double x, double y)
|
||||
public override void DrawTextLayout (object backend, TextLayout layout, double x, double y)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
Size measure = layout.GetSize ();
|
||||
|
@ -290,7 +290,7 @@ namespace Xwt.WPFBackend
|
|||
stringFormat);
|
||||
}
|
||||
|
||||
public void DrawImage (object backend, object img, double x, double y, double alpha)
|
||||
public override void DrawImage (object backend, object img, double x, double y, double alpha)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -298,7 +298,7 @@ namespace Xwt.WPFBackend
|
|||
DrawImageCore (c.Graphics, bmp, (float) x, (float) y, bmp.Width, bmp.Height, (float)alpha);
|
||||
}
|
||||
|
||||
public void DrawImage (object backend, object img, double x, double y, double width, double height, double alpha)
|
||||
public override void DrawImage (object backend, object img, double x, double y, double width, double height, double alpha)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -306,7 +306,7 @@ namespace Xwt.WPFBackend
|
|||
DrawImageCore (c.Graphics, bmp, (float) x, (float) y, (float) width, (float) height, (float) alpha);
|
||||
}
|
||||
|
||||
public void DrawImage (object backend, object img, Rectangle srcRect, Rectangle destRect, double alpha)
|
||||
public override void DrawImage (object backend, object img, Rectangle srcRect, Rectangle destRect, double alpha)
|
||||
{
|
||||
var c = (DrawingContext) backend;
|
||||
|
||||
|
@ -315,31 +315,31 @@ namespace Xwt.WPFBackend
|
|||
DrawImageCore (c.Graphics, bmp, srcRect, destRect, (float) alpha);
|
||||
}
|
||||
|
||||
public void ResetTransform (object backend)
|
||||
public override void ResetTransform (object backend)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
c.Graphics.ResetTransform ();
|
||||
}
|
||||
|
||||
public void Rotate (object backend, double angle)
|
||||
public override void Rotate (object backend, double angle)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
c.Graphics.RotateTransform ((float)angle);
|
||||
}
|
||||
|
||||
public void Scale (object backend, double scaleX, double scaleY)
|
||||
public override void Scale (object backend, double scaleX, double scaleY)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
c.Graphics.ScaleTransform ((float)scaleX, (float)scaleY);
|
||||
}
|
||||
|
||||
public void Translate (object backend, double tx, double ty)
|
||||
|
||||
public override void Translate (object backend, double tx, double ty)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
c.Graphics.TranslateTransform ((float)tx, (float)ty);
|
||||
}
|
||||
|
||||
public void TransformPoint (object backend, ref double x, ref double y)
|
||||
public override void TransformPoint (object backend, ref double x, ref double y)
|
||||
{
|
||||
Matrix m = ((DrawingContext)backend).Graphics.Transform;
|
||||
PointF p = new PointF ((float)x, (float)y);
|
||||
|
@ -349,7 +349,7 @@ namespace Xwt.WPFBackend
|
|||
y = pts[0].Y;
|
||||
}
|
||||
|
||||
public void TransformDistance (object backend, ref double dx, ref double dy)
|
||||
public override void TransformDistance (object backend, ref double dx, ref double dy)
|
||||
{
|
||||
Matrix m = ((DrawingContext)backend).Graphics.Transform;
|
||||
PointF p = new PointF ((float)dx, (float)dy);
|
||||
|
@ -359,7 +359,7 @@ namespace Xwt.WPFBackend
|
|||
dy = pts[0].Y;
|
||||
}
|
||||
|
||||
public void TransformPoints (object backend, Point[] points)
|
||||
public override void TransformPoints (object backend, Point[] points)
|
||||
{
|
||||
Matrix m = ((DrawingContext)backend).Graphics.Transform;
|
||||
PointF[] pts = new PointF[points.Length];
|
||||
|
@ -374,7 +374,7 @@ namespace Xwt.WPFBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void TransformDistances (object backend, Distance[] vectors)
|
||||
public override void TransformDistances (object backend, Distance[] vectors)
|
||||
{
|
||||
Matrix m = ((DrawingContext)backend).Graphics.Transform;
|
||||
PointF[] pts = new PointF[vectors.Length];
|
||||
|
@ -389,12 +389,12 @@ namespace Xwt.WPFBackend
|
|||
}
|
||||
}
|
||||
|
||||
public object CreatePath ()
|
||||
public override object CreatePath ()
|
||||
{
|
||||
return new DrawingContext ();
|
||||
}
|
||||
|
||||
public void AppendPath (object backend, object otherBackend)
|
||||
public override void AppendPath (object backend, object otherBackend)
|
||||
{
|
||||
var dest = (DrawingContext)backend;
|
||||
var src = (DrawingContext)otherBackend;
|
||||
|
@ -404,18 +404,18 @@ namespace Xwt.WPFBackend
|
|||
dest.CurrentY = src.CurrentY;
|
||||
}
|
||||
|
||||
public bool IsPointInFill (object backend, double x, double y)
|
||||
public override bool IsPointInFill (object backend, double x, double y)
|
||||
{
|
||||
return ((DrawingContext)backend).Path.IsVisible ((float)x, (float)y);
|
||||
}
|
||||
|
||||
public bool IsPointInStroke (object backend, double x, double y)
|
||||
public override bool IsPointInStroke (object backend, double x, double y)
|
||||
{
|
||||
var c = (DrawingContext)backend;
|
||||
return c.Path.IsOutlineVisible ((float)x, (float)y, c.Pen);
|
||||
}
|
||||
|
||||
public void Dispose (object backend)
|
||||
public override void Dispose (object backend)
|
||||
{
|
||||
((DrawingContext)backend).Dispose();
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ namespace Xwt.WPFBackend
|
|||
viewport = newViewport;
|
||||
if (!viewportAdjustmentQueued) {
|
||||
viewportAdjustmentQueued = true;
|
||||
Xwt.Engine.Toolkit.QueueExitAction (delegate
|
||||
Application.MainLoop.QueueExitAction (delegate
|
||||
{
|
||||
// Adjust the position, if it now falls outside the extents.
|
||||
// Doing it in an exit action to make sure the adjustement
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnButtonClicked (DialogButton button)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (() => DialogEventSink.OnDialogButtonClicked (button));
|
||||
Context.InvokeUserCode (() => DialogEventSink.OnDialogButtonClicked (button));
|
||||
}
|
||||
|
||||
private static readonly ItemsPanelTemplate PanelTemplate;
|
||||
|
|
|
@ -35,20 +35,20 @@ using FontFamily = System.Windows.Media.FontFamily;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class FontBackendHandler : FontBackendHandler
|
||||
public class WpfFontBackendHandler : FontBackendHandler
|
||||
{
|
||||
public object Create (string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
|
||||
public override object Create (string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
|
||||
{
|
||||
return new FontData (new FontFamily (fontName), size, sizeUnit);
|
||||
}
|
||||
|
||||
public object Copy (object handle)
|
||||
public override object Copy (object handle)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
return font.Clone ();
|
||||
}
|
||||
|
||||
public object SetSize (object handle, double size, FontSizeUnit sizeUnit)
|
||||
public override object SetSize (object handle, double size, FontSizeUnit sizeUnit)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
font = font.Clone ();
|
||||
|
@ -56,7 +56,7 @@ namespace Xwt.WPFBackend
|
|||
return font;
|
||||
}
|
||||
|
||||
public object SetFamily (object handle, string family)
|
||||
public override object SetFamily (object handle, string family)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
font = font.Clone ();
|
||||
|
@ -64,7 +64,7 @@ namespace Xwt.WPFBackend
|
|||
return font;
|
||||
}
|
||||
|
||||
public object SetStyle (object handle, FontStyle style)
|
||||
public override object SetStyle (object handle, FontStyle style)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
font = font.Clone ();
|
||||
|
@ -72,7 +72,7 @@ namespace Xwt.WPFBackend
|
|||
return font;
|
||||
}
|
||||
|
||||
public object SetWeight (object handle, FontWeight weight)
|
||||
public override object SetWeight (object handle, FontWeight weight)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
font = font.Clone ();
|
||||
|
@ -80,7 +80,7 @@ namespace Xwt.WPFBackend
|
|||
return font;
|
||||
}
|
||||
|
||||
public object SetStretch (object handle, FontStretch stretch)
|
||||
public override object SetStretch (object handle, FontStretch stretch)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
font = font.Clone ();
|
||||
|
@ -88,31 +88,31 @@ namespace Xwt.WPFBackend
|
|||
return font;
|
||||
}
|
||||
|
||||
public double GetSize (object handle)
|
||||
public override double GetSize (object handle)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
return font.Size;
|
||||
}
|
||||
|
||||
public string GetFamily (object handle)
|
||||
public override string GetFamily (object handle)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
return font.Family.Source;
|
||||
}
|
||||
|
||||
public FontStyle GetStyle (object handle)
|
||||
public override FontStyle GetStyle (object handle)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
return DataConverter.ToXwtFontStyle (font.Style);
|
||||
}
|
||||
|
||||
public FontStretch GetStretch (object handle)
|
||||
public override FontStretch GetStretch (object handle)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
return DataConverter.ToXwtFontStretch (font.Stretch);
|
||||
}
|
||||
|
||||
public FontWeight GetWeight (object handle)
|
||||
public override FontWeight GetWeight (object handle)
|
||||
{
|
||||
var font = (FontData)handle;
|
||||
return DataConverter.ToXwtFontWeight (font.Weight);
|
||||
|
@ -166,7 +166,7 @@ namespace Xwt.WPFBackend
|
|||
public double GetDeviceIndependentPixelSize (SW.Controls.Control control)
|
||||
{
|
||||
if (Unit == FontSizeUnit.Points)
|
||||
return FontBackendHandler.GetDeviceUnitsFromPoints (Size);
|
||||
return WpfFontBackendHandler.GetDeviceUnitsFromPoints (Size);
|
||||
else {
|
||||
Size pixelRatios = control.GetPixelRatios ();
|
||||
return Size / pixelRatios.Width;
|
||||
|
|
|
@ -36,22 +36,22 @@ using DrawingColor = System.Drawing.Color;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class GradientBackendHandler
|
||||
: Backend, GradientBackendHandler
|
||||
public class WpfGradientBackendHandler
|
||||
: GradientBackendHandler
|
||||
{
|
||||
public object CreateLinear (double x0, double y0, double x1, double y1)
|
||||
public override object CreateLinear (double x0, double y0, double x1, double y1)
|
||||
{
|
||||
return new LinearGradient (
|
||||
new PointF ((float) x0, (float) y0),
|
||||
new PointF ((float) x1, (float) y1));
|
||||
}
|
||||
|
||||
public object CreateRadial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
|
||||
public override object CreateRadial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
|
||||
{
|
||||
return new RadialGradient (cx0, cy0, radius0, cx1, cy1, radius1);
|
||||
}
|
||||
|
||||
public void AddColorStop (object backend, double position, Color color)
|
||||
public override void AddColorStop (object backend, double position, Color color)
|
||||
{
|
||||
((GradientBase)backend).ColorStops.Add (new Tuple<double, Color> (position, color));
|
||||
}
|
||||
|
|
|
@ -30,26 +30,26 @@ using Xwt.Drawing;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class ImageBuilderBackendHandler
|
||||
public class WpfImageBuilderBackendHandler
|
||||
: ImageBuilderBackendHandler
|
||||
{
|
||||
public object CreateImageBuilder (int width, int height, ImageFormat format)
|
||||
public override object CreateImageBuilder (int width, int height, ImageFormat format)
|
||||
{
|
||||
return new Bitmap (width, height, format.ToPixelFormat ());
|
||||
}
|
||||
|
||||
public object CreateContext (object backend)
|
||||
public override object CreateContext (object backend)
|
||||
{
|
||||
Bitmap bmp = (Bitmap) backend;
|
||||
return new DrawingContext (Graphics.FromImage (bmp));
|
||||
}
|
||||
|
||||
public object CreateImage (object backend)
|
||||
public override object CreateImage (object backend)
|
||||
{
|
||||
return DataConverter.AsImageSource (backend);
|
||||
}
|
||||
|
||||
public void Dispose (object backend)
|
||||
public override void Dispose (object backend)
|
||||
{
|
||||
Bitmap bmp = (Bitmap) backend;
|
||||
bmp.Dispose();
|
||||
|
|
|
@ -187,7 +187,7 @@ namespace Xwt.WPFBackend
|
|||
throw new ArgumentException ();
|
||||
Bitmap result = new Bitmap (bitmap.Width, bitmap.Height, bitmap.PixelFormat);
|
||||
Graphics g = Graphics.FromImage (result);
|
||||
ContextBackendHandler.DrawImageCore (g, bitmap, 0, 0, bitmap.Width, bitmap.Height, (float)opacity);
|
||||
WpfContextBackendHandler.DrawImageCore (g, bitmap, 0, 0, bitmap.Width, bitmap.Height, (float)opacity);
|
||||
g.Dispose ();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ using System.Drawing;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class ImagePatternBackendHandler
|
||||
public class WpfImagePatternBackendHandler
|
||||
: ImagePatternBackendHandler
|
||||
{
|
||||
public object Create (object img)
|
||||
public override object Create (object img)
|
||||
{
|
||||
Bitmap bmp = DataConverter.AsBitmap (img);
|
||||
return new TextureBrush (bmp, System.Drawing.Drawing2D.WrapMode.Tile);
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
void HandleClicked (object sender, EventArgs e)
|
||||
{
|
||||
Xwt.Engine.ApplicationContext.InvokeUserCode (() => {
|
||||
Context.InvokeUserCode (() => {
|
||||
EventSink.OnNavigateToUrl (Uri);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnSelectionChanged (object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (ListViewEventSink.OnSelectionChanged);
|
||||
Context.InvokeUserCode (ListViewEventSink.OnSelectionChanged);
|
||||
}
|
||||
|
||||
private bool headersVisible;
|
||||
|
|
|
@ -37,12 +37,13 @@ using Xwt.Backends;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class MenuBackend : IMenuBackend
|
||||
public class MenuBackend : Backend, IMenuBackend
|
||||
{
|
||||
List<MenuItemBackend> items;
|
||||
|
||||
public void InitializeBackend (object frontend)
|
||||
public override void InitializeBackend (object frontend, ApplicationContext context)
|
||||
{
|
||||
base.InitializeBackend (frontend, context);
|
||||
items = new List<MenuItemBackend> ();
|
||||
}
|
||||
|
||||
|
@ -122,14 +123,6 @@ namespace Xwt.WPFBackend
|
|||
menu.IsOpen = true;
|
||||
}
|
||||
|
||||
public void EnableEvent (object eventId)
|
||||
{
|
||||
}
|
||||
|
||||
public void DisableEvent (object eventId)
|
||||
{
|
||||
}
|
||||
|
||||
private ContextMenu menu;
|
||||
internal ContextMenu CreateContextMenu()
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnMenuOpening (object sender, DropDownButton.MenuOpeningEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (() =>
|
||||
Context.InvokeUserCode (() =>
|
||||
e.ContextMenu = ((MenuBackend) MenuButtonEventSink.OnCreateMenu ()).CreateContextMenu ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ using Xwt.Backends;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class MenuItemBackend : IMenuItemBackend
|
||||
public class MenuItemBackend : Backend, IMenuItemBackend
|
||||
{
|
||||
object item;
|
||||
SWC.MenuItem menuItem;
|
||||
|
@ -62,10 +62,6 @@ namespace Xwt.WPFBackend
|
|||
this.eventSink = eventSink;
|
||||
}
|
||||
|
||||
public void InitializeBackend (object frontend)
|
||||
{
|
||||
}
|
||||
|
||||
public object Item {
|
||||
get { return this.item; }
|
||||
}
|
||||
|
@ -155,7 +151,7 @@ namespace Xwt.WPFBackend
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public void EnableEvent (object eventId)
|
||||
public override void EnableEvent (object eventId)
|
||||
{
|
||||
if (menuItem == null)
|
||||
return;
|
||||
|
@ -169,7 +165,7 @@ namespace Xwt.WPFBackend
|
|||
}
|
||||
}
|
||||
|
||||
public void DisableEvent (object eventId)
|
||||
public override void DisableEvent (object eventId)
|
||||
{
|
||||
if (menuItem == null)
|
||||
return;
|
||||
|
@ -185,7 +181,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
void MenuItemClickHandler (object sender, EventArgs args)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (eventSink.OnClicked);
|
||||
Context.InvokeUserCode (eventSink.OnClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnCurrentTabChanged (object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (NotebookEventSink.OnCurrentTabChanged);
|
||||
Context.InvokeUserCode (NotebookEventSink.OnCurrentTabChanged);
|
||||
}
|
||||
|
||||
protected TabControl TabControl {
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace Xwt.WPFBackend
|
|||
internal void NotifyPositionChanged ()
|
||||
{
|
||||
if (this.reportPositionChanged)
|
||||
ApplicationContext.InvokeUserCode (((IPanedEventSink)EventSink).OnPositionChanged);
|
||||
Context.InvokeUserCode (((IPanedEventSink)EventSink).OnPositionChanged);
|
||||
}
|
||||
|
||||
PanelInfo GetPanel (int panel)
|
||||
|
|
|
@ -30,7 +30,7 @@ using System.Windows.Media;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class PopoverBackend : IPopoverBackend
|
||||
public class PopoverBackend : Backend, IPopoverBackend
|
||||
{
|
||||
public Xwt.Popover.Position ActualPosition {
|
||||
get; set;
|
||||
|
@ -44,8 +44,8 @@ namespace Xwt.WPFBackend
|
|||
get; set;
|
||||
}
|
||||
|
||||
Popover Frontend {
|
||||
get; set;
|
||||
new Popover Frontend {
|
||||
get { return (Popover)base.frontend; }
|
||||
}
|
||||
|
||||
System.Windows.Controls.Primitives.Popup NativeWidget {
|
||||
|
@ -87,19 +87,14 @@ namespace Xwt.WPFBackend
|
|||
EventSink = sink;
|
||||
}
|
||||
|
||||
public void InitializeBackend (object frontend)
|
||||
{
|
||||
Frontend = (Popover) frontend;
|
||||
}
|
||||
|
||||
public void EnableEvent (object eventId)
|
||||
public override void EnableEvent (object eventId)
|
||||
{
|
||||
if (eventId is PopoverEvent)
|
||||
if ((PopoverEvent)eventId == PopoverEvent.Closed)
|
||||
NativeWidget.Closed +=new EventHandler(NativeWidget_Closed);
|
||||
}
|
||||
|
||||
public void DisableEvent (object eventId)
|
||||
public override void DisableEvent (object eventId)
|
||||
{
|
||||
if (eventId is PopoverEvent)
|
||||
if ((PopoverEvent) eventId == PopoverEvent.Closed)
|
||||
|
@ -109,8 +104,8 @@ namespace Xwt.WPFBackend
|
|||
public void Show (Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
|
||||
{
|
||||
ActualPosition = orientation;
|
||||
Border.Child = (System.Windows.FrameworkElement) Xwt.Engine.WidgetRegistry.GetNativeWidget (child);
|
||||
NativeWidget.PlacementTarget =(System.Windows.FrameworkElement) Xwt.Engine.WidgetRegistry.GetNativeWidget (reference);
|
||||
Border.Child = (System.Windows.FrameworkElement)Context.Toolkit.GetNativeWidget (child);
|
||||
NativeWidget.PlacementTarget = (System.Windows.FrameworkElement)Context.Toolkit.GetNativeWidget (reference);
|
||||
NativeWidget.IsOpen = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
void HyperlinkNavigated (object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
||||
{
|
||||
Xwt.Engine.ApplicationContext.InvokeUserCode (() => {
|
||||
Context.InvokeUserCode (() => {
|
||||
EventSink.OnNavigateToUrl (e.Uri);
|
||||
e.Handled = true;
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
// The offset is relative to 0, it has to be converted to the lower/upper value range
|
||||
scrollValue = LowerValue + offset;
|
||||
Xwt.Engine.ApplicationContext.InvokeUserCode (EventSink.OnValueChanged);
|
||||
Context.InvokeUserCode (EventSink.OnValueChanged);
|
||||
}
|
||||
|
||||
public double Value
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnTextChanged (object s, TextChangedEventArgs e)
|
||||
{
|
||||
Xwt.Engine.ApplicationContext.InvokeUserCode (EventSink.OnChanged);
|
||||
Context.InvokeUserCode (EventSink.OnChanged);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,48 +34,48 @@ using Font = Xwt.Drawing.Font;
|
|||
|
||||
namespace Xwt.WPFBackend
|
||||
{
|
||||
public class TextLayoutBackendHandler
|
||||
public class WpfTextLayoutBackendHandler
|
||||
: TextLayoutBackendHandler
|
||||
{
|
||||
public object Create (Context context)
|
||||
public override object Create (Context context)
|
||||
{
|
||||
var drawingContext = (DrawingContext)WidgetRegistry.GetBackend (context);
|
||||
var drawingContext = (DrawingContext)Toolkit.GetBackend (context);
|
||||
return new TextLayoutContext (drawingContext);
|
||||
}
|
||||
|
||||
public object Create (ICanvasBackend canvas)
|
||||
public override object Create (ICanvasBackend canvas)
|
||||
{
|
||||
var drawingContext = new DrawingContext (Graphics.FromImage (new Bitmap (1, 1)));
|
||||
return new TextLayoutContext (drawingContext);
|
||||
}
|
||||
|
||||
public void SetWidth (object backend, double value)
|
||||
public override void SetWidth (object backend, double value)
|
||||
{
|
||||
((TextLayoutContext) backend).Width = value;
|
||||
}
|
||||
|
||||
public void SetHeight (object backend, double value)
|
||||
|
||||
public override void SetHeight (object backend, double value)
|
||||
{
|
||||
((TextLayoutContext) backend).Height = value;
|
||||
}
|
||||
|
||||
public void SetText (object backend, string text)
|
||||
|
||||
public override void SetText (object backend, string text)
|
||||
{
|
||||
((TextLayoutContext) backend).Text = text;
|
||||
}
|
||||
|
||||
public void SetFont (object backend, Font font)
|
||||
public override void SetFont (object backend, Font font)
|
||||
{
|
||||
((TextLayoutContext) backend).Font = font.ToDrawingFont();
|
||||
}
|
||||
|
||||
public void SetTrimming (object backend, TextTrimming textTrimming)
|
||||
|
||||
public override void SetTrimming (object backend, TextTrimming textTrimming)
|
||||
{
|
||||
((TextLayoutContext) backend).StringTrimming = textTrimming.ToDrawingStringTrimming();
|
||||
|
||||
}
|
||||
|
||||
public Size GetSize (object backend)
|
||||
|
||||
public override Size GetSize (object backend)
|
||||
{
|
||||
return ((TextLayoutContext) backend).GetSize ();
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnButtonToggled (object s, RoutedEventArgs e)
|
||||
{
|
||||
Xwt.Engine.ApplicationContext.InvokeUserCode (EventSink.OnToggled);
|
||||
Context.InvokeUserCode (EventSink.OnToggled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void OnSelectedItemsChanged (object sender, EventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (TreeViewEventSink.OnSelectionChanged);
|
||||
Context.InvokeUserCode (TreeViewEventSink.OnSelectionChanged);
|
||||
}
|
||||
|
||||
protected override void OnDragOver (object sender, DragOverEventArgs e)
|
||||
|
|
|
@ -49,55 +49,55 @@ namespace Xwt.WPFBackend
|
|||
if (application == null)
|
||||
application = new System.Windows.Application ();
|
||||
|
||||
WidgetRegistry.RegisterBackend (typeof (Window), typeof (WindowBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Dialog), typeof (DialogBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Notebook), typeof (NotebookBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Menu), typeof (MenuBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (MenuItem), typeof (MenuItemBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (CheckBoxMenuItem), typeof (CheckboxMenuItemBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (RadioButtonMenuItem), typeof (RadioButtonMenuItemBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (SeparatorMenuItem), typeof (SeparatorMenuItemBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Table), typeof (BoxBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Box), typeof (BoxBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Label), typeof (LabelBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (TextEntry), typeof (TextEntryBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Button), typeof (ButtonBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ToggleButton), typeof (ToggleButtonBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (MenuButton), typeof (MenuButtonBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (CheckBox), typeof (CheckBoxBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (TreeView), typeof (TreeViewBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (TreeStore), typeof (TreeStoreBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ImageView), typeof (ImageViewBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Separator), typeof (SeparatorBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Image), typeof (ImageHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (Font), typeof (FontBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (Clipboard), typeof (ClipboardBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ComboBox), typeof (ComboBoxBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ComboBoxEntry), typeof (ComboBoxEntryBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ScrollView), typeof (ScrollViewBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Frame), typeof (FrameBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Canvas), typeof (CanvasBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Context), typeof (ContextBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (DrawingPath), typeof (ContextBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (Gradient), typeof (GradientBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (TextLayout), typeof (TextLayoutBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (Widget), typeof (CustomWidgetBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Paned), typeof (PanedBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ScrollAdjustment), typeof (ScrollAdjustmentBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (OpenFileDialog), typeof (OpenFileDialogBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (SelectFolderDialog), typeof (SelectFolderDialogBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (IAlertDialogBackend), typeof (AlertDialogBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ImageBuilder), typeof (ImageBuilderBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (ImagePattern), typeof (ImagePatternBackendHandler));
|
||||
WidgetRegistry.RegisterBackend (typeof (ListView), typeof (ListViewBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ListStore), typeof (ListDataSource));
|
||||
WidgetRegistry.RegisterBackend (typeof (ListBox), typeof (ListBoxBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Placement), typeof (BoxBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Popover), typeof (PopoverBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (ProgressBar), typeof (ProgressBarBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (RichTextView), typeof (RichTextViewBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (LinkLabel), typeof (LinkLabelBackend));
|
||||
WidgetRegistry.RegisterBackend (typeof (Spinner), typeof (SpinnerBackend));
|
||||
RegisterBackend (typeof (Window), typeof (WindowBackend));
|
||||
RegisterBackend (typeof (Dialog), typeof (DialogBackend));
|
||||
RegisterBackend (typeof (Notebook), typeof (NotebookBackend));
|
||||
RegisterBackend (typeof (Menu), typeof (MenuBackend));
|
||||
RegisterBackend (typeof (MenuItem), typeof (MenuItemBackend));
|
||||
RegisterBackend (typeof (CheckBoxMenuItem), typeof (CheckboxMenuItemBackend));
|
||||
RegisterBackend (typeof (RadioButtonMenuItem), typeof (RadioButtonMenuItemBackend));
|
||||
RegisterBackend (typeof (SeparatorMenuItem), typeof (SeparatorMenuItemBackend));
|
||||
RegisterBackend (typeof (Table), typeof (BoxBackend));
|
||||
RegisterBackend (typeof (Box), typeof (BoxBackend));
|
||||
RegisterBackend (typeof (Label), typeof (LabelBackend));
|
||||
RegisterBackend (typeof (TextEntry), typeof (TextEntryBackend));
|
||||
RegisterBackend (typeof (Button), typeof (ButtonBackend));
|
||||
RegisterBackend (typeof (ToggleButton), typeof (ToggleButtonBackend));
|
||||
RegisterBackend (typeof (MenuButton), typeof (MenuButtonBackend));
|
||||
RegisterBackend (typeof (CheckBox), typeof (CheckBoxBackend));
|
||||
RegisterBackend (typeof (TreeView), typeof (TreeViewBackend));
|
||||
RegisterBackend (typeof (TreeStore), typeof (TreeStoreBackend));
|
||||
RegisterBackend (typeof (ImageView), typeof (ImageViewBackend));
|
||||
RegisterBackend (typeof (Separator), typeof (SeparatorBackend));
|
||||
RegisterBackend (typeof (Image), typeof (ImageHandler));
|
||||
RegisterBackend (typeof (Font), typeof (WpfFontBackendHandler));
|
||||
RegisterBackend (typeof (Clipboard), typeof (WpfClipboardBackend));
|
||||
RegisterBackend (typeof (ComboBox), typeof (ComboBoxBackend));
|
||||
RegisterBackend (typeof (ComboBoxEntry), typeof (ComboBoxEntryBackend));
|
||||
RegisterBackend (typeof (ScrollView), typeof (ScrollViewBackend));
|
||||
RegisterBackend (typeof (Frame), typeof (FrameBackend));
|
||||
RegisterBackend (typeof (Canvas), typeof (CanvasBackend));
|
||||
RegisterBackend (typeof (Context), typeof (WpfContextBackendHandler));
|
||||
RegisterBackend (typeof (DrawingPath), typeof (WpfContextBackendHandler));
|
||||
RegisterBackend (typeof (Gradient), typeof (WpfGradientBackendHandler));
|
||||
RegisterBackend (typeof (TextLayout), typeof (WpfTextLayoutBackendHandler));
|
||||
RegisterBackend (typeof (Widget), typeof (CustomWidgetBackend));
|
||||
RegisterBackend (typeof (Paned), typeof (PanedBackend));
|
||||
RegisterBackend (typeof (ScrollAdjustment), typeof (ScrollAdjustmentBackend));
|
||||
RegisterBackend (typeof (OpenFileDialog), typeof (OpenFileDialogBackend));
|
||||
RegisterBackend (typeof (SelectFolderDialog), typeof (SelectFolderDialogBackend));
|
||||
RegisterBackend (typeof (IAlertDialogBackend), typeof (AlertDialogBackend));
|
||||
RegisterBackend (typeof (ImageBuilder), typeof (WpfImageBuilderBackendHandler));
|
||||
RegisterBackend (typeof (ImagePattern), typeof (WpfImagePatternBackendHandler));
|
||||
RegisterBackend (typeof (ListView), typeof (ListViewBackend));
|
||||
RegisterBackend (typeof (ListStore), typeof (ListDataSource));
|
||||
RegisterBackend (typeof (ListBox), typeof (ListBoxBackend));
|
||||
RegisterBackend (typeof (Placement), typeof (BoxBackend));
|
||||
RegisterBackend (typeof (Popover), typeof (PopoverBackend));
|
||||
RegisterBackend (typeof (ProgressBar), typeof (ProgressBarBackend));
|
||||
RegisterBackend (typeof (RichTextView), typeof (RichTextViewBackend));
|
||||
RegisterBackend (typeof (LinkLabel), typeof (LinkLabelBackend));
|
||||
RegisterBackend (typeof (Spinner), typeof (SpinnerBackend));
|
||||
}
|
||||
|
||||
public override void DispatchPendingEvents()
|
||||
|
@ -148,13 +148,13 @@ namespace Xwt.WPFBackend
|
|||
|
||||
public override object GetNativeWidget (Widget w)
|
||||
{
|
||||
var backend = (IWpfWidgetBackend) WidgetRegistry.GetBackend (w);
|
||||
var backend = (IWpfWidgetBackend) Toolkit.GetBackend (w);
|
||||
return backend.Widget;
|
||||
}
|
||||
|
||||
public override object GetNativeParentWindow (Widget w)
|
||||
{
|
||||
var backend = (IWpfWidgetBackend) WidgetRegistry.GetBackend (w);
|
||||
var backend = (IWpfWidgetBackend)Toolkit.GetBackend (w);
|
||||
|
||||
FrameworkElement e = backend.Widget;
|
||||
while ((e = e.Parent as FrameworkElement) != null)
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace Xwt.WPFBackend
|
|||
FontData GetWidgetFont ()
|
||||
{
|
||||
if (!(Widget is Control)) {
|
||||
double size = FontBackendHandler.GetPointsFromDeviceUnits (SystemFonts.MessageFontSize);
|
||||
double size = WpfFontBackendHandler.GetPointsFromDeviceUnits (SystemFonts.MessageFontSize);
|
||||
|
||||
return new FontData (SystemFonts.MessageFontFamily, size, Drawing.FontSizeUnit.Points) {
|
||||
Style = SystemFonts.MessageFontStyle,
|
||||
|
@ -340,7 +340,7 @@ namespace Xwt.WPFBackend
|
|||
if (calculatingPreferredSize)
|
||||
return wpfMeasure;
|
||||
|
||||
ApplicationContext.InvokeUserCode (delegate
|
||||
Context.InvokeUserCode (delegate
|
||||
{
|
||||
if (eventSink.GetSizeRequestMode () == SizeRequestMode.HeightForWidth) {
|
||||
// Calculate the preferred width through the frontend, if there is an overriden OnGetPreferredWidth
|
||||
|
@ -578,7 +578,7 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
KeyEventArgs args;
|
||||
if (MapToXwtKeyArgs (e, out args)) {
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
eventSink.OnKeyPressed (args);
|
||||
});
|
||||
if (args.Handled)
|
||||
|
@ -590,7 +590,8 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
KeyEventArgs args;
|
||||
if (MapToXwtKeyArgs (e, out args)) {
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate
|
||||
{
|
||||
eventSink.OnKeyReleased (args);
|
||||
});
|
||||
if (args.Handled)
|
||||
|
@ -613,7 +614,7 @@ namespace Xwt.WPFBackend
|
|||
void WidgetMouseDownHandler (object o, MouseButtonEventArgs e)
|
||||
{
|
||||
var args = ToXwtButtonArgs (e);
|
||||
ApplicationContext.InvokeUserCode (delegate () {
|
||||
Context.InvokeUserCode (delegate () {
|
||||
eventSink.OnButtonPressed (args);
|
||||
});
|
||||
if (args.Handled)
|
||||
|
@ -623,7 +624,8 @@ namespace Xwt.WPFBackend
|
|||
void WidgetMouseUpHandler (object o, MouseButtonEventArgs e)
|
||||
{
|
||||
var args = ToXwtButtonArgs (e);
|
||||
ApplicationContext.InvokeUserCode (delegate () {
|
||||
Context.InvokeUserCode (delegate ()
|
||||
{
|
||||
eventSink.OnButtonReleased (args);
|
||||
});
|
||||
if (args.Handled)
|
||||
|
@ -643,12 +645,12 @@ namespace Xwt.WPFBackend
|
|||
|
||||
void WidgetGotFocusHandler (object o, RoutedEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (this.eventSink.OnGotFocus);
|
||||
Context.InvokeUserCode (this.eventSink.OnGotFocus);
|
||||
}
|
||||
|
||||
void WidgetLostFocusHandler (object o, RoutedEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (eventSink.OnLostFocus);
|
||||
Context.InvokeUserCode (eventSink.OnLostFocus);
|
||||
}
|
||||
|
||||
DragDropData DragDropInfo {
|
||||
|
@ -763,7 +765,7 @@ namespace Xwt.WPFBackend
|
|||
return;
|
||||
|
||||
DragStartData dragData = null;
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
dragData = eventSink.OnDragStarted ();
|
||||
});
|
||||
|
||||
|
@ -828,21 +830,21 @@ namespace Xwt.WPFBackend
|
|||
|
||||
protected virtual void OnDragFinished (object sender, DragFinishedEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
this.eventSink.OnDragFinished (e);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnDragOver (object sender, DragOverEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
eventSink.OnDragOver (e);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnDragLeave (object sender, EventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
eventSink.OnDragLeave (e);
|
||||
});
|
||||
}
|
||||
|
@ -878,7 +880,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
if ((enabledEvents & WidgetEvent.DragOverCheck) > 0) {
|
||||
var checkArgs = new DragOverCheckEventArgs (pos, types, proposedAction);
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
eventSink.OnDragOverCheck (checkArgs);
|
||||
});
|
||||
if (checkArgs.AllowedAction == DragDropAction.None) {
|
||||
|
@ -923,7 +925,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
if ((enabledEvents & WidgetEvent.DragDropCheck) > 0) {
|
||||
var checkArgs = new DragCheckEventArgs (pos, types, actualEffect.ToXwtDropAction ());
|
||||
bool res = ApplicationContext.InvokeUserCode (delegate {
|
||||
bool res = Context.InvokeUserCode (delegate {
|
||||
eventSink.OnDragDropCheck (checkArgs);
|
||||
});
|
||||
|
||||
|
@ -938,7 +940,7 @@ namespace Xwt.WPFBackend
|
|||
FillDataStore (store, e.Data, DragDropInfo.TargetTypes);
|
||||
|
||||
var args = new DragEventArgs (pos, store, actualEffect.ToXwtDropAction ());
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
eventSink.OnDragDrop (args);
|
||||
});
|
||||
|
||||
|
@ -954,17 +956,17 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void WidgetMouseEnteredHandler (object sender, MouseEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (eventSink.OnMouseEntered);
|
||||
Context.InvokeUserCode (eventSink.OnMouseEntered);
|
||||
}
|
||||
|
||||
private void WidgetMouseExitedHandler (object sender, MouseEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (eventSink.OnMouseExited);
|
||||
Context.InvokeUserCode (eventSink.OnMouseExited);
|
||||
}
|
||||
|
||||
private void WidgetMouseMoveHandler (object sender, MouseEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (() => {
|
||||
Context.InvokeUserCode (() => {
|
||||
var p = e.GetPosition (Widget);
|
||||
eventSink.OnMouseMoved (new MouseMovedEventArgs (
|
||||
e.Timestamp, p.X * WidthPixelRatio, p.Y * HeightPixelRatio));
|
||||
|
@ -979,7 +981,7 @@ namespace Xwt.WPFBackend
|
|||
int jumps = mouseScrollCumulation / 120;
|
||||
mouseScrollCumulation %= 120;
|
||||
var p = e.GetPosition(Widget);
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
for (int i = 0; i < jumps; i++) {
|
||||
eventSink.OnMouseScrolled(new MouseScrolledEventArgs(
|
||||
e.Timestamp, p.X * WidthPixelRatio, p.Y * HeightPixelRatio, ScrollDirection.Up));
|
||||
|
@ -994,7 +996,7 @@ namespace Xwt.WPFBackend
|
|||
private void WidgetOnSizeChanged (object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (Widget.IsVisible)
|
||||
ApplicationContext.InvokeUserCode (this.eventSink.OnBoundsChanged);
|
||||
Context.InvokeUserCode (this.eventSink.OnBoundsChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,10 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
}
|
||||
|
||||
void IBackend.InitializeBackend (object frontend)
|
||||
void IBackend.InitializeBackend (object frontend, ApplicationContext context)
|
||||
{
|
||||
this.frontend = (WindowFrame) frontend;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
void IWindowFrameBackend.Initialize (IWindowFrameEventSink eventSink)
|
||||
|
@ -56,6 +57,8 @@ namespace Xwt.WPFBackend
|
|||
Initialize ();
|
||||
}
|
||||
|
||||
public ApplicationContext Context { get; private set; }
|
||||
|
||||
public virtual void Initialize ()
|
||||
{
|
||||
}
|
||||
|
@ -133,7 +136,7 @@ namespace Xwt.WPFBackend
|
|||
var value = ToNonClientRect (new Rectangle (x, y, 1, 1));
|
||||
window.Top = value.Top;
|
||||
window.Left = value.Left;
|
||||
ApplicationContext.InvokeUserCode (delegate
|
||||
Context.InvokeUserCode (delegate
|
||||
{
|
||||
eventSink.OnBoundsChanged (Bounds);
|
||||
});
|
||||
|
@ -144,7 +147,7 @@ namespace Xwt.WPFBackend
|
|||
var value = ToNonClientRect (new Rectangle (0, 0, width, height));
|
||||
window.Width = value.Width;
|
||||
window.Height = value.Height;
|
||||
ApplicationContext.InvokeUserCode (delegate
|
||||
Context.InvokeUserCode (delegate
|
||||
{
|
||||
eventSink.OnBoundsChanged (Bounds);
|
||||
});
|
||||
|
@ -162,7 +165,7 @@ namespace Xwt.WPFBackend
|
|||
window.Left = value.Left;
|
||||
window.Width = value.Width;
|
||||
window.Height = value.Height;
|
||||
ApplicationContext.InvokeUserCode (delegate {
|
||||
Context.InvokeUserCode (delegate {
|
||||
eventSink.OnBoundsChanged (Bounds);
|
||||
});
|
||||
}
|
||||
|
@ -214,7 +217,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
void BoundsChangedHandler (object o, EventArgs args)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate () {
|
||||
Context.InvokeUserCode (delegate () {
|
||||
eventSink.OnBoundsChanged (Bounds);
|
||||
});
|
||||
}
|
||||
|
@ -223,7 +226,7 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
if((bool)e.NewValue)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate ()
|
||||
Context.InvokeUserCode (delegate ()
|
||||
{
|
||||
eventSink.OnShown ();
|
||||
});
|
||||
|
@ -234,7 +237,7 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
if((bool)e.NewValue == false)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate ()
|
||||
Context.InvokeUserCode (delegate ()
|
||||
{
|
||||
eventSink.OnHidden ();
|
||||
});
|
||||
|
@ -243,7 +246,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private void ClosingHandler (object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
ApplicationContext.InvokeUserCode (delegate ()
|
||||
Context.InvokeUserCode (delegate ()
|
||||
{
|
||||
e.Cancel = eventSink.OnCloseRequested ();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче