Ejemplo n.º 1
0
        public Cache()
        {
            this._defaultActions = new List <WoosterAction>(PredefinedActions.GetPredefinedActions());
            this._defaultActions.Add(new WoosterAction("Recache Wooster data", s => this.RecacheData()));
            //this._defaultActions.Add(new WoosterAction("Open Wooster preferences", s=> DialogService.ShowDialog(new PreferencesViewModel(), 700, 600)));
            this._defaultActions.Add(new WoosterAction("Open Wooster config folder", s => Process.Start(Path.GetDirectoryName(Config.GetRealConfigPath()))));

            this.ProgramShortcutActions = new List <ProgramShortcutAction>();
        }
        public SelectCardsPage(PredefinedActions action, string preSelectedGroupName, ContactModel defaultSelectedItem, bool addFromCardsHolder, string defaultSearchCardsString)
        {
            InitializeComponent();
#if __IOS__
            HasSystemPadding = false;
#endif

            Init(action, preSelectedGroupName, defaultSelectedItem, addFromCardsHolder, defaultSearchCardsString);
        }
        private void Init(PredefinedActions action, string preSelectedGroupName, ContactModel defaultSelectedItem, bool addFromCardsHolder, string defaultSearchCardsString)
        {
            _addFromCardsHolder   = addFromCardsHolder;
            _preSelectedGroupName = preSelectedGroupName;

            // Only show the remove from group action button inside this page if the cards shown are part of preselected group and no preselected action passed.
            if (action == PredefinedActions.All && string.IsNullOrWhiteSpace(preSelectedGroupName))
            {
                actionButtonsGrid.ColumnDefinitions.RemoveAt(actionButtonsGrid.ColumnDefinitions.Count - 1);
                actionButtonsGrid.Children.Remove(removeFromGroupActionButton);
            }

            if (addFromCardsHolder)
            {
                DeselectAllCards();
            }

            if (defaultSelectedItem != null)
            {
                defaultSelectedItem.IsSelected = true;
            }

            IsSingleActionPage = action != PredefinedActions.All;
            if (IsSingleActionPage)
            {
                contactsListRow.Height  = new GridLength(1, GridUnitType.Star);
                actionButtonsRow.Height = new GridLength(1, GridUnitType.Auto);
            }

            switch (action)
            {
            case PredefinedActions.Group:
                SingleActionName      = string.IsNullOrEmpty(preSelectedGroupName) ? "Add To Group" : "Add To [ " + preSelectedGroupName + " ]";
                actionButton.Clicked += GroupButton_Tapped;
                break;

            case PredefinedActions.Share:
                SingleActionName      = "Share";
                actionButton.Clicked += ShareButton_Tapped;
                break;

            case PredefinedActions.SaveToContacts:
                SingleActionName      = "Save to contacts";
                actionButton.Clicked += SaveToContactsButton_Tapped;
                break;

            case PredefinedActions.Delete:
                SingleActionName      = "Delete";
                actionButton.Clicked += DeleteCardsButton_Tapped;
                break;
            }

            if (!string.IsNullOrEmpty(defaultSearchCardsString))
            {
                mainSearchBar.Text = defaultSearchCardsString;
            }
            else
            {
                RefreshListView(defaultSelectedItem);
            }

            BindingContext = this;
        }