Пример #1
0
        public static void BuildStatusDialog(IAnimeData model, bool anime, Action <AnimeStatus> action = null)
        {
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetAdapter(new StatusDialogAdapter(MainActivity.CurrentContext,
                                                             !anime, model.IsRewatching, model.MyStatus));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnItemClickListener(new EnumDialogListener <AnimeStatus>
            {
                OnItemClickAction = (d, status) =>
                {
                    if (action == null)
                    {
                        model.MyStatus = status;
                    }
                    else
                    {
                        action.Invoke(status);
                    }
                    CleanupStatusDialog();
                }
            });
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupStatusDialog));
            _statusDialog = dialogBuilder.Create();
            _statusDialog.Show();
        }
Пример #2
0
        public static void BuildScoreDialog(IAnimeData model, Action <float> action = null)
        {
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetAdapter(new ScoreDialogAdapter(MainActivity.CurrentContext,
                                                            AnimeItemViewModel.ScoreFlyoutChoices, model.MyScore));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnItemClickListener(new IntegerDialogListener()
            {
                OnItemClickAction = (d, score) =>
                {
                    if (action == null)
                    {
                        model.MyScore = score;
                    }
                    else
                    {
                        action.Invoke(score);
                    }
                    CleanupScoreDialog();
                }
            });
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupScoreDialog));
            _scoreDialog = dialogBuilder.Create();
            _scoreDialog.Show();
        }
Пример #3
0
 /// <summary>
 /// Updates tile but tries to find it's setting beforehand.
 /// </summary>
 /// <param name="entry"></param>
 public static void UpdateTile(IAnimeData entry)
 {
     if (_pinnedCache.ContainsKey(entry.Id))
     {
         var cache = _pinnedCache[entry.Id];
         UpdateTile(entry, cache.ImgUri, cache.WideImgUri, cache.Settings);
     }
 }
 public AnimeDetailsPageNavigationArgs(int id, string title, AnimeGeneralDetailsData element,
                                       IAnimeData animeReference,
                                       object args = null, bool humId = false)
 {
     Id            = id;
     Title         = title;
     AnimeElement  = element;
     PrevPageSetup = args;
     AnimeItem     = animeReference;
     _isHumId      = humId;
 }
Пример #5
0
 public AnimeUpdateQuery(IAnimeData item)
     : this(item.Id, item.MyEpisodes, (int)item.MyStatus, item.MyScore, item.StartDate, item.EndDate, item.Notes, item.IsRewatching)
 {
     try
     {
         ResourceLocator.LiveTilesManager.UpdateTile(item);
     }
     catch (Exception)
     {
         //not windows
     }
 }
        public AnimeDetailsPageNavigationArgs(int id, string title, AnimeGeneralDetailsData element,
            IAnimeData animeReference,
            object args = null,bool humId = false)
        { 
            Id = id;
            Title = title;
            AnimeElement = element;
            PrevPageSetup = args;
            AnimeItem = animeReference;
            _isHumId = humId;

        }
Пример #7
0
 public AnimeUpdateQuery(IAnimeData item)
     : this(item.Id, item.MyEpisodes, (int)item.MyStatus, item.MyScore, item.StartDate, item.EndDate, item.Notes,item.IsRewatching)
 {
     try
     {
         ResourceLocator.LiveTilesManager.UpdateTile(item);
     }
     catch (Exception)
     {
         //not windows
     }
     
 }
Пример #8
0
        public static bool UpdatedSomething; //used for data saving on suspending in app.xaml.cs

        /// <summary>
        /// Just send rewatched value witch cannot be retrieved back
        /// </summary>
        /// <param name="item"></param>
        /// <param name="rewatched"></param>
        public MangaUpdateQuery(IAnimeData item, int rewatched)
        {
            var xml = new StringBuilder();
            xml.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            xml.AppendLine("<entry>");
            xml.AppendLine($"<times_reread>{rewatched}</times_reread>");
            xml.AppendLine("</entry>");

            Request =
                WebRequest.Create(Uri.EscapeUriString($"https://myanimelist.net/api/mangalist/update/{item.Id}.xml?data={xml}"));
            Request.Credentials = Credentials.GetHttpCreditentials();
            Request.ContentType = "application/x-www-form-urlencoded";
            Request.Method = "GET";
        }
Пример #9
0
        }                                                 //used for data saving on suspending in app.xaml.cs

        /// <summary>
        /// Just send rewatched value witch cannot be retrieved back
        /// </summary>
        /// <param name="item"></param>
        /// <param name="rewatched"></param>
        public MangaUpdateQuery(IAnimeData item, int rewatched)
        {
            var xml = new StringBuilder();

            xml.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            xml.AppendLine("<entry>");
            xml.AppendLine($"<times_reread>{rewatched}</times_reread>");
            xml.AppendLine("</entry>");

            Request =
                WebRequest.Create(Uri.EscapeUriString($"https://myanimelist.net/api/mangalist/update/{item.Id}.xml?data={xml}"));
            Request.Credentials = Credentials.GetHttpCreditentials();
            Request.ContentType = "application/x-www-form-urlencoded";
            Request.Method      = "GET";
        }
Пример #10
0
 public static void BuildStatusDialog(IAnimeData model,bool anime,Action<AnimeStatus> action = null)
 {
     var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
     dialogBuilder.SetAdapter(new StatusDialogAdapter(MainActivity.CurrentContext,
         !anime, model.IsRewatching, model.MyStatus));
     dialogBuilder.SetContentBackgroundResource(Resource.Color.BrushFlyoutBackground);
     dialogBuilder.SetOnItemClickListener(new EnumDialogListener<AnimeStatus>
     {
         OnItemClickAction = (d, status) =>
         {
             if(action == null)
                 model.MyStatus = status;
             else
                 action.Invoke(status);
             CleanupStatusDialog();
         }
     });
     dialogBuilder.SetOnDismissListener(
         new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
     ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupStatusDialog));
     _statusDialog = dialogBuilder.Create();
     _statusDialog.Show();
 }
Пример #11
0
 public AnimeUpdateQuery(IAnimeData item) : this(item.Id, item.MyEpisodes, item.MyStatus, item.MyScore, item.StartDate, item.EndDate)
 {
 }
Пример #12
0
        public static bool UpdatedSomething; //used for data saving on suspending in app.xaml.cs

        public MangaUpdateQuery(IAnimeData item)
            : this(
                item.Id, item.MyEpisodes, item.MyStatus, (int)item.MyScore, item.MyVolumes, item.StartDate,
                item.EndDate)
        {
        }
Пример #13
0
        public static bool UpdatedSomething; //used for data saving on suspending in app.xaml.cs

        public AnimeUpdateQuery(IAnimeData item)
            : this(item.Id, item.MyEpisodes, item.MyStatus, item.MyScore, item.StartDate, item.EndDate)
        {
            LiveTilesManager.UpdateTile(item);
        }
        public async void Init(AnimeDetailsPageNavigationArgs param)
        {
            Initialized = false;
            LoadingGlobal = true;
            //wait for UI
            await Task.Delay(5);
            ViewModelLocator.GeneralMain.IsCurrentStatusSelectable = true;

            _loadingAlternate = false;

            //details reset
            _loadedDetails = _loadedReviews = _loadedRecomm = _loadedRelated = _loadedVideos = false;

            //basic init assignment
            _animeItemReference = param.AnimeItem;
            AnimeMode = param.AnimeMode;
            Id = param.Id;
            Title = param.Title;
            if (Settings.SelectedApiType == ApiType.Mal)
                MalId = Id;
            else
                MalId = -1; //we will find this thing later

            //is manga stuff visibile
            if (AnimeMode)
            {
                MyVolumesVisibility = false;
                HiddenPivotItemIndex = -1;
            }
            else
            {
                MyVolumesVisibility = true;
                HiddenPivotItemIndex = 1;
            }
            //Add/Rem
            IsRemoveAnimeButtonEnabled = false;
            IsAddAnimeButtonEnabled = false;
            //favs
            IsFavourite = FavouritesManager.IsFavourite(AnimeMode ? FavouriteType.Anime : FavouriteType.Manga,
                Id.ToString());
            //staff
            CharactersGridVisibility = MangaCharacterGridVisibility = false;
            LoadCharactersButtonVisibility = true;
            AnimeStaffData = null;
            MangaCharacterData = null;
            //so there will be no floting start/end dates
            MyDetailsVisibility = false;
            StartDateValid = false;
            EndDateValid = false;
            _alternateImgUrl = null;

            if (AnimeMode)
            {
                Status1Label = "Watching";
                Status5Label = "Plan to watch";
                WatchedEpsLabel = "Watched\nepisodes";
                UpdateEpsUpperLabel = "Watched\nepisodes";
            }
            else
            {
                Status1Label = "Reading";
                Status5Label = "Plan to read";
                WatchedEpsLabel = "Read\nchapters";
                UpdateEpsUpperLabel = "Read\nchapters";
                LoadCharactersButtonVisibility = false;
            }

            if (_animeItemReference == null || _animeItemReference is AnimeSearchItemViewModel ||
                (_animeItemReference is AnimeItemViewModel && !(_animeItemReference as AnimeItemViewModel).Auth))
                //if we are from search or from unauthenticated item let's look for proper abstraction
            {
                var possibleRef =
                    await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(param.Id, AnimeMode);
                if (possibleRef == null) // else we don't have this item
                {
                    //we may only prepare for its creation
                    AddAnimeVisibility = true;
                    MyDetailsVisibility = false;
                }
                else
                    _animeItemReference = possibleRef;
            } // else we already have it

            if ((_animeItemReference as AnimeItemViewModel)?.Auth ?? false)
            {
                //we have item on the list , so there's valid data here
                MyDetailsVisibility = true;
                AddAnimeVisibility = false;
                IsRemoveAnimeButtonEnabled = true;
                IsAddAnimeButtonEnabled = false;
                PopulateStartEndDates();
                //tags
                if (Settings.SelectedApiType == ApiType.Mal)
                {
                    var tags = string.IsNullOrEmpty(_animeItemReference.Notes)
                        ? new List<string>()
                        : _animeItemReference.Notes.Contains(",")
                            ? _animeItemReference.Notes.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
                                .ToList()
                            : new List<string> {_animeItemReference.Notes};
                    var collection = new ObservableCollection<string>(tags);
                    MyTags = collection;
                }
            }
            else
            {
                IsRemoveAnimeButtonEnabled = false;
                IsAddAnimeButtonEnabled = true;
            }

            switch (param.Source)
            {
                case PageIndex.PageSearch:
                case PageIndex.PageMangaSearch:
                    ExtractData(param.AnimeElement);
                    if (PrevArgs != null)
                        ViewModelLocator.NavMgr.RegisterBackNav(PrevArgs);
                    ViewModelLocator.NavMgr.RegisterBackNav(param.Source, param.PrevPageSetup);
                    break;
                case PageIndex.PageAnimeList:
                case PageIndex.PageMangaList:
                case PageIndex.PageProfile:
                case PageIndex.PageHistory:
                case PageIndex.PageArticles:
                case PageIndex.PageForumIndex:
                case PageIndex.PageStaffDetails:
                case PageIndex.PageCharacterDetails: 
                case PageIndex.PagePopularVideos: 
                    await FetchData(false, param.Source);
                    if (PrevArgs != null)
                        ViewModelLocator.NavMgr.RegisterBackNav(PrevArgs);
                    if (ViewModelLocator.Mobile || (!ViewModelLocator.Mobile && param.Source != PageIndex.PageProfile))
                        ViewModelLocator.NavMgr.RegisterBackNav(param.Source, param.PrevPageSetup);
                    break;
                case PageIndex.PageAnimeDetails:
                    await FetchData();
                    if (param.RegisterBackNav) //we are already going back
                    {
                        ViewModelLocator.NavMgr.RegisterBackNav(param.PrevPageSetup as AnimeDetailsPageNavigationArgs);
                    }
                    break;
                case PageIndex.PageRecomendations:
                    ExtractData(param.AnimeElement);
                    if (PrevArgs != null)
                        ViewModelLocator.NavMgr.RegisterBackNav(PrevArgs);
                    ViewModelLocator.NavMgr.RegisterBackNav(param.Source, param.PrevPageSetup);
                    break;
            }

            PrevArgs = param;
            PrevArgs.RegisterBackNav = false;
            PrevArgs.Source = PageIndex.PageAnimeDetails;
            Initialized = true;
            DetailsPivotSelectedIndex = param.SourceTabIndex;
        }
Пример #15
0
 /// <summary>
 /// Updates tile but tries to find it's setting beforehand.
 /// </summary>
 /// <param name="entry"></param>
 public static void UpdateTile(IAnimeData entry)
 {
     if (_pinnedCache.ContainsKey(entry.Id))
     {
         var cache = _pinnedCache[entry.Id];
         UpdateTile(entry, cache.ImgUri, cache.WideImgUri, cache.Settings);
     }
 }
        private async void AddAnime()
        {
            LoadingUpdate = true;
            IsAddAnimeButtonEnabled = false;
            var response = AnimeMode
                ? await new AnimeAddQuery(Id.ToString()).GetRequestResponse()
                : await new MangaAddQuery(Id.ToString()).GetRequestResponse();
            LoadingUpdate = false;
            IsAddAnimeButtonEnabled = true;
            if (Settings.SelectedApiType == ApiType.Mal && !response.Contains("Created") && AnimeMode)
                return;
            AddAnimeVisibility = false;
            AnimeType typeA;
            MangaType typeM;
            var type = 0;
            try
            {
                if (AnimeMode)
                {
                    Enum.TryParse(Type, out typeA);
                    type = (int) typeA;
                }
                else
                {
                    Enum.TryParse(Type.Replace("-", ""), out typeM);
                    type = (int) typeM;
                }
            }
            catch (Exception)
            {
                //who knows what MAL has thrown at us...
            }


            var startDate = "0000-00-00";
            if (Settings.SetStartDateOnListAdd)
            {
                startDate = DateTimeOffset.Now.ToString("yyyy-MM-dd");
                _startDateTimeOffset = DateTimeOffset.Now; //update without mal-update
                RaisePropertyChanged(() => StartDateTimeOffset);
            }
            var animeItem = AnimeMode
                ? new AnimeItemAbstraction(true, new AnimeLibraryItemData
                {
                    Title = Title,
                    ImgUrl = _imgUrl,
                    Type = type,
                    Id = Id,
                    AllEpisodes = AllEpisodes,
                    MalId = MalId,
                    MyStatus = AnimeStatus.PlanToWatch,
                    MyEpisodes = 0,
                    MyScore = 0,
                    MyStartDate = startDate,
                    MyEndDate = AnimeItemViewModel.InvalidStartEndDate
                })
                : new AnimeItemAbstraction(true, new MangaLibraryItemData
                {
                    Title = Title,
                    ImgUrl = _imgUrl,
                    Type = type,
                    Id = Id,
                    AllEpisodes = AllEpisodes,
                    MalId = MalId,
                    MyStatus = AnimeStatus.PlanToWatch,
                    MyEpisodes = 0,
                    MyScore = 0,
                    MyStartDate = startDate,
                    MyEndDate = AnimeItemViewModel.InvalidStartEndDate,
                    AllVolumes = AllVolumes,
                    MyVolumes = MyVolumes
                });
            _animeItemReference = animeItem.ViewModel;

            MyScore = 0;
            MyStatus = AnimeStatus.PlanToWatch;
            MyEpisodes = 0;
            RaisePropertyChanged(() => GlobalScore); //trigger setter of anime item
            if (string.Equals(Status, "Currently Airing", StringComparison.CurrentCultureIgnoreCase))
                (_animeItemReference as AnimeItemViewModel).Airing = true;
            ViewModelLocator.AnimeList.AddAnimeEntry(animeItem);
            MyDetailsVisibility = true;
            PopulateStartEndDates();
            RaisePropertyChanged(() => StartDateTimeOffset);
            RaisePropertyChanged(() => EndDateTimeOffset);
            RaisePropertyChanged(() => IsIncrementButtonEnabled);
            RaisePropertyChanged(() => IncrementEpsCommand);
            RaisePropertyChanged(() => DecrementEpsCommand);
        }
Пример #17
0
        private static void UpdateTile(IAnimeData entry, Uri imgUri, Uri wideImgUri, PinTileSettings settings)
        {
            //scaryy...
            StringBuilder tileXmlString = new StringBuilder();
            tileXmlString.Append("<tile>");
            tileXmlString.Append($"<visual version='3' {(settings.AddBranding ? "branding='nameAndLogo'" : "")}>");
            tileXmlString.Append("<binding template='TileSquare150x150PeekImageAndText01' fallback='TileSquarePeekImageAndText01'>");
            if (settings.AddImage) tileXmlString.Append($"<image id=\"1\" src=\"{imgUri}\"/>");
            if (settings.AddTitle) tileXmlString.Append($"<text hint-style=\"subtitle\" hint-wrap=\"true\" hint-maxLines=\"{(settings.BigTitle ? "2" : "1")}\" id=\"1\">{entry.Title}</text>");
            if (settings.AddStatus) tileXmlString.Append($"<text hint-style=\"caption\" hint-wrap=\"false\" id=\"2\">{(AnimeStatus)entry.MyStatus}</text>");
            if (settings.AddScore) tileXmlString.Append($"<text hint-style=\"caption\" id=\"3\">{(entry.MyScore == 0 ? "Unranked" : entry.MyScore + $"/{(Settings.SelectedApiType == ApiType.Mal ? "10" : "5")}")}{(settings.AddWatched ? " - " + entry.MyEpisodes + $"/{(entry.AllEpisodes == 0 ? "?" : entry.AllEpisodes.ToString())}" : "")}</text>");
            if (settings.AddAirDay && entry is AnimeItemViewModel && ((AnimeItemViewModel)entry).TopLeftInfoBind != "") tileXmlString.Append($"<text hint-style=\"caption\" id=\"4\">\n{((AnimeItemViewModel)entry).TopLeftInfoBind}</text>");
            tileXmlString.Append("</binding>");
            tileXmlString.Append("<binding template='TileWide310x150ImageAndText02' fallback='TileWideImageAndText02'>");
            if (settings.AddImage) tileXmlString.Append($"<image id=\"1\" src=\"{wideImgUri}\"/>");
            if (settings.AddTitle) tileXmlString.Append($"<text hint-style=\"title\" hint-maxLines=\"{(settings.BigTitle ? "2" : "1")}\" id=\"1\">{entry.Title}</text>");
            tileXmlString.Append("<text id=\"2\"  hint-style=\"body\">");
            if (settings.AddStatus) tileXmlString.Append($"{(AnimeStatus)entry.MyStatus}{(settings.AddWatched ? " - " + entry.MyEpisodes + $"/{(entry.AllEpisodes == 0 ? "?" : entry.AllEpisodes.ToString())}" : "")}");
            if (settings.AddScore) tileXmlString.Append($"\n{(entry.MyScore == 0 ? "Unranked" : entry.MyScore + $"/{(Settings.SelectedApiType == ApiType.Mal ? "10" : "5")}")}");
            if (settings.AddAirDay && entry is AnimeItemViewModel && ((AnimeItemViewModel)entry).TopLeftInfoBind != "") tileXmlString.Append($" - {((AnimeItemViewModel)entry).TopLeftInfoBind}");
            tileXmlString.Append("</text>");
            tileXmlString.Append("</binding>");
            tileXmlString.Append("</visual>");
            tileXmlString.Append("</tile>");
            //uff, yup... that was scarry mess

            try
            {
                var mgr = TileUpdateManager.CreateTileUpdaterForSecondaryTile(entry.Id.ToString());
                var notif = new Windows.Data.Xml.Dom.XmlDocument();
                notif.LoadXml(tileXmlString.ToString());
                mgr.Update(new TileNotification(notif));
            }
            catch (Exception)
            {
                // no tile
            }

        }
 public void CurrentAnimeHasBeenAddedToList(IAnimeData reference)
 {
     _animeItemReference = reference;
     MyDetailsVisibility = true;
     AddAnimeVisibility = false;
     RaisePropertyChanged(() => IsIncrementButtonEnabled);
     RaisePropertyChanged(() => IncrementEpsCommand);
     RaisePropertyChanged(() => DecrementEpsCommand);
 }
Пример #19
0
 public void UpdateTile(IAnimeData item)
 {
     LiveTilesManager.UpdateTile(item);
 }
Пример #20
0
        public static async Task PinTile(IAnimeData entry, Uri imgUri, Uri wideImgUri, PinTileSettings settings, PinTileActionSetting action)
        {
            try
            {
                //prepare images
                if (imgUri != null)
                {
                    var file = await StorageFile.GetFileFromApplicationUriAsync(imgUri);

                    var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("PinnedTilesImages",
                                                                                             CreationCollisionOption.OpenIfExists);

                    await file.CopyAsync(folder, entry.Id + ".png", NameCollisionOption.ReplaceExisting);

                    if (!imgUri.Equals(wideImgUri))
                    {
                        file = await StorageFile.GetFileFromApplicationUriAsync(wideImgUri);

                        await file.CopyAsync(folder, entry.Id + "Wide.png", NameCollisionOption.ReplaceExisting);

                        wideImgUri = new Uri($"ms-appdata:///local/PinnedTilesImages/{entry.Id}Wide.png");
                    }
                    else
                    {
                        wideImgUri = new Uri($"ms-appdata:///local/PinnedTilesImages/{entry.Id}.png");
                    }

                    imgUri = new Uri($"ms-appdata:///local/PinnedTilesImages/{entry.Id}.png");
                }
                else
                {
                    imgUri     = new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png");
                    wideImgUri = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-200.png");
                }
                //pin tile
                if (action.Action == TileActions.OpenUrl)
                {
                    if (!action.Param.Contains("http"))
                    {
                        action.Param = "http://" + action.Param;
                    }
                }
                var tile = new SecondaryTile(entry.Id.ToString(), "MALClient", string.Join(";", new string[] { action.Action.ToString(), action.Param }), imgUri,
                                             TileSize.Square150x150);
                tile.WideLogo = wideImgUri;
                RegisterTile(entry.Id.ToString());
                await tile.RequestCreateAsync();

                RegisterTileCache(entry.Id, new PinnedTileCache {
                    ImgUri = imgUri, WideImgUri = wideImgUri, Settings = settings
                });
                if (settings.AnythingAtAll)
                {
                    UpdateTile(entry, imgUri, wideImgUri, settings);
                }
            }
            catch (Exception)
            {
                //who knows?
            }
        }
Пример #21
0
        private static void UpdateTile(IAnimeData entry, Uri imgUri, Uri wideImgUri, PinTileSettings settings)
        {
            //scaryy...
            StringBuilder tileXmlString = new StringBuilder();

            tileXmlString.Append("<tile>");
            tileXmlString.Append($"<visual version='3' {(settings.AddBranding ? "branding='nameAndLogo'" : "")}>");
            tileXmlString.Append("<binding template='TileSquare150x150PeekImageAndText01' fallback='TileSquarePeekImageAndText01'>");
            if (settings.AddImage)
            {
                tileXmlString.Append($"<image id=\"1\" src=\"{imgUri}\"/>");
            }
            if (settings.AddTitle)
            {
                tileXmlString.Append($"<text hint-style=\"subtitle\" hint-wrap=\"true\" hint-maxLines=\"{(settings.BigTitle ? "2" : "1")}\" id=\"1\">{entry.Title}</text>");
            }
            if (settings.AddStatus)
            {
                tileXmlString.Append($"<text hint-style=\"caption\" hint-wrap=\"false\" id=\"2\">{(AnimeStatus)entry.MyStatus}</text>");
            }
            if (settings.AddScore)
            {
                tileXmlString.Append($"<text hint-style=\"caption\" id=\"3\">{(entry.MyScore == 0 ? "Unranked" : entry.MyScore + $"/{(Settings.SelectedApiType == ApiType.Mal ? "10" : "5")}")}{(settings.AddWatched ? " - " + entry.MyEpisodes + $"/{(entry.AllEpisodes == 0 ? "?" : entry.AllEpisodes.ToString())}" : "")}</text>");
            }
            if (settings.AddAirDay && entry is AnimeItemViewModel && ((AnimeItemViewModel)entry).AirDayBind != "")
            {
                tileXmlString.Append($"<text hint-style=\"caption\" id=\"4\">\n{((AnimeItemViewModel)entry).AirDayBind}</text>");
            }
            tileXmlString.Append("</binding>");
            tileXmlString.Append("<binding template='TileWide310x150ImageAndText02' fallback='TileWideImageAndText02'>");
            if (settings.AddImage)
            {
                tileXmlString.Append($"<image id=\"1\" src=\"{wideImgUri}\"/>");
            }
            if (settings.AddTitle)
            {
                tileXmlString.Append($"<text hint-style=\"title\" hint-maxLines=\"{(settings.BigTitle ? "2" : "1")}\" id=\"1\">{entry.Title}</text>");
            }
            tileXmlString.Append("<text id=\"2\"  hint-style=\"body\">");
            if (settings.AddStatus)
            {
                tileXmlString.Append($"{(AnimeStatus)entry.MyStatus}{(settings.AddWatched ? " - " + entry.MyEpisodes + $"/{(entry.AllEpisodes == 0 ? "?" : entry.AllEpisodes.ToString())}" : "")}");
            }
            if (settings.AddScore)
            {
                tileXmlString.Append($"\n{(entry.MyScore == 0 ? "Unranked" : entry.MyScore + $"/{(Settings.SelectedApiType == ApiType.Mal ? "10" : "5")}")}");
            }
            if (settings.AddAirDay && entry is AnimeItemViewModel && ((AnimeItemViewModel)entry).AirDayBind != "")
            {
                tileXmlString.Append($" - {((AnimeItemViewModel)entry).AirDayBind}");
            }
            tileXmlString.Append("</text>");
            tileXmlString.Append("</binding>");
            tileXmlString.Append("</visual>");
            tileXmlString.Append("</tile>");
            //uff, yup... that was scarry mess

            try
            {
                var mgr   = TileUpdateManager.CreateTileUpdaterForSecondaryTile(entry.Id.ToString());
                var notif = new Windows.Data.Xml.Dom.XmlDocument();
                notif.LoadXml(tileXmlString.ToString());
                mgr.Update(new TileNotification(notif));
            }
            catch (Exception)
            {
                // no tile
            }
        }
Пример #22
0
        public static async Task PinTile(IAnimeData entry, Uri imgUri, Uri wideImgUri, PinTileSettings settings, PinTileActionSetting action)
        {
            try
            {
                //prepare images
                if (imgUri != null)
                {
                    var file = await StorageFile.GetFileFromApplicationUriAsync(imgUri);
                    var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("PinnedTilesImages",
                        CreationCollisionOption.OpenIfExists);
                    await file.CopyAsync(folder, entry.Id + ".png", NameCollisionOption.ReplaceExisting);

                    if (!imgUri.Equals(wideImgUri))
                    {
                        file = await StorageFile.GetFileFromApplicationUriAsync(wideImgUri);
                        await file.CopyAsync(folder, entry.Id + "Wide.png", NameCollisionOption.ReplaceExisting);
                        wideImgUri = new Uri($"ms-appdata:///local/PinnedTilesImages/{entry.Id}Wide.png");
                    }
                    else
                        wideImgUri = new Uri($"ms-appdata:///local/PinnedTilesImages/{entry.Id}.png");

                    imgUri = new Uri($"ms-appdata:///local/PinnedTilesImages/{entry.Id}.png");
                }
                else
                {
                    imgUri = new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png");
                    wideImgUri = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-200.png");
                }
                //pin tile
                if (action.Action == TileActions.OpenUrl)
                    if (!action.Param.Contains("http"))
                        action.Param = "http://" + action.Param;
                var tile = new SecondaryTile(entry.Id.ToString(),
                    "MALClient",
                    string.Join(";", action.Action.ToString(), action.Param),
                    imgUri,
                    TileSize.Square150x150);

                tile.WideLogo = wideImgUri;
                RegisterTile(entry.Id.ToString());
                await tile.RequestCreateAsync();
                RegisterTileCache(entry.Id, new PinnedTileCache { ImgUri = imgUri, WideImgUri = wideImgUri, Settings = settings });
                if (settings.AnythingAtAll)
                    UpdateTile(entry, imgUri, wideImgUri, settings);
                ResourceLocator.TelemetryProvider.TelemetryTrackEvent(TelemetryTrackedEvents.PinnedTile);
            }
            catch (Exception)
            {
                //who knows?
            }
        }
Пример #23
0
 public MangaUpdateQuery(IAnimeData item)
     : this(
         item.Id, item.MyEpisodes, (int)item.MyStatus, (int) item.MyScore, item.MyVolumes, item.StartDate,
         item.EndDate,item.Notes,item.IsRewatching)
 {
 }
Пример #24
0
 public void UpdateTile(IAnimeData item)
 {
     LiveTilesManager.UpdateTile(item);
 }
Пример #25
0
 public static void BuildScoreDialog(IAnimeData model,Action<float> action = null)
 {
     var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
     dialogBuilder.SetAdapter(new ScoreDialogAdapter(MainActivity.CurrentContext,
         AnimeItemViewModel.ScoreFlyoutChoices,model.MyScore));
     dialogBuilder.SetContentBackgroundResource(Resource.Color.BrushFlyoutBackground);
     dialogBuilder.SetOnItemClickListener(new IntegerDialogListener()
     {
         OnItemClickAction = (d, score) =>
         {
             if(action == null)
                 model.MyScore = score;
             else
                 action.Invoke(score);
             CleanupScoreDialog();
         }
     });
     dialogBuilder.SetOnDismissListener(
         new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
     ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupScoreDialog));
     _scoreDialog = dialogBuilder.Create();
     _scoreDialog.Show();
 }