protected override void EnsureTreeRendererPresent(TreeListView.TreeRenderer renderer) { if (showAutomaticTreeRenderer) { base.EnsureTreeRendererPresent(renderer); } }
private void comboBoxExpanders_SelectedIndexChanged(object sender, EventArgs e) { TreeListView.TreeRenderer treeColumnRenderer = this.treeListView.TreeColumnRenderer; ComboBox cb = (ComboBox)sender; switch (cb.SelectedIndex) { case 0: treeColumnRenderer.IsShowGlyphs = false; break; case 1: treeColumnRenderer.IsShowGlyphs = true; treeColumnRenderer.UseTriangles = false; break; case 2: treeColumnRenderer.IsShowGlyphs = true; treeColumnRenderer.UseTriangles = true; break; } // Cause a redraw so that the changes to the renderer take effect this.treeListView.Refresh(); }
private void SetupView() { TreeListView.TreeRenderer treeColumnRenderer = m_treeListView1.TreeColumnRenderer; //treeColumnRenderer.IsShowGlyphs = true; //treeColumnRenderer.UseTriangles = true; //********************************************************************* m_treeListView1.UseTranslucentHotItem = true; //********************************************************************* m_treeListView1.FullRowSelect = true; }
private void InitializeTreeListView() { this.treeListView.CanExpandGetter = delegate(object x) { WarningSign warningSign = x as WarningSign; if (x == null) { return(false); } return(warningSign.Warnings.Count > 0); }; this.treeListView.ChildrenGetter = delegate(object x) { WarningSign warningSign = x as WarningSign; if (warningSign == null) { return(new ArrayList()); } return(new ArrayList(warningSign.Warnings)); }; this.treeListView.CheckBoxes = false; TreeListView.TreeRenderer treeRenderer = this.treeListView.TreeColumnRenderer as TreeListView.TreeRenderer; treeRenderer.IsShowLines = false; this.treeColumnIcon.ImageGetter = delegate(object x) { WarningSign warningSign = x as WarningSign; if (String.IsNullOrEmpty(warningSign.Message)) { return(0); } else { return(1); } }; this.treeColumnName.AspectGetter = delegate(object x) { WarningSign warningSign = x as WarningSign; if (String.IsNullOrEmpty(warningSign.Message)) { return(warningSign.Name); } else { return(warningSign.Message); } }; }
protected override void InitializeTab() { // Setup the controls on the tab // On other tabs, we add "Vista" hot item style. But that only works when NOT in // owner draw mode, and TreeListViews *requires* OwnerDraw. So we can't use Vista style hot item // with TreeListView, so we don't give the option this.comboBoxHotItemStyle.SelectedIndex = 0; // None this.treeListView.HierarchicalCheckboxes = this.checkBoxHierarchicalCheckboxes.Checked; this.comboBoxExpanders.SelectedIndex = 2; // triangles SetupColumns(); SetupDragAndDrop(); SetupTree(); // You can change the way the connection lines are drawn by changing the pen TreeListView.TreeRenderer renderer = this.treeListView.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Firebrick, 0.5f); renderer.LinePen.DashStyle = DashStyle.Dot; }
protected override void InitializeTab() { // 设置选中的行用边框 高显 Coordinator.ChangeHotItemStyle(this.ListView, 2); //HotItemStyle hotItemStyle = new HotItemStyle(); //hotItemStyle.ForeColor = Color.AliceBlue; //hotItemStyle.BackColor = Color.FromArgb(255, 64, 64, 64); //this.ListView.HotItemStyle = hotItemStyle; // Setup the controls on the tab // On other tabs, we add "Vista" hot item style. But that only works when NOT in // owner draw mode, and TreeListViews *requires* OwnerDraw. So we can't use Vista style hot item // with TreeListView, so we don't give the option //this.comboBoxHotItemStyle.SelectedIndex = 0; // None this.treeListView.HierarchicalCheckboxes = this.checkBoxHierarchicalCheckboxes.Checked; //this.comboBoxExpanders.SelectedIndex = 2; // triangles SetupColumns(); //SetupDragAndDrop(); //SetupTree(); // You can change the way the connection lines are drawn by changing the pen TreeListView.TreeRenderer renderer = this.treeListView.TreeColumnRenderer; renderer.IsShowGlyphs = true; renderer.UseTriangles = false; renderer.LinePen = new Pen(Color.Firebrick, 0.5f); renderer.LinePen.DashStyle = DashStyle.Dot; }
private void SetupMasterTree() { this.treeListView.CanExpandGetter = (x) => { return(((MasterTreeNode)x).Children.Count > 0); }; this.treeListView.ChildrenGetter = (x) => { return(((MasterTreeNode)x).Children); }; this.olvColumn1.ImageGetter = (x) => { if (((MasterTreeNode)x).Type == NodeType.HostComputer) { return(imageList1.Images[1]); } else if (((MasterTreeNode)x).Type == NodeType.VirtualMachines) { return(imageList1.Images[2]); } else if (((MasterTreeNode)x).Type == NodeType.VirtualHardDisks) { return(imageList1.Images[3]); } else if (((MasterTreeNode)x).Type == NodeType.OrphanedVirtualHardDisks) { return(imageList1.Images[4]); } return(imageList1.Images[0]); }; this.treeListView.UseCellFormatEvents = true; this.treeListView.FormatCell += (o, e) => { if (e.ColumnIndex == this.olvColumn1.Index) { MasterTreeNode node = (MasterTreeNode)e.Model; if (node.VmType?.Value == VirtualMachineType.BASE) { e.SubItem.Font = new Font(e.SubItem.Font, FontStyle.Bold); } else if (node.VmType?.Value == VirtualMachineType.TEMPLATE) { e.SubItem.Font = new Font(e.SubItem.Font, FontStyle.Italic); } else if (node.VmType?.Value == VirtualMachineType.NONE) { e.SubItem.ForeColor = Color.Gray; } } }; this.treeListView.Roots = databaseManager.Directory.Values; // TODO: High DPI Awareness TreeListView.TreeRenderer renderer = this.treeListView.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Firebrick, 0.5f); renderer.LinePen.DashStyle = DashStyle.Dot; renderer.IsShowGlyphs = true; renderer.UseTriangles = true; //TreeListView.TreeRenderer.PIXELS_PER_LEVEL = 13; renderer.CellPadding = new Rectangle(0, 2, 0, 0); renderer.IsShowLines = false; this.treeListView.Refresh(); }
private void InitTree() { TreeListView.TreeRenderer renderer = this.treeListView1.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Firebrick, 0.5f); renderer.LinePen.DashStyle = DashStyle.Dot; treeListView1.FullRowSelect = true; Code.Services.LeadService service = new Code.Services.LeadService(); var list = service.GetTreeLeadList("浙江"); CreateColums(treeListView1); treeListView1.RowHeight = 50; // We just want to get the children of the given directory. // This becomes a little complicated when we can't (for whatever reason). We need to report the error // to the user, but we can't just call MessageBox.Show() directly, since that would stall the UI thread // leaving the tree in a potentially undefined state (not good). We also don't want to keep trying to // get the contents of the given directory if the tree is refreshed. To get around the first problem, // we immediately return an empty list of children and use BeginInvoke to show the MessageBox at the // earliest opportunity. We get around the second problem by collapsing the branch again, so it's children // will not be fetched when the tree is refreshed. The user could still explicitly unroll it again -- // that's their problem :) treeListView1.IsSimpleDragSource = true; treeListView1.IsSimpleDropSink = true; //treeListView1.DragSource = new SimpleDragSource(); //this.treeListView1.DropSink = new RearrangingDropSink(true); treeListView1.ModelCanDrop += delegate(object sender, ModelDropEventArgs e) { e.Effect = DragDropEffects.None; if (e.TargetModel == null) { return; } if (e.TargetModel is Code.Services.LeadModel) { e.Effect = e.StandardDropActionFromKeys; } else { e.InfoMessage = "Can only drop on directories"; } }; treeListView1.ModelDropped += delegate(object sender, ModelDropEventArgs e) { MessageBox.Show(e.DropTargetItem.Text); // treeListView1.UpdateVirtualListSize(); }; this.treeListView1.CanExpandGetter = delegate(object x) { return(((Code.Services.LeadModel)x).HasChild); }; this.treeListView1.ChildrenGetter = delegate(object x) { try { return(((Code.Services.LeadModel)x).GetChildLead(list)); } catch (UnauthorizedAccessException ex) { this.BeginInvoke((MethodInvoker) delegate() { this.treeListView1.Collapse(x); MessageBox.Show(this, ex.Message, "ObjectListViewDemo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }); return(new ArrayList()); } }; // Once those two delegates are in place, the TreeListView starts working // after setting the Roots property. // List all drives as the roots of the tree ArrayList roots = new ArrayList(); Code.Services.LeadModel model = new Code.Services.LeadModel(); model.AName = "浙江"; model.ID = 0; model.Level = 1; roots.Add(model); this.treeListView1.Roots = roots; //this.treeListView1.u }
private void IntializeTreeViewChartOfAccounts() { //Retrive data accounts and balances if (cbBranches.SelectedItem != null && cbCurrencies.SelectedItem != null) { List <Account> accounts = ServicesProvider.GetInstance().GetChartOfAccountsServices().FindAllAccounts(); foreach (Account account in accounts) { account.Balance = ServicesProvider.GetInstance().GetAccountingServices().GetAccountBalance(account.Id, ((Currency) cbCurrencies. SelectedItem).Id, _contractId, _mode, 1, ((Branch) cbBranches. SelectedItem). Id); account.CurrencyCode = ((Currency)cbCurrencies.SelectedItem).Code; } List <AccountCategory> accountCategories = ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectAccountCategories(); ///////////////////////////////////////////////////////////////////////////////////////// tlvBalances.CanExpandGetter = delegate(object o) { Account account = (Account)o; if (account.Id == -1) { return(true); } return (accounts.FirstOrDefault( item => item.ParentAccountId == account.Id) != null); }; tlvBalances.ChildrenGetter = delegate(object o) { Account account = (Account)o; if (account.Id == -1) { return (accounts.Where( item => item.AccountCategory == account.AccountCategory && item.ParentAccountId == null)); } return(accounts.Where(item => item.ParentAccountId == account.Id)); }; tlvBalances.RowFormatter = delegate(OLVListItem o) { Account account = (Account)o.RowObject; if (account.Id == -1) { o.ForeColor = Color.FromArgb(0, 88, 56); o.Font = new Font("Arial", 9, FontStyle.Bold); } }; TreeListView.TreeRenderer renderer = tlvBalances.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Gray, 0.5f); renderer.LinePen.DashStyle = DashStyle.Dot; List <Account> list = new List <Account>(); foreach (AccountCategory accountCategory in accountCategories) { string name = MultiLanguageStrings.GetString(Ressource.ChartOfAccountsForm, accountCategory.Name + ".Text"); name = name ?? accountCategory.Name; Account account = new Account { Number = name, Balance = ServicesProvider.GetInstance().GetAccountingServices(). GetAccountCategoryBalance(accountCategory.Id, ((Currency)cbCurrencies.SelectedItem).Id, _contractId, _mode), AccountCategory = (OAccountCategories)accountCategory.Id, CurrencyCode = ((Currency)cbCurrencies.SelectedItem).Code, Id = -1 }; list.Add(account); } olvColumnLACBalance.AspectToStringConverter = delegate(object value) { if (value.ToString().Length > 0) { OCurrency amount = (OCurrency)value; return(amount.GetFormatedValue(true)); } return(null); }; tlvBalances.Roots = list; tlvBalances.ExpandAll(); } }
private void IntializeTreeViewChartOfAccounts(List <Booking> bookings) { Currency currency = ServicesProvider.GetInstance().GetCurrencyServices().GetPivot(); List <Account> accounts = ServicesProvider.GetInstance().GetAccountingServices().GetTrialBalance(TimeProvider.Now, TimeProvider.Now, currency.Id, currency.Id); if (accounts != null) { foreach (Account account in accounts) { OCurrency debit = bookings.Sum(item => item.DebitAccount.Number == account.Number ? item.Amount.Value : 0); OCurrency credit = bookings.Sum(item => item.CreditAccount.Number == account.Number ? item.Amount.Value : 0); account.CloseBalance = account.DebitPlus ? account.OpenBalance + debit - credit : account.OpenBalance + credit - debit; account.CurrencyCode = currency.Code; } List <AccountCategory> accountCategories = ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectAccountCategories(); ///////////////////////////////////////////////////////////////////////////////////////// tlvBalances.CanExpandGetter = delegate(object o) { Account account = (Account)o; if (account.Id == -1) { return(true); } return (accounts.FirstOrDefault( item => item.ParentAccountId == account.Id) != null); }; tlvBalances.ChildrenGetter = delegate(object o) { Account account = (Account)o; if (account.Id == -1) { return (accounts.Where( item => item.AccountCategory == account.AccountCategory && item.ParentAccountId == null)); } return(accounts.Where(item => item.ParentAccountId == account.Id)); }; tlvBalances.RowFormatter = delegate(OLVListItem o) { Account account = (Account)o.RowObject; if (account.Id == -1) { o.ForeColor = Color.FromArgb(0, 88, 56); o.Font = new Font("Arial", 9, FontStyle.Bold); } }; TreeListView.TreeRenderer renderer = tlvBalances.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Gray, 0.5f) { DashStyle = DashStyle.Dot }; List <Account> list = new List <Account>(); foreach (AccountCategory accountCategory in accountCategories) { string name = MultiLanguageStrings.GetString(Ressource.ChartOfAccountsForm, accountCategory.Name + ".Text"); name = name ?? accountCategory.Name; Account account = new Account { Number = name, Balance = 0, AccountCategory = (OAccountCategories)accountCategory.Id, CurrencyCode = "", Id = -1 }; list.Add(account); } olvColumn_CloseBalance.AspectToStringConverter = delegate(object value) { if (value.ToString().Length > 0) { OCurrency amount = (OCurrency)value; return(amount.GetFormatedValue(true)); } return(null); }; olvColumnLACBalance.AspectToStringConverter = delegate(object value) { if (value.ToString().Length > 0) { OCurrency amount = (OCurrency)value; return(amount.GetFormatedValue(true)); } return(null); }; tlvBalances.Roots = list; tlvBalances.ExpandAll(); } }
private void IntializeTreeViewChartOfAccounts() { List <Account> accounts = ServicesProvider.GetInstance().GetChartOfAccountsServices().FindAllAccounts(); List <AccountCategory> accountCategories = ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectAccountCategories(); tlvAccounts.CanExpandGetter = delegate(object o) { Account account = (Account)o; if (account.Id == -1) { return(true); } return(accounts.FirstOrDefault(item => item.ParentAccountId == account.Id) != null); }; tlvAccounts.ChildrenGetter = delegate(object o) { Account account = (Account)o; if (account.Id == -1) { return(accounts.Where(item => item.AccountCategory == account.AccountCategory && item.ParentAccountId == null)); } return(accounts.Where(item => item.ParentAccountId == account.Id)); }; tlvAccounts.RowFormatter = delegate(OLVListItem o) { Account account = (Account)o.RowObject; if (account.Id == -1) { o.ForeColor = Color.FromArgb(0, 88, 56); o.Font = new Font("Arial", 9); } }; TreeListView.TreeRenderer renderer = tlvAccounts.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Gray, 0.5f) { DashStyle = DashStyle.Dot }; List <Account> list = new List <Account>(); foreach (AccountCategory accountCategory in accountCategories) { string name = MultiLanguageStrings.GetString( Ressource.ChartOfAccountsForm, accountCategory.Name + ".Text"); name = name ?? accountCategory.Name; Account account = new Account { Number = name, AccountCategory = (OAccountCategories)accountCategory.Id, Id = -1 }; list.Add(account); } tlvAccounts.Roots = list; tlvAccounts.ExpandAll(); }
void InitializeTreeListExample() { this.treeListView.HierarchicalCheckboxes = true; this.treeListView.HideSelection = false; this.treeListView.CanExpandGetter = delegate(object x) { return(((MyFileSystemInfo)x).IsDirectory); }; this.treeListView.ChildrenGetter = delegate(object x) { MyFileSystemInfo myFileSystemInfo = (MyFileSystemInfo)x; try { return(myFileSystemInfo.GetFileSystemInfos()); } catch (UnauthorizedAccessException ex) { MessageBox.Show(this, ex.Message, "ObjectListViewDemo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(new ArrayList()); } }; // You can change the way the connection lines are drawn by changing the pen TreeListView.TreeRenderer renderer = this.treeListView.TreeColumnRenderer; renderer.LinePen = new Pen(Color.Firebrick, 0.5f); renderer.LinePen.DashStyle = DashStyle.Dot; //------------------------------------------------------------------- // Eveything after this is the same as the Explorer example tab -- // nothing specific to the TreeListView. It doesn't have the grouping // delegates, since TreeListViews can't show groups. // Draw the system icon next to the name SysImageListHelper helper = new SysImageListHelper(this.treeListView); this.colName.ImageGetter = delegate(object x) { return(helper.GetImageIndex(((MyFileSystemInfo)x).FullName)); }; // Show the size of files as GB, MB and KBs. Also, group them by // some meaningless divisions this.colSize.AspectGetter = delegate(object x) { MyFileSystemInfo myFileSystemInfo = (MyFileSystemInfo)x; if (myFileSystemInfo.IsDirectory) { return((long)-1); } try { return(myFileSystemInfo.Length); } catch (System.IO.FileNotFoundException) { // Mono 1.2.6 throws this for hidden files return((long)-2); } }; this.colSize.AspectToStringConverter = delegate(object x) { if ((long)x == -1) // folder { return(""); } return(FormatFileSize((long)x)); }; // Show the system description for this object this.colType.AspectGetter = delegate(object x) { return(ShellUtilities.GetFileType(((MyFileSystemInfo)x).FullName)); }; // Show the file attributes for this object this.colAttrs.AspectGetter = delegate(object x) { return(((MyFileSystemInfo)x).Attributes); }; FlagRenderer attributesRenderer = new FlagRenderer(); attributesRenderer.Add(FileAttributes.Archive, "archive"); attributesRenderer.Add(FileAttributes.ReadOnly, "readonly"); attributesRenderer.Add(FileAttributes.System, "system"); attributesRenderer.Add(FileAttributes.Hidden, "hidden"); attributesRenderer.Add(FileAttributes.Temporary, "temporary"); this.colAttrs.Renderer = attributesRenderer; this.colAttrs.ClusteringStrategy = new FlagClusteringStrategy(typeof(FileAttributes)); // List all drives as the roots of the tree ArrayList roots = new ArrayList(); foreach (DriveInfo di in DriveInfo.GetDrives()) { if (di.IsReady) { roots.Add(new MyFileSystemInfo(new DirectoryInfo(di.Name))); break; } } this.treeListView.Roots = roots; }