示例#1
0
        public static List <Element> GetABPersonElementFrom(SmsGroupObject sms, bool returnOnlySelected = false)
        {
            List <Element> personElements = new List <Element>();

            foreach (var a in Contacts.AddressBook.Where(x => x.Type == ABRecordType.Person))
            {
                ABPerson person = a as ABPerson;

                foreach (var phone in person.GetPhones())
                {
                    if (phone.Label.ToString().ToLower().Contains("mobile"))
                    {
                        bool isInGroup = false;
                        try{
                            isInGroup = (sms != null && sms.Persons.Any(x => x.Id == a.Id));
                        }catch (Exception ex)
                        {
                            //Console.WriteLine(ex);
                        }

                        if (returnOnlySelected && !isInGroup)
                        {
                            break;
                        }
                        ABPersonElement el = new ABPersonElement(phone.Value, isInGroup, person);
                        personElements.Add(el);
                    }
                }
            }

            return(personElements.OrderBy(x => ((ABPersonElement)x).Person.FirstName).OrderByDescending(x => ((ABPersonElement)x).IsChecked).ToList <Element>());
        }
示例#2
0
        public static List<Element> GetABPersonElementFrom(SmsGroupObject sms, bool returnOnlySelected = false)
        {
            List<Element> personElements = new List<Element>();
            foreach(var a in Contacts.AddressBook.Where (x => x.Type == ABRecordType.Person))
            {
                ABPerson person = a as ABPerson;

                foreach(var phone in person.GetPhones())
                {
                    if(phone.Label.ToString().ToLower().Contains("mobile")){
                        bool isInGroup = false;
                        try{
                            isInGroup = (sms != null && sms.Persons.Any(x => x.Id == a.Id));
                        }catch(Exception ex)
                        {
                            //Console.WriteLine(ex);
                        }

                        if(returnOnlySelected && !isInGroup) break;
                        ABPersonElement el = new ABPersonElement(phone.Value, isInGroup, person);
                        personElements.Add(el);
                    }
                }
            }

            return personElements.OrderBy(x => ((ABPersonElement)x).Person.FirstName).OrderByDescending(x => ((ABPersonElement)x).IsChecked ).ToList<Element>();
        }
示例#3
0
        public void AddGroup(SmsGroupObject sms)
        {
            GroupDetailElement e = new GroupDetailElement(this, sms);

            this.ListGroupSection.Add(e);
            this.ReloadData();
        }
示例#4
0
 public GroupDetailElement(MainScreenGroup parent, SmsGroupObject sms) : base("")
 {
     this.parent           = parent;
     this.Sms              = sms;
     this.style            = UITableViewCellStyle.Subtitle;
     this.Accessory        = UITableViewCellAccessory.DetailDisclosureButton;
     this.AccessoryTapped += ShowGroupDetail;
     this.Tapped          += SendSms;
     this.LineBreakMode    = UILineBreakMode.TailTruncation;
 }
示例#5
0
 private static void DatabaseInsert(SmsGroupObject g)
 {
     foreach (var p in g.Persons)
     {
         var data = new GroupPersonData()
         {
             GroupName = g.Name, ABPersonId = p.Id
         };
         connection.AddGroupPerson(data);
     }
 }
示例#6
0
 public GroupDetailElement(MainScreenGroup parent, SmsGroupObject sms)
     : base("")
 {
     this.parent = parent;
     this.Sms = sms;
     this.style = UITableViewCellStyle.Subtitle;
     this.Accessory = UITableViewCellAccessory.DetailDisclosureButton;
     this.AccessoryTapped += ShowGroupDetail;
     this.Tapped += SendSms;
     this.LineBreakMode = UILineBreakMode.TailTruncation;
 }
示例#7
0
        /// <summary>
        /// Add the specified g and force.
        /// </summary>
        /// <param name='g'>
        /// The group to add.
        /// </param>
        public static void Add(SmsGroupObject g)
        {
            //deletes if exists
            if(Groups.ContainsKey(g.Name))
            {
                Remove (g.Name);
                Groups[g.Name] = g;
            }else
            {
                Groups.Add(g.Name, g);
            }

            //inserts it anyway
            DatabaseInsert(g);
        }
示例#8
0
        public EditContactBeforeSMSController(SmsGroupObject g) : base(true, ToolbarItemOption.Refresh, false)
        {
            Root     = new RootElement("Edit");
            contact  = new SegmentedSection("Contacts");
            this.Sms = g;

            contact.SegmentedControl.InsertSegment(
                Settings.GetLocalizedString("All", LocalizedKey),
                0, true);
            contact.SegmentedControl.InsertSegment(
                Settings.GetLocalizedString("None", LocalizedKey),
                1, true);
            contact.SegmentedControl.ValueChanged += HandleContactSegmentedControlAllTouchEvents;
            this.Root.Add(contact);
            Initialize();
        }
示例#9
0
        /// <summary>
        /// Add the specified g and force.
        /// </summary>
        /// <param name='g'>
        /// The group to add.
        /// </param>
        public static void Add(SmsGroupObject g)
        {
            //deletes if exists
            if (Groups.ContainsKey(g.Name))
            {
                Remove(g.Name);
                Groups[g.Name] = g;
            }
            else
            {
                Groups.Add(g.Name, g);
            }

            //inserts it anyway
            DatabaseInsert(g);
        }
        public EditContactBeforeSMSController(SmsGroupObject g)
            : base(true, ToolbarItemOption.Refresh, false)
        {
            Root = new RootElement("Edit");
            contact = new SegmentedSection("Contacts");
            this.Sms = g;

            contact.SegmentedControl.InsertSegment(
                Settings.GetLocalizedString("All", LocalizedKey),
                0,true);
            contact.SegmentedControl.InsertSegment(
                Settings.GetLocalizedString("None", LocalizedKey),
                1,true);
            contact.SegmentedControl.ValueChanged += HandleContactSegmentedControlAllTouchEvents;
            this.Root.Add(contact);
            Initialize();
        }
示例#11
0
        // add a new group!
        public void SaveGroup()
        {
            if (contactSection != null && nameElement != null)
            {
                // adds to the data holder
                SmsGroupObject g = new SmsGroupObject();
                g.Name    = nameElement.Value;
                g.Persons = GetCheckedContact();

                if (isEditing)
                {
                    Contacts.Remove(this.smsGroup.Sms.Name);
                    // it will update if exists
                    Contacts.Add(g);
                    // check if the group exist, update its inner data with new group
                    foreach (var element in Parent.ListGroupSection.Elements)
                    {
                        GroupDetailElement detail = (GroupDetailElement)element;
                        if (detail.Sms.Name == this.smsGroup.Sms.Name)
                        {
                            InvokeOnMainThread(() => {
                                detail.Sms = g;
                                if (detail.smsComposerViewController != null)
                                {
                                    string message = detail.smsComposerViewController.UserMessage;
                                    detail.smsComposerViewController.Dispose();
                                    detail.smsComposerViewController             = new SmsComposerViewController(Parent, g);
                                    detail.smsComposerViewController.UserMessage = message;
                                }
                                Parent.ReloadData();
                            });
                            // Updates UI here, if needed!
                            break;
                        }
                    }
                }
                else
                {
                    Contacts.Add(g);
                    Parent.AddGroup(g);
                }
            }
        }
        public SmsComposerViewController(MainScreenGroup parent, SmsGroupObject sms)
            : this()
        {
            this.Title = string.Format ("{0} ({1})",sms.Name, sms.Count);
            Parent = parent;
            Sms = sms;
            this.Slider.MinValue = 1;
            this.Slider.MaxValue = Sms.Count;
            this.Slider.Value = Sms.Count > 10 ? 10: Sms.Count;
            this.SliderCount.Text = this.Slider.Value.ToString();
            this.Slider.ValueChanged += HandleSliderhandleValueChanged;
            this.Message.Layer.CornerRadius = 10;

            // Localize Labels
            LabelComposeMessage.Text = Settings.GetLocalizedString(LabelComposeMessage.Text, LocalizedKey);
            LabelMaxContact.Text = Settings.GetLocalizedString(LabelMaxContact.Text, LocalizedKey);
            LabelUseMagicExpression.Text = Settings.GetLocalizedString(LabelUseMagicExpression.Text, LocalizedKey);

            ThreadPool.QueueUserWorkItem ((e) => {
                Sms.LoadPersons();
                hasFinishedLoadedPersons = true;
            });

            #if LITE
            MagicExpressionSwitch.Enabled = false;

            #endif
            // 			UITextView debug = null;
            //			debug = new UITextView(new RectangleF(0, SendButton.Frame.Y + 2,160,20));
            //			this.Add(debug);
            //			ThreadPool.QueueUserWorkItem ((e) => {
            //				while(true){
            //					if(Ad!= null){
            //						InvokeOnMainThread(() => {
            //							debug.Text =
            //								string.Format("Loaded {0}, AdSection {1},", Ad.BannerLoaded, Ad.AdvertisingSection);
            //						});
            //
            //						Thread.Sleep(1000);
            //					}
            //				}
            //			});
        }
示例#13
0
        public SmsComposerViewController(MainScreenGroup parent, SmsGroupObject sms) : this()
        {
            this.Title                      = string.Format("{0} ({1})", sms.Name, sms.Count);
            Parent                          = parent;
            Sms                             = sms;
            this.Slider.MinValue            = 1;
            this.Slider.MaxValue            = Sms.Count;
            this.Slider.Value               = Sms.Count > 10 ? 10: Sms.Count;
            this.SliderCount.Text           = this.Slider.Value.ToString();
            this.Slider.ValueChanged       += HandleSliderhandleValueChanged;
            this.Message.Layer.CornerRadius = 10;

            // Localize Labels
            LabelComposeMessage.Text     = Settings.GetLocalizedString(LabelComposeMessage.Text, LocalizedKey);
            LabelMaxContact.Text         = Settings.GetLocalizedString(LabelMaxContact.Text, LocalizedKey);
            LabelUseMagicExpression.Text = Settings.GetLocalizedString(LabelUseMagicExpression.Text, LocalizedKey);

            ThreadPool.QueueUserWorkItem((e) => {
                Sms.LoadPersons();
                hasFinishedLoadedPersons = true;
            });

#if LITE
            MagicExpressionSwitch.Enabled = false;
#endif
//          UITextView debug = null;
//			debug = new UITextView(new RectangleF(0, SendButton.Frame.Y + 2,160,20));
//			this.Add(debug);
//			ThreadPool.QueueUserWorkItem ((e) => {
//				while(true){
//					if(Ad!= null){
//						InvokeOnMainThread(() => {
//							debug.Text =
//								string.Format("Loaded {0}, AdSection {1},", Ad.BannerLoaded, Ad.AdvertisingSection);
//						});
//
//						Thread.Sleep(1000);
//					}
//				}
//			});
        }
示例#14
0
 private static void DatabaseRemove(SmsGroupObject g)
 {
 }
示例#15
0
 private static void DatabaseInsert(SmsGroupObject g)
 {
     foreach(var p in g.Persons)
     {
         var data = new GroupPersonData(){ GroupName = g.Name, ABPersonId = p.Id };
         connection.AddGroupPerson(data);
     }
 }
示例#16
0
 public void AddGroup(SmsGroupObject sms)
 {
     GroupDetailElement e = new GroupDetailElement(this, sms);
     this.ListGroupSection.Add(e);
     this.ReloadData();
 }
示例#17
0
 private static void DatabaseRemove(SmsGroupObject g)
 {
 }
示例#18
0
        // add a new group!
        public void SaveGroup()
        {
            if(contactSection != null && nameElement != null)
            {
                // adds to the data holder
                SmsGroupObject g = new SmsGroupObject();
                g.Name = nameElement.Value;
                g.Persons = GetCheckedContact();

                if(isEditing)
                {
                    Contacts.Remove(this.smsGroup.Sms.Name);
                    // it will update if exists
                    Contacts.Add(g);
                    // check if the group exist, update its inner data with new group
                    foreach(var element in Parent.ListGroupSection.Elements)
                    {
                        GroupDetailElement detail = (GroupDetailElement)element;
                        if(detail.Sms.Name == this.smsGroup.Sms.Name)
                        {
                            InvokeOnMainThread(()=> {
                                detail.Sms = g;
                                if(detail.smsComposerViewController != null)
                                {
                                    string message = detail.smsComposerViewController.UserMessage;
                                    detail.smsComposerViewController.Dispose();
                                    detail.smsComposerViewController = new SmsComposerViewController(Parent, g);
                                    detail.smsComposerViewController.UserMessage = message;
                                }
                                Parent.ReloadData();
                            });
                            // Updates UI here, if needed!
                            break;
                        }
                    }
                }
                else
                {
                    Contacts.Add(g);
                    Parent.AddGroup(g);
                }
            }
        }