示例#1
0
        public UserPreferencesView() : base(UITableViewStyle.Grouped, null)
        {
            bool filtered = PreferencesProvider.GetFilter() == 1 ? true : false;

            var filter = new CheckboxElement("Filter explicit jokes and photos", filtered);


            this.Pushing = true;

            Root = new RootElement("Settings")
            {
                new Section("")
                {
                    filter
                }
            };

            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) => {
                int success = PreferencesProvider.SetFilter(filter.Value);

                if (success > 0)
                {
                    new UIAlertView("Settings", "Your settings have been saved!", null, "ok", null).Show();
                }
                else
                {
                    new UIAlertView("Settings", "Uh oh something went wrong.  Please try again.", null, "ok", null).Show();
                }
            })

                , true);
        }
示例#2
0
        public void AddLayer(int layer)
        {
            PlatformerEditor actualGame = (PlatformerEditor)UIManager.Game;

            if (actualGame.GetWorldLayer(layer) != null)
            {
                return;
            }
            GroupElement  group       = new GroupElement(UIManager, new Vector2(0, 0), new Vector2(128, 32), Layer + 0.01f, Name + "_" + layer.ToString());
            ButtonElement layerButton = new ButtonElement(UIManager, new Vector2(0, 0), new Vector2(96, 32), group.Layer + 0.01f, group.Name + "_button", "layer " + layer.ToString());

            layerButton.Click = () =>
            {
                WorldLayer worldLayer = actualGame.GetWorldLayer(layer);
                actualGame.CurrentWorldLayer = worldLayer;
            };
            CheckboxElement layerDisplayCheckbox = new CheckboxElement(UIManager, new Vector2(layerButton.Size.X, 0), new Vector2(32, 32), group.Layer + 0.01f, group.Name + "_checkbox", true);

            layerDisplayCheckbox.Tick = (ticked) =>
            {
                WorldLayer worldLayer = actualGame.GetWorldLayer(layer);
                if (worldLayer != null)
                {
                    worldLayer.IsVisible = ticked;
                }
            };
            group.Elements.Add(layerButton);
            group.Elements.Add(layerDisplayCheckbox);
            AddItem(group);
            layerButtonGroups.Add(group);
        }
示例#3
0
        public LoginViewController() : base(UITableViewStyle.Grouped, null)
        {
            hostEntry = new EntryElement("Host", "imap.gmail.com", "imap.gmail.com");
            portEntry = new EntryElement("Port", "993", "993")
            {
                KeyboardType = UIKeyboardType.NumberPad
            };
            sslCheckbox = new CheckboxElement("Use SSL", true);

            userEntry     = new EntryElement("Username", "Email / Username", "");
            passwordEntry = new EntryElement("Password", "password", "", true);

            Root = new RootElement("IMAP Login")
            {
                new Section("Server")
                {
                    hostEntry,
                    portEntry,
                    sslCheckbox
                },
                new Section("Account")
                {
                    userEntry,
                    passwordEntry
                },
                new Section {
                    new StyledStringElement("Login", Login)
                }
            };

            foldersViewController = new FoldersViewController();
        }
示例#4
0
        private CheckboxElement GetCheckboxOfSetting(string settingName,
                                                     StringComparison stringComparison = StringComparison.Ordinal)
        {
            // Locate the row element.
            var row = RowElements.FirstOrDefault(e =>
            {
                var labelEl = e.FindElement(By.CssSelector(".control-label"));

                return(String.Equals(
                           settingName,
                           labelEl.TextHelper().InnerText,
                           stringComparison));
            });

            // Verify it exists.
            if (row == null)
            {
                throw new NoSuchElementException();
            }

            // Locate the checkbox..
            var checkboxEl = row.FindElement(By.CssSelector(".checkbox"));
            var checkbox   = new CheckboxElement(checkboxEl);

            return(checkbox);
        }
        /// <summary>
        /// Searches for product.
        /// </summary>
        /// <param name="productName">Name of the product.</param>
        public virtual void SearchForProduct(string productName)
        {
            var currentWindowHandle = WrappedDriver.CurrentWindowHandle;

            ProductNameElement.SetValue(productName);
            SearchElement.Click();

            WrappedDriver
            .Wait(TimeSpan.FromSeconds(2))
            .Until(d => !ProductsGrid.IsBusy());

            var firstCheckbox = ProductsGrid
                                .GetCell(0, 0)
                                .FindElement(By.TagName("input"));

            var checkbox = new CheckboxElement(firstCheckbox);

            checkbox.Check(true);
            SaveElement.Click();

            // Wait for the page to close.
            WrappedDriver
            .Wait(TimeSpan.FromSeconds(10))
            .Until(d => !d.WindowHandles.Contains(currentWindowHandle));
        }
        public CheckboxElementExpression To([NotNull] CheckBox box)
        {
            IScreenElement element = new CheckboxElement(_accessor, box);

            _binder.AddElement(element);

            return(new CheckboxElementExpression(element));
        }
示例#7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
            var title = expense == null ? "New Expense" : "Edit Expense";

            this.Root = new RootElement(title)
            {
                new Section("Expense Details")
                {
                    (name = new EntryElement("Name", "Expense Name", string.Empty)),
                    (total = new EntryElement("Total", "1.00", string.Empty)
                    {
                        KeyboardType = UIKeyboardType.DecimalPad
                    }),
                    (billable = new CheckboxElement("Billable", true)),
                    new RootElement("Category", categories = new RadioGroup("category", 0))
                    {
                        new Section()
                        {
                            from category in viewModel.Categories
                            select(Element) new RadioElement(category)
                        }
                    },
                    (due = new DateElement("Due Date", DateTime.Now))
                },
                new Section("Notes")
                {
                    (notes = new EntryElement(string.Empty, "Enter expense notes.", string.Empty))
                }
            };

            billable.Value      = viewModel.Billable;
            name.Value          = viewModel.Name;
            total.Value         = viewModel.Total;
            notes.Caption       = viewModel.Notes;
            categories.Selected = viewModel.Categories.IndexOf(viewModel.Category);
            due.DateValue       = viewModel.Due;

            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async delegate
            {
                viewModel.Category = viewModel.Categories[categories.Selected];
                viewModel.Name     = name.Value;
                viewModel.Billable = billable.Value;
                viewModel.Due      = due.DateValue;
                viewModel.Notes    = notes.Caption;
                viewModel.Total    = total.Value;

                await viewModel.ExecuteSaveExpenseCommand();
                if (!viewModel.CanNavigate)
                {
                    return;
                }
                NavigationController.PopToRootViewController(true);
            });
        }
示例#8
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     Root = new RootElement("About")
     {
         new Section("Social Networks")
         {
             (twitter = new CheckboxElement("Twitter", Settings.Twitter)),
             (facebook = new CheckboxElement("Facebook", Settings.Facebook)),
             (sina = new CheckboxElement("Sina Weibo", Settings.Sina)),
             (tencent = new CheckboxElement("Tencent Weibo", Settings.Tencent))
         },
         new Section("Customization")
         {
             Footer   = "Ensure notifications are enabled on your iOS devices main settings for Post It.",
             Elements = new List <Element> {
                 new RootElement("Colors",
                                 (color = new RadioGroup("color", Settings.Color)))
                 {
                     new Section()
                     {
                         new RadioElement("Blue", "color"),
                         new RadioElement("Dark Blue", "color"),
                         new RadioElement("Gray", "color"),
                         new RadioElement("Green", "color"),
                         new RadioElement("Light Gray", "color"),
                         new RadioElement("Pink (for @StefiSpice)", "color"),
                         new RadioElement("Purple", "color"),
                     }
                 },
                 (notifications = new CheckboxElement("Notifications", Settings.Notifications))
             }
         },
         new Section("Created")
         {
             new StringElement("By @JamesMontemagno", () => {
                 UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("http://www.twitter.com/jamesmontemagno"));
             }),
             new StringElement("In C# with Xamarin", () => {
                 UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("http://www.xamarin.com"));
             }),
             new StringElement("Copyright 2014 Refractored LLC", () => {
                 UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("http://www.refractored.com"));
             }),
         },
         new Section("Thank You")
         {
             new StringElement("Copy by Stephanie Sparer", () => {
                 UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("http://www.twitter.com/stefispice"));
             }),
             new StringElement("Icon by Seth D.", () => {
                 UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("http://www.fiverr.com/atomicbliss"));
             }),
         },
     };
 }
        public void AcceptTermsAndConditionsTest()
        {
            var el = new CheckboxElement(
                driver.FindElement(
                    By.CssSelector("#termsofservice")));

            var isCheckedBefore = el.IsChecked;

            orderSummary.AcceptTermsAndConditions(true);
            var isCheckedAfter = el.IsChecked;

            Assert.IsFalse(isCheckedBefore);
            Assert.IsTrue(isCheckedAfter);
        }
示例#10
0
        private RootElement RenderPicker(Item values, Item pickerValues)
        {
            // build a section with all the items in the current list
            section = new Section();
            foreach (var item in currentList)
            {
                CheckboxElement ce = new CheckboxElement(item.Name);
                // set the value to true if the current item is in the values list
                ce.Value   = values.Items.IndexOf(item) < 0 ? false : true;
                ce.Tapped += delegate { Checkbox_Click(ce, new EventArgs()); };
                section.Add(ce);
            }

            Section itemTypeSection = null;

            if (itemTypeID == SystemItemTypes.Contact)
            {
                itemTypeSection = new Section()
                {
                    new StringElement("Add contact", delegate {
                        var picker           = new ABPeoplePickerNavigationController();
                        picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                            // process the contact - if it's not null, handle adding the new contact to the ListPicker
                            var contact = ContactPickerHelper.ProcessContact(e.Person);
                            if (contact != null)
                            {
                                HandleAddedContact(contact);
                            }
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        picker.Cancelled += delegate {
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        // present the contact picker
                        controller.PresentModalViewController(picker, true);
                    }),
                };
            }

            var listPickerRoot = new RootElement(caption);

            if (itemTypeSection != null)
            {
                listPickerRoot.Add(itemTypeSection);
            }
            listPickerRoot.Add(section);
            return(listPickerRoot);
        }
示例#11
0
 public SupportPopupViewController() : base(UITableViewStyle.Grouped, null)
 {
     password   = new EntryElement("Password", "Support password", String.Empty, true);
     showScreen = new CheckboxElement("Show support screen", false);
     confirm    = new StyledStringElement("Confirm", delegate { Confirm(); });
     confirm.BackgroundColor = UIColor.DarkGray;
     confirm.TextColor       = UIColor.White;
     Root = new RootElement("SupportPopupViewController")
     {
         new Section("Support")
         {
             password,
             showScreen,
             confirm
         },
     };
 }
示例#12
0
        private 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 || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
                        skip = true;
                    else 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;
                    Action 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]); };
                        }
                    }

                    var value = (string)GetValue(mi, o);
                    if (pa != null)
                        element = new EntryElement(caption, pa.Placeholder, value, true);
                    else if (ea != null)
                        element = new EntryElement(caption, ea.Placeholder, value) { KeyboardType = ea.KeyboardType };
                    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)
                        (element).Tapped += invoke;
                }
                else if (mType == typeof(float))
                {
                    var floatElement = new FloatElement(null, null, (float)GetValue(mi, o)) { 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;

                        var ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute;
                        csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name)));
                        idx++;
                    }

                    element = new RootElement(caption, new RadioGroup(null, selected)) { csection };
                }
                else if (mType == typeof(UIImage))
                {
                    element = new ImageElement((UIImage)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++;
                    }
                    var 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)
                {
                    if (attrs.OfType<RadioSelectionAttribute>().Any())
                    {
                        last_radio_index = mi;
                    }
                }
                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);
        }
示例#13
0
        /// <summary>
        /// Adds the new associated products.
        /// </summary>
        /// <param name="productName">Name of the product.</param>
        /// <returns></returns>
        public virtual AssociatedProductsVariantsComponent AddNewAssociatedProducts(
            string productName)
        {
            var productNameSelector = By.CssSelector("#SearchProductName");
            var searchSelector      = By.CssSelector("#search-products");
            var saveSelector        = By.CssSelector("*[name='save']");

            var currentWindowHandle = WrappedDriver.CurrentWindowHandle;
            var windowHandles       = WrappedDriver.WindowHandles;
            var newWindowHandle     = default(string);

            AddNewAssociatedProductElement.Click();

            // Wait for the new window to appear.
            WrappedDriver
            .Wait(TimeSpan.FromSeconds(5))
            .Until(d => newWindowHandle = d.WindowHandles
                                          .Except(windowHandles)
                                          .FirstOrDefault());

            // Switch to new window.
            WrappedDriver.SwitchTo().Window(newWindowHandle);

            var productNameEl = new InputElement(
                WrappedDriver.FindElement(
                    productNameSelector));

            var searchElement = WrappedDriver.FindElement(searchSelector);

            var productsGrid = pageObjectFactory.PrepareComponent(
                new KGridComponent <AssociatedProductsVariantsComponent>(
                    new BaseKendoConfiguration(),
                    By.CssSelector("#products-grid"),
                    pageObjectFactory,
                    WrappedDriver,
                    this));

            var saveElement = WrappedDriver.FindElement(saveSelector);

            productNameEl.SetValue(productName);
            searchElement.Click();

            // Wait until ajax request finishes.
            WrappedDriver
            .Wait(TimeSpan.FromSeconds(10))
            .Until(d => !productsGrid.IsBusy());

            // Select the first product that appears.
            var firstCheckbox = productsGrid
                                .GetCell(0, 0)
                                .FindElement(By.TagName("input"));

            var checkbox = new CheckboxElement(firstCheckbox);

            checkbox.Check(true);

            // Save.
            saveElement.Click();

            // Wait until the window handle no longer exists.
            WrappedDriver
            .Wait(TimeSpan.FromSeconds(10))
            .Until(d => !d.WindowHandles.Contains(newWindowHandle));

            // Switch back to the main window.
            WrappedDriver.SwitchTo().Window(currentWindowHandle);

            // Wait for the ajx request to finish.
            WrappedDriver
            .Wait(TimeSpan.FromSeconds(10))
            .UntilChain(d => AssociatedProductsGridComponent.IsBusy())
            .UntilChain(d => !AssociatedProductsGridComponent.IsBusy());

            return(this);
        }
示例#14
0
 private string Gump_WriteCheckBox(CheckboxElement elem)
 {
     return(string.Format("checkbox {0} {1} {2} {3} {4} {5}", elem.X, elem.Y, elem.UnCheckedID, elem.CheckedID, BoolToString(elem.Checked), elem.Group));
 }
示例#15
0
        private StringWriter CreateBareScript()
        {
            StringWriter sw_Script = new StringWriter();
            //ArrayList al_Buttons = new ArrayList();
            //ArrayList al_Texts = new ArrayList();

            List <string> GumpCommands = new List <string>();
            List <string> GumpTexts    = new List <string>();


            sw_Script.WriteLine("// Created {0}, with Gump Studio.", DateTime.Now);
            sw_Script.WriteLine("// Exported with {0} ver {1}.", this.GetPluginInfo().PluginName, this.GetPluginInfo().Version);
            sw_Script.WriteLine("");

            if (!m_Designer.GumpProperties.Moveable)
            {
                GumpCommands.Add("NoMove");
            }

            if (!m_Designer.GumpProperties.Closeable)
            {
                GumpCommands.Add("NoClose");
            }

            if (!m_Designer.GumpProperties.Disposeable)
            {
                GumpCommands.Add("NoDispose");
            }

            if (m_Designer.Stacks.Count > 0)
            {
                int radiogroup = -1;
                int pageindex  = 0;
                // =================

                foreach (GroupElement ge_Elements in m_Designer.Stacks)
                {
                    GumpCommands.Add(Gump_WritePage(ref pageindex)); // "page pageid"
                    if (ge_Elements == null)
                    {
                        continue;
                    }

                    foreach (BaseElement be_Element in ge_Elements.GetElementsRecursive())
                    {
                        if (be_Element == null)
                        {
                            continue;
                        }

                        Type ElementType = be_Element.GetType();

                        if (ElementType == typeof(HTMLElement))
                        {
                            HTMLElement elem = be_Element as HTMLElement;
                            if (elem.TextType == HTMLElementType.HTML)
                            {
                                string cmd = Gump_WriteHTMLGump(elem, ref GumpTexts);
                                GumpCommands.Add(cmd);
                            }
                            else
                            {
                                string cmd = Gump_WriteXMFHtmlGump(elem);
                                GumpCommands.Add(cmd);
                            }
                        }
                        else if (ElementType == typeof(TextEntryElement))
                        {
                            TextEntryElement elem = be_Element as TextEntryElement;
                            string           cmd  = Gump_WriteTextEntry(elem, ref GumpTexts);
                            GumpCommands.Add(cmd);
                        }
                        else if (ElementType == typeof(LabelElement))
                        {
                            LabelElement elem = be_Element as LabelElement;
                            string       cmd  = Gump_WriteText(elem, ref GumpTexts);
                            GumpCommands.Add(cmd);
                        }

                        else if (ElementType == typeof(AlphaElement))
                        {
                            AlphaElement elem = be_Element as AlphaElement;
                            string       cmd  = Gump_WriteCheckerTrans(elem);
                            GumpCommands.Add(cmd);
                        }
                        else if (ElementType == typeof(BackgroundElement))
                        {
                            BackgroundElement elem = be_Element as BackgroundElement;
                            string            cmd  = Gump_WriteResizePic(elem);
                            GumpCommands.Add(cmd);
                        }
                        else if (ElementType == typeof(ImageElement))
                        {
                            ImageElement elem = be_Element as ImageElement;
                            string       cmd  = Gump_WriteGumpPic(elem);
                            GumpCommands.Add(cmd);
                        }
                        else if (ElementType == typeof(ItemElement))
                        {
                            ItemElement elem = be_Element as ItemElement;
                            string      cmd  = Gump_WriteTilePic(elem);
                            GumpCommands.Add(cmd);
                        }
                        else if (ElementType == typeof(TiledElement))
                        {
                            TiledElement elem = be_Element as TiledElement;
                            string       cmd  = Gump_WriteGumpPicTiled(elem);
                            GumpCommands.Add(cmd);
                        }

                        else if (ElementType == typeof(ButtonElement))
                        {
                            ButtonElement elem = be_Element as ButtonElement;
                            string        cmd  = Gump_WriteButton(elem);
                            GumpCommands.Add(cmd);
                        }

                        else if (ElementType == typeof(CheckboxElement))
                        {
                            CheckboxElement elem = be_Element as CheckboxElement;
                            string          cmd  = Gump_WriteCheckBox(elem);
                            GumpCommands.Add(cmd);
                        }
                        else if (ElementType == typeof(RadioElement))
                        {
                            RadioElement elem = be_Element as RadioElement;
                            if (elem.Group != radiogroup)
                            {
                                GumpCommands.Add("group " + elem.Group);
                                radiogroup = elem.Group;
                            }
                            string cmd = Gump_WriteRadioBox(elem);
                            GumpCommands.Add(cmd);
                        }
                    }
                }
            }
            sw_Script.WriteLine("");
            sw_Script.WriteLine("use uo;");
            sw_Script.WriteLine("use os;");
            sw_Script.WriteLine("");
            sw_Script.WriteLine("program gump_{0}(who)", frm_POLExportForm.GumpName);
            sw_Script.WriteLine("");

            sw_Script.WriteLine("\tvar gump := array {");

            int i = 1;

            foreach (string tmpCmd in GumpCommands)
            {
                sw_Script.Write("\t\t\"{0}\"", tmpCmd);

                if (i == GumpCommands.Count)
                {
                    sw_Script.WriteLine("");
                }
                else
                {
                    sw_Script.WriteLine(",", tmpCmd);
                }
                i++;
            }
            sw_Script.WriteLine("\t};");

            sw_Script.WriteLine("\tvar data := array {");

            i = 1;
            foreach (string tmpSe in GumpTexts)
            {
                sw_Script.Write("\t\t\"{0}\"", tmpSe);
                if (i == GumpTexts.Count)
                {
                    sw_Script.WriteLine("");
                }
                else
                {
                    sw_Script.WriteLine(",");
                }
                i++;
            }
            sw_Script.WriteLine("\t};");
            sw_Script.WriteLine("");
            sw_Script.WriteLine("\tSendDialogGump(who, gump, data{0});", Gump_Location(m_Designer.GumpProperties.Location));
            sw_Script.WriteLine("");
            sw_Script.WriteLine("endprogram");
            return(sw_Script);
        }
示例#16
0
 private string DistroGump_GFCheckBox(string gump_name, CheckboxElement elem)
 {
     return(String.Format("GFCheckBox({0}, {1}, {2}, {3}, {4}, {5}, {6});", gump_name, elem.X, elem.Y, elem.UnCheckedID, elem.CheckedID, BoolToString(elem.Checked), elem.Group));
 }
示例#17
0
 private string Gump_WriteCheckBox(CheckboxElement elem)
 {
     return string.Format("checkbox {0} {1} {2} {3} {4} {5}", elem.X, elem.Y, elem.UnCheckedID, elem.CheckedID, BoolToString(elem.Checked), elem.Group);        
 }
示例#18
0
        private 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 || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
                    {
                        skip = true;
                    }
                    else 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;
                    Action             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]); };
                        }
                    }

                    var value = (string)GetValue(mi, o);
                    if (pa != null)
                    {
                        element = new EntryElement(caption, pa.Placeholder, value, true);
                    }
                    else if (ea != null)
                    {
                        element = new EntryElement(caption, ea.Placeholder, value)
                        {
                            KeyboardType = ea.KeyboardType
                        }
                    }
                    ;
                    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)
                    {
                        (element).Tapped += invoke;
                    }
                }
                else if (mType == typeof(float))
                {
                    var floatElement = new FloatElement(null, null, (float)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;
                        }

                        var ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute;
                        csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name)));
                        idx++;
                    }

                    element = new RootElement(caption, new RadioGroup(null, selected))
                    {
                        csection
                    };
                }
                else if (mType == typeof(UIImage))
                {
                    element = new ImageElement((UIImage)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++;
                    }
                    var 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)
                {
                    if (attrs.OfType <RadioSelectionAttribute>().Any())
                    {
                        last_radio_index = mi;
                    }
                }
                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);
        }
示例#19
0
 public void WhenILookAtACheckboxWithId(string id)
 {
     this.checkbox = Browser.Current.Checkbox(By.Id(id));
 }
示例#20
0
		public static RootElement TestElements()
		{
			RootElement re1 = new RootElement("re1");
			Debug.WriteLine(re1.ToString());
			Section s1 = new Section();
			Debug.WriteLine(s1.ToString());
			//Section s2 = new Section(new Android.Views.View(a1));
			//Debug.WriteLine(s2.ToString());
			Section s3 = new Section("s3");
			Debug.WriteLine(s3.ToString());
			//Section s4 = new Section
			//					(
			//					  new Android.Views.View(a1)
			//					, new Android.Views.View(a1)
			//					);
			//Debug.WriteLine(s4.ToString());
			Section s5 = new Section("caption", "footer");
			Debug.WriteLine(s5.ToString());

			StringElement se1 = new StringElement("se1");
			Debug.WriteLine(se1.ToString());
			StringElement se2 = new StringElement("se2", delegate() { });
			Debug.WriteLine(se2.ToString());
			//StringElement se3 = new StringElement("se3", 4);
			StringElement se4 = new StringElement("se4", "v4");
			Debug.WriteLine(se4.ToString());
			//StringElement se5 = new StringElement("se5", "v5", delegate() { });
			
			// removed - protected (all with LayoutID)
			// StringElement se6 = new StringElement("se6", "v6", 4);
			// Debug.WriteLine(se6.ToString());

			// not cross platform! 
			// TODO: make it!?!?!?
			// AchievementElement
			
			BooleanElement be1 = new BooleanElement("be1", true);
			Debug.WriteLine(be1.ToString());
			BooleanElement be2 = new BooleanElement("be2", false, "key");
			Debug.WriteLine(be2.ToString());
			
			// Abstract
			// BoolElement be3 = new BoolElement("be3", true);

			CheckboxElement cb1 = new CheckboxElement("cb1");
			Debug.WriteLine(cb1.ToString());
			CheckboxElement cb2 = new CheckboxElement("cb2", true);
			Debug.WriteLine(cb2.ToString());
			CheckboxElement cb3 = new CheckboxElement("cb3", false, "group1");
			Debug.WriteLine(cb3.ToString());
			CheckboxElement cb4 = new CheckboxElement("cb4", false, "subcaption", "group2");
			Debug.WriteLine(cb4.ToString());

			DateElement de1 = new DateElement("dt1", DateTime.Now);
			Debug.WriteLine(de1.ToString());

			// TODO: see issues 
			// https://github.com/kevinmcmahon/MonoDroid.Dialog/issues?page=1&state=open
			EntryElement ee1 = new EntryElement("ee1", "ee1");
			Debug.WriteLine(ee1.ToString());
			EntryElement ee2 = new EntryElement("ee2", "ee2 placeholder", "ee2 value");
			Debug.WriteLine(ee2.ToString());
			EntryElement ee3 = new EntryElement("ee3", "ee3 placeholder", "ee3 value", true);
			Debug.WriteLine(ee3.ToString());

			FloatElement fe1 = new FloatElement("fe1");
			Debug.WriteLine(fe1.ToString());
			FloatElement fe2 = new FloatElement(-0.1f, 0.1f, 3.2f);
			Debug.WriteLine(fe2.ToString());
			FloatElement fe3 = new FloatElement
									(
									  null
									, null // no ctors new Android.Graphics.Bitmap()
									, 1.0f
									);
			Debug.WriteLine(fe3.ToString());

			HtmlElement he1 = new HtmlElement("he1", "http://holisiticware.net");
			Debug.WriteLine(he1.ToString());

			
			// TODO: image as filename - cross-platform
			ImageElement ie1 = new ImageElement(null);
			Debug.WriteLine(ie1.ToString());

			// TODO: not in Kevin's MA.D
			// ImageStringElement

			MultilineElement me1 = new MultilineElement("me1");
			Debug.WriteLine(me1.ToString());
			MultilineElement me2 = new MultilineElement("me2", delegate() { });
			Debug.WriteLine(me2.ToString());
			MultilineElement me3 = new MultilineElement("me3", "me3 value");
			Debug.WriteLine(me3.ToString());

			RadioElement rde1 = new RadioElement("rde1");
			Debug.WriteLine(rde1.ToString());
			RadioElement rde2 = new RadioElement("rde1", "group3");
			Debug.WriteLine(rde2.ToString());

			// TODO: not in Kevin's MA.D
			// StyledMultilineElement

			TimeElement te1 = new TimeElement("TimeElement", DateTime.Now);
			Debug.WriteLine(te1.ToString());



			re1.Add(s1);
			//re1.Add(s2);
			re1.Add(s3);
			//re1.Add(s4);
			re1.Add(s5);

			return re1;
		}
示例#21
0
        public UIViewController GetViewController()
        {
            var menu = new RootElement("Test Runner");

            var runMode             = new Section("Run Mode");
            var interactiveCheckBox = new CheckboxElement("Enable Interactive Mode");

            interactiveCheckBox.Tapped += () => GraphicsTestBase.ForceInteractiveMode = interactiveCheckBox.Value;
            runMode.Add(interactiveCheckBox);
            menu.Add(runMode);

            Section main = new Section("Loading test suites...");

            menu.Add(main);

            Section options = new Section()
            {
                new StyledStringElement("Options", Options)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                },
                new StyledStringElement("Credits", Credits)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                }
            };

            menu.Add(options);

            // large unit tests applications can take more time to initialize
            // than what the iOS watchdog will allow them on devices
            ThreadPool.QueueUserWorkItem(delegate {
                foreach (Assembly assembly in assemblies)
                {
                    Load(assembly, null);
                }

                window.InvokeOnMainThread(delegate {
                    while (suite.Tests.Count == 1 && (suite.Tests[0] is TestSuite))
                    {
                        suite = (TestSuite)suite.Tests[0];
                    }

                    foreach (TestSuite ts in suite.Tests)
                    {
                        main.Add(Setup(ts));
                    }
                    mre.Set();

                    main.Caption = null;
                    menu.Reload(main, UITableViewRowAnimation.Fade);

                    options.Insert(0, new StringElement("Run Everything", Run));
                    menu.Reload(options, UITableViewRowAnimation.Fade);
                });
                assemblies.Clear();
            });

            var dv = new DialogViewController(menu)
            {
                Autorotate = true
            };

            // AutoStart running the tests (with either the supplied 'writer' or the options)
            if (AutoStart)
            {
                ThreadPool.QueueUserWorkItem(delegate {
                    mre.WaitOne();
                    window.BeginInvokeOnMainThread(delegate {
                        Run();
                        // optionally end the process, e.g. click "Touch.Unit" -> log tests results, return to springboard...
                        // http://stackoverflow.com/questions/1978695/uiapplication-sharedapplication-terminatewithsuccess-is-not-there
                        if (TerminateAfterExecution)
                        {
                            TerminateWithSuccess();
                        }
                    });
                });
            }
            return(dv);
        }
示例#22
0
        public StringWriter GetSphereScript(bool bIsRevision)
        {
            StringWriter stringWriter1 = new StringWriter();
            ArrayList    arrayList1    = new ArrayList();
            ArrayList    arrayList2    = new ArrayList();

            stringWriter1.WriteLine("// Created {0}, with Gump Studio.", (object)DateTime.Now);
            stringWriter1.WriteLine("// Exported with with {0} ver {1}.", (object)this.GetPluginInfo().PluginName, (object)this.GetPluginInfo().Version);
            stringWriter1.WriteLine("// Script for {0}", bIsRevision ? (object)"0.56/Revisions" : (object)"0.99/1.0");
            stringWriter1.WriteLine("");
            stringWriter1.WriteLine("[DIALOG {0}]", (object)this.frm_SphereExportForm.GumpName);
            StringWriter stringWriter2 = stringWriter1;
            string       format        = "{0}";
            int          num1          = bIsRevision ? 1 : 0;
            Point        location      = ((GumpProperties)this.m_Designer.GumpProperties).Location;
            int          x             = location.X;

            location = ((GumpProperties)this.m_Designer.GumpProperties).Location;
            int    y   = location.Y;
            string str = this.Gump_WriteLocation(num1 != 0, x, y);

            stringWriter2.WriteLine(format, (object)str);
            if (!((GumpProperties)this.m_Designer.GumpProperties).Closeable)
            {
                stringWriter1.WriteLine("{0}", bIsRevision ? (object)"NOCLOSE" : (object)"NoClose");
            }
            if (!((GumpProperties)this.m_Designer.GumpProperties).Moveable)
            {
                stringWriter1.WriteLine("{0}", bIsRevision ? (object)"NOMOVE" : (object)"NoMove");
            }
            if (!((GumpProperties)this.m_Designer.GumpProperties).Disposeable)
            {
                stringWriter1.WriteLine("{0}", bIsRevision ? (object)"NODISPOSE" : (object)"NoDispose");
            }
            if (((ArrayList)this.m_Designer.Stacks).Count > 0)
            {
                int id1  = 0;
                int id2  = 0;
                int id3  = 0;
                int num2 = -1;
                for (int iPage = 0; iPage < ((ArrayList)this.m_Designer.Stacks).Count; ++iPage)
                {
                    stringWriter1.WriteLine("{0}", (object)this.Gump_WritePage(bIsRevision, iPage));
                    GroupElement stack = ((ArrayList)this.m_Designer.Stacks)[iPage] as GroupElement;
                    if (stack != null)
                    {
                        ArrayList elementsRecursive = stack.GetElementsRecursive();
                        if (elementsRecursive.Count > 0)
                        {
                            for (int index = 0; index < elementsRecursive.Count; ++index)
                            {
                                BaseElement baseElement = elementsRecursive[index] as BaseElement;
                                if (baseElement != null)
                                {
                                    HTMLElement htmlElement = baseElement as HTMLElement;
                                    if (htmlElement != null)
                                    {
                                        if (htmlElement.TextType == HTMLElementType.HTML)
                                        {
                                            if (bIsRevision)
                                            {
                                                string text = "HtmlGump id." + id1.ToString();
                                                if (htmlElement.HTML != null)
                                                {
                                                    arrayList2.Add((object)new SphereExporter.SphereElement(htmlElement.HTML.Length == 0 ? text : htmlElement.HTML, id1));
                                                }
                                                else
                                                {
                                                    arrayList2.Add((object)new SphereExporter.SphereElement(text, id1));
                                                }
                                            }
                                            stringWriter1.WriteLine("{0}", (object)this.Gump_WriteHTML(bIsRevision, ((BaseElement)htmlElement).X, ((BaseElement)htmlElement).Y, ((ResizeableElement)htmlElement).Width, ((ResizeableElement)htmlElement).Height, htmlElement.ShowBackground, htmlElement.ShowScrollbar, ref id1, htmlElement.HTML));
                                        }
                                        else
                                        {
                                            stringWriter1.WriteLine("{0}", (object)this.Gump_WriteXFHTML(bIsRevision, ((BaseElement)htmlElement).X, ((BaseElement)htmlElement).Y, ((ResizeableElement)htmlElement).Width, ((ResizeableElement)htmlElement).Height, htmlElement.ShowBackground, htmlElement.ShowScrollbar, htmlElement.CliLocID));
                                        }
                                    }
                                    else
                                    {
                                        AlphaElement alphaElement = baseElement as AlphaElement;
                                        if (alphaElement != null)
                                        {
                                            stringWriter1.WriteLine("{0}", (object)this.Gump_WriteCheckerTrans(bIsRevision, ((BaseElement)alphaElement).X, ((BaseElement)alphaElement).Y, ((ResizeableElement)alphaElement).Width, ((ResizeableElement)alphaElement).Height));
                                        }
                                        else
                                        {
                                            BackgroundElement backgroundElement = baseElement as BackgroundElement;
                                            if (backgroundElement != null)
                                            {
                                                stringWriter1.WriteLine("{0}", (object)this.Gump_WriteResizePic(bIsRevision, ((BaseElement)backgroundElement).X, ((BaseElement)backgroundElement).Y, ((ResizeableElement)backgroundElement).Width, ((ResizeableElement)backgroundElement).Height, backgroundElement.GumpID));
                                            }
                                            else
                                            {
                                                ButtonElement buttonElement = baseElement as ButtonElement;
                                                if (buttonElement != null)
                                                {
                                                    arrayList1.Add((object)new SphereExporter.SphereElement("// " + ((BaseElement)buttonElement).Name + "\n// " + buttonElement.Code, buttonElement.ButtonType == ButtonTypeEnum.Reply ? buttonElement.Param : id2));
                                                    stringWriter1.WriteLine("{0}", (object)this.Gump_WriteButton(bIsRevision, ((BaseElement)buttonElement).X, ((BaseElement)buttonElement).Y, buttonElement.NormalID, buttonElement.PressedID, buttonElement.ButtonType == ButtonTypeEnum.Page, buttonElement.Param, ref id2));
                                                }
                                                else
                                                {
                                                    ImageElement imageElement = baseElement as ImageElement;
                                                    if (imageElement != null)
                                                    {
                                                        stringWriter1.WriteLine("{0}", (object)this.Gump_WriteGumpPic(bIsRevision, ((BaseElement)imageElement).X, ((BaseElement)imageElement).Y, imageElement.GumpID, imageElement.Hue.ToString()));
                                                    }
                                                    else
                                                    {
                                                        ItemElement itemElement = baseElement as ItemElement;
                                                        if (itemElement != null)
                                                        {
                                                            stringWriter1.WriteLine("{0}", (object)this.Gump_WriteTilePic(bIsRevision, ((BaseElement)itemElement).X, ((BaseElement)itemElement).Y, itemElement.ItemID, itemElement.Hue.ToString()));
                                                        }
                                                        else
                                                        {
                                                            LabelElement labelElement = baseElement as LabelElement;
                                                            if (labelElement != null)
                                                            {
                                                                if (bIsRevision)
                                                                {
                                                                    string text = "Text id." + id1.ToString();
                                                                    if (labelElement.Text != null)
                                                                    {
                                                                        arrayList2.Add((object)new SphereExporter.SphereElement(labelElement.Text.Length == 0 ? text : labelElement.Text, id1));
                                                                    }
                                                                    else
                                                                    {
                                                                        arrayList2.Add((object)new SphereExporter.SphereElement(text, id1));
                                                                    }
                                                                }
                                                                stringWriter1.WriteLine("{0}", (object)this.Gump_WriteText(bIsRevision, ((BaseElement)labelElement).X, ((BaseElement)labelElement).Y, labelElement.Hue.ToString(), labelElement.Text, ref id1));
                                                            }
                                                            else
                                                            {
                                                                RadioElement radioElement = baseElement as RadioElement;
                                                                if (radioElement != null)
                                                                {
                                                                    if (radioElement.Group != num2)
                                                                    {
                                                                        stringWriter1.WriteLine("Group{0}", bIsRevision ? (object)(" " + radioElement.Group.ToString()) : (object)("(" + radioElement.Group.ToString() + ")"));
                                                                        num2 = radioElement.Group;
                                                                    }
                                                                    stringWriter1.WriteLine("{0}", (object)this.Gump_WriteRadioBox(bIsRevision, ((BaseElement)radioElement).X, ((BaseElement)radioElement).Y, ((CheckboxElement)radioElement).UnCheckedID, ((CheckboxElement)radioElement).CheckedID, radioElement.Checked, radioElement.Value));
                                                                }
                                                                else
                                                                {
                                                                    CheckboxElement checkboxElement = baseElement as CheckboxElement;
                                                                    if (checkboxElement != null)
                                                                    {
                                                                        stringWriter1.WriteLine("{0}", (object)this.Gump_WriteCheckBox(bIsRevision, ((BaseElement)checkboxElement).X, ((BaseElement)checkboxElement).Y, checkboxElement.UnCheckedID, checkboxElement.CheckedID, checkboxElement.Checked, ref id3));
                                                                    }
                                                                    else
                                                                    {
                                                                        TextEntryElement textEntryElement = baseElement as TextEntryElement;
                                                                        if (textEntryElement != null)
                                                                        {
                                                                            if (bIsRevision)
                                                                            {
                                                                                string text = "Textentry id." + textEntryElement.ID.ToString();
                                                                                if (textEntryElement.InitialText != null)
                                                                                {
                                                                                    arrayList2.Add((object)new SphereExporter.SphereElement(textEntryElement.InitialText.Length == 0 ? text : textEntryElement.InitialText, id1));
                                                                                }
                                                                                else
                                                                                {
                                                                                    arrayList2.Add((object)new SphereExporter.SphereElement(text, id1));
                                                                                }
                                                                            }
                                                                            stringWriter1.WriteLine("{0}", (object)this.Gump_WriteTextEntry(bIsRevision, ((BaseElement)textEntryElement).X, ((BaseElement)textEntryElement).Y, ((ResizeableElement)textEntryElement).Width, ((ResizeableElement)textEntryElement).Height, textEntryElement.Hue.ToString(), textEntryElement.InitialText, textEntryElement.ID, ref id1));
                                                                        }
                                                                        else
                                                                        {
                                                                            TiledElement tiledElement = baseElement as TiledElement;
                                                                            if (tiledElement != null)
                                                                            {
                                                                                stringWriter1.WriteLine("{0}", (object)this.Gump_WriteGumpPicTiled(bIsRevision, ((BaseElement)tiledElement).X, ((BaseElement)tiledElement).Y, ((ResizeableElement)tiledElement).Width, ((ResizeableElement)tiledElement).Height, tiledElement.GumpID));
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            stringWriter1.WriteLine("");
            if (bIsRevision)
            {
                stringWriter1.WriteLine("[DIALOG {0} text]", (object)this.frm_SphereExportForm.GumpName);
                foreach (SphereExporter.SphereElement sphereElement in arrayList2)
                {
                    stringWriter1.WriteLine("{0}", (object)sphereElement.sText);
                }
                stringWriter1.WriteLine("");
            }
            stringWriter1.WriteLine("[DIALOG {0} button]", (object)this.frm_SphereExportForm.GumpName);
            foreach (SphereExporter.SphereElement sphereElement in arrayList1)
            {
                stringWriter1.WriteLine("ON={0}", (object)sphereElement.iId.ToString());
                stringWriter1.WriteLine("{0}", (object)sphereElement.sText);
                stringWriter1.WriteLine("");
            }
            stringWriter1.WriteLine("{0}", (object)this.Gump_WriteEOF());
            return(stringWriter1);
        }
示例#23
0
        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();
                        }
                    });
                });
            }
        }
示例#24
0
        private StringWriter CreateDistroScript(bool bShowComment, bool bShowNames, bool bDefaultTexts)
        {
            StringWriter  sw_Script    = new StringWriter();
            List <string> GumpCommands = new List <string>();

            bGetDefaultText = bDefaultTexts; // define if plugin will set default text for empty elems

            string gump_name = GetGumpName();

            GumpCommands.Add(DistroGump_GFCreateGump(gump_name, m_Designer.GumpProperties.Location));
            GumpCommands.Add("");
            if (!m_Designer.GumpProperties.Moveable)
            {
                GumpCommands.Add(String.Format("GFMovable({0}, 0);", gump_name));
            }

            if (!m_Designer.GumpProperties.Closeable)
            {
                GumpCommands.Add(String.Format("GFClosable({0}, 0);", gump_name));
            }

            if (!m_Designer.GumpProperties.Disposeable)
            {
                GumpCommands.Add(String.Format("GFDisposable({0}, 0);", gump_name));
            }


            if (m_Designer.Stacks.Count > 0)
            {
                int radiogroup = -1;
                int pageindex  = 0;
                // =================

                foreach (GroupElement ge_Elements in m_Designer.Stacks)
                {
                    if (pageindex > 0)
                    {
                        GumpCommands.Add("");
                    }

                    GumpCommands.Add(DistroGump_GFPage(gump_name, ref pageindex)); // "page pageid"
                    if (ge_Elements == null)
                    {
                        continue;
                    }

                    foreach (BaseElement be_Element in ge_Elements.GetElementsRecursive())
                    {
                        if (be_Element == null)
                        {
                            continue;
                        }

                        if (bShowComment || bShowNames)
                        {
                            string comment = GetCommentString(be_Element, bShowComment, bShowNames);
                            if (comment != String.Empty)
                            {
                                GumpCommands.Add("");
                                GumpCommands.Add(comment);
                            }
                        }

                        Type ElementType = be_Element.GetType();

                        if (ElementType == typeof(HTMLElement))
                        {
                            HTMLElement elem = be_Element as HTMLElement;
                            if (elem.TextType == HTMLElementType.HTML)
                            {
                                GumpCommands.Add(DistroGump_GFHTMLArea(gump_name, elem));
                            }
                            else
                            {
                                GumpCommands.Add(DistroGump_GFAddHTMLLocalized(gump_name, elem));
                            }
                        }
                        else if (ElementType == typeof(TextEntryElement))
                        {
                            TextEntryElement elem = be_Element as TextEntryElement;
                            GumpCommands.Add(DistroGump_GFTextEntry(gump_name, elem));
                        }
                        else if (ElementType == typeof(LabelElement))
                        {
                            LabelElement elem = be_Element as LabelElement;
                            GumpCommands.Add(DistroGump_GFTextLine(gump_name, elem));
                        }

                        else if (ElementType == typeof(AlphaElement))
                        {
                            AlphaElement elem = be_Element as AlphaElement;
                            GumpCommands.Add(DistroGump_GFAddAlphaRegion(gump_name, elem));
                        }
                        else if (ElementType == typeof(BackgroundElement))
                        {
                            BackgroundElement elem = be_Element as BackgroundElement;
                            GumpCommands.Add(DistroGump_GFResizePic(gump_name, elem));
                        }
                        else if (ElementType == typeof(ImageElement))
                        {
                            ImageElement elem = be_Element as ImageElement;
                            GumpCommands.Add(DistroGump_GFGumpPic(gump_name, elem));
                        }
                        else if (ElementType == typeof(ItemElement))
                        {
                            ItemElement elem = be_Element as ItemElement;
                            GumpCommands.Add(DistroGump_GFTilePic(gump_name, elem));
                        }
                        else if (ElementType == typeof(TiledElement))
                        {
                            // TODO: Support "GFGumpPicTiled" when it´s in distro
                            TiledElement elem = be_Element as TiledElement;
                            GumpCommands.Add("");
                            GumpCommands.Add("//Gump package does not support GumpPicTiled");
                            GumpCommands.Add("//" + Gump_WriteGumpPicTiled(elem));
                            GumpCommands.Add("");
                        }

                        else if (ElementType == typeof(ButtonElement))
                        {
                            ButtonElement elem = be_Element as ButtonElement;
                            GumpCommands.Add(DistroGump_GFAddButton(gump_name, elem));
                        }

                        else if (ElementType == typeof(CheckboxElement))
                        {
                            CheckboxElement elem = be_Element as CheckboxElement;
                            GumpCommands.Add(DistroGump_GFCheckBox(gump_name, elem));
                        }
                        else if (ElementType == typeof(RadioElement))
                        {
                            RadioElement elem = be_Element as RadioElement;
                            if (elem.Group != radiogroup)
                            {
                                GumpCommands.Add(String.Format("GFSetRadioGroup({0}, {1});", gump_name, elem.Group));
                                radiogroup = elem.Group;
                            }
                            GumpCommands.Add(DistroGump_GFRadioButton(gump_name, elem));
                        }
                    }
                }
            }


            sw_Script.WriteLine("// Created {0}, with Gump Studio.", DateTime.Now);
            sw_Script.WriteLine("// Exported with {0} ver {1} for gump pkg", this.GetPluginInfo().PluginName, this.GetPluginInfo().Version);
            sw_Script.WriteLine();
            sw_Script.WriteLine("use uo;");
            sw_Script.WriteLine("use os;");
            sw_Script.WriteLine();
            sw_Script.WriteLine("include \":gumps:gumps\";");
            sw_Script.WriteLine();
            sw_Script.WriteLine("program gump_{0}(who)", gump_name);
            sw_Script.WriteLine();

            foreach (string cmd in GumpCommands)
            {
                sw_Script.WriteLine("\t" + cmd);
            }
            sw_Script.WriteLine();
            sw_Script.WriteLine("\tGFSendGump(who, {0});", gump_name);
            sw_Script.WriteLine();
            sw_Script.WriteLine("endprogram");


            return(sw_Script);
        }
示例#25
0
        public static RootElement TestElements()
        {
            RootElement re1 = new RootElement("re1");

            Debug.WriteLine(re1.ToString());
            Section s1 = new Section();

            Debug.WriteLine(s1.ToString());
            //Section s2 = new Section(new Android.Views.View(a1));
            //Debug.WriteLine(s2.ToString());
            Section s3 = new Section("s3");

            Debug.WriteLine(s3.ToString());
            //Section s4 = new Section
            //					(
            //					  new Android.Views.View(a1)
            //					, new Android.Views.View(a1)
            //					);
            //Debug.WriteLine(s4.ToString());
            Section s5 = new Section("caption", "footer");

            Debug.WriteLine(s5.ToString());

            StringElement se1 = new StringElement("se1");

            Debug.WriteLine(se1.ToString());
            StringElement se2 = new StringElement("se2", delegate() { });

            Debug.WriteLine(se2.ToString());
            //StringElement se3 = new StringElement("se3", 4);
            StringElement se4 = new StringElement("se4", "v4");

            Debug.WriteLine(se4.ToString());
            //StringElement se5 = new StringElement("se5", "v5", delegate() { });

            // removed - protected (all with LayoutID)
            // StringElement se6 = new StringElement("se6", "v6", 4);
            // Debug.WriteLine(se6.ToString());

            // not cross platform!
            // TODO: make it!?!?!?
            // AchievementElement

            BooleanElement be1 = new BooleanElement("be1", true);

            Debug.WriteLine(be1.ToString());
            BooleanElement be2 = new BooleanElement("be2", false, "key");

            Debug.WriteLine(be2.ToString());

            // Abstract
            // BoolElement be3 = new BoolElement("be3", true);

            CheckboxElement cb1 = new CheckboxElement("cb1");

            Debug.WriteLine(cb1.ToString());
            CheckboxElement cb2 = new CheckboxElement("cb2", true);

            Debug.WriteLine(cb2.ToString());
            CheckboxElement cb3 = new CheckboxElement("cb3", false, "group1");

            Debug.WriteLine(cb3.ToString());
            CheckboxElement cb4 = new CheckboxElement("cb4", false, "subcaption", "group2");

            Debug.WriteLine(cb4.ToString());

            DateElement de1 = new DateElement("dt1", DateTime.Now);

            Debug.WriteLine(de1.ToString());

            // TODO: see issues
            // https://github.com/kevinmcmahon/MonoDroid.Dialog/issues?page=1&state=open
            EntryElement ee1 = new EntryElement("ee1", "ee1");

            Debug.WriteLine(ee1.ToString());
            EntryElement ee2 = new EntryElement("ee2", "ee2 placeholder", "ee2 value");

            Debug.WriteLine(ee2.ToString());
            EntryElement ee3 = new EntryElement("ee3", "ee3 placeholder", "ee3 value", true);

            Debug.WriteLine(ee3.ToString());

            FloatElement fe1 = new FloatElement("fe1");

            Debug.WriteLine(fe1.ToString());
            FloatElement fe2 = new FloatElement(-0.1f, 0.1f, 3.2f);

            Debug.WriteLine(fe2.ToString());
            FloatElement fe3 = new FloatElement
                               (
                null
                , null                                                         // no ctors new Android.Graphics.Bitmap()
                , 1.0f
                               );

            Debug.WriteLine(fe3.ToString());

            HtmlElement he1 = new HtmlElement("he1", "http://holisiticware.net");

            Debug.WriteLine(he1.ToString());


            // TODO: image as filename - cross-platform
            ImageElement ie1 = new ImageElement(null);

            Debug.WriteLine(ie1.ToString());

            // TODO: not in Kevin's MA.D
            // ImageStringElement

            MultilineElement me1 = new MultilineElement("me1");

            Debug.WriteLine(me1.ToString());
            MultilineElement me2 = new MultilineElement("me2", delegate() { });

            Debug.WriteLine(me2.ToString());
            MultilineElement me3 = new MultilineElement("me3", "me3 value");

            Debug.WriteLine(me3.ToString());

            RadioElement rde1 = new RadioElement("rde1");

            Debug.WriteLine(rde1.ToString());
            RadioElement rde2 = new RadioElement("rde1", "group3");

            Debug.WriteLine(rde2.ToString());

            // TODO: not in Kevin's MA.D
            // StyledMultilineElement

            TimeElement te1 = new TimeElement("TimeElement", DateTime.Now);

            Debug.WriteLine(te1.ToString());



            re1.Add(s1);
            //re1.Add(s2);
            re1.Add(s3);
            //re1.Add(s4);
            re1.Add(s5);

            return(re1);
        }
示例#26
0
 private string DistroGump_GFCheckBox(string gump_name, CheckboxElement elem)
 {
     return String.Format("GFCheckBox({0}, {1}, {2}, {3}, {4}, {5}, {6});", gump_name, elem.X, elem.Y, elem.UnCheckedID, elem.CheckedID, BoolToString(elem.Checked), elem.Group);
 }