Ejemplo n.º 1
0
        public WDeathblow(IDeathblow Deathblow)
            : this()
        {
            this.Deathblow = Deathblow;

            LB = Deathblow.GetParser();
            LayoutRoot.DataContext = LB;
        }
Ejemplo n.º 2
0
        public async void Load(Chapter C, bool Cache = true)
        {
            if (C.Content == null)
            {
                await Task.Run(() => Shared.BooksDb.LoadRef(C, b => b.Content));

                await Task.Run(() => Shared.BooksDb.LoadRef(C, b => b.Image));
            }

            if (Cache && C.Content != null)
            {
                OnComplete(C);
            }
            else if (C.Book.Type == BookType.S)
            {
                LoadChapterInst(C);
            }
            else if (C.Book.Type.HasFlag(BookType.W))
            {
                if (C.Book.Type.HasFlag(BookType.L))
                {
                    IDeathblow Db = X.Instance <IDeathblow>(XProto.Deathblow, CurrentBook);
                    MessageBus.SendUI(GetType(), AppKeys.EX_DEATHBLOW, Db);
                }
                else
                {
                    IRuntimeCache wCache = X.Instance <IRuntimeCache>(XProto.WRuntimeCache);

                    // Initiate download, precache should not be done internally.
                    wCache.InitDownload(
                        C.Id.ToString()
                        , X.Call <XKey[]>(XProto.WRequest, "GetBookContent", CurrentBook.ZItemId, C.Meta[AppKeys.GLOBAL_CID])
                        , async(DRequestCompletedEventArgs e, string path) =>
                    {
                        await new ContentParser().ParseAsync(Shared.Conv.Chinese.Translate(e.ResponseString), C);
                        OnComplete(C);

                        X.Instance <IDeathblow>(XProto.Deathblow, CurrentBook).Check(e.ResponseBytes);
                    }
                        , (string Request, string path, Exception ex) =>
                    {
                        Logger.Log(ID, ex.Message, LogType.ERROR);
                        GSystem.ActionCenter.Instance.ShowError("Download");
                        OnComplete(C);
                    }
                        , false
                        );
                }
            }
        }
Ejemplo n.º 3
0
        private async void MessageBus_OnDelivery(Message Mesg)
        {
            switch (Mesg.Content)
            {
            case AppKeys.SH_SCRIPT_DATA:
                HubScriptItem HSI = ( HubScriptItem )Mesg.Payload;

                if ((HSI.Scope & SpiderScope.ZONE) != 0)
                {
                    ControlFrame.Instance.NavigateTo(
                        PageId.MASTER_EXPLORER, () => new MasterExplorer()
                        //  Open ZoneSpider Manager
                        , P => (( MasterExplorer )P).NavigateToDataSource(
                            typeof(ZSMDisplayData)
                            , async(ZSVS) =>
                    {
                        // Using the manager, import this script
                        ZSMDisplayData DisplayData = (( ZSManagerVS )ZSVS).ZSMData;
                        if (await DisplayData.OpenFile(HSI.ScriptFile))
                        {
                            // Open the imported script
                            ZoneSpider ZSpider = DisplayData.ZSTable.Items.Select(x => ( ZoneSpider )x.Source).FirstOrDefault(x => x.ZoneId == HSI.Id);
                            (( MasterExplorer )P).NavigateToZone(ZSpider);
                        }
                    }
                            ));
                    break;
                }

                // This will save the book
                SpiderBook SBook = await SpiderBook.ImportFile(await HSI.ScriptFile.ReadString(), true);

                if (SBook.CanProcess)
                {
                    ConfirmScriptParse(SBook);
                }
                else
                {
                    ConfirmErrorReport(HSI.Id, StatusType.HS_INVALID);
                }
                break;

            case AppKeys.HS_DECRYPT_FAIL:
                StringResources stx = StringResources.Load("Message", "ContextMenu");

                bool Place = false;

                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            stx.Str("Desc_DecryptionFailed"), stx.Str("DecryptionFailed")
                                            , () => Place = true
                                            , stx.Text("PlaceRequest", "ContextMenu"), stx.Str("OK")
                                            ));

                if (Place)
                {
                    HSI = ( HubScriptItem )Mesg.Payload;
                    TransferRequest(SHTarget.KEY, HSI);
                }

                break;

            case AppKeys.HS_OPEN_COMMENT:
                InboxMessage BoxMessage = ( InboxMessage )Mesg.Payload;
                ControlFrame.Instance.NavigateTo(PageId.SCRIPT_DETAILS
                                                 , () => new ScriptDetails(BoxMessage.HubScript)
                                                 , P => (( ScriptDetails )P).OpenCommentStack(BoxMessage.CommId)
                                                 );
                break;

            case AppKeys.HS_NO_VOLDATA:
                ConfirmErrorReport((( BookInstruction )Mesg.Payload).ZItemId, StatusType.HS_NO_VOLDATA);
                break;

            case AppKeys.EX_DEATHBLOW:
                stx = StringResources.Load("Message", "ContextMenu");

                bool UseDeathblow = false;

                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            stx.Str("ConfirmDeathblow")
                                            , () => UseDeathblow = true
                                            , stx.Str("Yes"), stx.Str("No")
                                            ));

                if (UseDeathblow)
                {
                    IDeathblow Deathblow = ( IDeathblow )Mesg.Payload;
                    ControlFrame.Instance.NavigateTo(PageId.W_DEATHBLOW, () => new WDeathblow(Deathblow), P => (( WDeathblow )P).Blow());
                }

                break;

            case AppKeys.PM_CHECK_TILES:
                CheckTiles();
                break;

            case AppKeys.OPEN_VIEWSOURCE:
                ControlFrame.Instance.NavigateTo(PageId.MASTER_EXPLORER, () => new MasterExplorer(), P => (( MasterExplorer )P).NavigateToViewSource(( GRViewSource )Mesg.Payload));
                break;

            case AppKeys.OPEN_ZONE:
                ControlFrame.Instance.NavigateTo(PageId.MASTER_EXPLORER, () => new MasterExplorer(), P => (( MasterExplorer )P).NavigateToZone(( ZoneSpider )Mesg.Payload));
                break;

            case AppKeys.PROMPT_LOGIN:
                (IMember Member, Action DialogClosed) = (Tuple <IMember, Action>)Mesg.Payload;
                if (!Member.IsLoggedIn)
                {
                    Login LoginDialog = new Login(Member);
                    await Popups.ShowDialog(LoginDialog);
                }
                DialogClosed();
                break;
            }
        }