Пример #1
0
 public ImagePreloadingSubsystem(MtgLayoutView layoutViewCards, MtgLayoutView layoutViewDeck, ScrollSubsystem scrollSubsystem, ImageCacheConfig imageCacheConfig)
 {
     _layoutViewCards    = layoutViewCards;
     _layoutViewDeck     = layoutViewDeck;
     _scrollSubsystem    = scrollSubsystem;
     _imageCacheCapacity = imageCacheConfig.GetCacheCapacity();
 }
Пример #2
0
        public DeckEditorUi(
            MtgLayoutView layoutViewCards,
            MtgLayoutView layoutViewDeck,
            DeckEditorModel deckEditorModel,
            CollectionEditorModel collectionModel,
            DraggingSubsystem draggingSubsystem,
            Cursor cursor,
            FormZoom formZoom,
            Control parent)
        {
            _layoutViewCards   = layoutViewCards;
            _layoutViewDeck    = layoutViewDeck;
            _cursor            = cursor;
            _deckEditorModel   = deckEditorModel;
            _collectionModel   = collectionModel;
            _draggingSubsystem = draggingSubsystem;
            _draggingSubsystem.DraggedLikeClick += draggedLikeClick;
            _draggingSubsystem.DragRemoved      += dragRemoved;
            _draggingSubsystem.DragAdded        += dragAdded;
            _layoutViewCards.SelectionStarted   += selectionStarted;

            _formZoom = formZoom;
            _parent   = parent;

            var hotSpot = Size.Empty.ByDpi();

            _zoomCursor = CursorHelper.CreateCursor(Resources.zoom_48.HalfResizeDpi(), hotSpot);

            var iBeamIcon    = Resources.text_selection_24.ResizeDpi();
            var iBeamHotSpot = new Size(iBeamIcon.Width / 2, iBeamIcon.Height / 2);

            _textSelectionCursor = CursorHelper.CreateCursor(iBeamIcon, iBeamHotSpot);
        }
Пример #3
0
        private List <Card> getCardsToPreview(MtgLayoutView view)
        {
            var pageSize = _scrollSubsystem.GetPageSize(view);

            int visibleRecordIndex = view.VisibleRecordIndex;

            var cardsToPreloadImage = new List <Card>();

            bool endReached   = false;
            bool startReached = false;
            int  i            = 0;

            while (true)
            {
                if (startReached && endReached)
                {
                    break;
                }

                if (cardsToPreloadImage.Count > _imageCacheCapacity - pageSize)
                {
                    break;
                }

                startReached = startReached || !preload(cardsToPreloadImage, view, visibleRecordIndex - i - 1);
                endReached   = endReached || !preload(cardsToPreloadImage, view, visibleRecordIndex + pageSize + i);

                i++;
            }

            return(cardsToPreloadImage);
        }
Пример #4
0
        private static int getIndexInView(Card card, MtgLayoutView view)
        {
            var handle = view.FindRow(card);
            var index  = view.GetVisibleIndex(handle);

            return(index);
        }
Пример #5
0
 public ScrollSubsystem(
     MtgLayoutView layoutViewDeck,
     MtgLayoutView layoutViewCards)
 {
     _layoutViewDeck  = layoutViewDeck;
     _layoutViewCards = layoutViewCards;
 }
Пример #6
0
        public int GetPageSize(MtgLayoutView view)
        {
            var visibleColumnsCount = getVisibleColumnsCount(view);
            var visibleRowsCount    = getVisibleRowsCount(view);

            return(visibleColumnsCount * visibleRowsCount);
        }
Пример #7
0
        public DrawingSubsystem(
            MtgLayoutView layoutViewCards,
            MtgLayoutView layoutViewDeck,
            DraggingSubsystem draggingSubsystem,
            CardSearchSubsystem cardSearchSubsystem,
            CardDocumentAdapter adapter,
            DeckEditorModel deckEditorModel,
            QuickFilterFacade quickFilterFacade,
            LegalitySubsystem legalitySubsystem,
            ImageLoader imageLoader,
            IconRecognizer iconRecognizer)
        {
            _layoutViewCards   = layoutViewCards;
            _layoutViewDeck    = layoutViewDeck;
            _draggingSubsystem = draggingSubsystem;
            _deckEditorModel   = deckEditorModel;
            _quickFilterFacade = quickFilterFacade;
            _legalitySubsystem = legalitySubsystem;
            _imageLoader       = imageLoader;

            _layoutViewCards.RowDataLoaded += setHighlightMatches;
            _layoutViewCards.SetIconRecognizer(iconRecognizer);

            _highlightSubsystem = new SearchResultHighlighter(
                cardSearchSubsystem,
                adapter,
                new KeywordHighlighter());
        }
Пример #8
0
        public CardSearchSubsystem(
            Form parent,
            RichTextBox findEditor,
            Panel panelSearchIcon,
            ListBox listBoxSuggest,
            CardSearcher searcher,
            CardDocumentAdapter adapter,
            MtgLayoutView viewCards,
            MtgLayoutView viewDeck)
        {
            _parent          = parent;
            _findEditor      = findEditor;
            _panelSearchIcon = panelSearchIcon;

            _listBoxSuggest = listBoxSuggest;

            _searcher  = searcher;
            _adapter   = adapter;
            _viewCards = viewCards;
            _viewDeck  = viewDeck;

            _listBoxSuggest.Visible = false;
            _listBoxSuggest.Height  = 0;

            _highligter = new SearchStringHighlighter(_findEditor);
            _highligter.Highlight();
        }
Пример #9
0
        private static HitInfo getHitInfo(MtgLayoutView view, Point position)
        {
            var clientLocation = view.Control.PointToClient(position);
            var hitInfo        = view.CalcHitInfo(clientLocation);

            return(hitInfo);
        }
Пример #10
0
 private static int getVisibleRowsCount(MtgLayoutView view)
 {
     return(getVisibleCount(
                view.Control.Height,
                view.CardMinSize.Height,
                view.CardVertInterval,
                view.PartialCardSize.Height,
                view.AllowPartialCards));
 }
Пример #11
0
 private static int getVisibleColumnsCount(MtgLayoutView view)
 {
     return(getVisibleCount(
                view.Control.Width - view.ScrollWidth,
                view.CardMinSize.Width,
                view.CardHorzInterval,
                view.PartialCardSize.Width,
                view.AllowPartialCards));
 }
Пример #12
0
        public SortSubsystem(MtgLayoutView layoutViewCards, CardRepository repository, Fields fields, CardSearchSubsystem cardSearchSubsystem)
        {
            _fields = fields;
            _cardSearchSubsystem = cardSearchSubsystem;
            _layoutViewCards     = layoutViewCards;
            _repository          = repository;

            ApplySort(string.Empty);
        }
Пример #13
0
 public ImagePreloadingSubsystem(
     MtgLayoutView layoutViewCards,
     MtgLayoutView layoutViewDeck,
     ScrollSubsystem scrollSubsystem,
     UiConfigRepository uiConfigRepository)
 {
     _layoutViewCards    = layoutViewCards;
     _layoutViewDeck     = layoutViewDeck;
     _scrollSubsystem    = scrollSubsystem;
     _uiConfigRepository = uiConfigRepository;
 }
Пример #14
0
        private static Card getCard(MtgLayoutView view, HitInfo hitInfo)
        {
            if (!hitInfo.IsOverImage() && hitInfo.CustomButtonIndex < 0)
            {
                return(null);
            }

            var card = (Card)view.GetRow(hitInfo.RowHandle);

            return(card);
        }
Пример #15
0
        private Card getCardBelowDragged(MtgLayoutView view)
        {
            var hitInfo = getHitInfo(view, Cursor.Position);

            if (hitInfo.IsOverImage())
            {
                return((Card)_layoutViewDeck.FindRow(hitInfo.RowHandle));
            }

            return(null);
        }
Пример #16
0
 public DraggingSubsystem(
     MtgLayoutView layoutViewDeck,
     MtgLayoutView layoutViewCards,
     DeckEditorModel deckEditorModel,
     FormMain parent,
     ImageLoader imageLoader,
     FormManager formManager)
 {
     _layoutViewDeck  = layoutViewDeck;
     _layoutViewCards = layoutViewCards;
     _deckEditorModel = deckEditorModel;
     _parent          = parent;
     _imageLoader     = imageLoader;
     _formManager     = formManager;
 }
Пример #17
0
 public DraggingSubsystem(
     MtgLayoutView layoutViewDeck,
     MtgLayoutView layoutViewCards,
     DeckEditorModel deckEditorModel,
     FormMain parent,
     ImageLoader imageLoader,
     Application application)
 {
     _layoutViewDeck  = layoutViewDeck;
     _layoutViewCards = layoutViewCards;
     _deckEditorModel = deckEditorModel;
     _parent          = parent;
     _imageLoader     = imageLoader;
     _application     = application;
 }
Пример #18
0
        public void DragBegin(Card card, MtgLayoutView dragFromView)
        {
            dragFromView.Control.Capture = false;
            _cardMouseDown = card;
            _dragFromView  = dragFromView;

            _dragStartedTime = DateTime.Now;

            _deckEditorModel.DragStart(card, fromDeck: dragFromView == _layoutViewDeck);

            createDragCursor(card);
            updateCursor();

            // Потому что появилась отметка на карте, которую мы тащим
            _layoutViewCards.InvalidateCard(card);
            _layoutViewDeck.InvalidateCard(card);
        }
Пример #19
0
        public void DragBegin(Card card, MtgLayoutView dragFromView)
        {
            dragFromView.Control.Capture = false;
            _cardMouseDown = card;
            _dragFromView  = dragFromView;

            _dragStartedTime = DateTime.Now;

            _deckEditorModel.DragStart(card, fromDeck: dragFromView == _layoutViewDeck);

            createDragCursor(card);
            updateCursor();

            // Because the card we are dragging received a mark
            _layoutViewCards.InvalidateCard(card);
            _layoutViewDeck.InvalidateCard(card);
        }
Пример #20
0
        private static bool preload(List <Card> cardsToPreloadImage, MtgLayoutView view, int i)
        {
            if (i < 0 || i >= view.RowCount)
            {
                return(false);
            }

            int handle = view.GetVisibleRowHandle(i);
            var card   = (Card)view.GetRow(handle);

            if (card == null)
            {
                return(false);
            }

            cardsToPreloadImage.Add(card);
            return(true);
        }
Пример #21
0
        public void EnsureCardVisibility(Card card, MtgLayoutView view)
        {
            var index = getIndexInView(card, view);

            if (index < 0)
            {
                return;
            }

            var visibleCardsCount = GetPageSize(view);

            if (index >= view.VisibleRecordIndex && index < view.VisibleRecordIndex + visibleCardsCount)
            {
                return;
            }

            var screenIndex = index / visibleCardsCount;

            view.VisibleRecordIndex = Math.Min(view.RowCount - visibleCardsCount, screenIndex * visibleCardsCount);
        }
Пример #22
0
        public Card GetCard(MtgLayoutView view, int rowHandle)
        {
            if (view == _layoutViewCards)
            {
                return((Card)view.FindRow(rowHandle));
            }

            if (view != _layoutViewDeck)
            {
                throw new ArgumentOutOfRangeException();
            }

            int visibleIndex = view.GetVisibleIndex(rowHandle);

            if (visibleIndex < 0)
            {
                return(null);
            }

            return(_deckEditorModel.GetVisibleCards()[visibleIndex]);
        }
Пример #23
0
        public FormMain(
            CardRepository cardRepo,
            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;

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

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

            _cardRepo            = cardRepo;
            _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);

            _cardSearch = new CardSearchSubsystem(
                this,
                _searchBar,
                cardSearcher,
                cardAdapter,
                _layoutViewCards,
                _layoutViewDeck);

            _cardSort = new CardSortSubsystem(_layoutViewCards, _cardRepo, _fields, _cardSearch);

            endRestoreSettings();

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

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

            _scroll = new ScrollSubsystem(_viewDeck, _viewCards);

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

            _deckEditor = new DeckEditorModel();

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

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

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

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

            _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;

            _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,
                                  this);

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

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

            subscribeToEvents();

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

            components.Add(_deckEditorSubsystem);

            _popupSearchExamples.MenuControl   = _menuSearchExamples;
            _popupSearchExamples.MenuAlignment = HorizontalAlignment.Right;
        }
Пример #24
0
        private void updateCardBelowDragged(MtgLayoutView view)
        {
            var card = getCardBelowDragged(view) ?? _deckEditorModel.CardBelowDragged;

            setCardBelowDragged(card);
        }