public FormTabEdit(ILifetimeScope scope) { _scope = scope; MainFormLogicManager logicManager = _scope.Resolve <MainFormLogicManager>(); var tabPageDataCollection = logicManager.GetTabPageDataCollection(); _listViewDataSource = tabPageDataCollection.Select(x => new DraggableListItem { Index = x.PageIndex, Label = x.TabPageLabel, PageData = x }).ToList(); InitializeComponent(); _tabPageCollectionStates = new TabPageCollectionStates(); _tabPageCollectionStates.SetInitialState(tabPageDataCollection); scope.CurrentScopeEnding += Scope_CurrentScopeEnding; }
public FormMain(AppSettingsService appSettingsService, ILifetimeScope scope, MainFormLogicManager logicManager, PasswordStorage passwordStorage) { if (DesignMode) { return; } _appSettingsService = appSettingsService; _scope = scope; _logicManager = logicManager; _passwordStorage = passwordStorage; _applicationState = new ApplicationState(); _licenseService = LicenseService.Instance; InitializeComponent(); logicManager.OnTabPageCollectionChange += LogicManager_OnTabPageCollectionChange; logicManager.OnActivePageIndexChange += LogicManager_OnActivePageIndexChange; }
//private void VerifyAndCorrectIndexing(TabPageDataCollection tabPageDataCollection) //{ // var pageIndexList = tabPageDataCollection.TabPageDictionary.Values.Select(x => x.PageIndex).ToList(); // bool incorrectPageIndexFound = pageIndexList.Any(i => i >= pageIndexList.Count) || tabPageDataCollection.TabPageDictionary.Any(x => x.Value.PageIndex != x.Key); // if (!incorrectPageIndexFound) return; // var tabPageDataList = tabPageDataCollection.TabPageDictionary.Values.ToList(); // tabPageDataCollection.TabPageDictionary.Clear(); // for (int i = 0; i < tabPageDataList.Count; i++) // { // tabPageDataList[i].PageIndex = i; // tabPageDataCollection.TabPageDictionary.Add(i, tabPageDataList[i]); // } // TabDataChanged = true; //} private void btnOk_Click(object sender, EventArgs e) { MainFormLogicManager logicManager = _scope.Resolve <MainFormLogicManager>(); //foreach (DraggableListItem draggableListItem in _listViewDataSource) //{ // int index = draggableListItem.Index; // _tabPageDataCollection.TabPageDictionary.Add(index, draggableListItem.PageData); // _ //} // set types of updates and sync the model db in response. //int lastIndex = _tabPageDataCollection.TabPageDictionary.Values.Max(x => x.PageIndex); //if (_tabPageDataCollection.ActiveTabIndex > lastIndex) // _tabPageDataCollection.ActiveTabIndex = lastIndex; DialogResult = DialogResult.OK; Close(); }