Пример #1
0
        void ViewModel_SelectedModuleTypeChanged(object sender, System.EventArgs e)
        {
            RibbonForm mainForm = modulesPanel.FindForm() as RibbonForm;

            if (mainForm != null)
            {
                mainForm.Ribbon.UnMergeRibbon();
                if (mainForm.Ribbon.StatusBar != null)
                {
                    mainForm.Ribbon.StatusBar.UnMergeStatusBar();
                }
            }
            modulesPanel.Controls.Clear();
            Control module = ViewModel.GetModule(ViewModel.SelectedModuleType) as Control;

            if (module != null)
            {
                module.Dock = DockStyle.Fill;
                modulesPanel.Controls.Add(module);
            }
            if (mainForm != null)
            {
                IRibbonModule ribbonModule = module as IRibbonModule;
                if (ribbonModule != null)
                {
                    mainForm.Ribbon.MergeRibbon(ribbonModule.Ribbon);
                    if (mainForm.Ribbon.StatusBar != null)
                    {
                        mainForm.Ribbon.StatusBar.MergeStatusBar(ribbonModule.Ribbon.StatusBar);
                    }
                }
            }
        }