Add MvvmCross_Mac solution for Xamarin Studio, Mac-implementation, sample project (N=0)

This commit is contained in:
Tim Uy 2013-09-20 17:58:20 -07:00
Родитель eb5d96a9d3
Коммит fb2dcb3b08
75 изменённых файлов: 11142 добавлений и 217 удалений

33
.gitignore поставляемый
Просмотреть файл

@ -32,3 +32,36 @@ _ReSharper*/
AppPackages/
*.ncrunchproject
*.nupkg
*.sdf
*.opensdf
#NuGet
packages/
!packages/Microsoft.Office.js.1.0.0/
!packages/repositories.config
#Allow NuGet.exe (do not ignore)
!NuGet.exe
*.orig
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
#CocoaPods
Pods

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

@ -33,12 +33,32 @@
<Reference Include="MonoMac, Version=0.0.0.0, Culture=neutral">
<Private>False</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="MvxMacBindingBuilder.cs" />
<Compile Include="Target\MvxNSViewVisibilityTargetBinding.cs" />
<Compile Include="Target\MvxNSViewVisibleTargetBinding.cs" />
<Compile Include="Target\MvxNSSliderValueTargetBinding.cs" />
<Compile Include="Target\MvxBaseNSDatePickerTargetBinding.cs" />
<Compile Include="Target\MvxNSDatePickerDateTargetBinding.cs" />
<Compile Include="Target\MvxNSDatePickerTimeTargetBinding.cs" />
<Compile Include="Target\MvxNSTextFieldTextTargetBinding.cs" />
<Compile Include="Target\MvxNSTextViewTextTargetBinding.cs" />
<Compile Include="Target\MvxNSSwitchOnTargetBinding.cs" />
<Compile Include="Target\MvxNSButtonTitleTargetBinding.cs" />
<Compile Include="Target\MvxNSSearchFieldTextTargetBinding.cs" />
<Compile Include="Views\IMvxBindable.cs" />
<Compile Include="Views\MvxView.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Properties\" />
<Folder Include="Target\" />
<Folder Include="Views\" />
<Folder Include="Views\Gestures\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>

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

@ -0,0 +1,17 @@
// IMvxBindingContext.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.MvvmCross.Binding.Interfaces.BindingContext;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Touch.Interfaces.BindingContext
{
public interface IMvxBindingContext
: IMvxBaseBindingContext<NSView>
{
}
}

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

@ -8,26 +8,64 @@
using System;
using Cirrious.MvvmCross.Binding.Bindings.Target.Construction;
using Cirrious.CrossCore.Converters;
using Cirrious.MvvmCross.Binding.BindingContext;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Binding.Mac.Target;
namespace Cirrious.MvvmCross.Binding.Touch
namespace Cirrious.MvvmCross.Binding.Mac
{
public class MvxMacBindingBuilder
: MvxBindingBuilder
{
private readonly Action<IMvxTargetBindingFactoryRegistry> _fillRegistryAction;
private readonly Action<IMvxValueConverterRegistry> _fillValueConvertersAction;
private readonly Action<IMvxTargetBindingFactoryRegistry> _fillRegistryAction;
private readonly Action<IMvxValueConverterRegistry> _fillValueConvertersAction;
private readonly Action<IMvxBindingNameRegistry> _fillBindingNamesAction;
public MvxMacBindingBuilder(Action<IMvxTargetBindingFactoryRegistry> fillRegistryAction,
Action<IMvxValueConverterRegistry> fillValueConvertersAction)
public MvxMacBindingBuilder(Action<IMvxTargetBindingFactoryRegistry> fillRegistryAction = null,
Action<IMvxValueConverterRegistry> fillValueConvertersAction = null,
Action<IMvxBindingNameRegistry> fillBindingNamesAction = null)
{
_fillRegistryAction = fillRegistryAction;
_fillValueConvertersAction = fillValueConvertersAction;
_fillRegistryAction = fillRegistryAction;
_fillValueConvertersAction = fillValueConvertersAction;
_fillBindingNamesAction = fillBindingNamesAction;
}
protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry)
{
base.FillTargetFactories(registry);
registry.RegisterCustomBindingFactory<NSView>("Visibility",
view =>
new MvxNSViewVisibilityTargetBinding(view));
registry.RegisterCustomBindingFactory<NSView>("Visible",
view =>
new MvxNSViewVisibleTargetBinding(view));
registry.RegisterPropertyInfoBindingFactory(typeof(MvxNSSliderValueTargetBinding), typeof(NSSlider),
"Value");
registry.RegisterPropertyInfoBindingFactory(typeof (MvxNSDatePickerDateTargetBinding),
typeof (NSDatePicker),
"Date");
registry.RegisterCustomBindingFactory<NSDatePicker>(
"Time",
view => new MvxNSDatePickerTimeTargetBinding(view, (typeof(NSDatePicker).GetProperty("Date"))));
registry.RegisterPropertyInfoBindingFactory(typeof (MvxNSTextFieldTextTargetBinding), typeof (NSTextField),
"StringValue");
registry.RegisterPropertyInfoBindingFactory(typeof (MvxNSTextViewTextTargetBinding), typeof (NSTextView),
"StringValue");
registry.RegisterPropertyInfoBindingFactory(typeof (MvxNSSwitchOnTargetBinding), typeof (NSButton), "On");
registry.RegisterPropertyInfoBindingFactory(typeof(MvxNSSearchFieldTextTargetBinding), typeof(NSSearchField), "Text");
registry.RegisterCustomBindingFactory<NSButton>("Title",
(button) => new MvxNSButtonTitleTargetBinding(button));
/* Todo: Address this for trackpad
registry.RegisterCustomBindingFactory<NSView>("Tap", view => new MvxNSViewTapTargetBinding(view));
registry.RegisterCustomBindingFactory<NSView>("DoubleTap", view => new MvxNSViewTapTargetBinding(view, 2, 1));
registry.RegisterCustomBindingFactory<NSView>("TwoFingerTap", view => new MvxNSViewTapTargetBinding(view, 1, 2));
*/
if (_fillRegistryAction != null)
_fillRegistryAction(registry);
}
@ -45,5 +83,31 @@ namespace Cirrious.MvvmCross.Binding.Touch
if (_fillValueConvertersAction != null)
_fillValueConvertersAction(registry);
}
}
protected override void FillDefaultBindingNames(IMvxBindingNameRegistry registry)
{
base.FillDefaultBindingNames(registry);
registry.AddOrOverwrite(typeof (NSButton), "TouchUpInside");
registry.AddOrOverwrite(typeof (NSSegmentedControl), "Clicked");
registry.AddOrOverwrite(typeof (NSSearchField), "Text");
registry.AddOrOverwrite(typeof (NSTextField), "Text");
registry.AddOrOverwrite(typeof (NSTextView), "Text");
registry.AddOrOverwrite(typeof (NSTextField), "Text");
// registry.AddOrOverwrite(typeof (MvxCollectionViewSource), "ItemsSource");
// registry.AddOrOverwrite(typeof (MvxTableViewSource), "ItemsSource");
// registry.AddOrOverwrite(typeof (MvxImageView), "ImageUrl");
registry.AddOrOverwrite(typeof (NSImageView), "Image");
registry.AddOrOverwrite(typeof (NSDatePicker), "Date");
registry.AddOrOverwrite(typeof (NSSlider), "Value");
registry.AddOrOverwrite(typeof (NSButton), "On");
registry.AddOrOverwrite(typeof (NSDatePicker), "Date");
// registry.AddOrOverwrite(typeof (IMvxImageHelper<UIImage>), "ImageUrl");
// registry.AddOrOverwrite(typeof (MvxImageViewLoader), "ImageUrl");
if (_fillBindingNamesAction != null)
_fillBindingNamesAction(registry);
}
}
}

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

@ -0,0 +1,63 @@
// MvxBaseUIDatePickerTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using System.Reflection;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public abstract class MvxBaseNSDatePickerTargetBinding : MvxPropertyInfoTargetBinding<NSDatePicker>
{
protected MvxBaseNSDatePickerTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
var datePicker = View;
if (datePicker == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error,
"Error - NSDatePicker is null in MvxBaseNSDatePickerTargetBinding");
}
else
{
datePicker.Action = new MonoMac.ObjCRuntime.Selector ("datePickerAction:");
}
}
[Export("datePickerAction:")]
private void datePickerAction()
{
var view = View;
if (view == null)
return;
FireValueChanged(GetValueFrom(view));
}
protected abstract object GetValueFrom(NSDatePicker view);
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.TwoWay; }
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (isDisposing)
{
var datePicker = View;
if (datePicker != null)
{
// datePicker.ValueChanged -= DatePickerOnValueChanged;
}
}
}
}
}

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

@ -0,0 +1,49 @@
// MvxUIButtonTitleTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSButtonTitleTargetBinding : MvxTargetBinding
{
protected NSButton Button
{
get { return base.Target as NSButton; }
}
public MvxNSButtonTitleTargetBinding(NSButton button)
: base(button)
{
if (button == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error, "Error - NSButton is null in MvxNSButtonTitleTargetBinding");
}
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
public override System.Type TargetType
{
get { return typeof (string); }
}
public override void SetValue(object value)
{
var button = Button;
if (button == null)
return;
button.Title = value as string;
}
}
}

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

@ -0,0 +1,36 @@
// MvxUIDatePickerDateTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using System.Reflection;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSDatePickerDateTargetBinding : MvxBaseNSDatePickerTargetBinding
{
public MvxNSDatePickerDateTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
}
protected override object GetValueFrom(NSDatePicker view)
{
return ((DateTime) view.DateValue).Date;
}
protected override object MakeSafeValue(object value)
{
if (value == null)
value = DateTime.UtcNow;
var date = (DateTime) value;
NSDate nsDate = date;
return nsDate;
}
}
}

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

@ -0,0 +1,53 @@
// MvxUIDatePickerTimeTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using System.Reflection;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSDatePickerTimeTargetBinding : MvxBaseNSDatePickerTargetBinding
{
public MvxNSDatePickerTimeTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
}
protected override object GetValueFrom(NSDatePicker view)
{
var components = NSCalendar.CurrentCalendar.Components(
NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second,
view.DateValue);
return new TimeSpan(components.Hour, components.Minute, components.Second);
}
public override Type TargetType
{
get { return typeof(TimeSpan); }
}
protected override object MakeSafeValue(object value)
{
if (value == null)
value = TimeSpan.FromSeconds(0);
var time = (TimeSpan) value;
var now = DateTime.Now;
var date = new DateTime(
now.Year,
now.Month,
now.Day,
time.Hours,
time.Minutes,
time.Seconds,
DateTimeKind.Local);
return date;
}
}
}

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

@ -0,0 +1,57 @@
// MvxUISearchBarTextTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System.Reflection;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSSearchFieldTextTargetBinding : MvxPropertyInfoTargetBinding<NSSearchField>
{
public MvxNSSearchFieldTextTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
var searchField = View;
if (searchField == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error,
"Error - NSSearchField is null in MvxNSSearchFieldTextTargetBinding");
}
else
{
searchField.Action = new MonoMac.ObjCRuntime.Selector ("searchFieldAction:");
}
}
[Export("searchFieldAction:")]
private void searchFieldAction()
{
FireValueChanged(View.StringValue);
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.TwoWay; }
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (isDisposing)
{
var searchBar = View;
if (searchBar != null)
{
// searchBar.TextChanged -= HandleSearchBarValueChanged;
}
}
}
}
}

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

@ -0,0 +1,59 @@
// MvxUISliderValueTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System.Reflection;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSSliderValueTargetBinding : MvxPropertyInfoTargetBinding<NSSlider>
{
public MvxNSSliderValueTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
var slider = View;
if (slider == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error, "Error - NSSlider is null in MvxNSSliderValueTargetBinding");
}
else
{
slider.Action = new MonoMac.ObjCRuntime.Selector ("sliderAction:");
}
}
[Export("sliderAction:")]
private void sliderAction()
{
var view = View;
if (view == null)
return;
FireValueChanged(view.IntValue);
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.TwoWay; }
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (isDisposing)
{
var slider = View;
if (slider != null)
{
// slider.ValueChanged -= HandleSliderValueChanged;
}
}
}
}
}

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

@ -0,0 +1,59 @@
// MvxUISwitchOnTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System.Reflection;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSSwitchOnTargetBinding : MvxPropertyInfoTargetBinding<NSButton>
{
public MvxNSSwitchOnTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
var checkBox = View;
if (checkBox == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error, "Error - NSButton is null in MvxNSSwitchOnTargetBinding");
}
else
{
checkBox.Action = new MonoMac.ObjCRuntime.Selector ("checkBoxAction:");
}
}
[Export("checkBoxAction:")]
private void checkBoxAction()
{
var view = View;
if (view == null)
return;
FireValueChanged(view.State == NSCellStateValue.On);
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.TwoWay; }
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (isDisposing)
{
var view = View;
if (view != null)
{
// view.ValueChanged -= HandleValueChanged;
}
}
}
}
}

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

@ -0,0 +1,57 @@
// MvxUITextFieldTextTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System.Reflection;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
using MonoMac.Foundation;
using System;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSTextFieldTextTargetBinding : MvxPropertyInfoTargetBinding<NSTextField>
{
public MvxNSTextFieldTextTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
var editText = View;
if (editText == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error,
"Error - NSTextField is null in MvxNSTextFieldTextTargetBinding");
}
else
{
editText.Changed += (object sender, EventArgs e) => {
var view = View;
if (view == null)
return;
FireValueChanged(view.StringValue);
};
}
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.TwoWay; }
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (isDisposing)
{
var editText = View;
if (editText != null)
{
// editText.EditingChanged -= HandleEditTextValueChanged;
}
}
}
}
}

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

@ -0,0 +1,60 @@
// MvxUITextViewTextTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using System.Reflection;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSTextViewTextTargetBinding : MvxPropertyInfoTargetBinding<NSTextView>
{
public MvxNSTextViewTextTargetBinding(object target, PropertyInfo targetPropertyInfo)
: base(target, targetPropertyInfo)
{
var editText = View;
if (editText == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error,
"Error - NSTextView is null in MvxNSTextViewTextTargetBinding");
}
else
{
// Todo: Perhaps we want to trigger on editing complete rather than didChange
editText.TextDidChange += EditTextDidChange;
}
}
private void EditTextDidChange(object sender, EventArgs eventArgs)
{
var view = View;
if (view == null)
return;
FireValueChanged(view.TextStorage.ToString());
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.TwoWay; }
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (isDisposing)
{
var editText = View;
if (editText != null)
{
editText.TextDidChange -= EditTextDidChange;
}
}
}
}
}

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

@ -0,0 +1,58 @@
// MvxNSViewVisibilityTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Contributed by Tim Uy, tim@loqu8.com
using Cirrious.CrossCore.Platform;
using Cirrious.CrossCore.UI;
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSViewVisibilityTargetBinding : MvxTargetBinding
{
protected NSView View
{
get { return (NSView) Target; }
}
public MvxNSViewVisibilityTargetBinding(NSView target)
: base(target)
{
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
public override System.Type TargetType
{
get { return typeof (MvxVisibility); }
}
public override void SetValue(object value)
{
var view = View;
if (view == null)
return;
var visibility = (MvxVisibility) value;
switch (visibility)
{
case MvxVisibility.Visible:
view.Hidden = false;
break;
case MvxVisibility.Collapsed:
view.Hidden = true;
break;
default:
MvxBindingTrace.Trace(MvxTraceLevel.Warning, "Visibility out of range {0}", value);
break;
}
}
}
}

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

@ -0,0 +1,45 @@
// MvxUIViewVisibleTargetBinding.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Contributed by Tim Uy, tim@loqu8.com
using Cirrious.MvvmCross.Binding.Bindings.Target;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Binding.Mac.Target
{
public class MvxNSViewVisibleTargetBinding : MvxTargetBinding
{
protected NSView View
{
get { return (NSView) Target; }
}
public MvxNSViewVisibleTargetBinding(NSView target)
: base(target)
{
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
public override System.Type TargetType
{
get { return typeof (bool); }
}
public override void SetValue(object value)
{
var view = View;
if (view == null)
return;
var visible = (bool) value;
view.Hidden = !visible;
}
}
}

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

@ -0,0 +1,18 @@
// IMvxBindable.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.CrossCore.Core;
using Cirrious.MvvmCross.Binding.BindingContext;
namespace Cirrious.MvvmCross.Binding.Mac.Views
{
public interface IMvxBindable
: IMvxBindingContextOwner
, IMvxDataConsumer
{
}
}

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

@ -0,0 +1,60 @@
// MvxView.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using System.Drawing;
using Cirrious.MvvmCross.Binding.BindingContext;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace Cirrious.MvvmCross.Binding.Mac.Views
{
public class MvxView
: NSView
, IMvxBindable
{
public IMvxBindingContext BindingContext { get; set; }
public MvxView()
{
this.CreateBindingContext();
}
public MvxView(IntPtr handle)
: base(handle)
{
this.CreateBindingContext();
}
public MvxView(NSCoder coder)
: base(coder)
{
this.CreateBindingContext();
}
public MvxView(RectangleF frame)
: base(frame)
{
this.CreateBindingContext();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
BindingContext.ClearAllBindings();
}
base.Dispose(disposing);
}
public object DataContext
{
get { return BindingContext.DataContext; }
set { BindingContext.DataContext = value; }
}
}
}

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

@ -30,13 +30,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="MonoMac" />
<Reference Include="MonoMac, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="ExtensionMethods\MvxMacDateTimeExtensionMethods.cs" />
<Compile Include="ExtensionMethods\MvxMacNSViewControllerExtensions.cs" />
<Compile Include="ExtensionMethods\MvxMacViewControllerExtensionMethods.cs" />
<Compile Include="Platform\MvxApplicationDelegate.cs" />
<Compile Include="Platform\MvxDebugTrace.cs" />
<Compile Include="Views\MvxMacUIThreadDispatcher.cs" />
@ -45,16 +44,29 @@
<Compile Include="Views\Presenters\MvxMacViewPresenter.cs" />
<Compile Include="Platform\MvxMacSetup.cs" />
<Compile Include="Views\MvxViewController.cs" />
<Compile Include="Views\Presenters\MvxBaseViewPresenter.cs" />
<Compile Include="Views\IMvxMacView.cs" />
<Compile Include="Views\IMvxMacNavigator.cs" />
<Compile Include="Views\IMvxMacViewCreator.cs" />
<Compile Include="Views\IMvxMacViewPresenter.cs" />
<Compile Include="Views\IMvxCanCreateTouchView.cs" />
<Compile Include="Views\IMvxCurrentRequest.cs" />
<Compile Include="Views\MvxViewModelInstanceRequest.cs" />
<Compile Include="Views\Presenters\MvxBaseMacViewPresenter.cs" />
<Compile Include="Views\Presenters\IMvxMacViewPresenter.cs" />
<Compile Include="Views\MvxViewControllerAdaptingExtensions.cs" />
<Compile Include="Views\MvxViewControllerAdapter.cs" />
<Compile Include="Views\MvxViewControllerExtensionMethods.cs" />
<Compile Include="Views\MvxBindingViewControllerAdapter.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\Cirrious.MvvmCross\Cirrious.MvvmCross.csproj">
<Project>{B6E27475-E7D0-448C-A5CC-5097DCA1E2DD}</Project>
<Name>Cirrious.MvvmCross</Name>
</ProjectReference>
<ProjectReference Include="..\Cirrious.MvvmCross.Binding.Mac\Cirrious.MvvmCross.Binding.Mac.csproj">
<Project>{B4789586-AEBB-4597-A849-23F3E45AF421}</Project>
<Name>Cirrious.MvvmCross.Binding.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>
<Name>Cirrious.CrossCore</Name>
@ -63,13 +75,9 @@
<Project>{64DCD397-9019-41E8-A928-E5F5C5DF185B}</Project>
<Name>Cirrious.MvvmCross.Binding</Name>
</ProjectReference>
<ProjectReference Include="..\Cirrious.MvvmCross\Cirrious.MvvmCross.csproj">
<Project>{B6E27475-E7D0-448C-A5CC-5097DCA1E2DD}</Project>
<Name>Cirrious.MvvmCross</Name>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore.Mac\Cirrious.CrossCore.Mac.csproj">
<Project>{596C75FB-F491-4037-89F6-B4F34183D83D}</Project>
<Name>Cirrious.CrossCore.Mac</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Interfaces\" />
</ItemGroup>
</Project>

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

@ -12,6 +12,7 @@ using System;
using Cirrious.MvvmCross.Platform;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Mac.Platform
{
public class MvxApplicationDelegate : NSApplicationDelegate

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

@ -9,7 +9,6 @@
using System;
using Cirrious.CrossCore.Interfaces.Platform.Diagnostics;
using Cirrious.CrossCore.Platform;
@ -19,14 +18,19 @@ namespace Cirrious.MvvmCross.Mac.Platform
{
public class MvxDebugTrace : IMvxTrace
{
public void Trace(MvxTraceLevel level, string tag, string message)
{
Console.WriteLine(tag + ": " + level + ": " + message);
}
public void Trace(MvxTraceLevel level, string tag, Func<string> message)
{
Console.WriteLine(tag + ":" + level + ":" + message());
}
public void Trace(MvxTraceLevel level, string tag, string message, params object[] args)
{
Console.WriteLine(tag + ": " + level + ": " + message, args);
}
public void Trace(MvxTraceLevel level, string tag, string message)
{
Console.WriteLine(tag + ": " + level + ": " + message);
}
public void Trace(MvxTraceLevel level, string tag, string message, params object[] args)
{
Console.WriteLine(tag + ": " + level + ": " + message, args);
}
}
}

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

@ -10,13 +10,21 @@
using System;
using System.Collections.Generic;
using Cirrious.MvvmCross.Platform;
using Cirrious.MvvmCross.Mac.Interfaces;
using Cirrious.MvvmCross.Mac.Views;
using Cirrious.MvvmCross.Views;
using System.Reflection;
using Cirrious.CrossCore;
using Cirrious.CrossCore.Converters;
using Cirrious.CrossCore.Platform;
using Cirrious.CrossCore.Plugins;
using Cirrious.MvvmCross.Binding;
using Cirrious.MvvmCross.Binding.Binders;
using Cirrious.MvvmCross.Binding.BindingContext;
using Cirrious.MvvmCross.Binding.Bindings.Target.Construction;
using Cirrious.MvvmCross.Platform;
using Cirrious.MvvmCross.Mac.Views;
using Cirrious.MvvmCross.Views;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Binding.Mac;
namespace Cirrious.MvvmCross.Mac.Platform
{
@ -24,27 +32,50 @@ namespace Cirrious.MvvmCross.Mac.Platform
: MvxSetup
{
private readonly MvxApplicationDelegate _applicationDelegate;
private readonly IMvxMacViewPresenter _presenter;
private readonly NSWindow _window;
private IMvxMacViewPresenter _presenter;
protected MvxMacSetup(MvxApplicationDelegate applicationDelegate, NSWindow window)
{
_window = window;
_applicationDelegate = applicationDelegate;
}
protected MvxMacSetup(MvxApplicationDelegate applicationDelegate, IMvxMacViewPresenter presenter)
{
_presenter = presenter;
_applicationDelegate = applicationDelegate;
}
protected NSWindow Window
{
get { return _window; }
}
protected override void InitializeDebugServices()
{
protected MvxApplicationDelegate ApplicationDelegate
{
get { return _applicationDelegate; }
}
protected override IMvxTrace CreateDebugTrace()
{
return new MvxDebugTrace();
}
protected override void InitializeDebugServices()
{
Mvx.RegisterSingleton<IMvxTrace>(new MvxDebugTrace());
base.InitializeDebugServices();
}
base.InitializeDebugServices();
}
protected override IMvxPluginManager CreatePluginManager()
{
protected override IMvxPluginManager CreatePluginManager()
{
var toReturn = new MvxLoaderPluginManager();
var registry = new MvxLoaderPluginRegistry(".Mac", toReturn.Loaders);
var registry = new MvxLoaderPluginRegistry(".Mac", toReturn.Finders);
AddPluginsLoaders(registry);
return toReturn;
}
}
protected virtual void AddPluginsLoaders(MvxLoaderPluginRegistry loaders)
{
@ -54,13 +85,14 @@ namespace Cirrious.MvvmCross.Mac.Platform
protected sealed override MvxViewsContainer CreateViewsContainer()
{
var container = new MvxMacViewsContainer();
RegisterTouchViewCreator(container);
RegisterMacViewCreator(container);
return container;
}
protected void RegisterTouchViewCreator(MvxMacViewsContainer container)
protected void RegisterMacViewCreator(MvxMacViewsContainer container)
{
Mvx.RegisterSingleton<IMvxMacViewCreator>(container);
Mvx.RegisterSingleton<IMvxCurrentRequest>(container);
}
protected override IMvxViewDispatcher CreateViewDispatcher()
@ -68,15 +100,36 @@ namespace Cirrious.MvvmCross.Mac.Platform
return new MvxMacViewDispatcher(_presenter);
}
protected override void InitializePlatformServices ()
protected override void InitializePlatformServices()
{
RegisterPresenter();
RegisterLifetime();
}
protected virtual void RegisterLifetime()
{
Mvx.RegisterSingleton<IMvxLifetime>(_applicationDelegate);
}
protected override IDictionary<Type, Type> GetViewModelViewLookup()
{
return GetViewModelViewLookup(GetType().Assembly, typeof(IMvxMacView));
}
protected IMvxMacViewPresenter Presenter
{
get
{
_presenter = _presenter ?? CreatePresenter();
return _presenter;
}
}
protected virtual IMvxMacViewPresenter CreatePresenter()
{
return new MvxMacViewPresenter(_applicationDelegate, _window);
}
protected virtual void RegisterPresenter()
{
var presenter = Presenter;
Mvx.RegisterSingleton(presenter);
}
protected override void InitializeLastChance()
{
@ -86,31 +139,46 @@ namespace Cirrious.MvvmCross.Mac.Platform
protected virtual void InitialiseBindingBuilder()
{
RegisterBindingBuilderCallbacks();
var bindingBuilder = CreateBindingBuilder();
bindingBuilder.DoRegistration();
}
protected virtual void RegisterBindingBuilderCallbacks()
{
Mvx.CallbackWhenRegistered<IMvxValueConverterRegistry>(FillValueConverters);
Mvx.CallbackWhenRegistered<IMvxTargetBindingFactoryRegistry>(FillTargetFactories);
Mvx.CallbackWhenRegistered<IMvxBindingNameRegistry>(FillBindingNames);
}
protected virtual MvxBindingBuilder CreateBindingBuilder()
{
var bindingBuilder = new MvxMacBindingBuilder(FillTargetFactories, FillValueConverters);
var bindingBuilder = new MvxMacBindingBuilder();
return bindingBuilder;
}
protected virtual void FillBindingNames (IMvxBindingNameRegistry obj)
{
// this base class does nothing
}
protected virtual void FillValueConverters(IMvxValueConverterRegistry registry)
{
var holders = ValueConverterHolders;
if (holders == null)
return;
var filler = new MvxInstanceBasedValueConverterRegistryFiller(registry);
var staticFiller = new MvxStaticBasedValueConverterRegistryFiller(registry);
foreach (var converterHolder in holders)
registry.Fill(ValueConverterAssemblies);
registry.Fill(ValueConverterHolders);
}
protected virtual List<Assembly> ValueConverterAssemblies
{
get
{
filler.AddFieldConverters(converterHolder);
staticFiller.AddStaticFieldConverters(converterHolder);
var toReturn = new List<Assembly>();
toReturn.AddRange(GetViewModelAssemblies());
toReturn.AddRange(GetViewAssemblies());
return toReturn;
}
}
protected virtual IEnumerable<Type> ValueConverterHolders
{
get { return null; }

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

@ -0,0 +1,132 @@
// MvxMacSetup.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using System.Collections.Generic;
using System.Reflection;
using Cirrious.CrossCore;
using Cirrious.CrossCore.Converters;
using Cirrious.CrossCore.Platform;
using Cirrious.CrossCore.Plugins;
using Cirrious.MvvmCross.Binding;
using Cirrious.MvvmCross.Binding.Binders;
using Cirrious.MvvmCross.Binding.Bindings.Target.Construction;
using Cirrious.MvvmCross.Binding.Touch;
using Cirrious.MvvmCross.Platform;
using Cirrious.MvvmCross.Mac.Views;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using Cirrious.MvvmCross.Views;
using Cirrious.CrossCore.Mac.Views;
namespace Cirrious.MvvmCross.Mac.Platform
{
public abstract class MvxMacSetup
: MvxSetup
{
private readonly MvxApplicationDelegate _applicationDelegate;
private readonly IMvxMacViewPresenter _presenter;
protected MvxMacSetup(MvxApplicationDelegate applicationDelegate, IMvxMacViewPresenter presenter)
{
_presenter = presenter;
_applicationDelegate = applicationDelegate;
}
protected override void InitializeDebugServices()
{
Mvx.RegisterSingleton<IMvxTrace>(new MvxDebugTrace());
base.InitializeDebugServices();
}
protected override IMvxPluginManager CreatePluginManager()
{
var toReturn = new MvxLoaderPluginManager();
var registry = new MvxLoaderPluginRegistry(".Mac", toReturn.Finders);
AddPluginsLoaders(registry);
return toReturn;
}
protected virtual void AddPluginsLoaders(MvxLoaderPluginRegistry loaders)
{
// none added by default
}
protected override sealed MvxViewsContainer CreateViewsContainer()
{
var container = new MvxMacViewsContainer();
RegisterTouchViewCreator(container);
return container;
}
protected virtual void RegisterTouchViewCreator(MvxMacViewsContainer container)
{
Mvx.RegisterSingleton<IMvxMacViewCreator>(container);
Mvx.RegisterSingleton<IMvxCurrentRequest>(container);
}
protected override IMvxViewDispatcher CreateViewDispatcher()
{
return new MvxMacViewDispatcher(_presenter);
}
protected override void InitializePlatformServices()
{
Mvx.RegisterSingleton(_presenter);
Mvx.RegisterSingleton<IMvxLifetime>(_applicationDelegate);
}
protected override void InitializeLastChance()
{
InitialiseBindingBuilder();
base.InitializeLastChance();
}
protected virtual void InitialiseBindingBuilder()
{
var bindingBuilder = CreateBindingBuilder();
bindingBuilder.DoRegistration();
}
protected virtual MvxBindingBuilder CreateBindingBuilder()
{
var bindingBuilder = new MvxMacBindingBuilder(FillTargetFactories, FillValueConverters, FillBindingNames);
return bindingBuilder;
}
protected virtual void FillBindingNames (Cirrious.MvvmCross.Binding.BindingContext.IMvxBindingNameRegistry obj)
{
// this base class does nothing
}
protected virtual void FillValueConverters(IMvxValueConverterRegistry registry)
{
registry.Fill(ValueConverterAssemblies);
registry.Fill(ValueConverterHolders);
}
protected virtual List<Type> ValueConverterHolders
{
get { return new List<Type>(); }
}
protected virtual List<Assembly> ValueConverterAssemblies
{
get
{
var toReturn = new List<Assembly>();
toReturn.AddRange(GetViewModelAssemblies());
toReturn.AddRange(GetViewAssemblies());
return toReturn;
}
}
protected virtual void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry)
{
// this base class does nothing
}
}
}

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

@ -0,0 +1,43 @@
// MvxBindingViewControllerAdapter.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using Cirrious.CrossCore.Platform;
using Cirrious.CrossCore.Mac.Views;
using Cirrious.MvvmCross.Binding.BindingContext;
namespace Cirrious.MvvmCross.Mac.Views
{
public class MvxBindingViewControllerAdapter : MvxBaseViewControllerAdapter
{
protected IMvxMacView MacView
{
get { return ViewController as IMvxMacView; }
}
public MvxBindingViewControllerAdapter(IMvxEventSourceViewController eventSource)
: base(eventSource)
{
if (!(eventSource is IMvxMacView))
throw new ArgumentException("eventSource", "eventSource should be a IMvxMacView");
MacView.BindingContext = new MvxBindingContext();
}
public override void HandleDisposeCalled(object sender, EventArgs e)
{
if (MacView == null)
{
MvxTrace.Warning( "MacView is null for clearup of bindings in type {0}",
MacView.GetType().Name);
return;
}
MacView.ClearAllBindings();
base.HandleDisposeCalled(sender, e);
}
}
}

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

@ -8,13 +8,10 @@
// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com
using System;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Interfaces.Views;
using Cirrious.MvvmCross.Mac.Interfaces;
using Cirrious.MvvmCross.Views;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.CrossCore.Platform.Diagnostics;
using Cirrious.CrossCore;
using Cirrious.MvvmCross.Views;
namespace Cirrious.MvvmCross.Mac.Views
{
@ -29,21 +26,20 @@ namespace Cirrious.MvvmCross.Mac.Views
_presenter = presenter;
}
public bool RequestNavigate(MvxViewModelRequest request)
{
Action action = () =>
{
Mvx.TaggedTrace("MacNavigation", "Navigate requested");
_presenter.Show(request);
};
return RequestMainThreadAction(action);
}
public bool ShowViewModel(MvxViewModelRequest request)
{
Action action = () =>
{
MvxTrace.TaggedTrace("MacNavigation", "Navigate requested");
_presenter.Show(request);
};
return RequestMainThreadAction(action);
}
public bool ChangePresentation(MvxPresentationHint hint)
{
Action action = () =>
{
Mvx.TaggedTrace("MacNavigation", "Change presentation requested");
MvxTrace.TaggedTrace("MacNavigation", "Change presentation requested");
_presenter.ChangePresentation(hint);
};
return RequestMainThreadAction(action);

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

@ -8,7 +8,6 @@
// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com
using System;
using Cirrious.MvvmCross.Mac.Interfaces;
using Cirrious.MvvmCross.Views;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.CrossCore.Exceptions;
@ -16,7 +15,7 @@ using Cirrious.CrossCore.Exceptions;
namespace Cirrious.MvvmCross.Mac.Views
{
public class MvxMacViewsContainer
: MvxViewsContainer, IMvxMacViewCreator
: MvxViewsContainer, IMvxMacViewCreator, IMvxCurrentRequest
{
public MvxViewModelRequest CurrentRequest { get; private set; }

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

@ -11,15 +11,12 @@
using System;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Mac.ExtensionMethods;
using Cirrious.MvvmCross.Mac.Interfaces;
using Cirrious.MvvmCross.Views;
using MonoMac.Foundation;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.MvvmCross.Binding.Interfaces.BindingContext;
using MonoMac.AppKit;
using Cirrious.CrossCore.Mac.Views;
using Cirrious.MvvmCross.Binding.BindingContext;
using Cirrious.MvvmCross.Views;
using Cirrious.MvvmCross.ViewModels;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Mac.Views

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

@ -0,0 +1,40 @@
// MvxViewControllerAdapter.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using Cirrious.CrossCore.Mac.Views;
using Cirrious.MvvmCross.Views;
namespace Cirrious.MvvmCross.Mac.Views
{
public class MvxViewControllerAdapter : MvxBaseViewControllerAdapter
{
protected IMvxMacView MacView
{
get { return base.ViewController as IMvxMacView; }
}
public MvxViewControllerAdapter(IMvxEventSourceViewController eventSource)
: base(eventSource)
{
if (!(eventSource is IMvxMacView))
throw new ArgumentException("eventSource", "eventSource should be a IMvxMacView");
}
public override void HandleViewDidLoadCalled(object sender, EventArgs e)
{
MacView.OnViewCreate();
base.HandleViewDidLoadCalled(sender, e);
}
public override void HandleDisposeCalled(object sender, EventArgs e)
{
MacView.OnViewDestroy();
base.HandleDisposeCalled(sender, e);
}
}
}

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

@ -0,0 +1,20 @@
// MvxViewControllerAdaptingExtensions.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.CrossCore.Mac.Views;
namespace Cirrious.MvvmCross.Mac.Views
{
public static class MvxViewControllerAdaptingExtensions
{
public static void AdaptForBinding(this IMvxEventSourceViewController view)
{
var adapter = new MvxViewControllerAdapter(view);
var binding = new MvxBindingViewControllerAdapter(view);
}
}
}

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

@ -0,0 +1,97 @@
// MvxViewControllerExtensionMethods.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System.Collections.Generic;
using Cirrious.CrossCore.Exceptions;
using Cirrious.CrossCore;
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.Platform;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.MvvmCross.Views;
namespace Cirrious.MvvmCross.Mac.Views
{
public static class MvxViewControllerExtensionMethods
{
public static void OnViewCreate(this IMvxMacView macView)
{
//var view = touchView as IMvxView<TViewModel>;
macView.OnViewCreate(() => { return macView.LoadViewModel(); });
}
private static IMvxViewModel LoadViewModel(this IMvxMacView macView)
{
#warning NullViewModel needed?
// how to do N
//if (typeof (TViewModel) == typeof (MvxNullViewModel))
// return new MvxNullViewModel() as TViewModel;
if (macView.Request == null)
{
MvxTrace.Trace(
"Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction");
macView.Request = Mvx.Resolve<IMvxCurrentRequest>().CurrentRequest;
}
var instanceRequest = macView.Request as MvxViewModelInstanceRequest;
if (instanceRequest != null)
{
return instanceRequest.ViewModelInstance;
}
var loader = Mvx.Resolve<IMvxViewModelLoader>();
var viewModel = loader.LoadViewModel(macView.Request, null /* no saved state on iOS currently */);
if (viewModel == null)
throw new MvxException("ViewModel not loaded for " + macView.Request.ViewModelType);
return viewModel;
}
public static IMvxMacView CreateViewControllerFor<TTargetViewModel>(this IMvxMacView view,
object parameterObject)
where TTargetViewModel : class, IMvxViewModel
{
return
view.CreateViewControllerFor<TTargetViewModel>(parameterObject == null
? null
: parameterObject.ToSimplePropertyDictionary());
}
#warning TODO - could this move down to IMvxView level?
public static IMvxMacView CreateViewControllerFor<TTargetViewModel>(
this IMvxMacView view,
IDictionary<string, string> parameterValues = null)
where TTargetViewModel : class, IMvxViewModel
{
var parameterBundle = new MvxBundle(parameterValues);
var request = new MvxViewModelRequest<TTargetViewModel>(parameterBundle, null,
MvxRequestedBy.UserAction);
return view.CreateViewControllerFor(request);
}
public static IMvxMacView CreateViewControllerFor<TTargetViewModel>(
this IMvxMacView view,
MvxViewModelRequest request)
where TTargetViewModel : class, IMvxViewModel
{
return Mvx.Resolve<IMvxMacViewCreator>().CreateView(request);
}
public static IMvxMacView CreateViewControllerFor(
this IMvxMacView view,
MvxViewModelRequest request)
{
return Mvx.Resolve<IMvxMacViewCreator>().CreateView(request);
}
public static IMvxMacView CreateViewControllerFor(
this IMvxMacView view,
IMvxViewModel viewModel)
{
return Mvx.Resolve<IMvxMacViewCreator>().CreateView(viewModel);
}
}
}

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

@ -0,0 +1,17 @@
// IMvxTouchViewPresenter.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.MvvmCross.ViewModels;
using Cirrious.MvvmCross.Views;
namespace Cirrious.MvvmCross.Mac.Views.Presenters
{
public interface IMvxMacViewPresenter
: IMvxViewPresenter
{
}
}

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

@ -0,0 +1,26 @@
// MvxBaseMacViewPresenter.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.CrossCore.Platform;
using Cirrious.MvvmCross.ViewModels;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Mac.Views.Presenters
{
public class MvxBaseMacViewPresenter
: IMvxMacViewPresenter
{
public virtual void Show(MvxViewModelRequest view)
{
}
public virtual void ChangePresentation(MvxPresentationHint hint)
{
MvxTrace.Warning("Hint ignored {0}", hint.GetType().Name);
}
}
}

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

@ -1,72 +1,86 @@
// <copyright file="MvxTouchViewPresenter.cs" company="Cirrious">
// (c) Copyright Cirrious. http://www.cirrious.com
// This source is subject to the Microsoft Public License (Ms-PL)
// Please see license.txt on http://opensource.org/licenses/ms-pl.html
// All other rights reserved.
// </copyright>
// MvxTouchViewPresenter.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com
using Cirrious.MvvmCross.Interfaces.Views;
using System;
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Mac.Interfaces;
using Cirrious.MvvmCross.Views;
using MonoMac.AppKit;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.CrossCore.Interfaces.IoC;
using Cirrious.CrossCore.Exceptions;
using Cirrious.CrossCore.Platform.Diagnostics;
using Cirrious.CrossCore;
using Cirrious.MvvmCross.ViewModels;
using MonoMac.AppKit;
namespace Cirrious.MvvmCross.Mac.Views.Presenters
{
public class MvxMacViewPresenter
: MvxBaseViewPresenter
public class MvxMacViewPresenter
: MvxBaseMacViewPresenter
{
private readonly NSApplicationDelegate _applicationDelegate;
private readonly NSWindow _window;
private readonly NSWindow _window;
protected NSWindow Window{
protected virtual NSApplicationDelegate ApplicationDelegate{
get{
return _applicationDelegate;
}
}
protected virtual NSWindow Window{
get{
return _window;
}
}
public MvxMacViewPresenter (NSApplicationDelegate applicationDelegate, NSWindow window)
public MvxMacViewPresenter(NSApplicationDelegate applicationDelegate, NSWindow window)
{
_applicationDelegate = applicationDelegate;
_window = window;
}
_window = window;
}
protected virtual void PlaceView(MvxShowViewModelRequest request, NSViewController viewController)
public override void Show(MvxViewModelRequest request)
{
var view = CreateView(request);
#warning Need to reinsert ClearTop type functionality here
//if (request.ClearTop)
// ClearBackStack();
Show(view, request);
}
public override void ChangePresentation(MvxPresentationHint hint)
{
if (hint is MvxClosePresentationHint)
{
Close((hint as MvxClosePresentationHint).ViewModelToClose);
return;
}
base.ChangePresentation(hint);
}
private IMvxMacView CreateView(MvxViewModelRequest request)
{
return Mvx.Resolve<IMvxMacViewCreator>().CreateView(request);
}
protected virtual void Show(IMvxMacView view, MvxViewModelRequest request)
{
var viewController = view as NSViewController;
if (viewController == null)
throw new MvxException("Passed in IMvxTouchView is not a UIViewController");
Show (viewController, request);
}
protected virtual void Show(NSViewController viewController, MvxViewModelRequest request)
{
Window.ContentView.AddSubview(viewController.View);
}
protected virtual IMvxMacView GetView(MvxShowViewModelRequest request)
{
var creator = Mvx.Resolve<IMvxMacViewCreator>();
return creator.CreateView(request);
}
public override void Show(MvxShowViewModelRequest request)
public virtual void Close(IMvxViewModel toClose)
{
try
{
var view = GetView(request);
var viewController = view as NSViewController;
if (viewController == null)
throw new MvxException("Passed in IMvxTouchView is not a NSViewController");
PlaceView(request, viewController);
}
catch (Exception exception)
{
MvxTrace.Trace("Error seen during navigation request to {0} - error {1}", request.ViewModelType.Name,
exception.ToLongString());
}
Mvx.Error("Sorry - don't know how to close a view!");
}
}
}
}
}

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

@ -117,12 +117,6 @@
<Compile Include="ViewModels\MvxViewModelRequest.cs" />
<Compile Include="Views\MvxViewsContainer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>
<Name>Cirrious.CrossCore</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@ -132,4 +126,10 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>
<Name>Cirrious.CrossCore</Name>
</ProjectReference>
</ItemGroup>
</Project>

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

@ -35,15 +35,16 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MyClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Views\MvxEventSourceViewController.cs" />
<Compile Include="Views\IMvxEventSourceViewController.cs" />
<Compile Include="Views\MvxBaseViewControllerAdapter.cs" />
<Compile Include="Views\MvxDelegateExtensionMethods.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Views\" />
<Folder Include="Platform\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cirrious.CrossCore\Cirrious.CrossCore.csproj">

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

@ -3,20 +3,25 @@ using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("Cirrious.CrossCore.Mac")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("stuartlodge")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
[assembly: AssemblyTitle("Cirrious.CrossCore.Mac")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("stuartlodge")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

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

@ -13,9 +13,9 @@ namespace Cirrious.CrossCore.Mac.Views
public interface IMvxEventSourceViewController : IMvxDisposeSource
{
event EventHandler ViewDidLoadCalled;
event EventHandler<MvxValueEventArgs<bool>> ViewWillAppearCalled;
event EventHandler<MvxValueEventArgs<bool>> ViewDidAppearCalled;
event EventHandler<MvxValueEventArgs<bool>> ViewDidDisappearCalled;
event EventHandler<MvxValueEventArgs<bool>> ViewWillDisappearCalled;
}
// event EventHandler<MvxValueEventArgs<bool>> ViewWillAppearCalled;
// event EventHandler<MvxValueEventArgs<bool>> ViewDidAppearCalled;
// event EventHandler<MvxValueEventArgs<bool>> ViewDidDisappearCalled;
// event EventHandler<MvxValueEventArgs<bool>> ViewWillDisappearCalled;
}
}

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

@ -29,10 +29,10 @@ namespace Cirrious.CrossCore.Mac.Views
throw new ArgumentException("eventSource - eventSource should be a NSViewController");
_eventSource = eventSource;
_eventSource.ViewDidAppearCalled += HandleViewDidAppearCalled;
_eventSource.ViewDidDisappearCalled += HandleViewDidDisappearCalled;
_eventSource.ViewWillAppearCalled += HandleViewWillAppearCalled;
_eventSource.ViewWillDisappearCalled += HandleViewWillDisappearCalled;
// _eventSource.ViewDidAppearCalled += HandleViewDidAppearCalled;
// _eventSource.ViewDidDisappearCalled += HandleViewDidDisappearCalled;
// _eventSource.ViewWillAppearCalled += HandleViewWillAppearCalled;
// _eventSource.ViewWillDisappearCalled += HandleViewWillDisappearCalled;
_eventSource.DisposeCalled += HandleDisposeCalled;
_eventSource.ViewDidLoadCalled += HandleViewDidLoadCalled;
}
@ -45,20 +45,20 @@ namespace Cirrious.CrossCore.Mac.Views
{
}
public virtual void HandleViewWillDisappearCalled(object sender, MvxValueEventArgs<bool> e)
{
}
public virtual void HandleViewWillAppearCalled(object sender, MvxValueEventArgs<bool> e)
{
}
public virtual void HandleViewDidDisappearCalled(object sender, MvxValueEventArgs<bool> e)
{
}
public virtual void HandleViewDidAppearCalled(object sender, MvxValueEventArgs<bool> e)
{
}
// public virtual void HandleViewWillDisappearCalled(object sender, MvxValueEventArgs<bool> e)
// {
// }
//
// public virtual void HandleViewWillAppearCalled(object sender, MvxValueEventArgs<bool> e)
// {
// }
//
// public virtual void HandleViewDidDisappearCalled(object sender, MvxValueEventArgs<bool> e)
// {
// }
//
// public virtual void HandleViewDidAppearCalled(object sender, MvxValueEventArgs<bool> e)
// {
// }
}
}

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

@ -0,0 +1,32 @@
// MvxDelegateExtensionMethods.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
using System;
using Cirrious.CrossCore.Core;
namespace Cirrious.CrossCore.Mac.Views
{
#warning Move these extension methods to the main corecross project
public static class MvxDelegateExtensionMethods
{
public static void Raise(this EventHandler eventHandler, object sender)
{
if (eventHandler == null)
return;
eventHandler(sender, EventArgs.Empty);
}
public static void Raise<T>(this EventHandler<MvxValueEventArgs<T>> eventHandler, object sender, T value)
{
if (eventHandler == null)
return;
eventHandler(sender, new MvxValueEventArgs<T>(value));
}
}
}

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

@ -11,7 +11,7 @@ using MonoMac.AppKit;
using Cirrious.CrossCore.Mac.Views;
using MonoMac.Foundation;
namespace Cirrious.CrossCore.Touch.Views
namespace Cirrious.CrossCore.Mac.Views
{
public class MvxEventSourceViewController
: NSViewController
@ -19,62 +19,81 @@ namespace Cirrious.CrossCore.Touch.Views
{
protected MvxEventSourceViewController()
{
Initialize ();
}
protected MvxEventSourceViewController(IntPtr handle)
: base(handle)
{
Initialize ();
}
protected MvxEventSourceViewController(NSCoder coder)
: base(coder)
{
Initialize ();
}
protected MvxEventSourceViewController(string nibName, NSBundle bundle)
: base(nibName, bundle)
{
{
Initialize ();
}
private void Initialize()
{
}
public override void ViewWillDisappear(bool animated)
{
base.ViewWillDisappear(animated);
ViewWillDisappearCalled.Raise(this, animated);
}
public override void LoadView ()
{
base.LoadView ();
ViewDidLoad ();
}
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
ViewDidDisappearCalled.Raise(this, animated);
}
public override void ViewWillAppear(bool animated)
// public override void ViewWillDisappear(bool animated)
// {
// base.ViewWillDisappear(animated);
// ViewWillDisappearCalled.Raise(this, animated);
// }
//
// public override void ViewDidAppear(bool animated)
// {
// base.ViewDidAppear(animated);
// ViewDidDisappearCalled.Raise(this, animated);
// }
//
// public override void ViewWillAppear(bool animated)
// {
// base.ViewWillAppear(animated);
// ViewWillAppearCalled.Raise(this, animated);
// }
//
// public override void ViewDidDisappear(bool animated)
// {
// base.ViewDidDisappear(animated);
// ViewDidAppearCalled.Raise(this, animated);
// }
//
public virtual void ViewDidLoad()
{
base.ViewWillAppear(animated);
ViewWillAppearCalled.Raise(this, animated);
}
public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
ViewDidAppearCalled.Raise(this, animated);
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
ViewDidLoadCalled.Raise(this);
}
protected override void Dispose(bool disposing)
protected override void Dispose(bool disposing)
{
if (disposing)
{
DisposeCalled.Raise(this);
}
if (disposing)
{
DisposeCalled.Raise (this);
}
base.Dispose(disposing);
}
public event EventHandler ViewDidLoadCalled;
public event EventHandler<MvxValueEventArgs<bool>> ViewWillAppearCalled;
public event EventHandler<MvxValueEventArgs<bool>> ViewDidAppearCalled;
public event EventHandler<MvxValueEventArgs<bool>> ViewDidDisappearCalled;
public event EventHandler<MvxValueEventArgs<bool>> ViewWillDisappearCalled;
// public event EventHandler<MvxValueEventArgs<bool>> ViewWillAppearCalled;
// public event EventHandler<MvxValueEventArgs<bool>> ViewDidAppearCalled;
// public event EventHandler<MvxValueEventArgs<bool>> ViewDidDisappearCalled;
// public event EventHandler<MvxValueEventArgs<bool>> ViewWillDisappearCalled;
public event EventHandler DisposeCalled;
}
}

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

@ -9,8 +9,8 @@
<RootNamespace>CrossUI.Core</RootNamespace>
<AssemblyName>CrossUI.Core</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>

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

@ -0,0 +1,17 @@
using Cirrious.CrossCore.IoC;
using FirstDemo.Core.ViewModels;
namespace FirstDemo.Core
{
public class App : Cirrious.MvvmCross.ViewModels.MvxApplication
{
public override void Initialize ()
{
CreatableTypes ()
.EndingWith ("Service")
.AsInterfaces ()
.RegisterAsLazySingleton ();
RegisterAppStart<FirstViewModel> ();
}
}
}

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

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E9CAC9B6-5013-4350-B617-77C979166230}</ProjectGuid>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>FirstDemo.Core</RootNamespace>
<AssemblyName>FirstDemo.Core</AssemblyName>
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="App.cs" />
<Compile Include="ViewModels\FirstViewModel.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>
<Name>Cirrious.CrossCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross\Cirrious.MvvmCross.csproj">
<Project>{B6E27475-E7D0-448C-A5CC-5097DCA1E2DD}</Project>
<Name>Cirrious.MvvmCross</Name>
</ProjectReference>
<ProjectReference Include="..\..\CrossUI\CrossUI.Core\CrossUI.Core.csproj">
<Project>{D9CBBFFE-57E8-4E97-9E16-C34BC4C52827}</Project>
<Name>CrossUI.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="ViewModels\" />
</ItemGroup>
</Project>

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

@ -0,0 +1,22 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("FirstDemo.Core")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Loqu8, Inc.")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("Copyright (c) 2012 Loqu8, Inc. All rights reserved worldwide.")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

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

@ -0,0 +1,36 @@
using Cirrious.MvvmCross.ViewModels;
namespace FirstDemo.Core.ViewModels
{
public class FirstViewModel : MvxViewModel
{
public FirstViewModel()
{
}
private string _firstName = string.Empty;
public string FirstName
{
get { return _firstName; }
set { _firstName = value;
RaisePropertyChanged (() => FirstName);
RaisePropertyChanged (() => FullName);
}
}
private string _lastName = string.Empty;
public string LastName
{
get { return _lastName; }
set { _lastName = value;
RaisePropertyChanged (() => LastName);
RaisePropertyChanged (() => FullName);
}
}
public string FullName
{
get { return string.Format ("{0} {1}", _firstName, _lastName); }
}
}
}

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

@ -0,0 +1,37 @@
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.CrossCore;
using Cirrious.MvvmCross.Mac.Platform;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using Cirrious.MvvmCross.ViewModels;
using System.Drawing;
namespace FirstDemo.Mac
{
public partial class AppDelegate : MvxApplicationDelegate
{
NSWindow _window;
public AppDelegate()
{
}
public override void FinishedLaunching (NSObject notification)
{
_window = new NSWindow (new RectangleF(200,200,400,400), NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled,
NSBackingStore.Buffered, false, NSScreen.MainScreen);
var presenter = new MvxMacViewPresenter (this, _window);
var setup = new Setup (this, presenter);
setup.Initialize ();
var startup = Mvx.Resolve<IMvxAppStart> ();
startup.Start ();
_window.MakeKeyAndOrderFront (this);
return;
}
}
}

10
Samples/FirstDemo.Mac/AppDelegate.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,10 @@
namespace FirstDemo.Mac
{
// Should subclass MonoMac.AppKit.NSResponder
[MonoMac.Foundation.Register("AppDelegate")]
public partial class AppDelegate
{
}
}

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

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{29B25E31-353C-4715-A58A-7402267A7705}</ProjectGuid>
<ProjectTypeGuids>{948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>FirstDemo.Mac</RootNamespace>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
<AssemblyName>FirstDemo.Mac</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<UseSGen>false</UseSGen>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<EnablePackageSigning>false</EnablePackageSigning>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LinkMode>Full</LinkMode>
<UseSGen>false</UseSGen>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<EnablePackageSigning>false</EnablePackageSigning>
<CodeSigningKey>Developer ID Application</CodeSigningKey>
<EnableCodeSigning>true</EnableCodeSigning>
<CreatePackage>true</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\AppStore</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LinkMode>Full</LinkMode>
<UseSGen>false</UseSGen>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
<CreatePackage>true</CreatePackage>
<CodeSigningKey>3rd Party Mac Developer Application</CodeSigningKey>
<EnableCodeSigning>true</EnableCodeSigning>
<EnablePackageSigning>true</EnablePackageSigning>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="MonoMac" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
<Folder Include="Views\" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainWindow.cs" />
<Compile Include="MainWindowController.cs" />
<Compile Include="MainWindow.designer.cs">
<DependentUpon>MainWindow.cs</DependentUpon>
</Compile>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="AppDelegate.designer.cs">
<DependentUpon>AppDelegate.cs</DependentUpon>
</Compile>
<Compile Include="Setup.cs" />
<Compile Include="Views\FirstView.cs" />
<Compile Include="Views\FirstViewController.cs" />
<Compile Include="Views\FirstView.designer.cs">
<DependentUpon>FirstView.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="MainWindow.xib" />
<InterfaceDefinition Include="MainMenu.xib" />
<InterfaceDefinition Include="Views\FirstView.xib" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>
<Name>Cirrious.CrossCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore.Mac\Cirrious.CrossCore.Mac.csproj">
<Project>{596C75FB-F491-4037-89F6-B4F34183D83D}</Project>
<Name>Cirrious.CrossCore.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross\Cirrious.MvvmCross.csproj">
<Project>{B6E27475-E7D0-448C-A5CC-5097DCA1E2DD}</Project>
<Name>Cirrious.MvvmCross</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Binding\Cirrious.MvvmCross.Binding.csproj">
<Project>{64DCD397-9019-41E8-A928-E5F5C5DF185B}</Project>
<Name>Cirrious.MvvmCross.Binding</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Binding.Mac\Cirrious.MvvmCross.Binding.Mac.csproj">
<Project>{B4789586-AEBB-4597-A849-23F3E45AF421}</Project>
<Name>Cirrious.MvvmCross.Binding.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Localization\Cirrious.MvvmCross.Localization.csproj">
<Project>{D89351C1-D48F-4AD0-A0B9-353A93425AB7}</Project>
<Name>Cirrious.MvvmCross.Localization</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Mac\Cirrious.MvvmCross.Mac.csproj">
<Project>{B3B40D12-3CF1-4BCE-B599-4E3AE438D39F}</Project>
<Name>Cirrious.MvvmCross.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\CrossUI\CrossUI.Core\CrossUI.Core.csproj">
<Project>{D9CBBFFE-57E8-4E97-9E16-C34BC4C52827}</Project>
<Name>CrossUI.Core</Name>
</ProjectReference>
<ProjectReference Include="..\FirstDemo.Core\FirstDemo.Core.csproj">
<Project>{E9CAC9B6-5013-4350-B617-77C979166230}</Project>
<Name>FirstDemo.Core</Name>
</ProjectReference>
</ItemGroup>
</Project>

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

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>FirstDemo.Mac</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIdentifier</key>
<string>FirstDemo</string>
</dict>
</plist>

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

@ -0,0 +1,18 @@
using System;
using System.Drawing;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
namespace FirstDemo.Mac
{
class MainClass
{
static void Main (string[] args)
{
NSApplication.Init ();
NSApplication.Main (args);
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace FirstDemo.Mac
{
public partial class MainWindow : MonoMac.AppKit.NSWindow
{
#region Constructors
// Called when created from unmanaged code
public MainWindow (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public MainWindow (NSCoder coder) : base (coder)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
}
}

15
Samples/FirstDemo.Mac/MainWindow.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,15 @@
namespace FirstDemo.Mac
{
// Should subclass MonoMac.AppKit.NSWindow
[MonoMac.Foundation.Register("MainWindow")]
public partial class MainWindow
{
}
// Should subclass MonoMac.AppKit.NSWindowController
[MonoMac.Foundation.Register("MainWindowController")]
public partial class MainWindowController
{
}
}

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

@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">762</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="2" />
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">MainWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="748157544">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{131, 74}, {606, 354}}</string>
<int key="NSWTFlags">611844096</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">MainWindow</string>
<nil key="NSViewClass" />
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="312036702">
<reference key="NSNextResponder" />
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{606, 354}</string>
<reference key="NSSuperview" />
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001" />
<reference key="destination" ref="748157544" />
</object>
<int key="connectionID">6</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0" />
<reference key="children" ref="1000" />
<nil key="parent" />
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001" />
<reference key="parent" ref="0" />
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003" />
<reference key="parent" ref="0" />
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004" />
<reference key="parent" ref="0" />
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="748157544" />
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="312036702" />
</object>
<reference key="parent" ref="0" />
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="312036702" />
<reference key="parent" ref="748157544" />
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>2.IBWindowTemplateEditedContentRect</string>
<string>2.NSWindowTemplate.visibleAtLaunch</string>
<string>3.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{319, 371}, {606, 354}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{319, 371}, {606, 354}}</string>
<boolean value="YES" />
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0" />
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization" />
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0" />
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID" />
<int key="maxID">6</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">MainWindow</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey" />
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MainWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey" />
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0" />
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<nil key="IBDocument.LastKnownRelativeProjectPath" />
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

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

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace FirstDemo.Mac
{
public partial class MainWindowController : MonoMac.AppKit.NSWindowController
{
#region Constructors
// Called when created from unmanaged code
public MainWindowController (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public MainWindowController (NSCoder coder) : base (coder)
{
Initialize ();
}
// Call to load from the XIB/NIB file
public MainWindowController () : base ("MainWindow")
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
//strongly typed window accessor
public new MainWindow Window {
get {
return (MainWindow)base.Window;
}
}
}
}

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

@ -0,0 +1,23 @@
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Mac.Platform;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using Cirrious.MvvmCross.ViewModels;
namespace FirstDemo.Mac
{
public class Setup : MvxMacSetup
{
public Setup (MvxApplicationDelegate applicationDelegate, IMvxMacViewPresenter presenter)
: base(applicationDelegate, presenter)
{
}
protected override IMvxApplication CreateApp ()
{
return new FirstDemo.Core.App ();
}
}
}

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

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Binding.Mac.Views;
namespace FirstDemo.Mac
{
public partial class FirstView : MvxView
{
#region Constructors
// Called when created from unmanaged code
public FirstView (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public FirstView (NSCoder coder) : base (coder)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
}
}

15
Samples/FirstDemo.Mac/Views/FirstView.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,15 @@
namespace FirstDemo.Mac
{
// Should subclass MonoMac.AppKit.NSView
[MonoMac.Foundation.Register("FirstView")]
public partial class FirstView
{
}
// Should subclass MonoMac.AppKit.NSViewController
[MonoMac.Foundation.Register("FirstViewController")]
public partial class FirstViewController
{
}
}

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

@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">762</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4" />
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">FirstViewController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="159381209">
<reference key="NSNextResponder" />
<int key="NSvFlags">268</int>
<string key="NSFrameSize">{470, 296}</string>
<reference key="NSSuperview" />
<string key="NSClassName">FirstView</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="1001" />
<reference key="destination" ref="159381209" />
</object>
<int key="connectionID">17</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0" />
<reference key="children" ref="1000" />
<nil key="parent" />
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001" />
<reference key="parent" ref="0" />
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003" />
<reference key="parent" ref="0" />
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004" />
<reference key="parent" ref="0" />
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="159381209" />
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="parent" ref="0" />
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>4.IBEditorWindowLastContentRect</string>
<string>4.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{380, 424}, {470, 296}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0" />
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization" />
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0" />
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID" />
<int key="maxID">17</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">FirstView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey" />
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">FirstViewController</string>
<string key="superclassName">NSViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey" />
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0" />
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<nil key="IBDocument.LastKnownRelativeProjectPath" />
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

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

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Mac.Views;
using Cirrious.MvvmCross.Binding.BindingContext;
using FirstDemo.Core.ViewModels;
namespace FirstDemo.Mac
{
public partial class FirstViewController : MvxViewController
{
#region Constructors
// Called when created from unmanaged code
public FirstViewController (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public FirstViewController (NSCoder coder) : base (coder)
{
Initialize ();
}
// Call to load from the XIB/NIB file
public FirstViewController () : base ("FirstView", NSBundle.MainBundle)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
//strongly typed view accessor
public new FirstView View {
get {
return (FirstView)base.View;
}
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var textEditFirst = new NSTextField(new System.Drawing.RectangleF(0,0,320,40));
View.AddSubview (textEditFirst);
var textEditSecond = new NSTextField(new System.Drawing.RectangleF(0,50,320,40));
View.AddSubview(textEditSecond);
var labelFull = new NSTextField(new System.Drawing.RectangleF(0,100,320,40));
View.AddSubview (labelFull);
var set = this.CreateBindingSet<FirstViewController, FirstViewModel> ();
set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName);
set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName);
set.Bind (labelFull).For(v => v.StringValue).To (vm => vm.FullName);
set.Apply ();
}
}
}

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

@ -0,0 +1,37 @@
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.CrossCore;
using Cirrious.MvvmCross.Mac.Platform;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using Cirrious.MvvmCross.ViewModels;
using System.Drawing;
namespace FirstDemo2.Mac
{
public partial class AppDelegate : MvxApplicationDelegate
{
NSWindow _window;
public AppDelegate()
{
}
public override void FinishedLaunching (NSObject notification)
{
_window = new NSWindow (new RectangleF(200,200,400,400), NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled,
NSBackingStore.Buffered, false, NSScreen.MainScreen);
var presenter = new MvxMacViewPresenter (this, _window);
var setup = new Setup (this, presenter);
setup.Initialize ();
var startup = Mvx.Resolve<IMvxAppStart> ();
startup.Start ();
_window.MakeKeyAndOrderFront (this);
return;
}
}
}

10
Samples/FirstDemo2.Mac/AppDelegate.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,10 @@
namespace FirstDemo2.Mac
{
// Should subclass MonoMac.AppKit.NSResponder
[MonoMac.Foundation.Register("AppDelegate")]
public partial class AppDelegate
{
}
}

Двоичный файл не отображается.

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

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{17E01863-3054-4933-887B-3F1EB04A4EAC}</ProjectGuid>
<ProjectTypeGuids>{948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>FirstDemo2.Mac</RootNamespace>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
<AssemblyName>FirstDemo2.Mac</AssemblyName>
<SuppressXamMacMigration>True</SuppressXamMacMigration>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<UseSGen>false</UseSGen>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<EnablePackageSigning>false</EnablePackageSigning>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LinkMode>Full</LinkMode>
<UseSGen>false</UseSGen>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<EnablePackageSigning>false</EnablePackageSigning>
<CodeSigningKey>Developer ID Application</CodeSigningKey>
<EnableCodeSigning>true</EnableCodeSigning>
<CreatePackage>true</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\AppStore</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LinkMode>Full</LinkMode>
<UseSGen>false</UseSGen>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
<CreatePackage>true</CreatePackage>
<CodeSigningKey>3rd Party Mac Developer Application</CodeSigningKey>
<EnableCodeSigning>true</EnableCodeSigning>
<EnablePackageSigning>true</EnablePackageSigning>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="MonoMac" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
<Folder Include="Views\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="AppDelegate.designer.cs">
<DependentUpon>AppDelegate.cs</DependentUpon>
</Compile>
<Compile Include="Setup.cs" />
<Compile Include="Views\FirstView.designer.cs">
<DependentUpon>FirstView.cs</DependentUpon>
</Compile>
<Compile Include="Views\FirstView.cs" />
<Compile Include="Views\FirstViewController.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="MainMenu.xib" />
<InterfaceDefinition Include="Views\FirstView.xib" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<BundleResource Include="Build\Intermediates\FirstDemo2.Mac.build\MonoMac\FirstDemo2.Mac.build\FirstDemo2.Mac-all-target-headers.hmap" />
<BundleResource Include="Build\Intermediates\FirstDemo2.Mac.build\MonoMac\FirstDemo2.Mac.build\FirstDemo2.Mac-generated-files.hmap" />
<BundleResource Include="Build\Intermediates\FirstDemo2.Mac.build\MonoMac\FirstDemo2.Mac.build\FirstDemo2.Mac-own-target-headers.hmap" />
<BundleResource Include="Build\Intermediates\FirstDemo2.Mac.build\MonoMac\FirstDemo2.Mac.build\FirstDemo2.Mac-project-headers.hmap" />
<BundleResource Include="Build\Intermediates\FirstDemo2.Mac.build\MonoMac\FirstDemo2.Mac.build\FirstDemo2.Mac.hmap" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore\Cirrious.CrossCore.csproj">
<Project>{CFF6F25A-3C3B-44EE-A54C-2ED4AAFF3ADB}</Project>
<Name>Cirrious.CrossCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Mac\Cirrious.MvvmCross.Mac.csproj">
<Project>{B3B40D12-3CF1-4BCE-B599-4E3AE438D39F}</Project>
<Name>Cirrious.MvvmCross.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross\Cirrious.MvvmCross.csproj">
<Project>{B6E27475-E7D0-448C-A5CC-5097DCA1E2DD}</Project>
<Name>Cirrious.MvvmCross</Name>
</ProjectReference>
<ProjectReference Include="..\..\CrossCore\Cirrious.CrossCore.Mac\Cirrious.CrossCore.Mac.csproj">
<Project>{596C75FB-F491-4037-89F6-B4F34183D83D}</Project>
<Name>Cirrious.CrossCore.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Binding\Cirrious.MvvmCross.Binding.csproj">
<Project>{64DCD397-9019-41E8-A928-E5F5C5DF185B}</Project>
<Name>Cirrious.MvvmCross.Binding</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Binding.Mac\Cirrious.MvvmCross.Binding.Mac.csproj">
<Project>{B4789586-AEBB-4597-A849-23F3E45AF421}</Project>
<Name>Cirrious.MvvmCross.Binding.Mac</Name>
</ProjectReference>
<ProjectReference Include="..\..\Cirrious\Cirrious.MvvmCross.Localization\Cirrious.MvvmCross.Localization.csproj">
<Project>{D89351C1-D48F-4AD0-A0B9-353A93425AB7}</Project>
<Name>Cirrious.MvvmCross.Localization</Name>
</ProjectReference>
<ProjectReference Include="..\FirstDemo.Core\FirstDemo.Core.csproj">
<Project>{E9CAC9B6-5013-4350-B617-77C979166230}</Project>
<Name>FirstDemo.Core</Name>
</ProjectReference>
</ItemGroup>
</Project>

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

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>FirstDemo2.Mac</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIdentifier</key>
<string>FirstDemo2</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.business</string>
</dict>
</plist>

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

@ -0,0 +1,18 @@
using System;
using System.Drawing;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
namespace FirstDemo2.Mac
{
class MainClass
{
static void Main (string[] args)
{
NSApplication.Init ();
NSApplication.Main (args);
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,23 @@
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Mac.Platform;
using Cirrious.MvvmCross.Mac.Views.Presenters;
using Cirrious.MvvmCross.ViewModels;
namespace FirstDemo2.Mac
{
public class Setup : MvxMacSetup
{
public Setup (MvxApplicationDelegate applicationDelegate, IMvxMacViewPresenter presenter)
: base(applicationDelegate, presenter)
{
}
protected override IMvxApplication CreateApp ()
{
return new FirstDemo.Core.App ();
}
}
}

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

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Binding.Mac.Views;
namespace FirstDemo2.Mac
{
public partial class FirstView : MvxView
{
#region Constructors
// Called when created from unmanaged code
public FirstView (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public FirstView (NSCoder coder) : base (coder)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
}
}

15
Samples/FirstDemo2.Mac/Views/FirstView.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,15 @@
namespace FirstDemo2.Mac
{
// Should subclass MonoMac.AppKit.NSView
[MonoMac.Foundation.Register("FirstView")]
public partial class FirstView
{
}
// Should subclass MonoMac.AppKit.NSViewController
[MonoMac.Foundation.Register("FirstViewController")]
public partial class FirstViewController
{
}
}

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

@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">762</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4" />
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">FirstViewController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="159381209">
<reference key="NSNextResponder" />
<int key="NSvFlags">268</int>
<string key="NSFrameSize">{470, 296}</string>
<reference key="NSSuperview" />
<string key="NSClassName">FirstView</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="1001" />
<reference key="destination" ref="159381209" />
</object>
<int key="connectionID">17</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0" />
<reference key="children" ref="1000" />
<nil key="parent" />
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001" />
<reference key="parent" ref="0" />
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003" />
<reference key="parent" ref="0" />
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004" />
<reference key="parent" ref="0" />
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="159381209" />
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="parent" ref="0" />
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>4.IBEditorWindowLastContentRect</string>
<string>4.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{380, 424}, {470, 296}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0" />
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization" />
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0" />
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID" />
<int key="maxID">17</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">FirstView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey" />
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">FirstViewController</string>
<string key="superclassName">NSViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey" />
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0" />
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<nil key="IBDocument.LastKnownRelativeProjectPath" />
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

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

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
using Cirrious.MvvmCross.Mac.Views;
using Cirrious.MvvmCross.Binding.BindingContext;
using FirstDemo.Core.ViewModels;
namespace FirstDemo2.Mac
{
public partial class FirstViewController : MvxViewController
{
#region Constructors
// Called when created from unmanaged code
public FirstViewController (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public FirstViewController (NSCoder coder) : base (coder)
{
Initialize ();
}
// Call to load from the XIB/NIB file
public FirstViewController () : base ("FirstView", NSBundle.MainBundle)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
//strongly typed view accessor
public new FirstView View {
get {
return (FirstView)base.View;
}
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var textEditFirst = new NSTextField(new System.Drawing.RectangleF(0,0,320,40));
View.AddSubview (textEditFirst);
var textEditSecond = new NSTextField(new System.Drawing.RectangleF(0,50,320,40));
View.AddSubview(textEditSecond);
var labelFull = new NSTextField(new System.Drawing.RectangleF(0,100,320,40));
View.AddSubview (labelFull);
var set = this.CreateBindingSet<FirstViewController, FirstViewModel> ();
set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName);
set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName);
set.Bind (labelFull).For(v => v.StringValue).To (vm => vm.FullName);
set.Apply ();
}
}
}