Beispiel #1
0
 public CopyPasteSubsystem(
     CardRepository cardRepo,
     DeckSerializationSubsystem serialization,
     CollectionEditorModel collection,
     DeckEditorModel deckEditor,
     FormMain targetForm,
     DeckListControl deckListControl,
     params Control[] targetControls)
 {
     _cardRepo        = cardRepo;
     _serialization   = serialization;
     _collection      = collection;
     _deckEditor      = deckEditor;
     _targetForm      = targetForm;
     _deckListControl = deckListControl;
     _targetControls  = targetControls;
 }
Beispiel #2
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();
        }
Beispiel #3
0
        public FormRoot(Func <FormMain> formMainFactory,
                        DownloaderSubsystem downloaderSubsystem,
                        NewsService newsService,
                        CardSuggestModel cardSuggestModel,
                        DeckSuggestModel deckSuggestModel,
                        [Named(GuiModule.DefaultTooltipScope)] TooltipController tooltipController,
                        [Named(GuiModule.QuickFilterTooltipScope)] TooltipController quickFilterTooltipController,
                        CardRepository repo,
                        DeckSerializationSubsystem serialization,
                        UiModel uiModel,
                        ColorSchemeEditor colorSchemeEditor,
                        App app,
                        AppSourceConfig appSourceConfig,
                        UiConfigRepository uiConfigRepository)
            : this()
        {
            TooltipController            = tooltipController;
            QuickFilterTooltipController = quickFilterTooltipController;

            UiModel = uiModel;

            DeckSuggestModel = deckSuggestModel;

            CardSuggestModel    = cardSuggestModel;
            CardSuggestModel.Ui = UiModel;

            _app                = app;
            _appSourceConfig    = appSourceConfig;
            _uiConfigRepository = uiConfigRepository;
            _repo               = repo;
            _serialization      = serialization;
            _colorSchemeEditor  = colorSchemeEditor;

            _formMainFactory     = formMainFactory;
            _downloaderSubsystem = downloaderSubsystem;
            _newsService         = newsService;

            KeyPreview      = true;
            PreviewKeyDown += previewKeyDown;
            KeyDown        += formKeyDown;

            QueryHandleDrag += queryHandleDrag;
            Load            += load;
            Closed          += closed;

            _tabs.AllowDrop              = true;
            _tabs.TabAdded              += tabCreated;
            _tabs.TabRemoving           += tabClosing;
            _tabs.TabRemoved            += tabClosed;
            _tabs.SelectedIndexChanging += selectedTabChanging;
            _tabs.SelectedIndexChanged  += selectedTabChanged;
            _tabs.DragOver              += tabsDragOver;

            _tabs.MouseEnter += tabMouseEnter;
            _tabs.MouseEnter += tabMouseLeave;
            _tabs.MouseMove  += tabMouseMove;

            MessageFilter.Instance.GlobalMouseMove += globalMouseMove;
            FormClosing += formClosing;

            _newsService.NewsFetched   += newsFetched;
            _newsService.NewsDisplayed += newsDisplayed;
            _downloaderSubsystem.ProgressCalculated += downloaderProgressCalculated;

            setupExternalLinks();
            setupButtonClicks();
            setupLanguageMenu();

            setupTooltips();

            foreach (var button in _deckButtons)
            {
                button.Enabled = false;
            }

            Text = $"Mtgdb.Gui v{AppDir.GetVersion()}";

            scale();
            updateFormBorderColor();
            ColorSchemeController.SystemColorsChanging += updateFormBorderColor;

            _menuColors.BackColor = SystemColors.Control;
            _menuColors.ForeColor = SystemColors.ControlText;

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

            components.Add(new UiConfigMenuSubsystem(
                               _menuUiScale,
                               _menuUiSmallImageQuality,
                               _menuUiSuggestDownloadMissingImages,
                               _menuUiImagesCacheCapacity,
                               _menuUiUndoDepth,
                               _menuUiApplySearchBar,
                               _checkboxAllPanels,
                               _checkboxTopPanel, _checkboxRightPanel, _checkboxSearchBar, _repo, uiConfigRepository));

            _dropdownOpenDeck.BeforeShow    = () => setMenuMode(_dropdownOpenDeck);
            _dropdownSaveDeck.BeforeShow    = () => setMenuMode(_dropdownSaveDeck);
            _dropdownColorScheme.BeforeShow = updateMenuColors;

            _ctsLifetime = new CancellationTokenSource();
            _ctsLifetime.Token.When(_repo.IsLoadingComplete).Run(repositoryLoaded);
        }
        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;
        }
Beispiel #5
0
        public FormRoot(Func <FormMain> formMainFactory,
                        DownloaderSubsystem downloaderSubsystem,
                        NewsService newsService,
                        CardSuggestModel cardSuggestModel,
                        DeckSuggestModel deckSuggestModel,
                        TooltipController tooltipController,
                        CardRepository repo,
                        DeckSerializationSubsystem serialization,
                        UiModel uiModel,
                        Application application)
            : this()
        {
            TooltipController = tooltipController;
            UiModel           = uiModel;

            DeckSuggestModel = deckSuggestModel;

            CardSuggestModel    = cardSuggestModel;
            CardSuggestModel.Ui = UiModel;

            _application         = application;
            _repo                = repo;
            _serialization       = serialization;
            _buttonSubsystem     = new ButtonSubsystem();
            _formMainFactory     = formMainFactory;
            _downloaderSubsystem = downloaderSubsystem;
            _newsService         = newsService;

            KeyPreview      = true;
            PreviewKeyDown += previewKeyDown;
            KeyDown        += formKeyDown;

            _repo.LoadingComplete += repositoryLoaded;

            QueryHandleDrag += queryHandleDrag;
            Load            += load;
            Closed          += closed;

            _tabs.AllowDrop              = true;
            _tabs.AddNewTabsToTheLeft    = true;
            _tabs.TabAdded              += tabCreated;
            _tabs.TabRemoving           += tabClosing;
            _tabs.TabRemoved            += tabClosed;
            _tabs.SelectedIndexChanging += selectedTabChanging;
            _tabs.SelectedIndexChanged  += selectedTabChanged;
            _tabs.DragOver              += tabsDragOver;
            _tabs.MouseMove             += tabMouseMove;

            FormClosing += formClosing;

            _newsService.NewsFetched   += newsFetched;
            _newsService.NewsDisplayed += newsDisplayed;
            _downloaderSubsystem.ProgressCalculated += downloaderProgressCalculated;

            setupButtons();

            setupExternalLinks();
            setupButtonClicks();
            setupLanguageMenu();
            setupTooltips();

            if (!DesignMode)
            {
                SnapTo(Direction.North, default(Point));
            }

            foreach (var button in _deckButtons)
            {
                button.Enabled = false;
            }

            Text = $"Mtgdb.Gui v{AppDir.GetVersion()}";

            WindowState = FormWindowState.Minimized;
        }