예제 #1
0
        public FormMain(
            UndoConfig undoConfig,
            CardRepository cardRepo,
            ImageRepository imageRepo,
            ImageCacheConfig imageCacheConfig,
            ImageLoader imageLoader,
            CollectionEditorModel collectionEditor,
            CardSearcher cardSearcher,
            CardDocumentAdapter cardAdapter,
            DeckDocumentAdapter deckAdapter,
            KeywordSearcher keywordSearcher,
            ForgeSetRepository forgeSetRepo,
            DeckListModel deckListModel,
            DeckSearcher deckSearcher,
            IconRecognizer iconRecognizer,
            FormManager formManager)
            : this()
        {
            DoubleBuffered = true;
            KeyPreview     = true;

            _viewCards = new MtgLayoutView(_layoutViewCards);
            _viewDeck  = new MtgLayoutView(_layoutViewDeck);

            _cardSearcher        = cardSearcher;
            _keywordSearcher     = keywordSearcher;
            _quickFilterControls = QuickFilterSetup.GetQuickFilterControls(this);

            _cardRepo         = cardRepo;
            _imageLoader      = imageLoader;
            _collectionEditor = collectionEditor;
            _serialization    = new DeckSerializationSubsystem(_cardRepo, forgeSetRepo);

            beginRestoreSettings();

            _fields = new Fields();

            QuickFilterSetup.SetQuickFilterProperties(this);
            QuickFilterImages.SetImages(this);

            _quickFilterFacade = new QuickFilterFacade(
                KeywordDefinitions.Patterns,
                KeywordDefinitions.Values.ToKeywordDisplayTexts(),
                KeywordDefinitions.PropertyNames,
                KeywordDefinitions.PropertyNamesDisplay,
                keywordSearcher);

            _buttons = new ButtonSubsystem();

            _cardSearch = new CardSearchSubsystem(
                this,
                _searchEditor,
                _panelIconSearch,
                _listBoxSuggest,
                cardSearcher,
                cardAdapter,
                _viewCards,
                _viewDeck);

            _panelSearchExamples.Setup(_cardSearch, _buttons, _buttonSearchExamplesDropDown);

            _sort = new SortSubsystem(_viewCards, _cardRepo, _fields, _cardSearch);

            endRestoreSettings();

            _tooltipViewCards = new LayoutViewTooltip(this, _viewCards, _cardSearch);
            _tooltipViewDeck  = new LayoutViewTooltip(this, _viewDeck, _cardSearch);

            var formZoomCard = new FormZoom(_cardRepo, imageRepo, _imageLoader);

            _scroll = new ScrollSubsystem(_viewDeck, _viewCards);

            _imagePreloading = new ImagePreloadingSubsystem(
                _viewCards,
                _viewDeck,
                _scroll,
                imageCacheConfig);

            _deckEditor = new DeckEditorModel();

            _dragging = new DraggingSubsystem(
                _viewDeck,
                _viewCards,
                _deckEditor,
                this,
                _imageLoader,
                formManager);

            _deckEditorUi = new DeckEditorUi(
                _viewCards,
                _viewDeck,
                _deckEditor,
                _collectionEditor,
                _dragging,
                Cursor,
                formZoomCard);

            _viewDeck.SetDataSource(_deckEditor.DataSource);
            _viewCards.SetDataSource(_searchResultCards);

            _legality = new LegalitySubsystem(
                _menuLegalityFormat,
                _buttonLegalityAllowLegal,
                _buttonLegalityAllowRestricted,
                _buttonLegalityAllowBanned);

            _drawing = new DrawingSubsystem(
                _viewCards,
                _viewDeck,
                _dragging,
                _cardSearch,
                cardAdapter,
                _deckEditor,
                _quickFilterFacade,
                _legality,
                _imageLoader,
                iconRecognizer);


            _printing = new PrintingSubsystem(imageRepo, _cardRepo);

            DeckZone = Zone.Main;

            scale();
            setRightPanelsWidth();

            _keywordsIndexUpToDate     = _keywordSearcher.IsUpToDate;
            _luceneSearchIndexUpToDate = _cardSearcher.IsUpToDate;
            _spellcheckerIndexUpToDate = _cardSearcher.Spellchecker.IsUpToDate;

            _searchTextSelection = new RichTextBoxSelectionSubsystem(_searchEditor);

            _history = new HistorySubsystem(undoConfig);

            _evaluators = new Evaluators
            {
                { 2, _legality.IsAllowedInFormat },
                { 3, evalFilterByCollection },
                { 4, evalFilterByDeck },
                { 0, _quickFilterFacade.Evaluate },
                { 1, evalFilterBySearchText }
            };

            _deckListControl.Init(
                deckListModel,
                iconRecognizer,
                deckSearcher,
                deckAdapter,
                this);

            _copyPaste = new CopyPasteSubsystem(
                _cardRepo,
                _serialization,
                _collectionEditor,
                _deckEditor,
                _formRoot,
                this,
                _layoutViewDeck,
                _tabHeadersDeck,
                _layoutViewCards,
                _deckListControl.DeckListView);

            setupCheckButtonImages();

            updateExcludeManaAbility();
            updateExcludeManaCost();
            updateShowProhibited();
            updateShowSampleHandButtons();
            updateDeckVisibility();

            subscribeToEvents();
        }
예제 #2
0
        public FormMain(
            CardRepository cardRepo,
            PriceRepository priceRepo,
            ImageRepository imageRepo,
            ImageLoader imageLoader,
            UiConfigRepository uiConfigRepository,
            CollectionEditorModel collectionEditor,
            CardSearcher cardSearcher,
            CardDocumentAdapter cardAdapter,
            DeckDocumentAdapter deckAdapter,
            KeywordSearcher keywordSearcher,
            DeckListModel deckListModel,
            DeckSearcher deckSearcher,
            IconRecognizer iconRecognizer,
            DeckSerializationSubsystem serialization,
            MtgArenaIntegration mtgArenaIntegration,
            App app)
            : this()
        {
            DoubleBuffered = true;

            _app                 = app;
            _cardSearcher        = cardSearcher;
            _keywordSearcher     = keywordSearcher;
            _quickFilterControls = QuickFilterSetup.GetQuickFilterControls(this);

            _cardRepo            = cardRepo;
            _priceRepo           = priceRepo;
            _imageLoader         = imageLoader;
            _uiConfigRepository  = uiConfigRepository;
            _collectionEditor    = collectionEditor;
            _serialization       = serialization;
            _mtgArenaIntegration = mtgArenaIntegration;

            beginRestoreSettings();

            _fields = new CardFields();

            QuickFilterSetup.SetQuickFilterProperties(this);
            QuickFilterImages.SetImages(this);

            _quickFilterFacade = new QuickFilterFacade(
                KeywordDefinitions.Patterns,
                KeywordDefinitions.Values.ToKeywordDisplayTexts(),
                KeywordDefinitions.PropertyNames,
                KeywordDefinitions.PropertyNamesDisplay,
                keywordSearcher);

            _searchSubsystem = new CardSearchSubsystem(
                this,
                _searchBar,
                uiConfigRepository,
                cardSearcher,
                cardAdapter,
                _viewCards,
                _viewDeck);

            _cardSort = new CardSortSubsystem(_viewCards, _cardRepo, _fields, _searchSubsystem);

            endRestoreSettings();

            _countInputSubsystem = new CountInputSubsystem();
            _tooltipViewCards    = new LayoutViewTooltip(this, _viewCards, _searchSubsystem, _countInputSubsystem);
            _tooltipViewDeck     = new LayoutViewTooltip(this, _viewDeck, _searchSubsystem, _countInputSubsystem);

            _formZoom = new FormZoom(_cardRepo, imageRepo, _imageLoader);

            _imagePreloading = new ImagePreloadingSubsystem(
                _viewCards,
                _viewDeck,
                uiConfigRepository);

            _deckEditor = new DeckEditorModel();

            _dragging = new DraggingSubsystem(
                _viewDeck,
                _viewCards,
                _deckEditor,
                this,
                _imageLoader,
                _app);

            _deckEditorSubsystem = new DeckEditorSubsystem(
                _viewCards,
                _viewDeck,
                _deckEditor,
                _collectionEditor,
                _dragging,
                _countInputSubsystem,
                Cursor,
                _formZoom,
                this);

            _viewDeck.DataSource  = _deckEditor.DataSource;
            _viewCards.DataSource = _searchResultCards;

            _legality = new LegalitySubsystem(
                _dropdownLegality,
                _buttonLegalityAllowLegal,
                _buttonLegalityAllowRestricted,
                _buttonLegalityAllowBanned,
                _buttonLegalityAllowFuture);

            _drawing = new DrawingSubsystem(
                _viewCards,
                _viewDeck,
                _searchSubsystem,
                cardAdapter,
                _deckEditor,
                _countInputSubsystem,
                _quickFilterFacade,
                _legality,
                iconRecognizer);


            _printing = new PrintingSubsystem(imageRepo, _cardRepo);

            _deckZones = new DeckZoneSubsystem(
                _tabHeadersDeck,
                _dragging,
                _viewDeck)
            {
                DeckZone = Zone.Main
            };

            scale();
            setRightPanelsWidth();

            _keywordsIndexUpToDate     = _keywordSearcher.IsUpToDate;
            _luceneSearchIndexUpToDate = _cardSearcher.IsUpToDate;
            _spellcheckerIndexUpToDate = _cardSearcher.Spellchecker.IsUpToDate;

            _history = new HistorySubsystem(uiConfigRepository);

            _evaluators = new Evaluators
            {
                { 2, _legality.MatchesLegalityFilter },
                { 3, evalFilterByCollection },
                { 4, evalFilterByDeck },
                { 0, _quickFilterFacade.Evaluate },
                { 1, evalFilterBySearchText }
            };

            _deckSearcher = deckSearcher;
            _deckListControl.Init(
                deckListModel,
                iconRecognizer,
                _deckSearcher,
                deckAdapter,
                collectionEditor,
                uiConfigRepository,
                this,
                _app);

            _copyPaste = new CopyPasteSubsystem(
                _cardRepo,
                _serialization,
                _collectionEditor,
                _deckEditor,
                this,
                _deckListControl,
                _viewDeck,
                _tabHeadersDeck,
                _viewCards,
                _deckListControl.DeckListView);

            updateExcludeManaAbility();
            updateExcludeManaCost();
            updateShowProhibited();
            updateShowSampleHandButtons();
            updateDeckVisibility();

            subscribeToEvents();

            if (components == null)
            {
                components = new Container();
            }

            components.Add(_deckEditorSubsystem);
            components.Add(_countInputSubsystem);
            components.Add(_formZoom);
            components.Add(_copyPaste);

            _popupSearchExamples.MenuControl   = _menuSearchExamples;
            _popupSearchExamples.MenuAlignment = HorizontalAlignment.Right;
        }