Exemplo n.º 1
0
        /// <summary>
        /// Create a default settings with one search item and the default cache folder points to:
        /// C:\\ProgramData\\FromThe.Blue\\WallpaperAbyss\\
        /// </summary>
        public Settings()
        {
            CacheDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\FromThe.Blue\\WallpaperAbyss";

            SearchMethods search = new SearchMethods();

            search.Method = LookupMethods.newest;

            Searches.Add(search);
        }
        void LoadSearches()
        {
            Log.Info("Load() searches");
            DbCommand command = GetCommand();

            command.CommandText = "SELECT * FROM Search;";
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                Searches.Add(CreateSearch(reader));
            }
        }
Exemplo n.º 3
0
        private void SubscribeToNewSearch()
        {
            if (string.IsNullOrEmpty(SearchQuery) ||
                Searches.Count >= 4)
            {
                return;
            }

            var searchFeed       = _twitterFeed.TweetsBySearch(SearchQuery);
            var searchObservable = HandleNewTweets(searchFeed);

            Searches.Add(new SearchViewModel(SearchQuery, searchObservable));
            SearchQuery = "";
        }
Exemplo n.º 4
0
        private void LoadSearchClick(object sender, RoutedEventArgs e)
        {
            if ((SubscriptionModule.Get().IsSubscribed ?? false) == false)
            {
                var res =
                    TopMostMessageBox.Show(
                        "Bummer. This is a subscriber only feature...If you would like to enable this, please visit http://www.octgn.net and subscribe, I know I would!"
                        + Environment.NewLine + "Would you like to go there now?",
                        "Oh No!",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Exclamation);
                if (res == MessageBoxResult.Yes)
                {
                    var url = SubscriptionModule.Get().GetSubscribeUrl(new SubType()
                    {
                        Description = "", Name = ""
                    });
                    if (url != null)
                    {
                        Program.LaunchUrl(url);
                    }
                }
                return;
            }
            if (!IsGameLoaded)
            {
                return;
            }
            var save = SearchSave.Load();

            if (save == null)
            {
                return;
            }

            var ctrl = new SearchControl(Game, save)
            {
                SearchIndex = Searches.Count == 0 ? 1 : Searches.Max(x => x.SearchIndex) + 1
            };

            ctrl.CardAdded    += AddResultCard;
            ctrl.CardRemoved  += RemoveResultCard;
            ctrl.CardSelected += CardSelected;
            LoadFonts(ctrl.resultsGrid);
            Searches.Add(ctrl);
            searchTabs.SelectedIndex = Searches.Count - 1;
        }
Exemplo n.º 5
0
        private void AddSearchTab()
        {
            if (Game == null) //ralig - issue 46
            {
                return;
            }
            var ctrl = new SearchControl(Game)
            {
                SearchIndex = Searches.Count == 0 ? 1 : Searches.Max(x => x.SearchIndex) + 1
            };

            ctrl.CardAdded    += AddResultCard;
            ctrl.CardRemoved  += RemoveResultCard;
            ctrl.CardSelected += CardSelected;
            Searches.Add(ctrl);
            searchTabs.SelectedIndex = Searches.Count - 1;
        }
Exemplo n.º 6
0
        private void AddToExistingSearchesOrCreateNew(ISearch searchToBeAdded)
        {
            if (searchToBeAdded == null)
            {
                throw new ArgumentNullException("searchToBeAdded");
            }

            lock (thisLock)
            {
                var matchingSearch = Searches.FirstOrDefault((existingSearch) => existingSearch.Owner == searchToBeAdded.Owner &&
                                                             existingSearch.DescriptionKey == searchToBeAdded.DescriptionKey);

                if (matchingSearch != null)
                {
                    matchingSearch.Criteria.AddRange(searchToBeAdded.Criteria);
                }
                else
                {
                    Searches.Add(searchToBeAdded);
                }
            }
        }
Exemplo n.º 7
0
        // SEARCHDATA 생성
        public async void CreateSearchData_Influx()
        {
            var    client    = head.getClient();
            string fluxquery = DB_influx.GetQuery_Search();
            var    tables    = await DB_influx.ExcuteInflux(client, fluxquery);

            string danji, build, house, room;
            string _danji = "", _build = "", _house = "", _room = "";

            Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
            {
                tables.ForEach(table =>
                {
                    danji = Convert.ToString(table.Records[0].Values["DANJI_ID"]);
                    build = Convert.ToString(table.Records[0].Values["BUILD_ID"]);
                    house = Convert.ToString(table.Records[0].Values["HOUSE_ID"]);
                    room  = Convert.ToString(table.Records[0].Values["ROOM_ID"]);

                    if (_danji == danji && _build == build && _house == house && _room == room)
                    {
                        return;
                    }
                    _danji = danji;
                    _build = build;
                    _house = house;
                    _room  = room;

                    Searches.Add(new SearchData()
                    {
                        DANJI_ID = Convert.ToString(table.Records[0].Values["DANJI_ID"]),
                        BUILD_ID = Convert.ToString(table.Records[0].Values["BUILD_ID"]),
                        HOUSE_ID = Convert.ToString(table.Records[0].Values["HOUSE_ID"]),
                        ROOM_ID  = Convert.ToString(table.Records[0].Values["ROOM_ID"]),
                    });
                });
            }));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            SearchCounter = 0;

            OnExit = new DelegateCommand(_ =>
            {
                // TODO interrupt running search threads?
                Application.Current.Shutdown();
            });

            OnNewSearch = new DelegateCommand(_ =>
            {
                var Search = new SearchVM(SearchCounter, searchResultStart =>
                {
                    if (searchResultStart == null)
                    {
                        SearchResult = null;
                    }
                    else
                    {
                        SearchResult = new SearchResultVM(searchResultStart.RootDir);
                    }
                }, searchResultPart =>
                {
                    SearchResult.Add(searchResultPart);
                });
                Searches.Add(Search);
                SearchCounter++;
                SelectedSearch = Search;
            });

            Searches = new MyBindingList <SearchVM>();

            // TODO remove
            OnNewSearch.Execute(null);
        }
Exemplo n.º 9
0
        private void LoadSearchClick(object sender, RoutedEventArgs e)
        {
            if ((SubscriptionModule.Get().IsSubscribed ?? false) == false)
            {
                var res =
                    TopMostMessageBox.Show(
                        "This feature is only for subscribers. Please visit http://www.octgn.net for subscription information."
                        + Environment.NewLine + "Would you like to go there now?",
                        "Oh No!",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Exclamation);
                if (res == MessageBoxResult.Yes)
                {
                    var url = SubscriptionModule.Get().GetSubscribeUrl(new SubType()
                    {
                        Description = "", Name = ""
                    });
                    if (url != null)
                    {
                        Program.LaunchUrl(url);
                    }
                }
                return;
            }
            if (!IsGameLoaded)
            {
                return;
            }
            var save = SearchSave.Load();

            if (save == null)
            {
                return;
            }

            var game = GameManager.Get().GetById(save.GameId);

            if (game == null)
            {
                TopMostMessageBox.Show("You don't have the game for this search installed", "Oh No", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else if (Game.Id != save.GameId)
            {
                TopMostMessageBox.Show(
                    "This search is for the game " + game.Name + ". You currently have the game " + Game.Name
                    + " loaded so you can not load this search.", "Oh No", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var ctrl = new SearchControl(Game, save)
            {
                SearchIndex = Searches.Count == 0 ? 1 : Searches.Max(x => x.SearchIndex) + 1
            };

            ctrl.CardAdded    += AddResultCard;
            ctrl.CardRemoved  += RemoveResultCard;
            ctrl.CardSelected += CardSelected;
            LoadFonts(ctrl.resultsGrid);
            Searches.Add(ctrl);
            searchTabs.SelectedIndex = Searches.Count - 1;
        }
        /// <summary>
        /// Adds a new empty search to the end of the list.
        /// </summary>
        private void AppendEmptySearchToTheEnd()
        {
            var newSearch = CreateAndBindEmptySearch();

            Searches.Add(newSearch);
        }