This commit is contained in:
aosoft 2018-02-02 13:34:01 +09:00
Родитель bff7ae7d05
Коммит 7fbc293995
18 изменённых файлов: 71 добавлений и 67 удалений

Просмотреть файл

@ -2,13 +2,14 @@
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class DrawingViewRenderer<TElement, TNativeElement> : public class DrawingViewRenderer<TElement, TNativeElement> :
ViewRenderer<TElement, TNativeElement> ViewRenderer<TElement, TNativeElement>
where TElement : View where TElement : View
where TNativeElement : System.Windows.Forms.Control where TNativeElement : WForms.Control
{ {
Matrix _matrix = new Matrix(); Matrix _matrix = new Matrix();
@ -55,7 +56,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
protected virtual void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) protected virtual void OnPaint(object sender, WForms.PaintEventArgs e)
{ {
var control = sender as TNativeElement; var control = sender as TNativeElement;
var element = Element; var element = Element;

Просмотреть файл

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Xamarin.Forms.Internals; using Xamarin.Forms.Internals;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
@ -15,7 +16,7 @@ namespace Xamarin.Forms.Platform.WinForms
private set; private set;
} }
public static void Init(System.Windows.Forms.Form mainForm) public static void Init(WForms.Form mainForm)
{ {
if (IsInitialized) if (IsInitialized)
{ {

Просмотреть файл

@ -4,10 +4,11 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class PlatformRenderer : System.Windows.Forms.Form public class PlatformRenderer : WForms.Form
{ {
public PlatformRenderer() public PlatformRenderer()
{ {

Просмотреть файл

@ -2,10 +2,11 @@
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class BoxViewRenderer : DrawingViewRenderer<BoxView, System.Windows.Forms.Control> public class BoxViewRenderer : DrawingViewRenderer<BoxView, WForms.Control>
{ {
Brush _brush = null; Brush _brush = null;
@ -25,7 +26,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.Control()); SetNativeControl(new WForms.Control());
} }
UpdateColor(Control); UpdateColor(Control);
@ -38,7 +39,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
base.OnPaint(sender, e); base.OnPaint(sender, e);
var control = sender as System.Windows.Forms.Control; var control = sender as WForms.Control;
if (control != null && _brush != null) if (control != null && _brush != null)
{ {
@ -56,7 +57,7 @@ namespace Xamarin.Forms.Platform.WinForms
UpdateColor(Control); UpdateColor(Control);
} }
void UpdateColor(System.Windows.Forms.Control nativeElement) void UpdateColor(WForms.Control nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;

Просмотреть файл

@ -1,9 +1,10 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class ButtonRenderer : ViewRenderer<Button, System.Windows.Forms.Button> public class ButtonRenderer : ViewRenderer<Button, WForms.Button>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -14,7 +15,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.Button()); SetNativeControl(new WForms.Button());
Control.Click += OnClick; Control.Click += OnClick;
} }
@ -57,7 +58,7 @@ namespace Xamarin.Forms.Platform.WinForms
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Internals #region Internals
void UpdateText(System.Windows.Forms.Button nativeElement) void UpdateText(WForms.Button nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;
@ -69,7 +70,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateTextColor(System.Windows.Forms.Button nativeElement) void UpdateTextColor(WForms.Button nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;
@ -85,7 +86,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateFont(System.Windows.Forms.Button nativeElement) void UpdateFont(WForms.Button nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;

Просмотреть файл

@ -1,12 +1,9 @@
using System; using System;
using System.Collections.Generic; using WForms = System.Windows.Forms;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class DatePickerRenderer : ViewRenderer<DatePicker, System.Windows.Forms.DateTimePicker> public class DatePickerRenderer : ViewRenderer<DatePicker, WForms.DateTimePicker>
{ {
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e) protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
{ {
@ -14,7 +11,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.DateTimePicker()); SetNativeControl(new WForms.DateTimePicker());
Control.ValueChanged += DateTimePicker_OnValueChanged; Control.ValueChanged += DateTimePicker_OnValueChanged;
} }
@ -28,7 +25,7 @@ namespace Xamarin.Forms.Platform.WinForms
base.OnElementChanged(e); base.OnElementChanged(e);
} }
void UpdateDate(System.Windows.Forms.DateTimePicker nativeElement) void UpdateDate(WForms.DateTimePicker nativeElement)
{ {
var element = Element; var element = Element;
if (nativeElement != null && element != null) if (nativeElement != null && element != null)
@ -37,7 +34,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateMaximumDate(System.Windows.Forms.DateTimePicker nativeElement) void UpdateMaximumDate(WForms.DateTimePicker nativeElement)
{ {
var element = Element; var element = Element;
if (nativeElement != null && element != null) if (nativeElement != null && element != null)
@ -46,7 +43,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateMinimumDate(System.Windows.Forms.DateTimePicker nativeElement) void UpdateMinimumDate(WForms.DateTimePicker nativeElement)
{ {
var element = Element; var element = Element;
if (nativeElement != null && element != null) if (nativeElement != null && element != null)
@ -55,7 +52,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateTextColor(System.Windows.Forms.DateTimePicker nativeElement) void UpdateTextColor(WForms.DateTimePicker nativeElement)
{ {
var element = Element; var element = Element;
if (nativeElement != null && element != null) if (nativeElement != null && element != null)

Просмотреть файл

@ -1,9 +1,10 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class EditorRenderer : ViewRenderer<Editor, System.Windows.Forms.TextBox> public class EditorRenderer : ViewRenderer<Editor, WForms.TextBox>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -16,12 +17,12 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.TextBox()); SetNativeControl(new WForms.TextBox());
Control.TextChanged += OnTextChanged; Control.TextChanged += OnTextChanged;
} }
Control.Multiline = true; Control.Multiline = true;
Control.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; Control.ScrollBars = WForms.ScrollBars.Vertical;
UpdateText(); UpdateText();
UpdateTextColor(); UpdateTextColor();

Просмотреть файл

@ -1,9 +1,10 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class EntryRenderer : ViewRenderer<Entry, System.Windows.Forms.TextBox> public class EntryRenderer : ViewRenderer<Entry, WForms.TextBox>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -16,7 +17,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.TextBox()); SetNativeControl(new WForms.TextBox());
Control.TextChanged += OnTextChanged; Control.TextChanged += OnTextChanged;
} }

Просмотреть файл

@ -1,13 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using WForms = System.Windows.Forms;
using System.Text;
using System.Threading.Tasks;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class LabelRenderer : ViewRenderer<Label, System.Windows.Forms.Label> public class LabelRenderer : ViewRenderer<Label, WForms.Label>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -18,7 +15,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.Label()); SetNativeControl(new WForms.Label());
} }
UpdateText(Control); UpdateText(Control);
@ -60,7 +57,7 @@ namespace Xamarin.Forms.Platform.WinForms
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Internals #region Internals
void UpdateText(System.Windows.Forms.Label nativeElement) void UpdateText(WForms.Label nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;
@ -72,7 +69,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateTextColor(System.Windows.Forms.Label nativeElement) void UpdateTextColor(WForms.Label nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;
@ -88,7 +85,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateAlign(System.Windows.Forms.Label nativeElement) void UpdateAlign(WForms.Label nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;
@ -101,7 +98,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateFont(System.Windows.Forms.Label nativeElement) void UpdateFont(WForms.Label nativeElement)
{ {
if (nativeElement == null) if (nativeElement == null)
return; return;

Просмотреть файл

@ -1,7 +1,8 @@
 using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class LayoutRenderer : ViewRenderer<Layout, System.Windows.Forms.Panel> public class LayoutRenderer : ViewRenderer<Layout, WForms.Panel>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -12,7 +13,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.Panel()); SetNativeControl(new WForms.Panel());
} }
} }

Просмотреть файл

@ -1,12 +1,8 @@
using System; using WForms = System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class PageRenderer : VisualElementRenderer<Page, System.Windows.Forms.Panel> public class PageRenderer : VisualElementRenderer<Page, WForms.Panel>
{ {
public PageRenderer() public PageRenderer()
{ {
@ -18,7 +14,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.Panel()); SetNativeControl(new WForms.Panel());
} }
} }
base.OnElementChanged(e); base.OnElementChanged(e);

Просмотреть файл

@ -1,10 +1,11 @@
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class PickerRenderer : ViewRenderer<Picker, System.Windows.Forms.ComboBox> public class PickerRenderer : ViewRenderer<Picker, WForms.ComboBox>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -19,12 +20,12 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.ComboBox()); SetNativeControl(new WForms.ComboBox());
Control.SelectedIndexChanged += OnSelectedIndexChanged; Control.SelectedIndexChanged += OnSelectedIndexChanged;
} }
e.NewElement.Items.AddCollectionChangedEvent(OnCollectionChanged); e.NewElement.Items.AddCollectionChangedEvent(OnCollectionChanged);
Control.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; Control.DropDownStyle = WForms.ComboBoxStyle.DropDownList;
UpdateItems(); UpdateItems();
UpdateSelectedIndex(); UpdateSelectedIndex();

Просмотреть файл

@ -1,9 +1,10 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class SliderRenderer : ViewRenderer<Slider, System.Windows.Forms.TrackBar> public class SliderRenderer : ViewRenderer<Slider, WForms.TrackBar>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -14,7 +15,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.TrackBar()); SetNativeControl(new WForms.TrackBar());
Control.ValueChanged += OnValueChanged; Control.ValueChanged += OnValueChanged;
} }

Просмотреть файл

@ -1,9 +1,10 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class StepperRenderer : ViewRenderer<Stepper, System.Windows.Forms.NumericUpDown> public class StepperRenderer : ViewRenderer<Stepper, WForms.NumericUpDown>
{ {
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e) protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
{ {
@ -11,7 +12,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.NumericUpDown()); SetNativeControl(new WForms.NumericUpDown());
} }
UpdateMinimum(); UpdateMinimum();

Просмотреть файл

@ -1,9 +1,10 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class SwitchRenderer : ViewRenderer<Switch, System.Windows.Forms.CheckBox> public class SwitchRenderer : ViewRenderer<Switch, WForms.CheckBox>
{ {
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
#region Event Handler #region Event Handler
@ -14,7 +15,7 @@ namespace Xamarin.Forms.Platform.WinForms
{ {
if (Control == null) if (Control == null)
{ {
SetNativeControl(new System.Windows.Forms.CheckBox()); SetNativeControl(new WForms.CheckBox());
Control.CheckedChanged += OnCheckedChanged; Control.CheckedChanged += OnCheckedChanged;
} }

Просмотреть файл

@ -5,20 +5,20 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WinFormsControl = System.Windows.Forms.Control; using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
public class VisualElementRendererCollection : IEnumerable<IVisualElementRenderer> public class VisualElementRendererCollection : IEnumerable<IVisualElementRenderer>
{ {
WinFormsControl _parentNativeElement = null; WForms.Control _parentNativeElement = null;
List<IVisualElementRenderer> _collection = new List<IVisualElementRenderer>(); List<IVisualElementRenderer> _collection = new List<IVisualElementRenderer>();
public VisualElementRendererCollection() public VisualElementRendererCollection()
{ {
} }
public WinFormsControl ParentNativeElement public WForms.Control ParentNativeElement
{ {
get => _parentNativeElement; get => _parentNativeElement;
@ -74,7 +74,7 @@ namespace Xamarin.Forms.Platform.WinForms
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
=> ((IEnumerable<IVisualElementRenderer>)_collection).GetEnumerator(); => ((IEnumerable<IVisualElementRenderer>)_collection).GetEnumerator();
void SetNativeElementParent(IVisualElementRenderer renderer, WinFormsControl parent) void SetNativeElementParent(IVisualElementRenderer renderer, WForms.Control parent)
{ {
var nativeElement = renderer?.NativeElement; var nativeElement = renderer?.NativeElement;
if (nativeElement != null) if (nativeElement != null)
@ -83,7 +83,7 @@ namespace Xamarin.Forms.Platform.WinForms
} }
} }
void UpdateParent(WinFormsControl parent) void UpdateParent(WForms.Control parent)
{ {
foreach (var item in _collection) foreach (var item in _collection)
{ {

Просмотреть файл

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms.Internals; using Xamarin.Forms.Internals;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
@ -16,7 +17,7 @@ namespace Xamarin.Forms.Platform.WinForms
internal WinFormsDeviceInfo() internal WinFormsDeviceInfo()
{ {
// DPI は考慮しない // DPI は考慮しない
var bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds; var bounds = WForms.Screen.PrimaryScreen.Bounds;
_pixelScreenSize = new Size(bounds.Width, bounds.Height); _pixelScreenSize = new Size(bounds.Width, bounds.Height);
_scaledScreenSize = _pixelScreenSize; _scaledScreenSize = _pixelScreenSize;
} }

Просмотреть файл

@ -9,17 +9,18 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms.Internals; using Xamarin.Forms.Internals;
using WForms = System.Windows.Forms;
namespace Xamarin.Forms.Platform.WinForms namespace Xamarin.Forms.Platform.WinForms
{ {
internal class WinFormsPlatformServices : IPlatformServices internal class WinFormsPlatformServices : IPlatformServices
{ {
System.Windows.Forms.Form _mainForm; WForms.Form _mainForm;
int _currentThreadId; int _currentThreadId;
Dictionary<NamedSize, double> _fontSizes = new Dictionary<NamedSize, double>(); Dictionary<NamedSize, double> _fontSizes = new Dictionary<NamedSize, double>();
static readonly MD5CryptoServiceProvider _md5 = new MD5CryptoServiceProvider(); static readonly MD5CryptoServiceProvider _md5 = new MD5CryptoServiceProvider();
internal WinFormsPlatformServices(System.Windows.Forms.Form mainForm, int currentThreadId) internal WinFormsPlatformServices(WForms.Form mainForm, int currentThreadId)
{ {
if (mainForm == null) if (mainForm == null)
{ {
@ -118,7 +119,7 @@ namespace Xamarin.Forms.Platform.WinForms
public void StartTimer(TimeSpan interval, Func<bool> callback) public void StartTimer(TimeSpan interval, Func<bool> callback)
{ {
var timer = new System.Windows.Forms.Timer(); var timer = new WForms.Timer();
timer.Interval = (int)interval.TotalMilliseconds; timer.Interval = (int)interval.TotalMilliseconds;
timer.Tick += (s, e) => timer.Tick += (s, e) =>
{ {
@ -132,7 +133,7 @@ namespace Xamarin.Forms.Platform.WinForms
public void QuitApplication() public void QuitApplication()
{ {
System.Windows.Forms.Application.Exit(); WForms.Application.Exit();
} }
} }
} }