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>()); }
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>(); }
public void AddGroup(SmsGroupObject sms) { GroupDetailElement e = new GroupDetailElement(this, sms); this.ListGroupSection.Add(e); this.ReloadData(); }
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; }
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); } }
/// <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(); }
/// <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(); }
// 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); // } // } // }); }
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); // } // } // }); }
private static void DatabaseRemove(SmsGroupObject g) { }
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); } }
// 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); } } }