Esempio n. 1
0
        /// <summary>
        /// Handles the RequestTreeItems event of the grid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param>
        static void grid_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args)
        {
            GridTreeControl gridTree = sender as GridTreeControl;

            //code showing how to use LoadAllAtStartUp property....
            if (gridTree.InternalGrid.LoadAllAtStartUp && args.ParentItem == null)
            {
                //need to load all the GridNodes into g.Nodes....
                IEnumerable <EmployeeInfo> rootNodes = viewModel.GetReportees(-1);
                foreach (EmployeeInfo e in rootNodes)
                {
                    gridTree.InternalGrid.RootNodes.Add(Populate(gridTree, e, null, 0, null));
                }
                return;
            }

            if (args.ParentItem == null)
            {
                //get the root list - get all employees who have no boss
                args.ChildList = viewModel.GetReportees(-1); //get all employees whose boss's id is -1 (no boss)
            }
            else
            {   //get the children of the parent object
                EmployeeInfo emp = args.ParentItem as EmployeeInfo;
                if (emp != null)
                {
                    //get all employees that report to the parent employee
                    args.ChildList = viewModel.GetReportees(emp.ID);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called when [execute apply style].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteApplyStyle(object sender, ExecutedRoutedEventArgs args)
        {
            CheckBox        checkbox = args.Parameter as CheckBox;
            GridTreeControl treeGrid = sender as GridTreeControl;

            if (checkbox.IsChecked.Value)
            {
                //set some miscellaneous level colors so they are easily seen (just set up to 6 levels...
                byte k  = 150; // 100;// 250;
                byte k1 = 250; // 125;
                for (int i = -1; i < 7; ++i)
                {
                    GridStyleInfo style = new GridStyleInfo();
                    style.Background = new SolidColorBrush(Color.FromArgb(255, 239, k1, k));
                    treeGrid.LevelStyles.Add(style);
                    k  += 15;
                    k1 -= 15;
                }
            }
            else
            {
                treeGrid.LevelStyles.Clear();
            }
            treeGrid.InternalGrid.InvalidateCells();
        }
Esempio n. 3
0
        private static void OnExport(object sender, ExecutedRoutedEventArgs args)
        {
            GridTreeControl treeGrid = args.Source as GridTreeControl;

            treeGrid.ExportToExcel("GridTreeContent.xls", Syncfusion.XlsIO.ExcelVersion.Excel97to2003);
            Process.Start("GridTreeContent.xls");
        }
Esempio n. 4
0
        /// <summary>
        /// Displays the employee tree.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="layout">The layout.</param>
        private static void DisplayEmployeeTree(GridTreeControl grid, LayoutControl layout)
        {
            DateTime start = DateTime.Now;

            AssignLookUpType();
            int count;

            if (!int.TryParse(viewModel.EmployeeCount, out count))
            {
                count = 500;
            }
            viewModel.PopulateWithSampleData(count);
            InitEmployeeTreeGrid(grid);
            grid.SupportRowSizing  = false;
            grid.RequestTreeItems += new GridTreeRequestTreeItemsHandler(grid_RequestTreeItems);
            grid.ModelLoaded      += (s, e) =>
            {
                grid.InternalGrid.QueryCellInfo  += new GridQueryCellInfoEventHandler(InternalGrid_QueryCellInfo);
                grid.InternalGrid.ExpandGlyphType = GridTreeExpandGlyph.PlusMinus;
                grid.VisualStyle = VisualStyle.Office14Blue;
            };
            grid.AllowAutoSizingNodeColumn = false;
            grid.Populate();
            viewModel.LoadingTime   = string.Format("elapsed time: {0:0.0000} secs", DateTime.Now.Subtract(start).TotalSeconds);
            grid.SupportRowSizing   = true;
            grid.EnableHotRowMarker = true;
            if (viewModel.UseColumnsIsChecked)
            {
                grid.Columns.Clear();
                SetUpColumnsCollection(grid);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Called when [execute serialize].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteLoadTree(object sender, ExecutedRoutedEventArgs args)
        {
            var             layout = args.Parameter as LayoutControl;
            GridTreeControl GTC    = layout.GridView as GridTreeControl;

            viewModel = GTC.DataContext as ViewModel;
            DisplayEmployeeTree(GTC, layout);
        }
Esempio n. 6
0
        /// <summary>
        /// Called when [execute de serialize].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteDeSerialize(object sender, ExecutedRoutedEventArgs args)
        {
            GridTreeControl GTC = args.Source as GridTreeControl;

            GTC.InternalGrid.CurrentCell.Deactivate();
            GTC.InternalGrid.Deserialize(LayoutControl.FindFile("Default.xml"));
            GTC.ExpandAllNodes();
        }
Esempio n. 7
0
        /// <summary>
        /// <summary>
        /// Called when [execute load new changes].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteLoadNewChanges(object sender, ExecutedRoutedEventArgs args)
        {
            GridTreeControl GTC = args.Source as GridTreeControl;

            GTC.InternalGrid.CurrentCell.Deactivate();
            GTC.InternalGrid.Deserialize("newChanges.xml");
            GTC.ExpandAllNodes();
        }
Esempio n. 8
0
        /// <summary>
        /// Called when [execute expand all].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteExpandAll(object sender, ExecutedRoutedEventArgs args)
        {
            DateTime        start = DateTime.Now;
            GridTreeControl GTC   = args.Source as GridTreeControl;

            GTC.ExpandAllNodes();
            (GTC.DataContext as ViewModel).ExpandTime   = string.Format("Expanded time: {0:0.0000} secs", DateTime.Now.Subtract(start).TotalSeconds);
            (GTC.DataContext as ViewModel).CollapseTime = string.Empty;
        }
Esempio n. 9
0
        private static void OnExecutePrint(object sender, ExecutedRoutedEventArgs args)
        {
            ScalingOptions option = ScalingOptions.NoScaling;

            if (args.Parameter != null)
            {
                option = GetScaling(args.Parameter.ToString());
            }

            GridTreeControl dataGrid = args.Source as GridTreeControl;

            dataGrid.Model.ActiveGridView.ScalingOptions = option;
            dataGrid.Print();
        }
Esempio n. 10
0
        /// <summary>
        /// Populates the specified g.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="e">The e.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="level">The level.</param>
        /// <param name="parentNode">The parent node.</param>
        /// <returns></returns>
        private static GridTreeNode Populate(GridTreeControl g, EmployeeInfo e, EmployeeInfo parent, int level, GridTreeNode parentNode)
        {
            GridTreeNode node = new GridTreeNode(level, e, true, parentNode);

            g.InternalGrid.Nodes.Add(node);
            node.ParentItem = parent;
            IEnumerable <EmployeeInfo> childNodes = viewModel.GetReportees(e.ID);
            bool hasChildren = false;

            foreach (EmployeeInfo e1 in childNodes)
            {
                Populate(g, e1, e, level + 1, node);
                hasChildren = true;
            }
            node.HasChildNodes = hasChildren;
            return(null);
        }
Esempio n. 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColumnChooserBehavior"/> class.
        /// </summary>
        public ColumnChooserBehavior()
            : base((s, e) =>
        {
            GridTreeControl treeGrid = Application.Current.MainWindow.FindName("treeGrid") as GridTreeControl;
            var visibleColumns       = treeGrid.Columns;
            var totalVisibleColumns  = new ObservableCollection <GridTreeColumn>(treeGrid.InternalGrid.GetVisibleColumns());
            ObservableCollection <ColumnChooserItems> totalColumns = GetColumnsDetails(totalVisibleColumns, visibleColumns);
            ColumnChooserViewModel viewModel      = new ColumnChooserViewModel(totalColumns);
            ColumnChooserWindow ColumnChooserView = new ColumnChooserWindow(viewModel);
            ColumnChooserView.Owner = Application.Current.MainWindow;

            if ((bool)ColumnChooserView.ShowDialog())
            {
                ClickOKButton(viewModel.ColumnCollection, treeGrid);
            }
            return(null);
        })
        { }
Esempio n. 12
0
        /// <summary>
        /// Sets up columns collection.
        /// </summary>
        /// <param name="grid">The grid.</param>
        private static void SetUpColumnsCollection(GridTreeControl grid)
        {
            //need to specify the columns you want to see in the grid as well as their order
            GridTreeColumn tc = new GridTreeColumn("FirstName", "First Name", 100);

            grid.Columns.Add(tc); //0
            tc = new GridTreeColumn("LastName", "Last Name", 100);
            tc.PercentWidth = 1;
            grid.Columns.Add(tc);
            tc = new GridTreeColumn("Department", "Department", 100);
            tc.PercentWidth = 1;
            grid.Columns.Add(tc); //3
            tc = new GridTreeColumn("Salary", "Salary", 80);
            tc.StyleInfo.HorizontalAlignment = HorizontalAlignment.Right;
            tc.PercentWidth            = 1;
            tc.StyleInfo.CellValueType = typeof(double);
            tc.StyleInfo.Format        = "0,000";
            grid.Columns.Add(tc); //4
        }
Esempio n. 13
0
        /// <summary>
        /// Called when [execute check box selection].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteCheckBoxSelection(object sender, ExecutedRoutedEventArgs args)
        {
            GridTreeControl GTC      = sender as GridTreeControl;
            CheckBox        checkbox = args.Parameter as CheckBox;

            if (GTC == null)
            {
                return;
            }
            GTC.SelectedNodes.Clear();
            GTC.EnableNodeSelection = checkbox.IsChecked.Value;
            if (!(bool)checkbox.IsChecked)
            {   //reset standard selection support as desired.
                GTC.Model.Options.AllowSelection       = GridSelectionFlags.Any;
                GTC.Model.Options.ListBoxSelectionMode = GridSelectionMode.None;
            }
            else
            {   //clear any standard selections...
                GTC.Model.SelectedRanges.Clear();
            }
            GTC.InternalGrid.UnloadArrangedCells();
        }
Esempio n. 14
0
        /// <summary>
        /// Inits the employee tree grid.
        /// </summary>
        /// <param name="grid">The grid.</param>
        private static void InitEmployeeTreeGrid(GridTreeControl grid)
        {
            //specify other miscellaneous properties
            grid.SupportRowSizing = true;
            grid.ShowRowHeader    = false;
            grid.ColumnHeaderStyle.HorizontalAlignment = HorizontalAlignment.Center;
            grid.ShowExpandColumnBorders = true;
            grid.AllowSort        = true;// false;
            grid.AllowDragColumns = true;
            Byte          k  = 150;
            Byte          k1 = 250;
            int           i  = -1;
            GridStyleInfo style;

            while (i < 6)
            {
                style = new GridStyleInfo();
                grid.LevelStyles.Add(style);
                k  += 15;
                k1 -= 15;
                i++;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Called when [execute serialize].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteSerialize(object sender, ExecutedRoutedEventArgs args)
        {
            GridTreeControl GTC = args.Source as GridTreeControl;

            GTC.InternalGrid.Serialize("newChanges.xml");
        }
Esempio n. 16
0
        /// <summary>
        /// Called when [execute collapse all].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnExecuteCollapseAll(object sender, ExecutedRoutedEventArgs args)
        {
            GridTreeControl GTC = args.Source as GridTreeControl;

            GTC.CollapseAllNodes();
        }
Esempio n. 17
0
 /// <summary>
 /// Clicks the OK button.
 /// </summary>
 /// <param name="ColumnCollection">The column collection.</param>
 /// <param name="treeGrid">The tree grid.</param>
 public static void ClickOKButton(ObservableCollection <ColumnChooserItems> ColumnCollection, GridTreeControl treeGrid)
 {
     foreach (var item in ColumnCollection)
     {
         var isFound = treeGrid.Columns.FirstOrDefault(v => v.MappingName == item.Name) != null;
         if (!isFound)
         {
             if (item.IsChecked == true)
             {
                 treeGrid.Columns.Add(new GridTreeColumn()
                 {
                     MappingName = item.Name, StyleInfo = new GridStyleInfo()
                 });
             }
         }
         else
         {
             if (item.IsChecked == false)
             {
                 var column = treeGrid.Columns.Where(c => c.MappingName == item.Name).FirstOrDefault();
                 treeGrid.Columns.Remove(column);
             }
         }
     }
     treeGrid.InternalGrid.PopulateGridNodes(false, true);
     treeGrid.InternalGrid.InvalidateCells();
 }