Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ITagDataBase tagDB = new TagDataBase();

            // Initializes DataBase
            tagDB.SetUpDataBase();
        }
Ejemplo n.º 2
0
        public async Task Update()
        {
            // Download the last 24 hr tags
            var posts = await Posts.DownloadPostsAsync(1, $"{YandeClient.HOST}/post.xml?tags=rating:s");

            long dayBefore = posts.First().created_at - 3600 * 24 * 1;

            while (posts.Last().created_at >= dayBefore)
            {
                await posts.LoadMoreItemsAsync(100);
            }
            var postsToday = posts.Where(o => o.created_at >= dayBefore);


            // Hide all blacklisted post using the search page setting
            // To prevent sexually suggestive
            var tagBlacklist = YandeSettings.Current.SearchPostFilter.TagBlacklist.Split(' ').ToList();

            postsToday = postsToday.Where(o => o.Tags.Split(' ').ToList().FirstOrDefault(tag => tagBlacklist.FirstOrDefault(t => String.Compare(t, tag, true) == 0) != default(string)) == default(string));


            UpdateTop3(postsToday);

            await TagDataBase.DownloadLatestTagDBAsync();

            var tags = GetAllTags(postsToday);

            UpdateFeatureTags(tags);
        }
Ejemplo n.º 3
0
        public async Task Update()
        {
            // Download the last 24 hr tags
            var p = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags=rating:s");

            var dayBefore = p.First().created_at - 3600 * 24 * 1;

            while (p.Last().created_at >= dayBefore)
            {
                await p.LoadMoreItemsAsync(100);
            }
            var x = p.Where(o => o.created_at >= dayBefore);


            UpdateTop3(x);


            await TagDataBase.DownloadLatestTagDBAsync();

            var tags = GetAllTags(x);

            await UpdateFeatureTags(tags);

            await UpdateFeatureCharacters();
        }
Ejemplo n.º 4
0
        private void UpdateSuggestion(AutoSuggestBox sender)
        {
            try
            {
                var grid              = VisualTreeHelper.GetChild(sender, 0) as Grid;
                var textbox           = grid.Children.First() as TextBox;
                var pointer           = textbox.SelectionStart;
                int selecetedKeyIndex = sender.Text.Take(pointer).Count(o => o == ' ');

                var tags = sender.Text.Split(' ');
                if (tags.Length >= 1 && tags[selecetedKeyIndex] != "")
                {
                    var results = TagDataBase.Search(tags[selecetedKeyIndex]);

                    // Add back the other tags to the string
                    var prefix = String.Join(" ", tags.Take(selecetedKeyIndex));
                    if (!String.IsNullOrWhiteSpace(prefix))
                    {
                        prefix += " ";
                    }
                    var suffix = String.Join(" ", tags.Skip(selecetedKeyIndex + 1));
                    if (!String.IsNullOrWhiteSpace(suffix))
                    {
                        suffix = " " + suffix;
                    }

                    // Also add an extra space at the end so that its easier to start typing next new type
                    var results2 = results.Select(o => new TagDetailInMiddle(o, prefix, suffix + " "));

                    // Display the tag search results
                    sender.ItemsSource = results2;
                }
                else
                {
                    sender.ItemsSource = null;
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 5
0
        private void UpdateSuggestion(AutoSuggestBox sender)
        {
            try
            {
                var grid              = VisualTreeHelper.GetChild(sender, 0) as Grid;
                var textbox           = grid.Children.First() as TextBox;
                var pointer           = textbox.SelectionStart;
                int selecetedKeyIndex = sender.Text.Take(pointer).Count(o => o == ' ');

                var tags = sender.Text.Split(' ');
                if (tags.Length >= 1 && tags[selecetedKeyIndex] != "")
                {
                    var result = TagDataBase.Search(tags[selecetedKeyIndex]);
                    sender.ItemsSource = result;
                }
                else
                {
                    sender.ItemsSource = null;
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            AppShell shell = Window.Current.Content as AppShell;



            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (shell == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                shell = new AppShell();

                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(shell.AppFrame, "AppFrame");

                shell.AppFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        // Something went wrong restoring state.
                        // Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = shell;
            }


            // Back to the first(home) page if the app already have pages
            while (shell.AppFrame.CanGoBack)
            {
                shell.AppFrame.GoBack();
            }

            foreach (var item in shell.AppFrame.BackStack)
            {
                Debug.WriteLine(item.SourcePageType);
            }


            if (shell.AppFrame.Content == null)
            {
                shell.AppFrame.Navigate(typeof(BooruViewer.Views.HomePage), e.Arguments);
            }


            // Handle the launch from a toast
            var queryString = QueryString.Parse(e.Arguments);
            if (queryString.TryGetValue("action", out string action))
            {
                switch (action)
                {
                case "viewPost":
                    break;

                default:
                    break;
                }
            }

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            // Ensure the current window is active
            Window.Current.Activate();

            AppSettings.Current.ScreenHeight = DisplayInformation.GetForCurrentView().ScreenHeightInRawPixels;
            AppSettings.Current.ScreenWidth  = DisplayInformation.GetForCurrentView().ScreenWidthInRawPixels;


            // Update Tags
            if (TagDataBase.AllTags.Count == 0)
            {
                try
                {
                    await TagDataBase.DownloadLatestTagDBAsync();
                }
                catch (Exception ex)
                {
                    //new MessageDialog(ex.Message).ShowAsync();
                }
            }


            // TODO: reenable after debug
            BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();

            BackgroundTaskBuilder builder = new BackgroundTaskBuilder()
            {
                Name = "ToastActionTask",
                //TaskEntryPoint = "RuntimeComponent1.NotificationActionBackgroundTask"
            };
            builder.SetTrigger(new ToastNotificationActionTrigger());
            BackgroundTaskRegistration registration = builder.Register();



            //await new MessageDialog("這是公測版應用,所有內容和功能不代表最終成品。公測者有義務不定期使用QQ或電郵提出反饋和改善建議。請勿在應用商店就內測版內容作出評分或評論。如果無法理解或者無法同意此守則,請卸載本應用。電郵:[email protected]", "使用須知").ShowAsync();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            AppShell shell = await PrepareAppShellAsync(e.PreviousExecutionState);


            // Back to the first(home) page if the app already have pages
            while (shell.AppFrame.CanGoBack)
            {
                shell.AppFrame.GoBack();
            }


            if (shell.AppFrame.Content == null)
            {
                shell.AppFrame.Navigate(typeof(BooruViewer.Views.HomePage), e.Arguments);
            }


            // Handle the launch from a toast
            var queryString = QueryString.Parse(e.Arguments);
            if (queryString.TryGetValue("action", out string action))
            {
                switch (action)
                {
                case "viewPost":
                    break;

                default:
                    break;
                }
            }

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            // Ensure the current window is active
            Window.Current.Activate();

            AppSettings.Current.ScreenHeight = DisplayInformation.GetForCurrentView().ScreenHeightInRawPixels;
            AppSettings.Current.ScreenWidth  = DisplayInformation.GetForCurrentView().ScreenWidthInRawPixels;


            // Update Tags
            if (TagDataBase.AllTags.Count == 0)
            {
                try
                {
                    await TagDataBase.DownloadLatestTagDBAsync();
                }
                catch (Exception ex)
                {
                    //new MessageDialog(ex.Message).ShowAsync();
                }
            }

            // TODO: reenable after debug
            BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();

            BackgroundTaskBuilder builder = new BackgroundTaskBuilder()
            {
                Name = "ToastActionTask",
                //TaskEntryPoint = "RuntimeComponent1.NotificationActionBackgroundTask"
            };
            builder.SetTrigger(new ToastNotificationActionTrigger());
            BackgroundTaskRegistration registration = builder.Register();
        }