Exemple #1
0
        public override void Update()
        {
            string text  = m_linkTextBoxWidget.Text.Trim();
            string text2 = m_nameTextBoxWidget.Text.Trim();

            m_typeLabelWidget.Text          = ExternalContentManager.GetEntryTypeDescription(m_type);
            m_typeIconWidget.Subtexture     = ExternalContentManager.GetEntryTypeIcon(m_type);
            m_publishButtonWidget.IsEnabled = (text.Length > 0 && text2.Length > 0);
            if (m_changeTypeButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new SelectExternalContentTypeDialog("Select Content Type", delegate(ExternalContentType item)
                {
                    m_type = item;
                }));
            }
            else if (base.Input.Cancel || m_cancelButtonWidget.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            else if (m_publishButtonWidget.IsClicked)
            {
                CancellableBusyDialog busyDialog = new CancellableBusyDialog("Publishing", autoHideOnCancel: false);
                DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
                CommunityContentManager.Publish(text, text2, m_type, m_user, busyDialog.Progress, delegate
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Link Published Successfully", "It should start appearing in the listings after it is moderated. Please keep the file accessible through this link, so that other community members can download it.", LanguageControl.Get("Usual", "ok"), null, delegate
                    {
                        DialogsManager.HideDialog(this);
                    }));
                }, delegate(Exception error)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }
        }
Exemple #2
0
        public ExternalContentScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/ExternalContentScreen");

            LoadContents(this, node);
            m_directoryLabel                  = Children.Find <LabelWidget>("TopBar.Label");
            m_directoryList                   = Children.Find <ListPanelWidget>("DirectoryList");
            m_providerNameLabel               = Children.Find <LabelWidget>("ProviderName");
            m_changeProviderButton            = Children.Find <ButtonWidget>("ChangeProvider");
            m_loginLogoutButton               = Children.Find <ButtonWidget>("LoginLogout");
            m_upDirectoryButton               = Children.Find <ButtonWidget>("UpDirectory");
            m_actionButton                    = Children.Find <ButtonWidget>("Action");
            m_copyLinkButton                  = Children.Find <ButtonWidget>("CopyLink");
            m_directoryList.ItemWidgetFactory = delegate(object item)
            {
                ExternalContentEntry externalContentEntry2 = (ExternalContentEntry)item;
                XElement             node2           = ContentManager.Get <XElement>("Widgets/ExternalContentItem");
                ContainerWidget      containerWidget = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                string fileName = Storage.GetFileName(externalContentEntry2.Path);
                string text     = m_downloadedFiles.ContainsKey(externalContentEntry2.Path) ? LanguageControl.Get(fName, 11) : string.Empty;
                string text2    = (externalContentEntry2.Type != ExternalContentType.Directory) ? $"{ExternalContentManager.GetEntryTypeDescription(externalContentEntry2.Type)} | {DataSizeFormatter.Format(externalContentEntry2.Size)} | {externalContentEntry2.Time:dd-MMM-yyyy HH:mm}{text}" : ExternalContentManager.GetEntryTypeDescription(externalContentEntry2.Type);
                containerWidget.Children.Find <RectangleWidget>("ExternalContentItem.Icon").Subtexture = ExternalContentManager.GetEntryTypeIcon(externalContentEntry2.Type);
                containerWidget.Children.Find <LabelWidget>("ExternalContentItem.Text").Text           = fileName;
                containerWidget.Children.Find <LabelWidget>("ExternalContentItem.Details").Text        = text2;
                return(containerWidget);
            };
            m_directoryList.ItemClicked += delegate(object item)
            {
                if (m_directoryList.SelectedItem == item)
                {
                    ExternalContentEntry externalContentEntry = item as ExternalContentEntry;
                    if (externalContentEntry != null && externalContentEntry.Type == ExternalContentType.Directory)
                    {
                        SetPath(externalContentEntry.Path);
                    }
                }
            };
        }
        public override void Update()
        {
            string text = m_linkTextBoxWidget.Text.Trim();
            string name = m_nameTextBoxWidget.Text.Trim();

            m_typeLabelWidget.Text      = ExternalContentManager.GetEntryTypeDescription(m_type);
            m_typeIconWidget.Subtexture = ExternalContentManager.GetEntryTypeIcon(m_type);
            if (ExternalContentManager.DoesEntryTypeRequireName(m_type))
            {
                m_nameTextBoxWidget.IsEnabled    = true;
                m_downloadButtonWidget.IsEnabled = (text.Length > 0 && name.Length > 0 && m_type != ExternalContentType.Unknown);
                if (m_updateContentName)
                {
                    m_nameTextBoxWidget.Text = GetNameFromLink(m_linkTextBoxWidget.Text);
                    m_updateContentName      = false;
                }
            }
            else
            {
                m_nameTextBoxWidget.IsEnabled    = false;
                m_nameTextBoxWidget.Text         = string.Empty;
                m_downloadButtonWidget.IsEnabled = (text.Length > 0 && m_type != ExternalContentType.Unknown);
            }
            if (m_updateContentType)
            {
                m_type = GetTypeFromLink(m_linkTextBoxWidget.Text);
                m_updateContentType = false;
            }
            if (m_changeTypeButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new SelectExternalContentTypeDialog("Select Content Type", delegate(ExternalContentType item)
                {
                    m_type = item;
                    m_updateContentName = true;
                }));
            }
            else if (base.Input.Cancel || m_cancelButtonWidget.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            else if (m_downloadButtonWidget.IsClicked)
            {
                CancellableBusyDialog busyDialog = new CancellableBusyDialog("Downloading", autoHideOnCancel: false);
                DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
                WebManager.Get(text, null, null, busyDialog.Progress, delegate(byte[] data)
                {
                    ExternalContentManager.ImportExternalContent(new MemoryStream(data), m_type, name, delegate
                    {
                        DialogsManager.HideDialog(busyDialog);
                        DialogsManager.HideDialog(this);
                    }, delegate(Exception error)
                    {
                        DialogsManager.HideDialog(busyDialog);
                        DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                    });
                }, delegate(Exception error)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }
        }
Exemple #4
0
        public CommunityContentScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/CommunityContentScreen");

            LoadContents(this, node);
            m_listPanel                   = Children.Find <ListPanelWidget>("List");
            m_orderLabel                  = Children.Find <LabelWidget>("Order");
            m_changeOrderButton           = Children.Find <ButtonWidget>("ChangeOrder");
            m_filterLabel                 = Children.Find <LabelWidget>("Filter");
            m_changeFilterButton          = Children.Find <ButtonWidget>("ChangeFilter");
            m_downloadButton              = Children.Find <ButtonWidget>("Download");
            m_deleteButton                = Children.Find <ButtonWidget>("Delete");
            m_moreOptionsButton           = Children.Find <ButtonWidget>("MoreOptions");
            m_listPanel.ItemWidgetFactory = delegate(object item)
            {
                CommunityContentEntry communityContentEntry = item as CommunityContentEntry;
                if (communityContentEntry != null)
                {
                    XElement        node2 = ContentManager.Get <XElement>("Widgets/CommunityContentItem");
                    ContainerWidget obj   = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                    obj.Children.Find <RectangleWidget>("CommunityContentItem.Icon").Subtexture   = ExternalContentManager.GetEntryTypeIcon(communityContentEntry.Type);
                    obj.Children.Find <LabelWidget>("CommunityContentItem.Text").Text             = communityContentEntry.Name;
                    obj.Children.Find <LabelWidget>("CommunityContentItem.Details").Text          = $"{ExternalContentManager.GetEntryTypeDescription(communityContentEntry.Type)} {DataSizeFormatter.Format(communityContentEntry.Size)}";
                    obj.Children.Find <StarRatingWidget>("CommunityContentItem.Rating").Rating    = communityContentEntry.RatingsAverage;
                    obj.Children.Find <StarRatingWidget>("CommunityContentItem.Rating").IsVisible = (communityContentEntry.RatingsAverage > 0f);
                    obj.Children.Find <LabelWidget>("CommunityContentItem.ExtraText").Text        = communityContentEntry.ExtraText;
                    return(obj);
                }
                XElement        node3           = ContentManager.Get <XElement>("Widgets/CommunityContentItemMore");
                ContainerWidget containerWidget = (ContainerWidget)Widget.LoadWidget(this, node3, null);
                m_moreLink     = containerWidget.Children.Find <LinkWidget>("CommunityContentItemMore.Link");
                m_moreLink.Tag = (item as string);
                return(containerWidget);
            };
            m_listPanel.SelectionChanged += delegate
            {
                if (m_listPanel.SelectedItem != null && !(m_listPanel.SelectedItem is CommunityContentEntry))
                {
                    m_listPanel.SelectedItem = null;
                }
            };
        }
Exemple #5
0
 public SelectExternalContentTypeDialog(string title, Action <ExternalContentType> selectionHandler)
     : base(title, from v in EnumUtils.GetEnumValues(typeof(ExternalContentType))
            where ExternalContentManager.IsEntryTypeDownloadSupported((ExternalContentType) v)
            select v, 64f, delegate(object item)
 {
     ExternalContentType type = (ExternalContentType)item;
     XElement node            = ContentManager.Get <XElement>("Widgets/SelectExternalContentTypeItem");
     ContainerWidget obj      = (ContainerWidget)Widget.LoadWidget(null, node, null);
     obj.Children.Find <RectangleWidget>("SelectExternalContentType.Icon").Subtexture = ExternalContentManager.GetEntryTypeIcon(type);
     obj.Children.Find <LabelWidget>("SelectExternalContentType.Text").Text           = ExternalContentManager.GetEntryTypeDescription(type);
     return(obj);
 }, delegate(object item)
 {
     selectionHandler((ExternalContentType)item);
 })
 {
 }