Esempio n. 1
0
        void ShowList(IEnumerable <string> strs)
        {
            var children = list.Items;
            int index    = 0;

            foreach (string s in strs)
            {
                if (index < children.Count)
                {
                    ((LabelWidget)children[index]).Text = s;
                }
                else
                {
                    list.AddItem(new LabelWidget
                    {
                        Text = s,
                        HorizontalAlignment = WidgetAlignment.Center,
                        VerticalAlignment   = WidgetAlignment.Center
                    });
                }
                index++;
            }

            int count = children.Count;

            if (index < count)
            {
                for (int i = index; i < count; i++)
                {
                    list.RemoveItemAt(i);
                }
            }
        }
Esempio n. 2
0
        public void PopulateList(string cursor)
        {
            string text = string.Empty;

            if (SettingsManager.CommunityContentMode == CommunityContentMode.Strict)
            {
                text = "1";
            }
            if (SettingsManager.CommunityContentMode == CommunityContentMode.Normal)
            {
                text = "0";
            }
            string text2    = (m_filter is string) ? ((string)m_filter) : string.Empty;
            string text3    = (m_filter is ExternalContentType) ? LanguageControl.Get(fName, m_filter.ToString()) : string.Empty;
            string text4    = LanguageControl.Get(fName, m_order.ToString());
            string cacheKey = text2 + "\n" + text3 + "\n" + text4 + "\n" + text;

            m_moreLink = null;
            if (string.IsNullOrEmpty(cursor))
            {
                m_listPanel.ClearItems();
                m_listPanel.ScrollPosition = 0f;
                if (m_contentExpiryTime != 0.0 && Time.RealTime < m_contentExpiryTime && m_itemsCache.TryGetValue(cacheKey, out IEnumerable <object> value))
                {
                    foreach (object item in value)
                    {
                        m_listPanel.AddItem(item);
                    }
                    return;
                }
            }
            CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 2), autoHideOnCancel: false);

            DialogsManager.ShowDialog(null, busyDialog);
            CommunityContentManager.List(cursor, text2, text3, text, text4, busyDialog.Progress, delegate(List <CommunityContentEntry> list, string nextCursor)
            {
                DialogsManager.HideDialog(busyDialog);
                m_contentExpiryTime = Time.RealTime + 300.0;
                while (m_listPanel.Items.Count > 0 && !(m_listPanel.Items[m_listPanel.Items.Count - 1] is CommunityContentEntry))
                {
                    m_listPanel.RemoveItemAt(m_listPanel.Items.Count - 1);
                }
                foreach (CommunityContentEntry item2 in list)
                {
                    m_listPanel.AddItem(item2);
                }
                if (list.Count > 0 && !string.IsNullOrEmpty(nextCursor))
                {
                    m_listPanel.AddItem(nextCursor);
                }
                m_itemsCache[cacheKey] = new List <object>(m_listPanel.Items);
            }, delegate(Exception error)
            {
                DialogsManager.HideDialog(busyDialog);
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
            });
        }