Skip to content

Commit

Permalink
Merge branch 'BindingChanges' of https://github.com/slodge/MvvmCross
Browse files Browse the repository at this point in the history
…into mac-play
  • Loading branch information
slodge committed Oct 5, 2013
2 parents 6933594 + d0380c9 commit 464f398
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,31 @@ protected override Delegate CreateEventHandler()
return new EventHandler(OnSourceEvent);
}
}

/*
public class MvxGeneralEventSubscription<TSource, TEventArgs>
: MvxWeakEventSubscription<TSource, TEventArgs>
where TSource : class
where TEventArgs : EventArgs
{
public MvxGeneralEventSubscription(TSource source,
EventInfo eventInfo,
EventHandler<TEventArgs> eventHandler)
: base(source, eventInfo, eventHandler)
{
}
public MvxGeneralEventSubscription(TSource source,
string eventName,
EventHandler<TEventArgs> eventHandler)
: base(source, typeof(TSource).GetEvent(eventName), eventHandler)
{
}
protected override Delegate CreateEventHandler()
{
return new EventHandler<TEventArgs>(OnSourceEvent);
}
}
*/
}
1 change: 1 addition & 0 deletions CrossUI/CrossUI.Droid/CrossUI.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<Compile Include="Dialog\CustomDataSetObserver.cs" />
<Compile Include="Dialog\DividerAwareLinearLayout.cs" />
<Compile Include="Dialog\Elements\IRadioElement.cs" />
<Compile Include="Dialog\Elements\SimplePickerElement.cs" />
<Compile Include="Dialog\LinearDialogActivity.cs" />
<Compile Include="Dialog\Elements\AchievementElement.cs" />
<Compile Include="Dialog\ElementAttributes\AlignmentAttribute.cs" />
Expand Down
73 changes: 73 additions & 0 deletions CrossUI/CrossUI.Droid/Dialog/Elements/SimplePickerElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System.Collections;
using System.Linq;
using Android.App;
using Android.Content;

namespace CrossUI.Droid.Dialog.Elements
{
public class SimplePickerElement : StringDisplayingValueElement<object>
{
public SimplePickerElement(string caption, object value = null, string layoutName = null)
: base(caption, value, layoutName ?? "dialog_multiline_labelfieldbelow")
{
Click = delegate { ShowDialog(); };
}

IList _entries = new object[0];
public IList Entries
{
get { return _entries; }
set { _entries = value; BindItemArray(); }
}

private void BindItemArray()
{
var arr = new object[Entries.Count];
Entries.CopyTo(arr, 0);
_itemArray = arr.Select(x => Format(x)).ToArray();
}

string[] _itemArray = new string[0];

private int FindSelectedIndex()
{
var i = 0;
foreach (var x in Entries)
{
if (x == Value)
return i;
i++;
}
return -1;
}

private void ShowDialog()
{
var context = Context;
if (context == null)
{
Android.Util.Log.Warn("RadioDialogElement", "No Context for Edit");
return;
}

new AlertDialog.Builder(context)
.SetTitle(base.Caption)
.SetSingleChoiceItems(_itemArray, FindSelectedIndex(), (o, e) => OnClick(o, e))
.Create()
.Show();
}

protected virtual void OnClick(object o, DialogClickEventArgs e)
{
OnUserValueChanged(Entries[e.Which]);
((AlertDialog)o).Dismiss();
}

protected override string Format(object value)
{
if (value == null)
return string.Empty;
return value.ToString();
}
}
}
20 changes: 8 additions & 12 deletions MvvmCross_All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2466,26 +2466,22 @@ Global
{ED445165-3EBC-4474-8178-A2C3A41A18FD}.Release|x86.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|ARM.ActiveCfg = Debug|ARM
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|ARM.Build.0 = Debug|ARM
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|x64.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|x86.ActiveCfg = Debug|x86
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|x86.Build.0 = Debug|x86
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|Any CPU.Build.0 = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|ARM.ActiveCfg = Release|ARM
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|ARM.Build.0 = Release|ARM
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|ARM.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|iPhone.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|x64.ActiveCfg = Release|Any CPU
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|x86.ActiveCfg = Release|x86
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|x86.Build.0 = Release|x86
{DA0D299A-C35B-4CF7-8DC7-C0D9E6CCED4B}.Release|x86.ActiveCfg = Release|Any CPU
{87C31E67-3DED-43A7-982D-B108C45CA0AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87C31E67-3DED-43A7-982D-B108C45CA0AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87C31E67-3DED-43A7-982D-B108C45CA0AD}.Debug|ARM.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -2975,8 +2971,8 @@ Global
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|x64.ActiveCfg = Debug|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|x86.ActiveCfg = Debug|x86
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|x86.Build.0 = Debug|x86
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|x86.ActiveCfg = Debug|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Debug|x86.Build.0 = Debug|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|Any CPU.Build.0 = Release|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|ARM.ActiveCfg = Release|Any CPU
Expand All @@ -2985,8 +2981,8 @@ Global
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|x64.ActiveCfg = Release|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|x86.ActiveCfg = Release|x86
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|x86.Build.0 = Release|x86
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|x86.ActiveCfg = Release|Any CPU
{2775EDBB-090E-43DC-8D16-2B8288169ACA}.Release|x86.Build.0 = Release|Any CPU
{B98681D2-2FB9-4F57-AD57-8B2962BB9A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B98681D2-2FB9-4F57-AD57-8B2962BB9A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B98681D2-2FB9-4F57-AD57-8B2962BB9A54}.Debug|ARM.ActiveCfg = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<OutputPath>unusedbin\ARM\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>unusedbin\x86\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>unusedbin\x86\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>unusedbin\ARM\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="MvxAccelerometer.cs" />
<Compile Include="Plugin.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<OutputPath>unusedbin\x86\Debug\</OutputPath>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
Expand All @@ -64,6 +65,9 @@
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>unusedbin\x86\Release\</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit 464f398

Please sign in to comment.