コード例 #1
0
ファイル: MainForm.cs プロジェクト: aaana/rfid
        /// <summary>
        /// Initialize DockPanel according to DockPanel.config or Default Settings in AppConfig
        /// </summary>
        private void InitializeDockPanel()
        {
            _readerSettingsForm = new ReaderSettingsForm(this);
            _tagTableForm       = new TagTableForm();
            _rssiGraphForm      = new RSSIGraphFrom();
            _phaseGraphForm     = new PhaseGraphForm();
            _vitalSignsForm     = new VitalSignsForm(this);

            _sortingBooksForm = new SortingBooksForm();
            _linearGuideForm  = new LinearGuideForm();
            _updateEpcForm    = new UpdateEpcForm();
            _searchRegionForm = new SearchRegionForm();

            _simulationForm = new SimulationForm(this, _linearGuideForm);

            if (File.Exists(Path.Combine(_filepath, "DockPanel.config")))
            {
                // If DockPanel.config exists, load forms dynamicly
                this.dockPanelMain.LoadFromXml(Path.Combine(_filepath, "DockPanel.config"), delegate(string persistString)
                {
                    if (persistString == typeof(ReaderSettingsForm).ToString())
                    {
                        return(_readerSettingsForm);
                    }

                    if (persistString == typeof(UpdateEpcForm).ToString())
                    {
                        return(_updateEpcForm);
                    }

                    if (persistString == typeof(TagTableForm).ToString())
                    {
                        return(_tagTableForm);
                    }

                    if (persistString == typeof(RSSIGraphFrom).ToString())
                    {
                        return(_rssiGraphForm);
                    }

                    if (persistString == typeof(PhaseGraphForm).ToString())
                    {
                        return(_phaseGraphForm);
                    }

                    if (persistString == typeof(SearchRegionForm).ToString())
                    {
                        return(_searchRegionForm);
                    }

                    if (persistString == typeof(SimulationForm).ToString())
                    {
                        return(_simulationForm);
                    }

                    if (persistString == typeof(LinearGuideForm).ToString())
                    {
                        return(_linearGuideForm);
                    }

                    if (persistString == typeof(SortingBooksForm).ToString())
                    {
                        return(_sortingBooksForm);
                    }

                    if (persistString == typeof(VitalSignsForm).ToString())
                    {
                        return(_vitalSignsForm);
                    }

                    // Undefined forms
                    return(null);
                });

                // Record original DockState
                if (_readerSettingsForm.DockState != DockState.Unknown && _readerSettingsForm.DockState != DockState.Hidden)
                {
                    AppConfig.readerSettingsDockState = _readerSettingsForm.DockState;
                }

                if (_tagTableForm.DockState != DockState.Unknown && _tagTableForm.DockState != DockState.Hidden)
                {
                    AppConfig.tagTableDockState = _tagTableForm.DockState;
                }

                if (_vitalSignsForm.DockState != DockState.Unknown && _vitalSignsForm.DockState != DockState.Hidden)
                {
                    AppConfig.vitalSignsDockState = _vitalSignsForm.DockState;
                }

                if (_rssiGraphForm.DockState != DockState.Unknown && _rssiGraphForm.DockState != DockState.Hidden)
                {
                    AppConfig.rssiGraphDockState = _rssiGraphForm.DockState;
                }

                if (_phaseGraphForm.DockState != DockState.Unknown && _phaseGraphForm.DockState != DockState.Hidden)
                {
                    AppConfig.phaseGraphDockState = _phaseGraphForm.DockState;
                }

                if (_searchRegionForm.DockState != DockState.Unknown && _searchRegionForm.DockState != DockState.Hidden)
                {
                    AppConfig.searchRegionDockState = _searchRegionForm.DockState;
                }

                if (_updateEpcForm.DockState != DockState.Unknown && _updateEpcForm.DockState != DockState.Hidden)
                {
                    AppConfig.updateEpcDockState = _updateEpcForm.DockState;
                }

                if (_simulationForm.DockState != DockState.Unknown && _simulationForm.DockState != DockState.Hidden)
                {
                    AppConfig.simulationDockState = _simulationForm.DockState;
                }

                if (_linearGuideForm.DockState != DockState.Unknown && _linearGuideForm.DockState != DockState.Hidden)
                {
                    AppConfig.linearGuideDockState = _linearGuideForm.DockState;
                }

                if (_sortingBooksForm.DockState != DockState.Unknown && _sortingBooksForm.DockState != DockState.Hidden)
                {
                    AppConfig.sortingBooksDockState = _sortingBooksForm.DockState;
                }
            }
            else
            {
                // If DockPanel.config does not exists, load forms according to AppConfig
                _readerSettingsForm = new ReaderSettingsForm(this);
                _readerSettingsForm.Show(this.dockPanelMain, AppConfig.readerSettingsDockState);

                _tagTableForm = new TagTableForm();
                _tagTableForm.Show(this.dockPanelMain, AppConfig.tagTableDockState);
            }
        }