コード例 #1
0
ファイル: SearchSave.cs プロジェクト: jonbonne/OCTGN
        public static SearchSave Create(SearchControl control)
        {
            var ss = new SearchSave();
            ss.GameId = control.Game.Id;
            ss.Name = control.SearchName.Clone() as string;
            ss.FileName = control.FileName.Clone() as string;

            // Load filters
            var generator = control.filterList.ItemContainerGenerator;
            for (int i = 0; i < control.filterList.Items.Count; i++)
            {
                var container = generator.ContainerFromIndex(i);
                var filterCtrl = (FilterControl)VisualTreeHelper.GetChild(container, 0);
                ss.AddFilter(filterCtrl);
            }
            return ss;
        }
コード例 #2
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;
 }
コード例 #3
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 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;
        }