/* A D D H E A D E R */ /*---------------------------------------------------------------------------- * %%Function: AddHeader * %%Qualified: AzLog.AzLogWindow.AddHeader * %%Contact: rlittle * * Add the named header to the view. This handles adding the column * and invalidating the current view so it will get rebuild with the * correct list view items. * ----------------------------------------------------------------------------*/ private void AddHeader(AzLogViewSettings.DefaultColumnDef dcd, string sColumnInsertBefore) { lock (SyncLock) { int iazlvcInsert = m_azlvs.IazlvcFind(sColumnInsertBefore); int iazlvc = m_azlvs.IazlvcFind(dcd.sName); if (iazlvc == -1) { // we are adding this column m_azlvs.AddLogViewColumn(dcd.sName, dcd.sName, dcd.nWidthDefault, dcd.lc, true); iazlvc = m_azlvs.IazlvcFind(dcd.sName); } else { m_azlvs.ShowHideColumn(dcd.sName, true); } m_azlvs.MoveColumn(iazlvc, iazlvcInsert); int c = m_lvLog.VirtualListSize; SetupListViewForView(m_azlvs); m_azlv.BumpGeneration(); m_lvLog.SetVirtualListSize(c); // m_lvLog.VirtualListSize = c; } DirtyView(true); }
/* H A N D L E S E L E C T H E A D E R I T E M */ /*---------------------------------------------------------------------------- * %%Function: HandleSelectHeaderItem * %%Qualified: AzLog.AzLogWindow.HandleSelectHeaderItem * %%Contact: rlittle * * Deal with selecting an item on the header context menu. * ----------------------------------------------------------------------------*/ private void HandleSelectHeaderItem(object sender, EventArgs e) { // first, figure out what column they right clicked on (this is useful if they are asking // to show a column -- this will tell us where to insert the column before) // this information is squirrelled away in the Tag of the context menu ColumnHeader ch = (ColumnHeader)m_ctxmHeader.Tag; // are we removing or checking? ToolStripMenuItem tsmi = (ToolStripMenuItem)sender; AzLogViewSettings.DefaultColumnDef dcd = (AzLogViewSettings.DefaultColumnDef)tsmi.Tag; if (tsmi.Checked) { // we are removing a column tsmi.Checked = false; RemoveHeader(dcd.sName); } else { tsmi.Checked = true; AddHeader(dcd, (string)ch.Tag); } }