コード例 #1
0
 void PlayConfirmCommand()
 {
     if (Def.PlayCommandSound != null)
     {
         Def.PlayCommandSound();
     }
     else
     {
         Sounds.PlayBeep();
     }
 }
コード例 #2
0
 void SelectMessage(NSIndexPath p, MessageRef m)
 {
     Sounds.PlayBeep();
     SelectMessage(m);
 }
コード例 #3
0
        string InitializePropsUI()
        {
            var help     = Source as IHelpful;
            var helpText = "";


            var q = from t in SourceType.GetProperties()
                    where t.DeclaringType == SourceType && t.CanWrite
                    select t;
            var props = q.ToArray();

            var rows = new List <Row> ();


            foreach (var p in props)
            {
                var ignoreAttrs = p.GetCustomAttributes(typeof(IgnoreAttribute), true);
                if (ignoreAttrs.Length > 0)
                {
                    continue;
                }

                var isEmail = p.GetCustomAttributes(typeof(EmailInputAttribute), true).Length > 0;
                if (!isEmail && p.Name == "Email")
                {
                    isEmail = true;
                }
                var isChooseEmail = p.GetCustomAttributes(typeof(ChooseEmailInputAttribute), true).Length > 0;

                var title = Theme.GetTitle(p.Name);

                if (help != null)
                {
                    var h = help.HelpForProperty(p.Name);
                    if (h != "")
                    {
                        helpText += title + " " + h + "\n";
                    }
                }

                var label = new UILabel {
                    BackgroundColor = UIColor.Black, TextColor = Lcars.ComponentColors[LcarsComponentType.CriticalFunction], Text = title, TextAlignment = UITextAlignment.Right, BaselineAdjustment = UIBaselineAdjustment.AlignBaselines, Font = Theme.InputFont, AdjustsFontSizeToFitWidth = true
                };

                var row = new Row {
                    Property = p
                };
                rows.Add(row);

                row.Label = label;
                UIKeyboardType kbd = UIKeyboardType.Default;
                if (isEmail || isChooseEmail)
                {
                    kbd = UIKeyboardType.EmailAddress;
                }
                else if (p.Name == "Url")
                {
                    kbd = UIKeyboardType.Url;
                }
                else if (p.PropertyType == typeof(int))
                {
                    kbd = UIKeyboardType.NumberPad;
                }

                var init = p.GetValue(Source, null);

                var text = new UITextField {
                    Placeholder = title, BackgroundColor = UIColor.Black, TextColor = UIColor.White, Font = Theme.InputFont, AdjustsFontSizeToFitWidth = false, AutocapitalizationType = UITextAutocapitalizationType.None, KeyboardType = kbd, Text = init != null?init.ToString() : ""
                };
                row.Text = text;
                if (p.Name.ToLowerInvariant().IndexOf("password") >= 0)
                {
                    text.SecureTextEntry    = true;
                    text.AutocorrectionType = UITextAutocorrectionType.No;
                }
                if (p.Name != "Search")
                {
                    text.AutocorrectionType = UITextAutocorrectionType.No;
                }
                if (text.Text.Length == 0 && !isChooseEmail)
                {
                    text.BecomeFirstResponder();
                }
                label.Hidden = text.Text.Length == 0;
                if (isChooseEmail)
                {
                    text.EditingDidBegin += delegate {
                        try {
                            bool hasPeople = false;
                            using (var adds = new ABAddressBook()) {
                                foreach (var pe in adds.GetPeople())
                                {
                                    var es = pe.GetEmails();
                                    if (es.Count > 0)
                                    {
                                        hasPeople = true;
                                        break;
                                    }
                                }
                            }

                            if (hasPeople)
                            {
                                Sounds.PlayBeep();
                                var em = new ChooseEmail();
                                em.EmailSelected += emailAddress =>
                                {
                                    text.Text = emailAddress;
                                    UpdateUI();
                                };
                                App.Inst.ShowDialog(em);
                                NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(30), delegate {
                                    try {
                                        HideKeyBoard(this);
                                    } catch (Exception err) {
                                        Log.Error(err);
                                    }
                                });
                            }
                        } catch (Exception error) {
                            Log.Error(error);
                        }
                    };
                }
                text.AllEditingEvents += delegate {
                    try {
                        label.Hidden = string.IsNullOrEmpty(text.Text);
                        UpdateUI();
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                };
                AddSubview(label);
                AddSubview(text);
            }


            _propViews = rows.ToArray();

            return(helpText);
        }