Example #1
0
        private string GenerateString(StringElement stringElement)
        {
            var possibleChars = string.Empty;

            if (stringElement.HasBigLetters)
            {
                possibleChars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            }
            if (stringElement.HasSmallLetters)
            {
                possibleChars += "abcdefghijklmnopqrstuvwxyz";
            }
            if (stringElement.HasDigits)
            {
                possibleChars += "0123456789";
            }
            if (stringElement.HasSymbols)
            {
                possibleChars += "!@#$%^&*()-_=+[]{}\\|;:'\"/?.>,<`~";
            }

            var length = _random.Next(stringElement.MinLength, stringElement.MaxLength + 1);

            return(new string(Enumerable.Repeat(0, length).Select(x => possibleChars[_random.Next(0, possibleChars.Length)]).ToArray()));
        }
Example #2
0
        public override Verb CreateVerb(string[] tokens)
        {
            var hexValue = "0x" + tokens[3];

            Color(position, tokens[1].Length, Whitespaces);
            Color(tokens[2].Length, Operators);
            Color(hexValue.Length, Numbers);

            string character;

            try
            {
                var intValue = hexValue.FromHex();
                if (intValue.IsSome)
                {
                    character = ((char)intValue.Value).ToString();
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
            Element = new StringElement(character);
            return(new NullOp());
        }
Example #3
0
        private Element CreateElement(Octokit.RepositoryTag tag)
        {
            var e = new StringElement(tag.Name);

            e.Clicked.Subscribe(_ => _tagSubject.OnNext(tag));
            return(e);
        }
Example #4
0
        public override void LoadView()
        {
            base.LoadView();

            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, (o, e) => {
                //do some stuff
                NavigationController.PopViewControllerAnimated(true);
            });

            SecondDlgBtn = new StringElement("Third Dlg", OnThirdDlgBtn)
            {
                Alignment = UITextAlignment.Center
            };

            var root = new RootElement("Second Dlg")
            {
                new Section("", "")
                {
                },
                new Section("")
                {
                    SecondDlgBtn
                },
            };

            Root = root;
        }
Example #5
0
        private void FoundResults(PFObject[] array, NSError error)
        {
            var easySection   = new Section("Easy");
            var mediumSection = new Section("Medium");
            var hardSection   = new Section("Hard");

            var objects = array.Select(x => x.ToObject <GameScore>()).OrderByDescending(x => x.Score).ToList();

            foreach (var score in objects)
            {
                var element = new StringElement(score.Player, score.Score.ToString("#,###"));
                switch (score.Dificulty)
                {
                case GameDificulty.Easy:
                    easySection.Add(element);
                    break;

                case GameDificulty.Medium:
                    mediumSection.Add(element);
                    break;

                case GameDificulty.Hard:
                    hardSection.Add(element);
                    break;
                }
            }
            Root = new RootElement("High Scores")
            {
                easySection,
                mediumSection,
                hardSection,
            };
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            dvc = new DialogViewController(
                new RootElement("Root")
            {
                new Section("Main")
                {
                    (button = new GlassButton(new RectangleF(0, 0, window.Bounds.Width - 20, 60))),
                    (upper = new StringElement("this should become uppercased")),
                    (lower = new StringElement("THIS SHOULD BECOME LOWERCASED")),
                }
            }
                );

            button.SetTitle("Test", UIControlState.Normal);
            button.Tapped += (obj) =>
            {
                button.Enabled = false;
                Test();
            };

            window.RootViewController = dvc;
            window.MakeKeyAndVisible();

            return(true);
        }
Example #7
0
        public override void ViewDidLoad()
        {
            Title = "Edit Issue";

            base.ViewDidLoad();

            var status = new StringElement("Status", ViewModel.Status, UITableViewCellStyle.Value1);
            var delete = new StringElement("Delete", AtlassianIcon.Delete.ToImage())
            {
                Accessory = UITableViewCellAccessory.None
            };

            Root[0].Insert(1, UITableViewRowAnimation.None, status);
            Root.Insert(Root.Count, UITableViewRowAnimation.None, new Section {
                delete
            });

            OnActivation(d =>
            {
                d(ViewModel.Bind(x => x.Status, true).Subscribe(x => status.Value = x));
                d(delete.Clicked.BindCommand(ViewModel.DeleteCommand));
                d(status.Clicked.Subscribe(_ =>
                {
                    var ctrl = new IssueAttributesView(IssueModifyViewModel.Statuses, ViewModel.Status)
                    {
                        Title = "Status"
                    };
                    ctrl.SelectedValue = x => ViewModel.Status = x.ToLower();
                    NavigationController.PushViewController(ctrl, true);
                }));
            });
        }
Example #8
0
        UIViewController MakeLogin()
        {
            var login = new EntryElement("Login", "Type 'Root'", "");
            var pass  = new EntryElement("Password", "Type 'Root'", "");

            var loginButton = new StringElement("Login", delegate {
                login.FetchValue();
                pass.FetchValue();
                if (login.Value == "Root" && pass.Value == "Root")
                {
                    NSUserDefaults.StandardUserDefaults.SetBool(true, "loggedIn");

                    window.RootViewController.PresentViewController(MakeOptions(), true, delegate {});
                }
            });

            return(new DialogViewController(new RootElement("Login")
            {
                new Section("Enter login and password")
                {
                    login, pass,
                },
                new Section()
                {
                    loginButton
                }
            }));
        }
Example #9
0
    /// <summary>末尾に文字追加</summary>
    public void addLast(string aText)
    {
        TagReader tReader = new TagReader(aText);

        while (!tReader.isEnd())
        {
            TagReader.Element tElement = tReader.read();
            //1文字
            if (tElement is TagReader.OneChar)
            {
                StringElement tStringElement = StringElement.create(((TagReader.OneChar)tElement).mChar, this);
                addLast(tStringElement);
                continue;
            }
            //開始タグ
            if (tElement is TagReader.StartTag)
            {
                applyStartTag(((TagReader.StartTag)tElement));
                continue;
            }
            //終了タグ
            if (tElement is TagReader.EndTag)
            {
                applyEndTag(((TagReader.EndTag)tElement));
                continue;
            }
            Debug.LogWarning("MyTextBoard : 文字読み込み失敗 次の文字「" + tReader.mNext.ToString() + "」");
        }
        _Text += aText;
    }
Example #10
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // create a new window instance based on the screen size
            window       = new UIWindow(UIScreen.MainScreen.Bounds);
            entryElement = new EntryElement("", "Type the text to speak here.", "");
            spearkBtn    = new StringElement("Speak", delegate {
                entryElement.FetchValue();
                Flite.Flite.ConvertTextToWav(entryElement.Value, "test.wav", 0);
            });
            window.RootViewController = new DialogViewController(new RootElement("")
            {
                new Section()
                {
                    entryElement,
                    spearkBtn
                }
            });
            // If you have defined a view, add it here:
            // window.AddSubview (navigationController.View);

            // make the window visible
            window.MakeKeyAndVisible();

            return(true);
        }
Example #11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var split         = new SplitButtonElement();
            var followers     = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan());
            var following     = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan());
            var events        = new StringElement("Events", () => ViewModel.GoToEventsCommand.ExecuteIfCan(), Octicon.Rss.ToImage());
            var organizations = new StringElement("Organizations", () => ViewModel.GoToOrganizationsCommand.ExecuteIfCan(), Octicon.Organization.ToImage());
            var repos         = new StringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.ExecuteIfCan(), Octicon.Repo.ToImage());
            var gists         = new StringElement("Gists", () => ViewModel.GoToGistsCommand.ExecuteIfCan(), Octicon.Gist.ToImage());

            Root.Reset(new [] { new Section {
                                    split
                                }, new Section {
                                    events, organizations, repos, gists
                                } });

            this.WhenAnyValue(x => x.ViewModel.User).IsNotNull().Subscribe(x =>
            {
                HeaderView.ImageUri = x.AvatarUrl;
                followers.Text      = x.Followers.ToString();
                following.Text      = x.Following.ToString();
                HeaderView.SubText  = string.IsNullOrEmpty(x.Name) ? null : x.Name;
                RefreshHeaderView();
            });
        }
Example #12
0
        public SupportView()
        {
            var contributors = _split.AddButton("Contributors", "-");
            var lastCommit   = _split.AddButton("Last Commit", "-");

            _addFeatureButton = new ButtonElement("Suggest a feature", () => ViewModel.GoToSuggestFeatureCommand.ExecuteIfCan(), Octicon.LightBulb.ToImage());
            _addBugButton     = new ButtonElement("Report a bug", () => ViewModel.GoToReportBugCommand.ExecuteIfCan(), Octicon.Bug.ToImage());
            _featuresButton   = new ButtonElement("Submitted Work Items", () => ViewModel.GoToFeedbackCommand.ExecuteIfCan(), Octicon.Clippy.ToImage());

            this.WhenAnyValue(x => x.ViewModel.Contributors).Where(x => x.HasValue).SubscribeSafe(x =>
                                                                                                  contributors.Text = (x.Value >= 100 ? "100+" : x.Value.ToString()));

            this.WhenAnyValue(x => x.ViewModel.LastCommit).Where(x => x.HasValue).SubscribeSafe(x =>
                                                                                                lastCommit.Text = x.Value.UtcDateTime.Humanize());

            this.WhenAnyValue(x => x.ViewModel)
            .IsNotNull().Take(1)
            .Subscribe(x => x.LoadCommand.ExecuteIfCan());

            this.WhenAnyValue(x => x.ViewModel).Subscribe(x =>
                                                          HeaderView.ImageButtonAction = x != null ? new Action(x.GoToRepositoryCommand.ExecuteIfCan) : null);

            HeaderView.SubText = "This app is the product of hard work and great suggestions! Thank you to all whom provide feedback!";
            HeaderView.Image   = UIImage.FromFile("*****@*****.**");
        }
        private void buildActionElements()
        {
            deleteMoviesElement         = new StringElement("Delete Movies");
            deleteMoviesElement.Tapped += delegate
            {
                try
                {
                    Directory.Delete(Settings.VideoDataPath, true);
                }
                catch
                {
                }
            };

            deleteImagesElement         = new StringElement("Delete Images");
            deleteImagesElement.Tapped += delegate
            {
                try
                {
                    Directory.Delete(Settings.ImageDataPath, true);
                }
                catch
                {
                }
            };
        }
Example #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var vm = (DefaultStartupViewModel)ViewModel;

            BindCollection(vm.StartupViews, x => {
                var e = new StringElement(x);
                e.Clicked.Subscribe(_ => vm.SelectedStartupView = x);
                if (string.Equals(vm.SelectedStartupView, x))
                {
                    e.Accessory = UITableViewCellAccessory.Checkmark;
                }
                return(e);
            }, true);

            vm.Bind(x => x.SelectedStartupView, true).Subscribe(x =>
            {
                if (Root.Count == 0)
                {
                    return;
                }
                foreach (var m in Root[0].Elements.Cast <StringElement>())
                {
                    m.Accessory = (string.Equals(m.Caption, x)) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
                }
            });
        }
Example #15
0
        private Element CreateElement(ContentModel x)
        {
            var weakVm = new WeakReference <SourceTreeViewModel>(ViewModel);

            if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
            {
                var e = new StringElement(x.Name, Octicon.FileDirectory.ToImage());
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToItemCommand.ExecuteNow(x));
                return(e);
            }
            if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
            {
                if (x.DownloadUrl != null)
                {
                    var e = new StringElement(x.Name, Octicon.FileCode.ToImage());
                    e.Clicked.Subscribe(_ => weakVm.Get()?.GoToItemCommand.ExecuteNow(x));
                    return(e);
                }
                else
                {
                    var e = new StringElement(x.Name, Octicon.FileSubmodule.ToImage());
                    e.Clicked.Subscribe(_ => weakVm.Get()?.GoToItemCommand.ExecuteNow(x));
                    return(e);
                }
            }

            return(new StringElement(x.Name)
            {
                Image = Octicon.FileMedia.ToImage()
            });
        }
Example #16
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            facebook = new Section("Facebook");
            facebook.Add(new StyledStringElement("Log in", () => LoginToFacebook(true)));
            facebook.Add(new StyledStringElement("Log in (no cancel)", () => LoginToFacebook(false)));
            facebook.Add(facebookStatus = new StringElement(String.Empty));

            dialog = new DialogViewController(new RootElement("Xamarin.Auth Sample")
            {
                facebook,
            });

            activity = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White)
            {
                Frame            = new RectangleF(0, 11.5f, 21, 21),
                HidesWhenStopped = true,
                Hidden           = true,
            };

            dialog.NavigationItem.RightBarButtonItem = new UIBarButtonItem(activity);

            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.RootViewController = new UINavigationController(dialog);
            window.MakeKeyAndVisible();

            return(true);
        }
 protected override void Initialize(StringElement template,
                                    BindingSet <StringElement, Tuple <string, ViewModelCommandParameter> > bindingSet)
 {
     bindingSet.Bind(element => element.Caption).To(tuple => tuple.Item1);
     bindingSet.Bind(AttachedMemberConstants.CommandParameter).To(tuple => tuple.Item2);
     bindingSet.BindFromExpression("Tapped $Relative(UIViewController).DataContext.ShowCommand");
 }
        public override void LoadView()
        {
            base.LoadView();

//			NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Done, (o,e) => {
//				parentNav.NavigationController.PopViewControllerAnimated(true);
//			});

            SecondDlgBtn = new StringElement("Second Dlg", OnSecondDlgBtn)
            {
                Alignment = UITextAlignment.Center
            };
            var root = new RootElement("First Dlg")
            {
                new Section("", "")
                {
                },
                new Section("")
                {
                    SecondDlgBtn
                },
            };

            Root = root;
        }
        private Element CreateElement(Octokit.Branch branch)
        {
            var e = new StringElement(branch.Name);

            e.Clicked.Subscribe(_ => _branchSubject.OnNext(branch));
            return(e);
        }
        public EnumChoiceElement <T> CreateEnumElement <T>(string title, T value) where T : struct, IConvertible
        {
            var element = new EnumChoiceElement <T>(title, value);

            element.Clicked.Subscribe(_ =>
            {
                var ctrl   = new DialogViewController(UITableViewStyle.Grouped);
                ctrl.Title = title;

                var sec = new Section();
                foreach (var x in Enum.GetValues(typeof(T)).Cast <Enum>())
                {
                    var e = new StringElement(x.Humanize())
                    {
                        Accessory = object.Equals(x, element.Value) ?
                                    UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None
                    };
                    e.Clicked.Subscribe(__ =>
                    {
                        element.Value = (T)Enum.ToObject(typeof(T), x);
                        NavigationController.PopViewController(true);
                    });

                    sec.Add(e);
                }
                ctrl.Root.Reset(sec);
                NavigationController.PushViewController(ctrl, true);
            });

            return(element);
        }
Example #21
0
        Section MakeAccounts()
        {
            var section = new Section(Locale.GetText("Accounts"));

            lock (Database.Main){
                foreach (var account in Database.Main.Query <TwitterAccount> ("SELECT * from TwitterAccount"))
                {
                    var copy    = account;
                    var element = new AccountElement(account);
                    element.Tapped += delegate {
                        DismissModalViewControllerAnimated(true);

                        TwitterAccount.SetDefault(copy);
                        AppDelegate.MainAppDelegate.Account = copy;
                    };
                    section.Add(element);
                }
                ;
            }
            var addAccount = new StringElement(Locale.GetText("Add account"));

            addAccount.Tapped += delegate {
                AppDelegate.MainAppDelegate.AddAccount(this, delegate {
                    DismissModalViewControllerAnimated(false);
                });
            };
            section.Add(addAccount);
            return(section);
        }
Example #22
0
        public virtual StringElement CreateStringElement(XString name, XString value)
        {
            System.IntPtr cPtr = SharingClientPINVOKE.ObjectElement_CreateStringElement(swigCPtr, XString.getCPtr(name), XString.getCPtr(value));
            StringElement ret  = (cPtr == System.IntPtr.Zero) ? null : new StringElement(cPtr, true);

            return(ret);
        }
Example #23
0
        public LabelListScreen(IList <string> labels) : base(UITableViewStyle.Grouped, null)
        {
            // Navigation
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) =>
            {
                NavigationController.DismissViewController(true, null);
            });
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, DoneButtonClicked);

            Root = new RootElement("");
            var labelSection = new Section();

            Root.Add(labelSection);
            foreach (var label in labels)
            {
                var element = new StringElement(label);
                element.Tapped += () => {};
                labelSection.Add(element);
            }

            var customSection = new Section();

            Root.Add(customSection);
            var customElement = new StringElement("Add Custom Label");

            customElement.Tapped += () => {};
            customSection.Add(customElement);
        }
Example #24
0
        private void CreateTable()
        {
            var application    = Mvx.Resolve <IApplicationService>();
            var vm             = (SettingsViewModel)ViewModel;
            var currentAccount = application.Account;

            var showOrganizationsInEvents = new BooleanElement("Show Teams under Events", currentAccount.ShowTeamEvents);

            showOrganizationsInEvents.Changed.Subscribe(e =>
            {
                currentAccount.ShowTeamEvents = e;
                application.Accounts.Update(currentAccount);
            });

            var showOrganizations = new BooleanElement("List Teams & Groups in Menu", currentAccount.ExpandTeamsAndGroups);

            showOrganizations.Changed.Subscribe(x =>
            {
                currentAccount.ExpandTeamsAndGroups = x;
                application.Accounts.Update(currentAccount);
            });

            var repoDescriptions = new BooleanElement("Show Repo Descriptions", currentAccount.RepositoryDescriptionInList);

            repoDescriptions.Changed.Subscribe(e =>
            {
                currentAccount.RepositoryDescriptionInList = e;
                application.Accounts.Update(currentAccount);
            });

            var startupView = new ButtonElement("Startup View", vm.DefaultStartupViewName);

            startupView.Clicked.BindCommand(vm.GoToDefaultStartupViewCommand);

            var sourceCommand = new ButtonElement("Source Code");

            sourceCommand.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://github.com/thedillonb/CodeBucket")));

            var twitter = new StringElement("Follow On Twitter");

            twitter.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/Codebucketapp")));

            var rate = new StringElement("Rate This App");

            rate.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codebucket/id551531422?mt=8")));

            //Assign the root
            ICollection <Section> root = new LinkedList <Section>();

            root.Add(new Section());
            root.Add(new Section {
                showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView
            });
            root.Add(new Section(String.Empty, "Thank you for downloading. Enjoy!")
            {
                sourceCommand, twitter, rate,
                new StringElement("App Version", NSBundle.MainBundle.InfoDictionary.ValueForKey(new NSString("CFBundleVersion")).ToString())
            });
            Root.Reset(root);
        }
Example #25
0
        public static StringElement Cast(Element element)
        {
            global::System.IntPtr cPtr = SharingClientPINVOKE.StringElement_Cast(Element.getCPtr(element));
            StringElement         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new StringElement(cPtr, true);

            return(ret);
        }
Example #26
0
        private Element CreateElement(ContentModel x)
        {
            var weakVm = new WeakReference <SourceTreeViewModel>(ViewModel);

            if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
            {
                var e = new StringElement(x.Name, Octicon.FileDirectory.ToImage());
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToSourceTreeCommand.Execute(x));
                return(e);
            }
            if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
            {
                //If there's a size, it's a file
                if (x.Size != null)
                {
                    var e = new StringElement(x.Name, Octicon.FileCode.ToImage());
                    e.Clicked.Subscribe(_ => weakVm.Get()?.GoToSourceCommand.Execute(x));
                    return(e);
                }
                else
                {
                    //If there is no size, it's most likey a submodule
                    var e = new StringElement(x.Name, Octicon.FileSubmodule.ToImage());
                    e.Clicked.Subscribe(_ => weakVm.Get()?.GoToSubmoduleCommand.Execute(x));
                    return(e);
                }
            }

            return(new StringElement(x.Name)
            {
                Image = Octicon.FileMedia.ToImage()
            });
        }
Example #27
0
        public MainViewController() : base(UITableViewStyle.Grouped, null)
        {
            SignIn.SharedInstance.Delegate   = this;
            SignIn.SharedInstance.UIDelegate = this;

            // Automatically sign in the user.
            SignIn.SharedInstance.SignInUserSilently();

            status = new StringElement("Not Signed In", () => {
                // Sign out
                SignIn.SharedInstance.SignOutUser();

                // Clear signed in app state
                currentAuth = null;
                Root[1].Clear();
                ToggleAuthUI();
            });
            signinButton = new SignInButtonElement();

            Root = new RootElement("Sign In Migration")
            {
                new Section {
                    signinButton,
                    status,
                },
                new Section {
                },
            };

            ToggleAuthUI();
        }
Example #28
0
        public StringElement CopyWithoutSpec()
        {
            StringElement result = Copy();

            result.val = null;
            return(result);
        }
Example #29
0
        private Element CreateElement(Octokit.RepositoryContent content)
        {
            var weakRef = new WeakReference <SourceTreeViewController>(this);

            if (content.Type == Octokit.ContentType.Dir)
            {
                var e = new StringElement(content.Name, Octicon.FileDirectory.ToImage());
                e.Clicked.Subscribe(_ => weakRef.Get()?.GoToSourceTree(content));
                return(e);
            }

            if (content.Type == Octokit.ContentType.File)
            {
                if (content.DownloadUrl != null)
                {
                    var e = new StringElement(content.Name, Octicon.FileCode.ToImage());
                    e.Style = UITableViewCellStyle.Subtitle;
                    e.Value = content.Size.Bytes().ToString("#.#");
                    e.Clicked.Subscribe(_ => weakRef.Get()?.GoToFile(content));
                    return(e);
                }
                else
                {
                    var e = new StringElement(content.Name, Octicon.FileSubmodule.ToImage());
                    e.Clicked.Subscribe(_ => weakRef.Get()?.GoToSubModule(content));
                    return(e);
                }
            }

            return(new StringElement(content.Name)
            {
                Image = Octicon.FileMedia.ToImage()
            });
        }
Example #30
0
        public PaymentViewController(string title) : base(UITableViewStyle.Grouped, null, true)
        {
            var eleCardNumber = new EntryElement(string.Empty, "Kort nummer", this.ViewModel.CardNumber)
            {
                KeyboardType = UIKeyboardType.NumberPad
            };
            var eleExpirationDate = new StringElement("Udløbs dato", this.ViewModel.ExpirationDate.ToString("MM-yy"));
            var eleSecurityCode   = new EntryElement(string.Empty, "Sikkerheds kode", this.ViewModel.SecurityCode)
            {
                KeyboardType = UIKeyboardType.NumberPad
            };

            this.Root = new RootElement(title)
            {
                new Section
                {
                    eleCardNumber,
                    eleExpirationDate,
                    eleSecurityCode
                }
            };

            eleCardNumber.BindText(this.ViewModel, vm => vm.CardNumber);
            eleExpirationDate.BindText(this.ViewModel, vm => this.ViewModel.ExpirationDateText);
            eleSecurityCode.BindText(this.ViewModel, vm => this.ViewModel.SecurityCode);

            eleExpirationDate.Tapped += this.EleExpirationDateOnTapped;

            this.toolbar = new UIToolbar(new CGRect(0, 0, 320, 44));
            this.toolbar.SetItems(new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => this.View.EndEditing(true)),
            }, false);
        }
        public static Section[] CreateContactDetailSections(Contact c)
        {
            List<Section> sections = new List<Section>();

            //TODO: awating a refactor of Phones/Emails/Address to being lists in Contact
            var Phones = new List<string>(new string[] { c.Phone });
            var emails = new List<string>(new string[] { c.Email });
            var addresses = new List<string>(new string[] { c.Address });

            var phoneSec = new Section() { Caption = "Phone Numbers" };
            sections.Add(phoneSec);
            if (Phones != null && Phones.Count > 0)
            {
                var cell = new StringElement("Cell", Phones[0]);
                phoneSec.Add(cell);
            }
            var work = new StringElement("Office", "651-555-1212");
            phoneSec.Add(work);
            var home = new StringElement("Home", "507-555-1212");
            phoneSec.Add(home);

            // email
            var emailSec = new Section() { Caption = "Email Addresses" };
            sections.Add(emailSec);
            if (emails != null && emails.Count > 0)
            {
                string emailAddress = emails[0];
                var email = new StringElement("Work", emailAddress);
                emailSec.Add(email);
            }
            var homeEmail = new StringElement("Home", "*****@*****.**");
            emailSec.Add(homeEmail);

            // addresses
            var addressSec = new Section() { Caption = "Addresses" };
            sections.Add(addressSec);
            if (addresses != null && addresses.Count > 0)
                addressSec.Add(new MultilineElement("Home", addresses[0]));
            return sections.ToArray();
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StringElement obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Example #33
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);
        }
Example #34
0
        public override void VisitStringElement(StringElement element)
        {
            if (inParallelFor == 1)
            {

                parallelString.Append(element.getText());
            }
            else
            {
                mat_stack.Push(element);
            }            
        }
Example #35
0
 public void setTitle(StringElement t)
 { title = t; }
Example #36
0
        protected void GotoCustomControl(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);
            tb.Title = "Custom Control";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "Custom Control";

            var view = new UIViewDefinition<CustomElementTableViewCell, StringElement>(DefaultElementViewDefintions.SimpleElementBinding)
            {
                Param = UITableViewCellStyle.Default
            };

            var customData = new StringElement("");
            var wrapper = new ElementDataViewWrapper(view, customData);
            section1.Add(wrapper);

            this.rootController.PushViewController(tb, true);
        }
Example #37
0
 public override void VisitStringElement(StringElement element)
 {
     //throw new NotImplementedException();
     mat_stack.Push(element);
 }
Example #38
0
 public abstract void VisitStringElement(StringElement element);
Example #39
0
		//
		// Creates one of the various StringElement classes, based on the
		// properties set.   It tries to load the most memory efficient one
		// StringElement, if not, it fallsback to MultilineStringElement or
		// StyledStringElement
		//
		static Element LoadString (JsonObject json, object data)
		{
			string value = null;
			string caption = value;
			string background = null;
			NSAction ontap = null;
			NSAction onaccessorytap = null;
			int? lines = null;
			UITableViewCellAccessory? accessory = null;
			UILineBreakMode? linebreakmode = null;
			UITextAlignment? alignment = null;
			UIColor textcolor = null, detailcolor = null;
			UIFont font = null;
			UIFont detailfont = null;
			UITableViewCellStyle style = UITableViewCellStyle.Value1;

			foreach (var kv in json){
				string kvalue = (string) kv.Value;
				switch (kv.Key){
				case "caption":
					caption = kvalue;
					break;
				case "value":
					value = kvalue;
					break;
				case "background":	
					background = kvalue;
					break;
				case "style":
					style = ToCellStyle (kvalue);
					break;
				case "ontap": case "onaccessorytap":
					string sontap = kvalue;
					int p = sontap.LastIndexOf ('.');
					if (p == -1)
						break;
					NSAction d = delegate {
						string cname = sontap.Substring (0, p);
						string mname = sontap.Substring (p+1);
						foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()){
							Type type = a.GetType (cname);
						
							if (type != null){
								var mi = type.GetMethod (mname, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
								if (mi != null)
									mi.Invoke (null, new object [] { data });
								break;
							}
						}
					};
					if (kv.Key == "ontap")
						ontap = d;
					else
						onaccessorytap = d;
					break;
				case "lines":
					int res;
					if (int.TryParse (kvalue, out res))
						lines = res;
					break;
				case "accessory":
					accessory = ToAccessory (kvalue);
					break;
				case "textcolor":
					textcolor = ParseColor (kvalue);
					break;
				case "linebreak":
					linebreakmode = ToLinebreakMode (kvalue);
					break;
				case "font":
					font = ToFont (kvalue);
					break;
				case "subtitle":
					value = kvalue;
					style = UITableViewCellStyle.Subtitle;
					break;
				case "detailfont":
					detailfont = ToFont (kvalue);
					break;
				case "alignment":
					alignment = ToAlignment (kvalue);
					break;
				case "detailcolor":
					detailcolor = ParseColor (kvalue);
					break;
				case "type":
					break;
				default:
					Console.WriteLine ("Unknown attribute: '{0}'", kv.Key);
					break;
				}
			}
			if (caption == null)
				caption = "";
			if (font != null || style != UITableViewCellStyle.Value1 || detailfont != null || linebreakmode.HasValue || textcolor != null || accessory.HasValue || onaccessorytap != null || background != null || detailcolor != null){
				StyledStringElement styled;
				
				if (lines.HasValue){
					styled = new StyledMultilineElement (caption, value, style);
					styled.Lines = lines.Value;
				} else {
					styled = new StyledStringElement (caption, value, style);
				}
				if (ontap != null)
					styled.Tapped += ontap;
				if (onaccessorytap != null)
					styled.AccessoryTapped += onaccessorytap;
				if (font != null)
					styled.Font = font;
				if (detailfont != null)
					styled.SubtitleFont = detailfont;
				if (detailcolor != null)
					styled.DetailColor = detailcolor;
				if (textcolor != null)
					styled.TextColor = textcolor;
				if (accessory.HasValue)
					styled.Accessory = accessory.Value;
				if (linebreakmode.HasValue)
					styled.LineBreakMode = linebreakmode.Value;
				if (background != null){
					if (background.Length > 1 && background [0] == '#')
						styled.BackgroundColor = ParseColor (background);
					else
						styled.BackgroundUri = new Uri (background);
				}
				if (alignment.HasValue)
					styled.Alignment = alignment.Value;
				return styled;
			} else {
				StringElement se;
				if (lines == 0)
					se = new MultilineElement (caption, value);
				else
					se = new StringElement (caption, value);
				if (alignment.HasValue)
					se.Alignment = alignment.Value;
				if (ontap != null)
					se.Tapped += ontap;
				return se;
			}
		}
Example #40
0
 public void setZTitle(StringElement m)
 { zTitle = m; }
Example #41
0
 public override void VisitStringElement(StringElement element)
 {
     //throw new NotImplementedException();
     Console.Write("String Value:" + element.getText());
     interp.sendres(114, "String Value:" + element.getText());
 }
Example #42
0
 public void setXTitle(StringElement m)
 { xTitle = m; }
Example #43
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;
		}
Example #44
0
 public void setYTitle(StringElement m)
 { yTitle = m; }
Example #45
0
        public void InitializeSoar(SoarMSRState initialState)
        {
            if (_kernel != null)
            {
                throw new Exception("Soar: Already initialized");
            }

            _kernel = sml.Kernel.CreateKernelInNewThread("SoarKernelSML");
            if (_kernel.HadError())
            {
                _kernel = null;
                throw new Exception("Soar: Error initializing kernel: " + _kernel.GetLastErrorDescription());
            }

            _running = false;
            _stop = false;

            _agent = _kernel.CreateAgent(initialState.AgentName);

            // We test the kernel for an error after creating an agent as the agent
            // object may not be properly constructed if the create call failed so
            // we store errors in the kernel in this case.  Once this create is done we can work directly with the agent.
            if (_kernel.HadError())
                throw new Exception("Soar: Error creating agent: " + _kernel.GetLastErrorDescription());

            _kernel.SetAutoCommit(false);
            _agent.SetBlinkIfNoChange(false);

            bool result = _agent.LoadProductions(initialState.Productions);
            if (!result)
            {
                throw new Exception("Soar: Error loading productions " + initialState.Productions
                    + " (current working directory: " + _agent.ExecuteCommandLine("pwd") + ")");
            }

            // reset state
            Bumper = new BumperState();
            Override = new OverrideState();
            Obstacle = false;

            // Prepare communication channel
            Identifier inputLink = _agent.GetInputLink();

            if (inputLink == null)
                throw new Exception("Soar: Error getting the input link");

            Identifier overrideWME = _agent.CreateIdWME(inputLink, "override");
            _overrideActiveWME = _agent.CreateStringWME(overrideWME, "active", "false");
            Identifier drivePowerWME = _agent.CreateIdWME(overrideWME, "drive-power");
            _overrideLeftWME = _agent.CreateFloatWME(drivePowerWME, "left", 0);
            _overrideRightWME = _agent.CreateFloatWME(drivePowerWME, "right", 0);
            _overrideStopWME = _agent.CreateStringWME(drivePowerWME, "stop", "false");

            Identifier configWME = _agent.CreateIdWME(inputLink, "config");

            Identifier powerWME = _agent.CreateIdWME(configWME, "power");
            _agent.CreateFloatWME(powerWME, "drive", initialState.DrivePower);
            _agent.CreateFloatWME(powerWME, "reverse", initialState.ReversePower);

            Identifier delayWME = _agent.CreateIdWME(configWME, "delay");
            _agent.CreateFloatWME(delayWME, "stop", initialState.StopTimeout);
            _agent.CreateFloatWME(delayWME, "reverse", initialState.BackUpTimeout);
            _agent.CreateFloatWME(delayWME, "turn", initialState.TurnTimeout);
            _agent.CreateFloatWME(delayWME, "variance", initialState.TimeoutVariance);

            Identifier sensorsWME = _agent.CreateIdWME(inputLink, "sensors");

            Identifier bumperWME = _agent.CreateIdWME(sensorsWME, "bumper");
            Identifier frontWME = _agent.CreateIdWME(bumperWME, "front");
            _frontBumperPressedWME = _agent.CreateStringWME(frontWME, "pressed", "false");
            _frontBumperWasPressedWME = _agent.CreateStringWME(frontWME, "was-pressed", "false");
            Identifier rearWME = _agent.CreateIdWME(bumperWME, "rear");
            _rearBumperPressedWME = _agent.CreateStringWME(rearWME, "pressed", "false");
            _rearBumperWasPressedWME = _agent.CreateStringWME(rearWME, "was-pressed", "false");

            Identifier sickLRFWME = _agent.CreateIdWME(sensorsWME, "sicklrf");
            _obstacleWME = _agent.CreateStringWME(sickLRFWME, "obstacle", "false");

            // Current time WME
            _timeWME = _agent.CreateFloatWME(inputLink, "time", 0);

            // Random number WME and supporting state
            _randomWME = _agent.CreateFloatWME(inputLink, "random", 0);
            if (initialState.HasRandomSeed)
            {
                _random = new Random(initialState.RandomSeed);
                Trace.WriteLine("Seeding Soar's random number generator.");
                _agent.ExecuteCommandLine("srand " + initialState.RandomSeed);
                if (_agent.HadError())
                {
                    throw new Exception("Failed to seed Soar's random number generator");
                }
            }
            else
            {
                _random = new Random();
            }

            // commit input link structure
            _agent.Commit();

            _updateCall = new sml.Kernel.UpdateEventCallback(UpdateEventCallback);
            _kernel.RegisterForUpdateEvent(sml.smlUpdateEventId.smlEVENT_AFTER_ALL_OUTPUT_PHASES, _updateCall, null);

            // spawn debugger
            if (initialState.SpawnDebugger)
            {
                SpawnDebugger();
            }

            _simulationStart = DateTime.Now;

            OnLog("Soar initialized.");
        }