示例#1
0
        public void MoveFormHistoryToEnd(FormRoot form)
        {
            var idBeforeClosing = GetId(form);

            FsPath tempDir = AppDir.History.Join("temp");

            if (tempDir.IsDirectory())
            {
                tempDir.DeleteDirectory(recursive: true);
            }

            AppDir.History.Join(idBeforeClosing.ToString()).MoveDirectoryTo(tempDir);

            int lastId = _instances.Count - 1;

            for (int i = idBeforeClosing + 1; i <= lastId; i++)
            {
                AppDir.History.Join(i.ToString()).MoveDirectoryTo(AppDir.History.Join((i - 1).ToString()));
            }

            tempDir.MoveDirectoryTo(AppDir.History.Join(lastId.ToString()));

            _instances.RemoveAt(idBeforeClosing);
            _instances.Add(form);
        }
示例#2
0
        public void MoveFormHistoryToEnd(FormRoot form)
        {
            var idBeforeClosing = GetId(form);

            var tempDir = AppDir.History.AddPath("temp");

            if (Directory.Exists(tempDir))
            {
                Directory.Delete(tempDir, recursive: true);
            }

            Directory.Move(AppDir.History.AddPath(idBeforeClosing.ToString()), tempDir);

            int lastId = _instances.Count - 1;

            for (int i = idBeforeClosing + 1; i <= lastId; i++)
            {
                Directory.Move(AppDir.History.AddPath(i.ToString()), AppDir.History.AddPath((i - 1).ToString()));
            }

            Directory.Move(tempDir, AppDir.History.AddPath(lastId.ToString()));

            _instances.RemoveAt(idBeforeClosing);
            _instances.Add(form);
        }
示例#3
0
        public void Remove(FormRoot form)
        {
            _instances.Remove(form);

            if (_instances.Count == 0)
            {
                ExitThread();
            }
        }
示例#4
0
        public void StopForm(FormRoot form)
        {
            _log.Info($"{nameof(StopForm)}");

            _instances.Remove(form);

            if (_instances.Count == 0)
            {
                ExitThread();
            }
        }
示例#5
0
        public int GetId(FormRoot form)
        {
            int result = _instances.IndexOf(form);

            if (result == -1)
            {
                return(_instances.Count);
            }

            return(result);
        }
示例#6
0
        public void SetFormRoot(FormRoot formRoot)
        {
            if (formRoot == _formRoot)
            {
                return;
            }

            if (_formRoot != null)
            {
                _searchSubsystem.UnsubscribeSuggestModelEvents();

                _searchSubsystem.TextApplied -= searchSubsystemStringApplied;
                _searchSubsystem.TextChanged -= searchSubsystemStringChanged;

                _formRoot.UiModel.LanguageController.LanguageChanged -= languageChanged;
                _formRoot.TooltipController.UnsetTooltips(this);
                _formRoot.QuickFilterTooltipController.UnsetTooltips(this);
            }

            _formRoot = formRoot;

            if (formRoot != null)
            {
                _searchSubsystem.Ui                    =
                    _deckEditorSubsystem.Ui            =
                        _countInputSubsystem.Ui        =
                            _imagePreloading.Ui        =
                                _printing.Ui           =
                                    _dragging.Ui       =
                                        _drawing.Ui    =
                                            _fields.Ui = _formRoot.UiModel;

                _searchSubsystem.SuggestModel = _formRoot.CardSuggestModel;

                _deckListControl.SetUi(_formRoot.TooltipController, _formRoot.DeckSuggestModel);

                _searchSubsystem.SubscribeSuggestModelEvents();

                _searchSubsystem.TextApplied += searchSubsystemStringApplied;
                _searchSubsystem.TextChanged += searchSubsystemStringChanged;

                _formRoot.UiModel.LanguageController.LanguageChanged += languageChanged;

                setupTooltips(_formRoot.TooltipController, _formRoot.QuickFilterTooltipController);

                _formRoot.TooltipController.SubscribeToEvents();
                _formRoot.QuickFilterTooltipController.SubscribeToEvents();

                // calls cardCreating handler
                _viewCards.ResetLayout();
                _viewDeck.ResetLayout();
            }
        }
示例#7
0
        private void takeTabFromAnotherForm(FormRoot tabDraggingForm, int draggedIndex)
        {
            var dragSourceTabs = tabDraggingForm._tabs;

            dragSourceTabs.AbortDrag();
            dragSourceTabs.Capture = false;

            var formMain = tabDraggingForm.GetTab(draggedIndex);

            // implicit connection: move_tab_between_forms
            dragSourceTabs.TabIds[draggedIndex] = null;
            tabDraggingForm._panelClient.Controls.Remove(formMain);

            dragSourceTabs.RemoveTab(draggedIndex);

            _app.MoveTabHistory(Id, TabsCount, tabDraggingForm.Id, draggedIndex);

            addTab(formMain);

            _tabs.Capture = true;
            _tabs.BeginDrag(TabsCount - 1);
        }