protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); test_suite = Intent.GetStringExtra ("TestSuite"); suite = AndroidRunner.Suites [test_suite]; var menu = new RootElement (String.Empty); main = new Section (test_suite); foreach (ITest test in suite.Tests) { TestSuite ts = test as TestSuite; if (ts != null) main.Add (new TestSuiteElement (ts)); else main.Add (new TestCaseElement (test as TestCase)); } menu.Add (main); Section options = new Section () { new ActionElement ("Run all", Run), }; menu.Add (options); var da = new DialogAdapter (this, menu); var lv = new ListView (this) { Adapter = da }; SetContentView (lv); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var root = new RootElement("Test Root Elem") { new Section("Test Header", "Test Footer") { new ButtonElement("DialogActivity", (o, e) => StartNew()), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), new StringElement("Text label", "The Value"), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), }, new Section("Part II") { new StringElement("This is the String Element", "The Value"), new CheckboxElement("Check this out", true), new EntryElement("Username",""){ Hint = "Enter Login" }, new EntryElement("Password", "") { Hint = "Enter Password", Password = true, }, } }; var da = new DialogAdapter(this, root); var lv = new ListView(this) {Adapter = da}; SetContentView(lv); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); sourceName = Intent.GetStringExtra("TestSuite"); suiteElement = AndroidRunner.Runner.Suites[sourceName]; var menu = new RootElement(String.Empty); main = new Section(sourceName); foreach (var test in suiteElement.TestCases) { main.Add(test); } menu.Add(main); var options = new Section() { new ActionElement("Run all", Run), }; menu.Add(options); var da = new DialogAdapter(this, menu); var lv = new ListView(this) { Adapter = da }; SetContentView(lv); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ImageView img = new ImageView(this); img.SetImageResource(Resource.Drawable.spadeicon); var root = new RootElement("Test Root Elem") { new Section("Test Header", "Test Footer") { new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), new StringElement("Text label", "The Value"), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), }, new Section("Part II") { new StringElement("This is the String Element", "The Value"), new CheckboxElement("Check this out", true), new ImageElement(img), new HtmlElement("Go to Google.com","http://www.google.com") } }; var da = new DialogAdapter(this, root); var lv = new ListView(this) {Adapter = da}; SetContentView(lv); }
public DialogHelper(Context context, ListView dialogView, RootElement root) { root.Context = context; dialogView.Adapter = this.DialogAdapter = new DialogAdapter(context, root); dialogView.ItemClick += new EventHandler<ItemEventArgs>(ListView_ItemClick); dialogView.ItemLongClick += new EventHandler<ItemEventArgs>(ListView_ItemLongClick); dialogView.Tag = root; }
public DialogHelper(Context context, ListView dialogView, RootElement root) { this.Root = root; this.Root.Context = context; dialogView.Adapter = this.DialogAdapter = new DialogAdapter(context, this.Root); dialogView.ItemClick += ListView_ItemClick; // FIXME: should I comment out this? some branch seems to have done it. dialogView.ItemLongClick += ListView_ItemLongClick;; dialogView.Tag = root; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); var menu = new RootElement ("Test Runner"); var runMode = new Section("Run Mode"); var interactiveCheckBox = new CheckboxElement("Enable Interactive Mode"); interactiveCheckBox.ValueChanged += (sender , args) => GraphicsTestBase.ForceInteractiveMode = interactiveCheckBox.Value; runMode.Add(interactiveCheckBox); menu.Add(runMode); main = new Section ("Test Suites"); IList<ITest> suites = new List<ITest>(AndroidRunner.AssemblyLevel); while (suites.Count == 1 && (suites[0] is TestSuite)) suites = suites[0].Tests; foreach (var test in suites) { var ts = test as TestSuite; if (ts != null) main.Add(new TestSuiteElement(ts)); else main.Add(new TestCaseElement(test)); } menu.Add (main); Section options = new Section () { new ActionElement ("Run Everything", Run), new ActivityElement ("Credits", typeof (CreditsActivity)) }; menu.Add (options); var lv = new ListView (this) { Adapter = new DialogAdapter (this, menu) }; SetContentView (lv); // AutoStart running the tests (with either the supplied 'writer' or the options) if (Runner.AutoStart) { string msg = String.Format ("Automatically running tests{0}...", Runner.TerminateAfterExecution ? " and closing application" : String.Empty); Toast.MakeText (this, msg, ToastLength.Long).Show (); ThreadPool.QueueUserWorkItem (delegate { RunOnUiThread (delegate { Run (); // optionally end the process, e.g. click "Andr.Unit" -> log tests results, return to springboard... if (Runner.TerminateAfterExecution) Finish (); }); }); } }
protected override void OnCreate (Bundle bundle) { Options options = AndroidRunner.Runner.Options; remote = new BooleanElement ("Remote Server", options.EnableNetwork); host_name = new EntryElement ("HostName", options.HostName); host_port = new EntryElement ("Port", options.HostPort.ToString ()) { Numeric = true }; Root = new RootElement ("Options") { new Section () { remote, host_name, host_port } }; base.OnCreate (bundle); }
protected override void OnCreate (Bundle bundle) { Root = new RootElement (String.Empty) { new FormattedSection (notice) { new HtmlElement ("About Xamarin", "http://xamarin.com"), new HtmlElement ("About Mono for Android", "http://android.xamarin.com"), new HtmlElement ("About MonoDroid.Dialog", "https://github.com/spouliot/MonoDroid.Dialog"), new HtmlElement ("About NUnitLite", "http://www.nunitlite.org") } }; base.OnCreate (bundle); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.main); progressBar = FindViewById<ProgressBar> (Resource.Id.dialog_progressbar); listView = FindViewById<ListView> (Resource.Id.dialog_listView); var s = new Section("Test Header", "Test Footer") { new StringElement("Do Something", "Foo", (int)DroidResources.ElementLayout.dialog_labelfieldright, delegate { Console.WriteLine("OK"); }, Resource.Color.creme, Android.Graphics.Color.Transparent), new ButtonElement("DialogActivity", () => StartNew()), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), new StringElement("Text label", "The Value"), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), }; //s.BackgroundColor = Color.DarkRed; var root = new RootElement ("Test Root Elem") { s, // new Section("Part II") // { // new StringElement("This is the String Element", "The Value", delegate { // Console.WriteLine("Clicked string element.");} // ), // new CheckboxElement("Check this out", true), // new EntryElement("Username",""){ // Hint = "Enter Login" // }, // new EntryElement("Password", "") { // Hint = "Enter Password", // Password = true, // }, // //new ProgressBarElement("") // }, // new Section("Part III") // { // new ButtonElement("Hide Progress", () => HideProgress()) // } }; var da = new DialogAdapter (this, root); listView.Adapter = da; //var lv = new ListView(this) {Adapter = da}; //SetContentView(listView); }
public DialogHelper(Context context, ListView dialogView, RootElement root) { root.Context = context; dialogView.Adapter = this.DialogAdapter = new DialogAdapter(context, root); dialogView.ItemClick += new EventHandler<ItemEventArgs>(ListView_ItemClick); // TODO - sort out long click changes /* dialogView.ItemLongClick = new AdapterView.ItemLongClickHandler(ListView_ItemLongClick); dialogView.ItemLongClick += new EventHandler<ItemEventArgs>(ListView_ItemLongClick); */ dialogView.Tag = root; }
public DialogHelper(Context context, ListView dialogView, RootElement root) { this.Root = root; this.Root.Context = context; dialogView.Adapter = this.DialogAdapter = new DialogAdapter(context, this.Root); dialogView.ItemClick += new EventHandler<AdapterView.ItemClickEventArgs>(ListView_ItemClick); dialogView.ItemLongClick += ListView_ItemLongClick; dialogView.Scroll += delegate(object sender, AbsListView.ScrollEventArgs e) { Console.WriteLine( "Item Count " + e.View.Count ); }; dialogView.Tag = root; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ImageView img = new ImageView(this); img.SetImageResource(Resource.Drawable.spadeicon); var root = new RootElement("Test Root Elem") { new Section("Test Header", "Test Footer") { new StringElement("Do Something", "Foo", () => { Console.WriteLine("Did Something"); }), new ButtonElement("DialogActivity", () => StartNew()), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), new StringElement("Text label", "The Value"), new BooleanElement("Push my button", true), new BooleanElement("Push this too", false), }, new Section("Part II") { new StringElement("This is the String Element", "The Value"), new CheckboxElement("Check this out", true), new EntryElement("Username",""){ Hint = "Enter Login" }, new EntryElement("Password", "") { Hint = "Enter Password", Password = true, }, } }; var da = new DialogAdapter(this, root); var lv = new ListView(this) {Adapter = da}; SetContentView(lv); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); if (Runner.Options == null) Runner.Options = new Options (this); var menu = new RootElement ("Test Runner"); main = new Section ("Test Suites"); foreach (TestSuite suite in AndroidRunner.AssemblyLevel) { main.Add (new TestSuiteElement (suite)); } menu.Add (main); Section options = new Section () { new ActionElement ("Run Everything", Run), new ActivityElement ("Options", typeof (OptionsActivity)), new ActivityElement ("Credits", typeof (CreditsActivity)) }; menu.Add (options); var lv = new ListView (this) { Adapter = new DialogAdapter (this, menu) }; SetContentView (lv); // AutoStart running the tests (with either the supplied 'writer' or the options) if (Runner.AutoStart) { string msg = String.Format ("Automatically running tests{0}...", Runner.TerminateAfterExecution ? " and closing application" : String.Empty); Toast.MakeText (this, msg, ToastLength.Long).Show (); ThreadPool.QueueUserWorkItem (delegate { RunOnUiThread (delegate { Run (); // optionally end the process, e.g. click "Andr.Unit" -> log tests results, return to springboard... if (Runner.TerminateAfterExecution) Finish (); }); }); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); string test_case = Intent.GetStringExtra ("TestCase"); TestResult result = AndroidRunner.Results [test_case]; string error = String.Format ("<b>{0}<b><br><font color='grey'>{1}</font>", result.Message, result.StackTrace.Replace (System.Environment.NewLine, "<br>")); var menu = new RootElement (String.Empty) { new Section (test_case) { new FormattedElement (error) } }; var da = new DialogAdapter (this, menu); var lv = new ListView (this) { Adapter = da }; SetContentView (lv); }
public SpiffyDialogActivity(RootElement root, Bitmap bgImage) : base (root) { this.bgImage = bgImage; }
void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) { continue; } string caption = null; object[] attrs = mi.GetCustomAttributes(false); bool skip = false; foreach (var attr in attrs) { if (attr is SkipAttribute) { skip = true; } if (attr is CaptionAttribute) { caption = ((CaptionAttribute)attr).Caption; } else if (attr is SectionAttribute) { if (section != null) { root.Add(section); } var sa = attr as SectionAttribute; section = new Section(sa.Caption, sa.Footer); } } if (skip) { continue; } if (caption == null) { caption = MakeCaption(mi.Name); } if (section == null) { section = new Section(); } Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; EventHandler invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) { pa = attr as PasswordAttribute; } else if (attr is EntryAttribute) { ea = attr as EntryAttribute; } else if (attr is MultilineAttribute) { multi = true; } else if (attr is HtmlAttribute) { html = attr; } else if (attr is AlignmentAttribute) { align = attr as AlignmentAttribute; } if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) { throw new Exception("Did not find method " + mname); } invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); }; } } string value = (string)GetValue(mi, o); if (pa != null) { element = new EntryElement(caption, value) { Hint = pa.Placeholder, Password = true } } ; else if (ea != null) { element = new EntryElement(caption, value) { Hint = ea.Placeholder } } ; else if (multi) { element = new MultilineElement(caption, value); } else if (html != null) { element = new HtmlElement(caption, value); } else { var selement = new StringElement(caption, value); element = selement; if (align != null) { selement.Alignment = align.Alignment; } } if (invoke != null) { ((StringElement)element).Click = invoke; } } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (int)GetValue(mi, o)); floatElement.Caption = caption; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) { checkbox = true; } } if (checkbox) { element = new CheckboxElement(caption, (bool)GetValue(mi, o)); } else { element = new BooleanElement(caption, (bool)GetValue(mi, o)); } } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) { asDate = true; } else if (attr is TimeAttribute) { asTime = true; } } if (asDate) { element = new DateElement(caption, dateTime); } else if (asTime) { element = new TimeElement(caption, dateTime); } else { element = new DateTimeElement(caption, dateTime); } } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) { selected = idx; } csection.Add(new RadioElement(MakeCaption(fi.Name))); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(ImageView)) { element = new ImageElement(null); // (ImageView)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) { throw new Exception("IEnumerable found, but no previous int found"); } foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } int selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) { selected = 0; } element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { foreach (object attr in attrs) { if (attr is RadioSelectionAttribute) { last_radio_index = mi; break; } } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) { continue; } section.Add(element); mappings[element] = new MemberAndInstance(mi, o); } root.Add(section); }
public BindingContext(Context context, object callbacks, object o, string title) { _context = context; if (o == null) throw new ArgumentNullException("o"); mappings = new Dictionary<Element, MemberAndInstance>(); Root = new RootElement(title); Populate(callbacks, o, Root); }
void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) continue; string caption = null; object[] attrs = mi.GetCustomAttributes(false); bool skip = false; foreach (var attr in attrs) { if (attr is SkipAttribute) skip = true; if (attr is CaptionAttribute) caption = ((CaptionAttribute)attr).Caption; else if (attr is SectionAttribute) { if (section != null) root.Add(section); var sa = attr as SectionAttribute; section = new Section(sa.Caption, sa.Footer); } } if (skip) continue; if (caption == null) caption = MakeCaption(mi.Name); if (section == null) section = new Section(); Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; EventHandler invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) pa = attr as PasswordAttribute; else if (attr is EntryAttribute) ea = attr as EntryAttribute; else if (attr is MultilineAttribute) multi = true; else if (attr is HtmlAttribute) html = attr; else if (attr is AlignmentAttribute) align = attr as AlignmentAttribute; if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) throw new Exception("Did not find method " + mname); invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); }; } } string value = (string)GetValue(mi, o); if (pa != null) element = new EntryElement(caption, value) { Hint = pa.Placeholder, Password = true }; else if (ea != null) element = new EntryElement(caption, value) { Hint = ea.Placeholder }; else if (multi) element = new MultilineElement(caption, value); else if (html != null) element = new HtmlElement(caption, value); else { var selement = new StringElement(caption, value); element = selement; if (align != null) selement.Alignment = align.Alignment; } if (invoke != null) { // ((StringElement)element).Click += invoke; } } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (int)GetValue(mi, o)); floatElement.Caption = caption; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) checkbox = true; } if (checkbox) element = new CheckboxElement(caption, (bool)GetValue(mi, o)); else element = new BooleanElement(caption, (bool)GetValue(mi, o)); } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) asDate = true; else if (attr is TimeAttribute) asTime = true; } if (asDate) element = new DateElement(caption, dateTime); else if (asTime) element = new TimeElement(caption, dateTime); else element = new DateTimeElement(caption, dateTime); } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) selected = idx; csection.Add(new RadioElement(MakeCaption(fi.Name))); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(ImageView)) { element = new ImageElement(null); // (ImageView)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) throw new Exception("IEnumerable found, but no previous int found"); foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } int selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) selected = 0; element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { foreach (object attr in attrs) { if (attr is RadioSelectionAttribute) { last_radio_index = mi; break; } } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) continue; section.Add(element); mappings[element] = new MemberAndInstance(mi, o); } root.Add(section); }
public DialogAdapter(Context context, RootElement root) { this.context = context; this.inflater = LayoutInflater.From(context); this.Root = root; }
public DialogActivity(RootElement root) : base() { this.Root = root; this.DialogAdapter = new DialogAdapter(this, root); }
public DialogAdapter(Context context, RootElement root) { _context = context; this.Root = root; }