コード例 #1
0
        public void LoadHistory(string file)
        {
            string directory = Path.GetDirectoryName(file);

            if (string.IsNullOrEmpty(directory))
            {
                throw new ArgumentException($"parent directory not found for path: {file}", nameof(file));
            }

            Directory.CreateDirectory(directory);

            if (File.Exists(file))
            {
                var state = ReadHistory(file);

                _settingsHistory = state.SettingsHistory;
                _settingsIndex   = state.SettingsIndex;
            }
            else
            {
                _settingsHistory = new List <GuiSettings>();
                var defaultSettings = new GuiSettings();
                Add(defaultSettings);
            }

            IsLoaded = true;
            Loaded?.Invoke();
        }
コード例 #2
0
ファイル: HistorySubsystem.cs プロジェクト: rajeshwarn/Mtgdb
        public void LoadHistory(string file)
        {
            string directory = Path.GetDirectoryName(file);

            if (string.IsNullOrEmpty(directory))
            {
                throw new ArgumentException($"parent directory not found for path: {file}", nameof(file));
            }

            Directory.CreateDirectory(directory);

            if (File.Exists(file))
            {
                HistoryState state;

                using (var fileReader = File.OpenText(file))
                    using (var jsonReader = new JsonTextReader(fileReader))
                        state = _serializer.Deserialize <HistoryState>(jsonReader);

                _settingsHistory = state.SettingsHistory;
                _settingsIndex   = state.SettingsIndex;
            }
            else
            {
                _settingsHistory = new List <GuiSettings>();
                var defaultSettings = new GuiSettings();
                Add(defaultSettings);
            }

            IsLoaded = true;
            Loaded?.Invoke();
        }
コード例 #3
0
        public void LoadHistory(string historyFile)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(historyFile));

            if (File.Exists(historyFile))
            {
                HistoryState state;

                using (var fileReader = File.OpenText(historyFile))
                    using (var jsonReader = new JsonTextReader(fileReader))
                        state = _serializer.Deserialize <HistoryState>(jsonReader);

                _settingsHistory = state.SettingsHistory;
                _settingsIndex   = state.SettingsIndex;
            }
            else
            {
                _settingsHistory = new List <GuiSettings>();
                var defaultSettings = new GuiSettings();
                Add(defaultSettings);
            }

            IsLoaded = true;
            Loaded?.Invoke();
        }
コード例 #4
0
ファイル: FormMain.cs プロジェクト: NikolayXHD/Mtgdb
        private void historyUpdate()
        {
            if (_history == null)
            {
                return;
            }

            var settings = new GuiSettings
            {
                Find                = _searchSubsystem.AppliedText,
                FilterAbility       = _filterAbility.States,
                FilterCastKeyword   = _filterCastKeyword.States,
                FilterMana          = _filterManaCost.States,
                FilterManaAbility   = _filterManaAbility.States,
                FilterManaGenerated = _filterGeneratedMana.States,
                FilterRarity        = _filterRarity.States,
                FilterType          = _filterType.States,
                FilterCmc           = _filterCmc.States,
                FilterLayout        = _filterLayout.States,
                FilterCardType      = _filterCardType.States,
                FilterGrid          = _filterManager.States,
                Language            = _formRoot.UiModel.LanguageController.Language,

                MainDeckCount  = _deckEditor.MainDeck.CountById.ToDictionary(),
                MainDeckOrder  = _deckEditor.MainDeck.CardsIds.ToList(),
                SideDeckCount  = _deckEditor.SideDeck.CountById.ToDictionary(),
                SideDeckOrder  = _deckEditor.SideDeck.CardsIds.ToList(),
                MaybeDeckCount = _deckEditor.MaybeDeck.CountById.ToDictionary(),
                MaybeDeckOrder = _deckEditor.MaybeDeck.CardsIds.ToList(),

                Collection           = _collectionEditor.CountById.ToDictionary(),
                ShowDuplicates       = _buttonShowDuplicates.Checked,
                HideTooltips         = !_formRoot.TooltipController.Active,
                ExcludeManaAbilities = _buttonExcludeManaAbility.Checked,
                ExcludeManaCost      = _buttonExcludeManaCost.Checked,
                ShowProhibit         = _buttonShowProhibit.Checked,
                Sort = _cardSort.SortString,
                LegalityFilterFormat    = _legality.FilterFormat,
                LegalityAllowLegal      = _legality.AllowLegal,
                LegalityAllowRestricted = _legality.AllowRestricted,
                LegalityAllowBanned     = _legality.AllowBanned,
                DeckFile           = _deckEditor.DeckFile,
                DeckName           = _deckEditor.DeckName,
                SearchResultScroll = _viewCards.CardIndex,
                ShowDeck           = !_buttonHideDeck.Checked,
                ShowScroll         = _buttonShowScrollCards.Checked,
                ShowPartialCards   = _buttonShowPartialCards.Checked,
                ShowTextualFields  = _buttonShowText.Checked,
                FilterByDeckMode   = _deckListControl.FilterByDeckMode,
                Zoom = _formZoom.Settings
            };

            historyUpdateFormPosition(settings);

            _history.Add(settings);
            historyUpdateButtons();
        }
コード例 #5
0
ファイル: FormMain.cs プロジェクト: NikolayXHD/Mtgdb
        private void historyUpdateFormPosition(GuiSettings settings)
        {
            if (Runtime.IsMono)
            {
                return;
            }

            settings.WindowSnapDirection = _formRoot.SnapDirection;
            settings.WindowArea          = _formRoot.BoundsBeforeMaximized;
        }
コード例 #6
0
        private void writeFormSettingsTo(GuiSettings settings)
        {
            settings.ShowDeck          = _formRoot.ShowDeck;
            settings.ShowPartialCards  = _formRoot.ShowPartialCards;
            settings.ShowTextualFields = _formRoot.ShowTextualFields;
            settings.ShowScroll        = _formRoot.ShowScroll;

            settings.HideTooltips = _formRoot.HideTooltips;
            settings.Language     = _formRoot.UiModel.LanguageController.Language;
            settings.Zoom         = _formRoot.ZoomSettings;
        }
コード例 #7
0
ファイル: FormMain.cs プロジェクト: mtucker6784/Mtgdb
        private void readFormSettingsTo(GuiSettings settings)
        {
            settings.ShowDeck          = _formRoot.ShowDeck;
            settings.ShowPartialCards  = _formRoot.ShowPartialCards;
            settings.ShowTextualFields = _formRoot.ShowTextualFields;
            settings.ShowScroll        = _formRoot.ShowScroll;

            settings.ShowFilterPanels = _formRoot.ShowFilterPanels;
            settings.HideTooltips     = _formRoot.HideTooltips;
            settings.Language         = _formRoot.UiModel.LanguageController.Language;
        }
コード例 #8
0
ファイル: JsonDeckFormatter.cs プロジェクト: rajeshwarn/Mtgdb
        public string ExportDeck(string name, Deck current)
        {
            var settings = new GuiSettings
            {
                MainDeckCount = current.MainDeck?.Count,
                MainDeckOrder = current.MainDeck?.Order,
                SideDeckCount = current.Sideboard?.Count,
                SideDeckOrder = current.Sideboard?.Order
            };

            return(JsonConvert.SerializeObject(settings, Formatting.Indented));
        }
コード例 #9
0
ファイル: HistorySubsystem.cs プロジェクト: NikolayXHD/Mtgdb
        public void LoadHistory(FsPath file)
        {
            FsPath directory = file.Parent();

            directory.CreateDirectory();

            if (TryReadHistory(file, out var state))
            {
                _settingsHistory = state.SettingsHistory;
                _settingsIndex   = state.SettingsIndex;
            }
            else
            {
                _settingsHistory = new List <GuiSettings>();
                var defaultSettings = new GuiSettings();
                Add(defaultSettings);
            }

            IsLoaded = true;
            Loaded?.Invoke();
        }
コード例 #10
0
        private void historyApply(GuiSettings settings)
        {
            beginRestoreSettings();

            if (settings.FilterAbility == null || settings.FilterAbility.Length == FilterAbility.PropertiesCount)
            {
                FilterAbility.States = settings.FilterAbility;
            }

            if (settings.FilterCastKeyword == null || settings.FilterCastKeyword.Length == FilterCastKeyword.PropertiesCount)
            {
                FilterCastKeyword.States = settings.FilterCastKeyword;
            }

            if (settings.FilterMana == null || settings.FilterMana.Length == FilterManaCost.PropertiesCount)
            {
                FilterManaCost.States = settings.FilterMana;
            }

            if (settings.FilterManaAbility == null || settings.FilterManaAbility.Length == FilterManaAbility.PropertiesCount)
            {
                FilterManaAbility.States = settings.FilterManaAbility;
            }

            if (settings.FilterManaGenerated == null || settings.FilterManaGenerated.Length == FilterGeneratedMana.PropertiesCount)
            {
                FilterGeneratedMana.States = settings.FilterManaGenerated;
            }

            if (settings.FilterRarity == null || settings.FilterRarity.Length == FilterRarity.PropertiesCount)
            {
                FilterRarity.States = settings.FilterRarity;
            }

            if (settings.FilterType == null || settings.FilterType.Length == FilterType.PropertiesCount)
            {
                FilterType.States = settings.FilterType;
            }

            if (settings.FilterCmc == null || settings.FilterCmc.Length == FilterCmc.PropertiesCount)
            {
                FilterCmc.States = settings.FilterCmc;
            }

            if (settings.FilterLayout == null || settings.FilterLayout.Length == FilterLayout.PropertiesCount)
            {
                FilterLayout.States = settings.FilterLayout;
            }

            if (settings.FilterGrid == null || settings.FilterGrid.Length == FilterManager.PropertiesCount)
            {
                FilterManager.States = settings.FilterGrid;
            }

            updateFilterByDeckMode();

            updateTerms();


            _formRoot.UiModel.LanguageController.Language = settings.Language ?? CardLocalization.DefaultLanguage;

            _cardSearch.AppliedText = settings.Find ?? string.Empty;
            _cardSearch.Apply();

            _buttonShowDuplicates.Checked = settings.ShowDuplicates;

            _formRoot.HideTooltips = settings.HideTooltips;

            _buttonExcludeManaAbility.Checked = settings.ExcludeManaAbilities;
            _buttonExcludeManaCost.Checked    = settings.ExcludeManaCost != false;
            _buttonShowProhibit.Checked       = settings.ShowProhibit;
            _cardSort.ApplySort(settings.Sort);

            hideSampleHand();

            _collectionEditor.LoadCollection(settings.CollectionModel, append: false);
            _copyPaste.LoadDeck(_requiredDeck ?? settings.Deck);

            _legality.SetFilterFormat(settings.LegalityFilterFormat);
            _legality.SetAllowLegal(settings.LegalityAllowLegal != false);
            _legality.SetAllowRestricted(settings.LegalityAllowRestricted != false);
            _legality.SetAllowBanned(settings.LegalityAllowBanned == true);
            _legality.SetAllowFuture(settings.LegalityAllowFuture != false);

            _requiredScroll = settings.SearchResultScroll;

            _buttonHideDeck.Checked         = settings.ShowDeck == false;
            _buttonShowScrollCards.Checked  = settings.ShowScroll != false;
            _buttonShowPartialCards.Checked = settings.ShowPartialCards != false;
            _buttonShowText.Checked         = settings.ShowTextualFields != false;

            _deckListControl.FilterByDeckMode = settings.FilterByDeckMode ??
                                                (isFilterGroupEnabled(FilterGroup.Deck)
                                ? FilterByDeckMode.CurrentDeck
                                : FilterByDeckMode.Ignored);

            _formZoom.Settings = settings.Zoom;

            endRestoreSettings();


            resetTouchedCard();
            RunRefilterTask();
            historyUpdateButtons();

            DeckName = settings.DeckName;
        }
コード例 #11
0
 private void historyUpdateFormPosition(GuiSettings settings)
 {
     settings.WindowSnapDirection = _formRoot.SnapDirection;
     settings.WindowArea          = _formRoot.WindowArea;
 }
コード例 #12
0
 public void Add(GuiSettings settings)
 {
     _settingsHistory.Add(settings);
     _settingsIndex = _settingsHistory.Count - 1;
 }