private void btnCreate_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
        {
            Dashboard dashboard = new Dashboard();
            DashboardObjectDataSource dataSource = new DashboardObjectDataSource();

            dashboard.BeginUpdate();
            dashboard.DataSources.Add(dataSource);

            dashboard.Items.Add(DashboardItemGenerator.GenerateCardItem(dataSource, "card1"));
            dashboard.Items.Add(DashboardItemGenerator.GenerateGridItem(dataSource, "grid1"));
            dashboard.Items.Add(DashboardItemGenerator.GeneratePieItem(dataSource, "pie1"));
            dashboard.Items.Add(DashboardItemGenerator.GenerateListBoxItem(dataSource, "list1"));

            TabContainerDashboardItem tabContainer = new TabContainerDashboardItem();

            tabContainer.TabPages.Add(new DashboardTabPage()
            {
                Name = "Tab Page One", ComponentName = "page1"
            });
            tabContainer.TabPages["page1"].AddRange(dashboard.Items["grid1"], dashboard.Items["pie1"]);

            DashboardTabPage secondTabPage = tabContainer.CreateTabPage();

            secondTabPage.Name = "Tab Page Two";
            secondTabPage.Add(dashboard.Items["list1"]);
            secondTabPage.ShowItemAsTabPage = true;

            dashboard.Items.Add(tabContainer);

            dashboard.DataLoading += Dashboard_DataLoading;

            dashboard.EndUpdate();

            dashboardControl.Dashboard = dashboard;
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            Dashboard dashboard = new Dashboard();
            DashboardObjectDataSource dataSource = new DashboardObjectDataSource(DataGenerator.GenerateTestData());

            dashboard.DataSources.Add(dataSource);

            dashboard.Items.Add(DashboardItemGenerator.GenerateCardItem(dataSource, "card1"));
            dashboard.Items.Add(DashboardItemGenerator.GenerateGridItem(dataSource, "grid1"));
            dashboard.Items.Add(DashboardItemGenerator.GeneratePieItem(dataSource, "pie1"));
            dashboard.Items.Add(DashboardItemGenerator.GenerateListBoxItem(dataSource, "list1"));

            TabContainerDashboardItem tabContainer = new TabContainerDashboardItem();

            tabContainer.ComponentName = "tabContainer1";
            tabContainer.TabPages.Add(new DashboardTabPage()
            {
                Name = "Tab Page One", ComponentName = "page1"
            });
            tabContainer.TabPages["page1"].AddRange(dashboard.Items["grid1"], dashboard.Items["pie1"]);

            DashboardTabPage secondTabPage = tabContainer.CreateTabPage();

            secondTabPage.Name = "Tab Page Two";
            secondTabPage.Add(dashboard.Items["list1"]);
            secondTabPage.ShowItemAsTabPage = true;

            dashboard.Items.Add(tabContainer);

            dashboard.RebuildLayout();
            // Adjust the dashboard layout.
            dashboard.LayoutRoot.FindRecursive(dashboard.Items["grid1"]).Weight = 40;
            dashboard.LayoutRoot.FindRecursive(dashboard.Items["pie1"]).Weight  = 60;
            DashboardLayoutGroup rootGroup = dashboard.LayoutRoot.ChildNodes[0] as DashboardLayoutGroup;

            rootGroup.Orientation = DashboardLayoutGroupOrientation.Horizontal;

            dashboardViewer1.Dashboard = dashboard;

            btnModify.Enabled         = true;
            toggleSwitchTimer.Enabled = true;
        }
Пример #3
0
 void UpdateTabContainer()
 {
     TabContainer = TargetDashboard.Items.FirstOrDefault(item => item is TabContainerDashboardItem) as TabContainerDashboardItem;
     if (TabContainer == null)
     {
         CreateTabContainer();
         DashboardLayoutTabContainer layoutTabContainer = new DashboardLayoutTabContainer(TabContainer, 1);
         if (ItemsAndGroups.Count() > 0)
         {
             DashboardTabPage tabPage = TabContainer.CreateTabPage();
             tabPage.Name = TargetDashboard.Title.Text;
             DashboardLayoutTabPage layoutPage = new DashboardLayoutTabPage(tabPage);
             layoutTabContainer.ChildNodes.Add(layoutPage);
             MoveRootToTabPage(layoutPage);
             SetParentContainer(tabPage);
         }
         TargetDashboard.LayoutRoot = new DashboardLayoutGroup();
         TargetDashboard.LayoutRoot.ChildNodes.Add(layoutTabContainer);
     }
 }
        private void btnModify_Click(object sender, EventArgs e)
        {
            Dashboard dashboard = dashboardViewer1.Dashboard;

            // Move the card1 item to a tab page containing the list1 item.
            dashboard.Items["card1"].ParentContainer = dashboard.Items["list1"].ParentContainer;
            // Reorder tab pages.
            TabContainerDashboardItem tabContainer = dashboard.Items["tabContainer1"] as TabContainerDashboardItem;
            DashboardTabPage          tabPage      = tabContainer.TabPages[0];

            tabContainer.TabPages.Remove(tabPage);
            tabContainer.TabPages.Insert(1, tabPage);

            dashboard.Items.ForEach(delegate(DashboardItem item)
            {
                if (item is PieDashboardItem)
                {
                    ((PieDashboardItem)item).PieType = PieType.Donut;
                }
            });
        }
Пример #5
0
        public static void MergeLayout(DashboardLayoutGroup layoutRoot, string newPageName, DashboardMerger dashboardMerger)
        {
            TabContainerDashboardItem tabContainer             = dashboardMerger.TabContainer;
            Dashboard originalDashboard                        = dashboardMerger.OriginalDashboard;
            IDictionary <string, string> dashboardItemNamesMap = dashboardMerger.DashboardItemNamesMap;
            IDictionary <string, string> groupNamesMap         = dashboardMerger.GroupNamesMap;
            IEnumerable <DashboardItem>  newItems              = dashboardMerger.NewItems;
            DashboardTabPage             newTabPage            = tabContainer.CreateTabPage();
            DashboardLayoutTabPage       layoutPage            = new DashboardLayoutTabPage(newTabPage);

            foreach (DashboardLayoutNode node in layoutRoot.GetNodesRecursive())
            {
                if (node.DashboardItem != null)
                {
                    DashboardItemGroup group = node.DashboardItem as DashboardItemGroup;
                    if (group != null)
                    {
                        string groupComponentName    = group.ComponentName;
                        string newGroupComponentName = String.Empty;
                        if (!groupNamesMap.TryGetValue(group.ComponentName, out newGroupComponentName))
                        {
                            newGroupComponentName = group.ComponentName;
                        }
                        node.DashboardItem = newItems.Single(itm => itm.ComponentName == newGroupComponentName);
                    }
                    else
                    {
                        DashboardItem item        = node.DashboardItem;
                        string        newItemName = String.Empty;
                        if (!dashboardItemNamesMap.TryGetValue(item.ComponentName, out newItemName))
                        {
                            newItemName = item.ComponentName;
                        }
                        node.DashboardItem = newItems.Single(itm => itm.ComponentName == newItemName);
                    }
                }
            }
            layoutPage.ChildNodes.Add(layoutRoot);
            foreach (DashboardItem item in newItems)
            {
                if (item.ParentContainer == null)
                {
                    item.ParentContainer = newTabPage;
                }
                else
                {
                    IDashboardItemContainer container = item.ParentContainer;
                    if (container is DashboardItemGroup)
                    {
                        string newGroupName = String.Empty;
                        if (!groupNamesMap.TryGetValue(container.ComponentName, out newGroupName))
                        {
                            newGroupName = container.ComponentName;
                        }
                        item.ParentContainer = originalDashboard.Groups[newGroupName];
                    }
                    else
                    {
                        item.ParentContainer = newTabPage;
                    }
                }
            }
            DashboardLayoutTabContainer layoutTabContainer = originalDashboard.LayoutRoot.FindRecursive(tabContainer);

            layoutTabContainer.ChildNodes.Add(layoutPage);
            newTabPage.Name = newPageName;
        }