Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor changes

commit e5533dc6fccf41347bc6c030fcfcb2b1ec86aba5 1 parent 9f6c642
@Clancey authored
View
8 DialogSampleApp/DialogSampleApp.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -14,6 +14,7 @@
<FileAlignment>512</FileAlignment>
<AndroidApplication>true</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
+ <TargetFrameworkVersion>v2.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,6 +33,8 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AndroidLinkMode>SdkOnly</AndroidLinkMode>
+ <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
@@ -61,7 +65,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MonoDroid.Dialog\MonoDroid.Dialog.csproj">
- <Project>{E9616034-1C4B-4189-A4FB-8EDDCB53188D}</Project>
+ <Project>{33044C7B-47A4-4113-A61A-EB429407F818}</Project>
<Name>MonoDroid.Dialog</Name>
</ProjectReference>
</ItemGroup>
View
338 DialogSampleApp/Resources/Resource.Designer.cs
@@ -1,169 +1,169 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.225
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace DialogSampleApp
-{
-
-
- public partial class Resource
- {
-
- public partial class Attribute
- {
-
- private Attribute()
- {
- }
- }
-
- public partial class Drawable
- {
-
- // aapt resource value: 0x7f020000
- public const int dialog_disclosure = 2130837504;
-
- // aapt resource value: 0x7f020001
- public const int dialog_expander_ic_minimized = 2130837505;
-
- // aapt resource value: 0x7f020002
- public const int icon = 2130837506;
-
- private Drawable()
- {
- }
- }
-
- public partial class Id
- {
-
- // aapt resource value: 0x7f050000
- public const int dialog_BoolField = 2131034112;
-
- // aapt resource value: 0x7f050003
- public const int dialog_Button = 2131034115;
-
- // aapt resource value: 0x7f050009
- public const int dialog_DisclosureField = 2131034121;
-
- // aapt resource value: 0x7f050005
- public const int dialog_ImageLeft = 2131034117;
-
- // aapt resource value: 0x7f050007
- public const int dialog_ImageRight = 2131034119;
-
- // aapt resource value: 0x7f050001
- public const int dialog_LabelField = 2131034113;
-
- // aapt resource value: 0x7f050002
- public const int dialog_LabelSubtextField = 2131034114;
-
- // aapt resource value: 0x7f050008
- public const int dialog_Panel = 2131034120;
-
- // aapt resource value: 0x7f05000a
- public const int dialog_RadioButtonList = 2131034122;
-
- // aapt resource value: 0x7f050006
- public const int dialog_SliderField = 2131034118;
-
- // aapt resource value: 0x7f05000b
- public const int dialog_Spinner = 2131034123;
-
- // aapt resource value: 0x7f050004
- public const int dialog_ValueField = 2131034116;
-
- // aapt resource value: 0x7f05000c
- public const int iFormFieldValue = 2131034124;
-
- private Id()
- {
- }
- }
-
- public partial class Layout
- {
-
- // aapt resource value: 0x7f030000
- public const int dialog_boolfieldleft = 2130903040;
-
- // aapt resource value: 0x7f030001
- public const int dialog_boolfieldright = 2130903041;
-
- // aapt resource value: 0x7f030002
- public const int dialog_boolfieldsubleft = 2130903042;
-
- // aapt resource value: 0x7f030003
- public const int dialog_boolfieldsubright = 2130903043;
-
- // aapt resource value: 0x7f030004
- public const int dialog_button = 2130903044;
-
- // aapt resource value: 0x7f030005
- public const int dialog_datefield = 2130903045;
-
- // aapt resource value: 0x7f030006
- public const int dialog_fieldsetlabel = 2130903046;
-
- // aapt resource value: 0x7f030007
- public const int dialog_floatimage = 2130903047;
-
- // aapt resource value: 0x7f030008
- public const int dialog_labelfieldbelow = 2130903048;
-
- // aapt resource value: 0x7f030009
- public const int dialog_labelfieldright = 2130903049;
-
- // aapt resource value: 0x7f03000a
- public const int dialog_onofffieldright = 2130903050;
-
- // aapt resource value: 0x7f03000b
- public const int dialog_panel = 2130903051;
-
- // aapt resource value: 0x7f03000c
- public const int dialog_root = 2130903052;
-
- // aapt resource value: 0x7f03000d
- public const int dialog_selectlist = 2130903053;
-
- // aapt resource value: 0x7f03000e
- public const int dialog_selectlistfield = 2130903054;
-
- // aapt resource value: 0x7f03000f
- public const int dialog_textarea = 2130903055;
-
- // aapt resource value: 0x7f030010
- public const int dialog_textfieldbelow = 2130903056;
-
- // aapt resource value: 0x7f030011
- public const int dialog_textfieldright = 2130903057;
-
- // aapt resource value: 0x7f030012
- public const int main = 2130903058;
-
- private Layout()
- {
- }
- }
-
- public partial class String
- {
-
- // aapt resource value: 0x7f040001
- public const int app_name = 2130968577;
-
- // aapt resource value: 0x7f040000
- public const int hello = 2130968576;
-
- private String()
- {
- }
- }
- }
-}
+// ------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Mono Runtime Version: 4.0.30319.1
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace DialogSampleApp
+{
+
+
+ public partial class Resource
+ {
+
+ public partial class Attribute
+ {
+
+ private Attribute()
+ {
+ }
+ }
+
+ public partial class Drawable
+ {
+
+ // aapt resource value: 0x7f020000
+ public const int dialog_disclosure = 2130837504;
+
+ // aapt resource value: 0x7f020001
+ public const int dialog_expander_ic_minimized = 2130837505;
+
+ // aapt resource value: 0x7f020002
+ public const int icon = 2130837506;
+
+ private Drawable()
+ {
+ }
+ }
+
+ public partial class Id
+ {
+
+ // aapt resource value: 0x7f050000
+ public const int dialog_BoolField = 2131034112;
+
+ // aapt resource value: 0x7f050003
+ public const int dialog_Button = 2131034115;
+
+ // aapt resource value: 0x7f050009
+ public const int dialog_DisclosureField = 2131034121;
+
+ // aapt resource value: 0x7f050005
+ public const int dialog_ImageLeft = 2131034117;
+
+ // aapt resource value: 0x7f050007
+ public const int dialog_ImageRight = 2131034119;
+
+ // aapt resource value: 0x7f050001
+ public const int dialog_LabelField = 2131034113;
+
+ // aapt resource value: 0x7f050002
+ public const int dialog_LabelSubtextField = 2131034114;
+
+ // aapt resource value: 0x7f050008
+ public const int dialog_Panel = 2131034120;
+
+ // aapt resource value: 0x7f05000a
+ public const int dialog_RadioButtonList = 2131034122;
+
+ // aapt resource value: 0x7f050006
+ public const int dialog_SliderField = 2131034118;
+
+ // aapt resource value: 0x7f05000b
+ public const int dialog_Spinner = 2131034123;
+
+ // aapt resource value: 0x7f050004
+ public const int dialog_ValueField = 2131034116;
+
+ // aapt resource value: 0x7f05000c
+ public const int iFormFieldValue = 2131034124;
+
+ private Id()
+ {
+ }
+ }
+
+ public partial class Layout
+ {
+
+ // aapt resource value: 0x7f030000
+ public const int dialog_boolfieldleft = 2130903040;
+
+ // aapt resource value: 0x7f030001
+ public const int dialog_boolfieldright = 2130903041;
+
+ // aapt resource value: 0x7f030002
+ public const int dialog_boolfieldsubleft = 2130903042;
+
+ // aapt resource value: 0x7f030003
+ public const int dialog_boolfieldsubright = 2130903043;
+
+ // aapt resource value: 0x7f030004
+ public const int dialog_button = 2130903044;
+
+ // aapt resource value: 0x7f030005
+ public const int dialog_datefield = 2130903045;
+
+ // aapt resource value: 0x7f030006
+ public const int dialog_fieldsetlabel = 2130903046;
+
+ // aapt resource value: 0x7f030007
+ public const int dialog_floatimage = 2130903047;
+
+ // aapt resource value: 0x7f030008
+ public const int dialog_labelfieldbelow = 2130903048;
+
+ // aapt resource value: 0x7f030009
+ public const int dialog_labelfieldright = 2130903049;
+
+ // aapt resource value: 0x7f03000a
+ public const int dialog_onofffieldright = 2130903050;
+
+ // aapt resource value: 0x7f03000b
+ public const int dialog_panel = 2130903051;
+
+ // aapt resource value: 0x7f03000c
+ public const int dialog_root = 2130903052;
+
+ // aapt resource value: 0x7f03000d
+ public const int dialog_selectlist = 2130903053;
+
+ // aapt resource value: 0x7f03000e
+ public const int dialog_selectlistfield = 2130903054;
+
+ // aapt resource value: 0x7f03000f
+ public const int dialog_textarea = 2130903055;
+
+ // aapt resource value: 0x7f030010
+ public const int dialog_textfieldbelow = 2130903056;
+
+ // aapt resource value: 0x7f030011
+ public const int dialog_textfieldright = 2130903057;
+
+ // aapt resource value: 0x7f030012
+ public const int Main = 2130903058;
+
+ private Layout()
+ {
+ }
+ }
+
+ public partial class String
+ {
+
+ // aapt resource value: 0x7f040001
+ public const int app_name = 2130968577;
+
+ // aapt resource value: 0x7f040000
+ public const int hello = 2130968576;
+
+ private String()
+ {
+ }
+ }
+ }
+}
View
1  DialogSampleApp/Resources/layout/dialog_boolfieldleft.xml
@@ -5,6 +5,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
+android:background="@android:color/transparent"
>
<CheckBox
android:id="@+id/dialog_BoolField"
View
1  DialogSampleApp/Resources/layout/dialog_textarea.xml
@@ -9,4 +9,5 @@ android:gravity="top"
android:lines="5"
android:inputType="text|textMultiLine"
android:textSize="21sp"
+android:background="@android:color/transparent"
android:textColor="#ff000000"/>
View
5 MonoDroid.Dialog.sln
@@ -17,11 +17,14 @@ Global
{33044C7B-47A4-4113-A61A-EB429407F818}.Release|Any CPU.Build.0 = Release|Any CPU
{62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Release|Any CPU.Build.0 = Release|Any CPU
+ {62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{62BAEFFF-BBF1-4BFC-BFCB-79BD60184A54}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = DialogSampleApp\DialogSampleApp.csproj
+ EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
View
4 MonoDroid.Dialog/CheckboxElement.cs
@@ -14,7 +14,9 @@ public bool Value
{
bool emit = _val != value;
_val = value;
- if (emit && ValueChanged != null)
+ if(_checkbox != null && _checkbox.Checked != _val)
+ _checkbox.Checked = _val;
+ else if (emit && ValueChanged != null)
ValueChanged(this, EventArgs.Empty);
}
}
View
2  MonoDroid.Dialog/DialogActivity.cs
@@ -19,7 +19,7 @@ public class DialogActivity : ListActivity
{
public RootElement Root { get; set; }
private DialogHelper Dialog { get; set; }
-
+
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
View
7 MonoDroid.Dialog/ImageElement.cs
@@ -67,8 +67,9 @@ public override View GetView(Context context, View convertView, ViewGroup parent
var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
parms.SetMargins(5, 2, 5, 2);
- parms.AddRule((int) LayoutRules.AlignParentLeft);
-
+ parms.AddRule( LayoutRules.AlignParentLeft);
+ if(_imageView.Parent != null && _imageView.Parent is ViewGroup)
+ ((ViewGroup)_imageView.Parent).RemoveView(_imageView);
view.AddView(_imageView, parms);
return view;
@@ -79,7 +80,7 @@ private void SelectImage()
Context context = GetContext();
Activity activity = (Activity)context;
Intent intent = new Intent(Intent.ActionPick, Android.Provider.MediaStore.Images.Media.InternalContentUri);
- activity.StartActivity(intent);
+ activity.StartActivityForResult(intent,1);
}
}
}
View
6 MonoDroid.Dialog/MonoDroid.Dialog.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -12,6 +12,7 @@
<RootNamespace>MonoDroid.Dialog</RootNamespace>
<AssemblyName>MonoDroid.Dialog</AssemblyName>
<FileAlignment>512</FileAlignment>
+ <TargetFrameworkVersion>v2.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -21,7 +22,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -31,6 +31,8 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AndroidLinkMode>SdkOnly</AndroidLinkMode>
+ <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
View
792 MonoDroid.Dialog/RootElement.cs
@@ -1,393 +1,411 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Android.App;
-using Android.Content;
-using Android.Views;
-using Android.Widget;
-
-namespace MonoDroid.Dialog
-{
- public class RootElement : Element, IEnumerable<Section>, IDialogInterfaceOnClickListener
- {
- TextView _caption;
- TextView _value;
-
- int _summarySection, _summaryElement;
- internal Group _group;
- public bool UnevenRows;
- public Func<RootElement, View> _createOnSelected;
-
- /// <summary>
- /// Initializes a RootSection with a caption
- /// </summary>
- /// <param name="caption">
- /// The caption to render.
- /// </param>
- public RootElement(string caption)
- : base(caption, (int) DroidResources.ElementLayout.dialog_root)
- {
- _summarySection = -1;
- Sections = new List<Section>();
- }
-
- /// <summary>
- /// Initializes a RootSection with a caption and a callback that will
- /// create the nested UIViewController that is activated when the user
- /// taps on the element.
- /// </summary>
- /// <param name="caption">
- /// The caption to render.
- /// </param>
- public RootElement(string caption, Func<RootElement, View> createOnSelected)
- : base(caption, (int)DroidResources.ElementLayout.dialog_root)
- {
- _summarySection = -1;
- this._createOnSelected = createOnSelected;
- Sections = new List<Section>();
- }
-
- /// <summary>
- /// Initializes a RootElement with a caption with a summary fetched from the specified section and leement
- /// </summary>
- /// <param name="caption">
- /// The caption to render cref="System.String"/>
- /// </param>
- /// <param name="section">
- /// The section that contains the element with the summary.
- /// </param>
- /// <param name="element">
- /// The element index inside the section that contains the summary for this RootSection.
- /// </param>
- public RootElement(string caption, int section, int element)
- : base(caption, (int)DroidResources.ElementLayout.dialog_root)
- {
- _summarySection = section;
- _summaryElement = element;
- }
-
- /// <summary>
- /// Initializes a RootElement that renders the summary based on the radio settings of the contained elements.
- /// </summary>
- /// <param name="caption">
- /// The caption to ender
- /// </param>
- /// <param name="group">
- /// The group that contains the checkbox or radio information. This is used to display
- /// the summary information when a RootElement is rendered inside a section.
- /// </param>
- public RootElement(string caption, Group group)
- : base(caption, (int)DroidResources.ElementLayout.dialog_root)
- {
- this._group = group;
- }
-
- /// <summary>
- /// Single save point for a context, elements can get this context via GetContext() for navigation operations
- /// </summary>
- public Context Context { get; set; }
-
- internal List<Section> Sections = new List<Section>();
-
- public int Count
- {
- get
- {
- return Sections.Count;
- }
- }
-
- public Section this[int idx]
- {
- get
- {
- return Sections[idx];
- }
- }
-
- internal int IndexOf(Section target)
- {
- int idx = 0;
- foreach (Section s in Sections)
- {
- if (s == target)
- return idx;
- idx++;
- }
- return -1;
- }
-
- internal void Prepare()
- {
- int current = 0;
- foreach (Section s in Sections)
- {
- foreach (Element e in s.Elements)
- {
- var re = e as RadioElement;
- if (re != null)
- re.RadioIdx = current++;
- if (UnevenRows == false && e is IElementSizing)
- UnevenRows = true;
- }
- }
- }
-
- public override string Summary()
- {
- return GetSelectedValue();
- }
-
- /// <summary>
- /// Adds a new section to this RootElement
- /// </summary>
- /// <param name="section">
- /// The section to add, if the root is visible, the section is inserted with no animation
- /// </param>
- public void Add(Section section)
- {
- if (section == null)
- return;
-
- Sections.Add(section);
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Android.App;
+using Android.Content;
+using Android.Views;
+using Android.Widget;
+
+namespace MonoDroid.Dialog
+{
+ public class RootElement : Element, IEnumerable<Section>, IDialogInterfaceOnClickListener
+ {
+ TextView _caption;
+ TextView _value;
+
+ int _summarySection, _summaryElement;
+ internal Group _group;
+ public bool UnevenRows;
+ public Func<RootElement, View> _createOnSelected;
+
+ /// <summary>
+ /// Initializes a RootSection with a caption
+ /// </summary>
+ /// <param name="caption">
+ /// The caption to render.
+ /// </param>
+ public RootElement(string caption)
+ : base(caption, (int) DroidResources.ElementLayout.dialog_root)
+ {
+ _summarySection = -1;
+ Sections = new List<Section>();
+ }
+
+ /// <summary>
+ /// Initializes a RootSection with a caption and a callback that will
+ /// create the nested UIViewController that is activated when the user
+ /// taps on the element.
+ /// </summary>
+ /// <param name="caption">
+ /// The caption to render.
+ /// </param>
+ public RootElement(string caption, Func<RootElement, View> createOnSelected)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_root)
+ {
+ _summarySection = -1;
+ this._createOnSelected = createOnSelected;
+ Sections = new List<Section>();
+ }
+
+ /// <summary>
+ /// Initializes a RootElement with a caption with a summary fetched from the specified section and leement
+ /// </summary>
+ /// <param name="caption">
+ /// The caption to render cref="System.String"/>
+ /// </param>
+ /// <param name="section">
+ /// The section that contains the element with the summary.
+ /// </param>
+ /// <param name="element">
+ /// The element index inside the section that contains the summary for this RootSection.
+ /// </param>
+ public RootElement(string caption, int section, int element)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_root)
+ {
+ _summarySection = section;
+ _summaryElement = element;
+ }
+
+ /// <summary>
+ /// Initializes a RootElement that renders the summary based on the radio settings of the contained elements.
+ /// </summary>
+ /// <param name="caption">
+ /// The caption to ender
+ /// </param>
+ /// <param name="group">
+ /// The group that contains the checkbox or radio information. This is used to display
+ /// the summary information when a RootElement is rendered inside a section.
+ /// </param>
+ public RootElement(string caption, Group group)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_root)
+ {
+ this._group = group;
+ }
+
+ /// <summary>
+ /// Single save point for a context, elements can get this context via GetContext() for navigation operations
+ /// </summary>
+ public Context Context { get; set; }
+
+ internal List<Section> Sections = new List<Section>();
+
+ public int Count
+ {
+ get
+ {
+ return Sections.Count;
+ }
+ }
+
+ public Section this[int idx]
+ {
+ get
+ {
+ return Sections[idx];
+ }
+ }
+
+ internal int IndexOf(Section target)
+ {
+ int idx = 0;
+ foreach (Section s in Sections)
+ {
+ if (s == target)
+ return idx;
+ idx++;
+ }
+ return -1;
+ }
+
+ internal void Prepare()
+ {
+ int current = 0;
+ foreach (Section s in Sections)
+ {
+ foreach (Element e in s.Elements)
+ {
+ var re = e as RadioElement;
+ if (re != null)
+ re.RadioIdx = current++;
+ if (UnevenRows == false && e is IElementSizing)
+ UnevenRows = true;
+ }
+ }
+ }
+
+ public override string Summary()
+ {
+ return GetSelectedValue();
+ }
+
+ void SetSectionStartIndex()
+ {
+ int currentIndex = 0;
+ foreach(var section in Sections)
+ {
+ section.StartIndex = currentIndex;
+ currentIndex += section.Count;
+ }
+ }
+ /// <summary>
+ /// Adds a new section to this RootElement
+ /// </summary>
+ /// <param name="section">
+ /// The section to add, if the root is visible, the section is inserted with no animation
+ /// </param>
+ public void Add(Section section)
+ {
+ if (section == null)
+ return;
+
+ Sections.Add(section);
section.Parent = this;
- }
-
- //
- // This makes things LINQ friendly; You can now create RootElements
- // with an embedded LINQ expression, like this:
- // new RootElement ("Title") {
- // from x in names
- // select new Section (x) { new StringElement ("Sample") }
- //
- public void Add(IEnumerable<Section> sections)
- {
- foreach (var s in sections)
+ SetSectionStartIndex();
+ }
+
+ //
+ // This makes things LINQ friendly; You can now create RootElements
+ // with an embedded LINQ expression, like this:
+ // new RootElement ("Title") {
+ // from x in names
+ // select new Section (x) { new StringElement ("Sample") }
+ //
+ public void Add(IEnumerable<Section> sections)
+ {
+ foreach (var s in sections)
Add(s);
- }
-
- /// <summary>
- /// Inserts a new section into the RootElement
- /// </summary>
- /// <param name="idx">
- /// The index where the section is added <see cref="System.Int32"/>
- /// </param>
- /// <param name="newSections">
- /// A <see cref="Section[]"/> list of sections to insert
- /// </param>
- /// <remarks>
- /// This inserts the specified list of sections (a params argument) into the
- /// root using the specified animation.
- /// </remarks>
- public void Insert(int idx, params Section[] newSections)
- {
- if (idx < 0 || idx > Sections.Count)
- return;
- if (newSections == null)
- return;
-
- //if (Table != null)
- // Table.BeginUpdates();
-
- int pos = idx;
- foreach (var s in newSections)
- {
- s.Parent = this;
- Sections.Insert(pos++, s);
+
+ SetSectionStartIndex();
+ }
+
+ /// <summary>
+ /// Inserts a new section into the RootElement
+ /// </summary>
+ /// <param name="idx">
+ /// The index where the section is added <see cref="System.Int32"/>
+ /// </param>
+ /// <param name="newSections">
+ /// A <see cref="Section[]"/> list of sections to insert
+ /// </param>
+ /// <remarks>
+ /// This inserts the specified list of sections (a params argument) into the
+ /// root using the specified animation.
+ /// </remarks>
+ public void Insert(int idx, params Section[] newSections)
+ {
+ if (idx < 0 || idx > Sections.Count)
+ return;
+ if (newSections == null)
+ return;
+
+ //if (Table != null)
+ // Table.BeginUpdates();
+
+ int pos = idx;
+ foreach (var s in newSections)
+ {
+ s.Parent = this;
+ Sections.Insert(pos++, s);
}
- }
-
- /// <summary>
- /// Removes a section at a specified location
- /// </summary>
- public void RemoveAt(int idx)
- {
- if (idx < 0 || idx >= Sections.Count)
- return;
-
+
+ SetSectionStartIndex();
+ }
+
+ /// <summary>
+ /// Removes a section at a specified location
+ /// </summary>
+ public void RemoveAt(int idx)
+ {
+ if (idx < 0 || idx >= Sections.Count)
+ return;
+
Sections.RemoveAt(idx);
- }
-
- public void Remove(Section s)
- {
- if (s == null)
- return;
- int idx = Sections.IndexOf(s);
- if (idx == -1)
- return;
+
+ SetSectionStartIndex();
+ }
+
+ public void Remove(Section s)
+ {
+ if (s == null)
+ return;
+ int idx = Sections.IndexOf(s);
+ if (idx == -1)
+ return;
RemoveAt(idx);
- }
-
- public void Clear()
- {
- foreach (var s in Sections)
- s.Dispose();
- Sections = new List<Section>();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- Context = null;
- if (Sections == null)
- return;
- Clear();
- Sections = null;
- }
- }
-
- /// <summary>
- /// The currently selected Radio item in the whole Root.
- /// </summary>
- public int RadioSelected
- {
- get
- {
- var radio = _group as RadioGroup;
- if (radio != null)
- return radio.Selected;
- return -1;
- }
- set
- {
- var radio = _group as RadioGroup;
- if (radio != null)
- radio.Selected = value;
- }
- }
-
- private string GetSelectedValue()
- {
- var radio = _group as RadioGroup;
- if (radio == null)
- return string.Empty;
-
- int selected = radio.Selected;
- int current = 0;
- string radioValue = string.Empty;
- foreach (var s in Sections)
- {
- foreach (var e in s.Elements)
- {
- if (!(e is RadioElement))
- continue;
-
- if (current == selected)
- return e.Summary();
-
- current++;
- }
- }
-
- return string.Empty;
- }
-
- public override View GetView(Context context, View convertView, ViewGroup parent)
- {
- Context = context;
-
- LayoutInflater inflater = LayoutInflater.FromContext(context);
-
- View cell = new TextView(context) {TextSize = 16f, Text = Caption};
- var radio = _group as RadioGroup;
-
- if (radio != null)
- {
- string radioValue = GetSelectedValue();
- cell = DroidResources.LoadStringElementLayout(context, convertView, parent, LayoutId, out _caption, out _value);
- if (cell != null)
- {
- _caption.Text = Caption;
- _value.Text = radioValue;
- this.Click = (o, e) => { SelectRadio(); };
- }
- }
- else if (_group != null)
- {
- int count = 0;
- foreach (var s in Sections)
- {
- foreach (var e in s.Elements)
- {
- var ce = e as CheckboxElement;
- if (ce != null)
- {
- if (ce.Value)
- count++;
- continue;
- }
- var be = e as BoolElement;
- if (be != null)
- {
- if (be.Value)
- count++;
- continue;
- }
- }
- }
- //cell.DetailTextLabel.Text = count.ToString();
- }
- else if (_summarySection != -1 && _summarySection < Sections.Count)
- {
- var s = Sections[_summarySection];
- //if (summaryElement < s.Elements.Count)
- // cell.DetailTextLabel.Text = s.Elements[summaryElement].Summary();
- }
- //cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
-
- return cell;
- }
-
-
- public void SelectRadio()
- {
- List<string> items = new List<string>();
- foreach (var s in Sections)
- {
- foreach (var e in s.Elements)
- {
- if (e is RadioElement)
- items.Add(e.Summary());
- }
- }
-
- var dialog = new AlertDialog.Builder(Context);
- dialog.SetSingleChoiceItems(items.ToArray(), this.RadioSelected, this);
- dialog.SetTitle(this.Caption);
- dialog.SetNegativeButton("Cancel", this);
- dialog.Create().Show();
- }
-
- void IDialogInterfaceOnClickListener.OnClick(IDialogInterface dialog, DialogInterfaceButton which)
- {
- if ((int)which >= 0)
- {
- this.RadioSelected = (int)which;
- string radioValue = GetSelectedValue();
- _value.Text = radioValue;
- }
-
- dialog.Dismiss();
- }
-
- /// <summary>
- /// Enumerator that returns all the sections in the RootElement.
- /// </summary>
- /// <returns>
- /// A <see cref="IEnumerator"/>
- /// </returns>
- public IEnumerator<Section> GetEnumerator()
- {
- return Sections.GetEnumerator();
- }
-
- /// <summary>
- /// Enumerator that returns all the sections in the RootElement.
- /// </summary>
- IEnumerator IEnumerable.GetEnumerator()
- {
- return Sections.GetEnumerator();
- }
- }
+
+ SetSectionStartIndex();
+ }
+
+ public void Clear()
+ {
+ foreach (var s in Sections)
+ s.Dispose();
+ Sections = new List<Section>();
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ Context = null;
+ if (Sections == null)
+ return;
+ Clear();
+ Sections = null;
+ }
+ }
+
+ /// <summary>
+ /// The currently selected Radio item in the whole Root.
+ /// </summary>
+ public int RadioSelected
+ {
+ get
+ {
+ var radio = _group as RadioGroup;
+ if (radio != null)
+ return radio.Selected;
+ return -1;
+ }
+ set
+ {
+ var radio = _group as RadioGroup;
+ if (radio != null)
+ radio.Selected = value;
+ }
+ }
+
+ private string GetSelectedValue()
+ {
+ var radio = _group as RadioGroup;
+ if (radio == null)
+ return string.Empty;
+
+ int selected = radio.Selected;
+ int current = 0;
+ string radioValue = string.Empty;
+ foreach (var s in Sections)
+ {
+ foreach (var e in s.Elements)
+ {
+ if (!(e is RadioElement))
+ continue;
+
+ if (current == selected)
+ return e.Summary();
+
+ current++;
+ }
+ }
+
+ return string.Empty;
+ }
+
+ public override View GetView(Context context, View convertView, ViewGroup parent)
+ {
+ Context = context;
+
+ LayoutInflater inflater = LayoutInflater.FromContext(context);
+
+ View cell = new TextView(context) {TextSize = 16f, Text = Caption};
+ var radio = _group as RadioGroup;
+
+ if (radio != null)
+ {
+ string radioValue = GetSelectedValue();
+ cell = DroidResources.LoadStringElementLayout(context, convertView, parent, LayoutId, out _caption, out _value);
+ if (cell != null)
+ {
+ _caption.Text = Caption;
+ _value.Text = radioValue;
+ this.Click = (o, e) => { SelectRadio(); };
+ }
+ }
+ else if (_group != null)
+ {
+ int count = 0;
+ foreach (var s in Sections)
+ {
+ foreach (var e in s.Elements)
+ {
+ var ce = e as CheckboxElement;
+ if (ce != null)
+ {
+ if (ce.Value)
+ count++;
+ continue;
+ }
+ var be = e as BoolElement;
+ if (be != null)
+ {
+ if (be.Value)
+ count++;
+ continue;
+ }
+ }
+ }
+ //cell.DetailTextLabel.Text = count.ToString();
+ }
+ else if (_summarySection != -1 && _summarySection < Sections.Count)
+ {
+ var s = Sections[_summarySection];
+ //if (summaryElement < s.Elements.Count)
+ // cell.DetailTextLabel.Text = s.Elements[summaryElement].Summary();
+ }
+ //cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
+
+ return cell;
+ }
+
+
+ public void SelectRadio()
+ {
+ List<string> items = new List<string>();
+ foreach (var s in Sections)
+ {
+ foreach (var e in s.Elements)
+ {
+ if (e is RadioElement)
+ items.Add(e.Summary());
+ }
+ }
+
+ var dialog = new AlertDialog.Builder(Context);
+ dialog.SetSingleChoiceItems(items.ToArray(), this.RadioSelected, this);
+ dialog.SetTitle(this.Caption);
+ dialog.SetNegativeButton("Cancel", this);
+ dialog.Create().Show();
+ }
+
+ void IDialogInterfaceOnClickListener.OnClick(IDialogInterface dialog, DialogInterfaceButton which)
+ {
+ if ((int)which >= 0)
+ {
+ this.RadioSelected = (int)which;
+ string radioValue = GetSelectedValue();
+ _value.Text = radioValue;
+ }
+
+ dialog.Dismiss();
+ }
+
+ /// <summary>
+ /// Enumerator that returns all the sections in the RootElement.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="IEnumerator"/>
+ /// </returns>
+ public IEnumerator<Section> GetEnumerator()
+ {
+ return Sections.GetEnumerator();
+ }
+
+ /// <summary>
+ /// Enumerator that returns all the sections in the RootElement.
+ /// </summary>
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return Sections.GetEnumerator();
+ }
+ }
}
View
772 MonoDroid.Dialog/Section.cs
@@ -1,387 +1,387 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Android.Content;
-using Android.Views;
-using Android.Widget;
-using Orientation = Android.Widget.Orientation;
-
-namespace MonoDroid.Dialog
-{
- /// <summary>
- /// Sections contain individual Element instances that are rendered by MonoDroid.Dialog
- /// </summary>
- /// <remarks>
- /// Sections are used to group elements in the screen and they are the
- /// only valid direct child of the RootElement. Sections can contain
- /// any of the standard elements, including new RootElements.
- ///
- /// RootElements embedded in a section are used to navigate to a new
- /// deeper level.
- ///
- /// You can assign a header and a footer either as strings (Header and Footer)
- /// properties, or as Views to be shown (HeaderView and FooterView). Internally
- /// this uses the same storage, so you can only show one or the other.
- /// </remarks>
- public class Section : Element, IEnumerable<Element>
- {
- public List<Element> Elements = new List<Element>();
-
- List<string> ElementTypes = new List<string>();
-
- public SectionAdapter Adapter;
-
- // X corresponds to the alignment, Y to the height of the password
- private object footer;
- private object header;
-
- /// <summary>
- /// Constructs a Section without header or footers.
- /// </summary>
- public Section()
- : this("")
- {
- Adapter = new SectionAdapter(this);
- }
-
- /// <summary>
- /// Constructs a Section with the specified header
- /// </summary>
- /// <param name="caption">
- /// The header to display
- /// </param>
- public Section(string caption)
- : base(caption)
- {
- Adapter = new SectionAdapter(this);
- }
-
- /// <summary>
- /// Constructs a Section with a header and a footer
- /// </summary>
- /// <param name="caption">
- /// The caption to display (or null to not display a caption)
- /// </param>
- /// <param name="footer">
- /// The footer to display.
- /// </param>
- public Section(string caption, string footer)
- : this(caption)
- {
- Footer = footer;
- }
-
- public Section(View header)
- : this()
- {
- HeaderView = header;
- }
-
- public Section(View header, View footer)
- : this()
- {
- HeaderView = header;
- FooterView = footer;
- }
-
- /// <summary>
- /// The section header, as a string
- /// </summary>
- public string Header
- {
- get { return Caption; }
- set { Caption = value; }
- }
-
- /// <summary>
- /// The section footer, as a string.
- /// </summary>
- public string Footer
- {
- get { return footer as string; }
- set { footer = value; }
- }
-
- /// <summary>
- /// The section's header view.
- /// </summary>
- public View HeaderView
- {
- get { return header as View; }
- set { header = value; }
- }
-
- /// <summary>
- /// The section's footer view.
- /// </summary>
- public View FooterView
- {
- get { return footer as View; }
- set { footer = value; }
- }
-
- public int Count
- {
- get { return Elements.Count; }
- }
-
- public Element this[int idx]
- {
- get { return Elements[idx]; }
- }
-
- /// <summary>
- /// Adds a new child Element to the Section
- /// </summary>
- /// <param name="element">
- /// An element to add to the section.
- /// </param>
- public void Add(Element element)
- {
- if (element == null)
- return;
-
- var elementType = element.GetType().FullName;
-
- if (!ElementTypes.Contains(elementType))
- ElementTypes.Add(elementType);
-
- Elements.Add(element);
- element.Parent = this;
-
- if (Parent != null)
- InsertVisual(Elements.Count - 1, 1);
- }
-
- /// <summary>
- /// Add version that can be used with LINQ
- /// </summary>
- /// <param name="elements">
- /// An enumerable list that can be produced by something like:
- /// from x in ... select (Element) new MyElement (...)
- /// </param>
- public int Add(IEnumerable<Element> elements)
- {
- int count = 0;
- foreach (Element e in elements)
- {
- Add(e);
- count++;
- }
- return count;
- }
-
- /// <summary>
- /// Use to add a View to a section, it makes the section opaque, to
- /// get a transparent one, you must manually call ViewElement
- public void Add(View view)
- {
- if (view == null)
- return;
- Add(new ViewElement(null, view, false));
- }
-
- /// <summary>
- /// Adds the Views to the section.
- /// </summary>
- /// <param name="views">
- /// An enumarable list that can be produced by something like:
- /// from x in ... select (View) new UIFoo ();
- /// </param>
- public void Add(IEnumerable<View> views)
- {
- foreach (View v in views)
- Add(v);
- }
-
- /// <summary>
- /// Inserts a series of elements into the Section using the specified animation
- /// </summary>
- /// <param name="idx">
- /// The index where the elements are inserted
- /// </param>
- /// <param name="anim">
- /// The animation to use
- /// </param>
- /// <param name="newElements">
- /// A series of elements.
- /// </param>
- public void Insert(int idx, params Element[] newElements)
- {
- if (newElements == null)
- return;
-
- int pos = idx;
- foreach (Element e in newElements)
- {
- Elements.Insert(pos++, e);
- e.Parent = this;
- }
- var root = Parent as RootElement;
- if (Parent != null)
- {
- InsertVisual(idx, newElements.Length);
- }
- }
-
- public int Insert(int idx, IEnumerable<Element> newElements)
- {
- if (newElements == null)
- return 0;
-
- int pos = idx;
- int count = 0;
- foreach (Element e in newElements)
- {
- Elements.Insert(pos++, e);
- e.Parent = this;
- count++;
- }
- var root = Parent as RootElement;
- if (root != null )
- {
- InsertVisual(idx, pos - idx);
- }
- return count;
- }
-
- private void InsertVisual(int idx, int count)
- {
- //var root = Parent as RootElement;
-
- //if (root == null || root.TableView == null)
- // return;
-
- //int sidx = root.IndexOf(this);
- //var paths = new NSIndexPath[count];
- //for (int i = 0; i < count; i++)
- // paths[i] = NSIndexPath.FromRowSection(idx + i, sidx);
-
- //root.TableView.InsertRows(paths);
- }
-
- public void Remove(Element e)
- {
- if (e == null)
- return;
- for (int i = Elements.Count; i > 0;)
- {
- i--;
- if (Elements[i] == e)
- {
- RemoveRange(i, 1);
- return;
- }
- }
- }
-
- public void Remove(int idx)
- {
- RemoveRange(idx, 1);
- }
-
- /// <summary>
- /// Removes a range of elements from the Section
- /// </summary>
- /// <param name="start">
- /// Starting position
- /// </param>
- /// <param name="count">
- /// Number of elements to remove from the section
- /// </param>
- public void RemoveRange(int start, int count)
- {
- if (start < 0 || start >= Elements.Count)
- return;
- if (count == 0)
- return;
-
- var root = Parent as RootElement;
-
- if (start + count > Elements.Count)
- count = Elements.Count - start;
-
- Elements.RemoveRange(start, count);
-
- if (root == null)
- return;
-
- int sidx = root.IndexOf(this);
- //var paths = new NSIndexPath[count];
- //for (int i = 0; i < count; i++)
- // paths[i] = NSIndexPath.FromRowSection(start + i, sidx);
- //root.TableView.DeleteRows(paths, anim);
- }
-
- public void Clear()
- {
- foreach (Element e in Elements)
- e.Dispose();
- Elements = new List<Element>();
-
- var root = Parent as RootElement;
- //if (root != null && root.TableView != null)
- // root.TableView.ReloadData();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- Parent = null;
- Clear();
- Elements = null;
- }
- }
-
- public int GetElementViewType(Element e)
- {
- var elementType = e.GetType().FullName;
-
- for (int i = 0; i < ElementTypes.Count; i++)
- {
- if (ElementTypes[i].Equals(elementType))
- return i + 1;
- }
-
- return 0;
- }
-
- public int ElementViewTypeCount
- {
- get { return ElementTypes.Count; }
- }
-
- public override View GetView(Context context, View convertView, ViewGroup parent)
- {
- TextView view = (convertView as TextView)
- ?? new TextView(context, null, Android.Resource.Attribute.ListSeparatorTextViewStyle);
-
- view.Text = this.Caption;
-
- return view;
- }
-
- /// Enumerator to get all the elements in the Section.
- /// </summary>
- /// <returns>
- /// A <see cref="IEnumerator{T}"/>
- /// </returns>
- public IEnumerator<Element> GetEnumerator()
- {
- foreach (Element e in Elements)
- yield return e;
- }
-
- /// Enumerator to get all the elements in the Section.
- /// </summary>
- /// <returns>
- /// A <see cref="IEnumerator{T}"/>
- /// </returns>
- IEnumerator IEnumerable.GetEnumerator()
- {
- foreach (Element e in Elements)
- yield return e;
- }
- }
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Android.Content;
+using Android.Views;
+using Android.Widget;
+using Orientation = Android.Widget.Orientation;
+
+namespace MonoDroid.Dialog
+{
+ /// <summary>
+ /// Sections contain individual Element instances that are rendered by MonoDroid.Dialog
+ /// </summary>
+ /// <remarks>
+ /// Sections are used to group elements in the screen and they are the
+ /// only valid direct child of the RootElement. Sections can contain
+ /// any of the standard elements, including new RootElements.
+ ///
+ /// RootElements embedded in a section are used to navigate to a new
+ /// deeper level.
+ ///
+ /// You can assign a header and a footer either as strings (Header and Footer)
+ /// properties, or as Views to be shown (HeaderView and FooterView). Internally
+ /// this uses the same storage, so you can only show one or the other.
+ /// </remarks>
+ public class Section : Element, IEnumerable<Element>
+ {
+ public List<Element> Elements = new List<Element>();
+
+ List<string> ElementTypes = new List<string>();
+
+ public SectionAdapter Adapter;
+ public int StartIndex {get;set;}
+ // X corresponds to the alignment, Y to the height of the password
+ private object footer;
+ private object header;
+
+ /// <summary>
+ /// Constructs a Section without header or footers.
+ /// </summary>
+ public Section()
+ : this("")
+ {
+ Adapter = new SectionAdapter(this);
+ }
+
+ /// <summary>
+ /// Constructs a Section with the specified header
+ /// </summary>
+ /// <param name="caption">
+ /// The header to display
+ /// </param>
+ public Section(string caption)
+ : base(caption)
+ {
+ Adapter = new SectionAdapter(this);
+ }
+
+ /// <summary>
+ /// Constructs a Section with a header and a footer
+ /// </summary>
+ /// <param name="caption">
+ /// The caption to display (or null to not display a caption)
+ /// </param>
+ /// <param name="footer">
+ /// The footer to display.
+ /// </param>
+ public Section(string caption, string footer)
+ : this(caption)
+ {
+ Footer = footer;
+ }
+
+ public Section(View header)
+ : this()
+ {
+ HeaderView = header;
+ }
+
+ public Section(View header, View footer)
+ : this()
+ {
+ HeaderView = header;
+ FooterView = footer;
+ }
+
+ /// <summary>
+ /// The section header, as a string
+ /// </summary>
+ public string Header
+ {
+ get { return Caption; }
+ set { Caption = value; }
+ }
+
+ /// <summary>
+ /// The section footer, as a string.
+ /// </summary>
+ public string Footer
+ {
+ get { return footer as string; }
+ set { footer = value; }
+ }
+
+ /// <summary>
+ /// The section's header view.
+ /// </summary>
+ public View HeaderView
+ {
+ get { return header as View; }
+ set { header = value; }
+ }
+
+ /// <summary>
+ /// The section's footer view.
+ /// </summary>
+ public View FooterView
+ {
+ get { return footer as View; }
+ set { footer = value; }
+ }
+
+ public int Count
+ {
+ get { return Elements.Count; }
+ }
+
+ public Element this[int idx]
+ {
+ get { return Elements[idx]; }
+ }
+
+ /// <summary>
+ /// Adds a new child Element to the Section
+ /// </summary>
+ /// <param name="element">
+ /// An element to add to the section.
+ /// </param>
+ public void Add(Element element)
+ {
+ if (element == null)
+ return;
+
+ var elementType = element.GetType().FullName;
+
+ if (!ElementTypes.Contains(elementType))
+ ElementTypes.Add(elementType);
+
+ Elements.Add(element);
+ element.Parent = this;
+
+ if (Parent != null)
+ InsertVisual(Elements.Count - 1, 1);
+ }
+
+ /// <summary>
+ /// Add version that can be used with LINQ
+ /// </summary>
+ /// <param name="elements">
+ /// An enumerable list that can be produced by something like:
+ /// from x in ... select (Element) new MyElement (...)
+ /// </param>
+ public int Add(IEnumerable<Element> elements)
+ {
+ int count = 0;
+ foreach (Element e in elements)
+ {
+ Add(e);
+ count++;
+ }
+ return count;
+ }
+
+ /// <summary>
+ /// Use to add a View to a section, it makes the section opaque, to
+ /// get a transparent one, you must manually call ViewElement
+ public void Add(View view)
+ {
+ if (view == null)
+ return;
+ Add(new ViewElement(null, view, false));
+ }
+
+ /// <summary>
+ /// Adds the Views to the section.
+ /// </summary>
+ /// <param name="views">
+ /// An enumarable list that can be produced by something like:
+ /// from x in ... select (View) new UIFoo ();
+ /// </param>
+ public void Add(IEnumerable<View> views)
+ {
+ foreach (View v in views)
+ Add(v);
+ }
+
+ /// <summary>
+ /// Inserts a series of elements into the Section using the specified animation
+ /// </summary>
+ /// <param name="idx">
+ /// The index where the elements are inserted
+ /// </param>
+ /// <param name="anim">
+ /// The animation to use
+ /// </param>
+ /// <param name="newElements">
+ /// A series of elements.
+ /// </param>
+ public void Insert(int idx, params Element[] newElements)
+ {
+ if (newElements == null)
+ return;
+
+ int pos = idx;
+ foreach (Element e in newElements)
+ {
+ Elements.Insert(pos++, e);
+ e.Parent = this;
+ }
+ var root = Parent as RootElement;
+ if (Parent != null)
+ {
+ InsertVisual(idx, newElements.Length);
+ }
+ }
+
+ public int Insert(int idx, IEnumerable<Element> newElements)
+ {
+ if (newElements == null)
+ return 0;
+
+ int pos = idx;
+ int count = 0;
+ foreach (Element e in newElements)
+ {
+ Elements.Insert(pos++, e);
+ e.Parent = this;
+ count++;
+ }
+ var root = Parent as RootElement;
+ if (root != null )
+ {
+ InsertVisual(idx, pos - idx);
+ }
+ return count;
+ }
+
+ private void InsertVisual(int idx, int count)
+ {
+ //var root = Parent as RootElement;
+
+ //if (root == null || root.TableView == null)
+ // return;
+
+ //int sidx = root.IndexOf(this);
+ //var paths = new NSIndexPath[count];
+ //for (int i = 0; i < count; i++)
+ // paths[i] = NSIndexPath.FromRowSection(idx + i, sidx);
+
+ //root.TableView.InsertRows(paths);
+ }
+
+ public void Remove(Element e)
+ {
+ if (e == null)
+ return;
+ for (int i = Elements.Count; i > 0;)
+ {
+ i--;
+ if (Elements[i] == e)
+ {
+ RemoveRange(i, 1);
+ return;
+ }
+ }
+ }
+
+ public void Remove(int idx)
+ {
+ RemoveRange(idx, 1);
+ }
+
+ /// <summary>
+ /// Removes a range of elements from the Section
+ /// </summary>
+ /// <param name="start">
+ /// Starting position
+ /// </param>
+ /// <param name="count">
+ /// Number of elements to remove from the section
+ /// </param>
+ public void RemoveRange(int start, int count)
+ {
+ if (start < 0 || start >= Elements.Count)
+ return;
+ if (count == 0)
+ return;
+
+ var root = Parent as RootElement;
+
+ if (start + count > Elements.Count)
+ count = Elements.Count - start;
+
+ Elements.RemoveRange(start, count);
+
+ if (root == null)
+ return;
+
+ int sidx = root.IndexOf(this);
+ //var paths = new NSIndexPath[count];
+ //for (int i = 0; i < count; i++)
+ // paths[i] = NSIndexPath.FromRowSection(start + i, sidx);
+ //root.TableView.DeleteRows(paths, anim);
+ }
+
+ public void Clear()
+ {
+ foreach (Element e in Elements)
+ e.Dispose();
+ Elements = new List<Element>();
+
+ var root = Parent as RootElement;
+ //if (root != null && root.TableView != null)
+ // root.TableView.ReloadData();
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ Parent = null;
+ Clear();
+ Elements = null;
+ }
+ }
+
+ public int GetElementViewType(Element e)
+ {
+ var elementType = e.GetType().FullName;
+
+ for (int i = 0; i < ElementTypes.Count; i++)
+ {
+ if (ElementTypes[i].Equals(elementType))
+ return i + 1;
+ }
+
+ return 0;
+ }
+
+ public int ElementViewTypeCount
+ {
+ get { return ElementTypes.Count; }
+ }
+
+ public override View GetView(Context context, View convertView, ViewGroup parent)
+ {
+ TextView view = (convertView as TextView)
+ ?? new TextView(context, null, Android.Resource.Attribute.ListSeparatorTextViewStyle);
+
+ view.Text = this.Caption;
+
+ return view;
+ }
+
+ /// Enumerator to get all the elements in the Section.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="IEnumerator{T}"/>
+ /// </returns>
+ public IEnumerator<Element> GetEnumerator()
+ {
+ foreach (Element e in Elements)
+ yield return e;
+ }
+
+ /// Enumerator to get all the elements in the Section.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="IEnumerator{T}"/>
+ /// </returns>
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ foreach (Element e in Elements)
+ yield return e;
+ }
+ }
}
View
177 MonoDroid.Dialog/StringElement.cs
@@ -1,84 +1,95 @@
-using System;
-
-using System.Linq;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Views;
-using Android.Widget;
-using Android.Runtime;
-
-
-namespace MonoDroid.Dialog
-{
- public class StringElement : Element
- {
- public string Value
- {
- get { return _value; }
- set { _value = value; if (_text != null) _text.Text = _value; }
- }
- private string _value;
-
- public object Alignment;
-
- public StringElement(string caption)
- : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
- {
- }
-
- public StringElement(string caption, int layoutId)
- : base(caption, layoutId)
- {
- }
-
- public StringElement(string caption, string value)
- : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
- {
- Value = value;
- }
-
- public StringElement(string caption, string value, int layoutId)
- : base(caption, layoutId)
- {
- Value = value;
- }
-
- public override View GetView(Context context, View convertView, ViewGroup parent)
- {
- View view = DroidResources.LoadStringElementLayout(context, convertView, parent, LayoutId, out _caption, out _text);
- if (view != null)
- {
- _caption.Text = Caption;
- _text.Text = Value;
- }
- return view;
- }
-
- public override string Summary()
- {
- return Value;
- }
-
- public override bool Matches(string text)
- {
- return (Value != null ? Value.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) != -1 : false) ||
- base.Matches(text);
- }
-
- protected TextView _caption;
- protected TextView _text;
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- //_caption.Dispose();
- _caption = null;
- //_text.Dispose();
- _text = null;
- }
- }
- }
+using System;
+
+using System.Linq;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Views;
+using Android.Widget;
+using Android.Runtime;
+
+
+namespace MonoDroid.Dialog
+{
+ public class StringElement : Element
+ {
+ public int FontSize {get;set;}
+ public string Value
+ {
+ get { return _value; }
+ set { _value = value; if (_text != null) _text.Text = _value; }
+ }
+ private string _value;
+
+ public object Alignment;
+
+ public StringElement(string caption)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
+ {
+ }
+
+ public StringElement(string caption, int layoutId)
+ : base(caption, layoutId)
+ {
+ }
+
+ public StringElement(string caption, string value)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
+ {
+ Value = value;
+ }
+
+
+ public StringElement(string caption, string value, EventHandler clicked)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
+ {
+ Value = value;
+ this.Click = clicked;
+ }
+
+ public StringElement(string caption, string value, int layoutId)
+ : base(caption, layoutId)
+ {
+ Value = value;
+ }
+
+ public override View GetView(Context context, View convertView, ViewGroup parent)
+ {
+ View view = DroidResources.LoadStringElementLayout(context, convertView, parent, LayoutId, out _caption, out _text);
+ if (view != null)
+ {
+ _caption.Text = Caption;
+ _caption.TextSize = FontSize;
+ _text.Text = Value;
+ _text.TextSize = FontSize;
+ }
+ return view;
+ }
+
+ public override string Summary()
+ {
+ return Value;
+ }
+
+ public override bool Matches(string text)
+ {
+ return (Value != null ? Value.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) != -1 : false) ||
+ base.Matches(text);
+ }
+
+ protected TextView _caption;
+ protected TextView _text;
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ //_caption.Dispose();
+ _caption = null;
+ //_text.Dispose();
+ _text = null;
+ }
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.