예제 #1
0
        private void SimpleButton1_Click(object sender, EventArgs e)
        {
            // 선택된 document가 없을 경우 추가
            for (int x = 0; x < documentManager1.View.Documents.Count; x++)
            {
                DevExpress.XtraBars.Docking2010.Views.BaseDocumentCollection ds = documentManager1.View.Documents;
                if (ds[x].Caption == "Yes3")
                {
                    Document document = documentManager1.View.Documents[x] as Document;
                    //tabbedView1.Controller.Activate(document);
                    //documentManager1.View.ActivateDocument(tabbedView1.ActiveDocument.Control);
                    //documentManager1.View.ActivateDocument(document.Control);
                    documentManager1.View.ActivateDocument(ds[x].Control);
                    return;
                }
            }

            dockPanel      = new DevExpress.XtraBars.Docking.DockPanel();
            dockPanel.Text = "Yes3";
            dockPanel.Controls.Add(new UserControl());
            documentManager1.View.AddDocument(dockPanel);
        }
예제 #2
0
        private void treeList1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                object mainTab = new object();

                // https://lambdaexp.tistory.com/19
                // https://m.blog.naver.com/delight_gruv/130071915177
                //string className = "F5074.DevExpressWinforms.MyForm.D_TileBar.MyTileBar03";
                string className = "";
                //string[] arrSplit = Regex.Split(resultList[0].MenuFullPath, "\r\n\r\n");
                //string arrSplit = Path.GetDirectoryName(resultList[2].MenuFullPath).Split(Path.DirectorySeparatorChar).Last();

                //for (int x = 0; x < resultList.Count; x++)
                //{
                //    if (resultList[x].AssemblyName == "F5074.DevExpressWinforms" && resultList[x].MenuFullPath.Contains(this.treeList1.FocusedValue.ToString()))
                //    {
                //        className = "F5074.DevExpressWinforms.MyForm." + resultList[x].ClassName + "." + resultList[x].MenuName;
                //        //assembly = Assembly.GetExecutingAssembly();
                //        assembly = Assembly.LoadFrom(programPath + "\\F5074.DevExpressWInforms.dll");

                //        break;
                //    }
                //    else if (resultList[x].AssemblyName == "F5074.Winforms" && resultList[x].MenuFullPath.Contains(this.treeList1.FocusedValue.ToString()))
                //    {
                //        className = "F5074.Winforms.MyForm." + resultList[x].ClassName + "." + resultList[x].MenuName;
                //        assembly = Assembly.LoadFrom(programPath + "\\F5074.WInforms.dll");
                //        break;
                //    }
                //}

                for (int x = 0; x < resultList.Count; x++)
                {
                    if (resultList[x].FullName.Contains("F5074.DevExpressWinforms") && resultList[x].Name.Contains(this.treeList1.FocusedValue.ToString()))
                    {
                        className = resultList[x].FullName;
                        //assembly = Assembly.GetExecutingAssembly();
                        assembly = Assembly.LoadFrom(programPath + "\\F5074.DevExpressWInforms.dll");
                        break;
                    }
                    else if (resultList[x].FullName.Contains("F5074.Winforms") && resultList[x].Name.Contains(this.treeList1.FocusedValue.ToString()))
                    {
                        className = resultList[x].FullName;
                        //assembly = Assembly.GetExecutingAssembly();
                        assembly = Assembly.LoadFrom(programPath + "\\F5074.WInforms.dll");
                        break;
                    }
                    else if (resultList[x].FullName.Contains("F5074.UI") && resultList[x].Name.Contains(this.treeList1.FocusedValue.ToString()))
                    {
                        className = resultList[x].FullName;
                        //assembly = Assembly.GetExecutingAssembly();
                        assembly = Assembly.LoadFrom(programPath + "\\F5074.UI.dll");
                        break;
                    }
                }

                // XtraTabControl 사용
                //Type t = assembly.GetType(className);
                //string classNamespace = t.Namespace;
                //Object obj = Activator.CreateInstance(t);
                //Control tabControl = obj as Control;
                //tabControl.Dock = DockStyle.Fill;
                //string tabName = this.treeList1.FocusedValue.ToString();
                //XtraTabPage tabPage = new XtraTabPage() { Name = tabName, Text = tabName };
                //tabPage.Controls.Add(tabControl);
                //xtraTabControl1.TabPages.Add(tabPage);
                //xtraTabControl1.SelectedTabPageIndex = xtraTabControl1.TabPages.Count - 1;



                // 선택된 document가 없을 경우 추가
                // https://www.devexpress.com/Support/Center/Question/Details/Q335155/how-to-programmatically-select-a-documentmanager-tab-without-focusing-it
                for (int x = 0; x < documentManager1.View.Documents.Count; x++)
                {
                    DevExpress.XtraBars.Docking2010.Views.BaseDocumentCollection ds = documentManager1.View.Documents;
                    if (ds[x].Caption == this.treeList1.FocusedValue.ToString())
                    {
                        Document document = documentManager1.View.Documents[x] as Document;
                        //tabbedView1.Controller.Activate(document);
                        //documentManager1.View.ActivateDocument(tabbedView1.ActiveDocument.Control);
                        //documentManager1.View.ActivateDocument(document.Control);
                        documentManager1.View.ActivateDocument(ds[x].Control);
                        return;
                    }
                }
                // DocumentManager 사용
                Type    t = assembly.GetType(className);
                string  classNamespace = t.Namespace;
                Object  obj            = Activator.CreateInstance(t);
                Control userControl    = obj as Control;
                userControl.Dock = DockStyle.Fill;
                string tabName = this.treeList1.FocusedValue.ToString();
                dockPanel = new DevExpress.XtraBars.Docking.DockPanel()
                {
                    Text = tabName
                };
                dockPanel.Controls.Add(userControl);
                documentManager1.View.AddDocument(dockPanel);
                //documentManager1.View.ActivateDocument(dockPanel);
                dockPanel.Select();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }