Exemplo n.º 1
0
        /* H A N D L E  C O N T E X T  O P E N I N G */

        /*----------------------------------------------------------------------------
        *       %%Function: HandleContextOpening
        *       %%Qualified: AzLog.AzLogWindow.HandleContextOpening
        *       %%Contact: rlittle
        *
        *   This is going to get executed every time they go to open a context menu.
        *   We want to know *where* they are invoking from, so we do some clever
        *   hacker in HeaderSup.ColumnHeaderFromContextOpening(...) -- it figures out
        *   (based on the client rects of the column header items) where they are
        *   clicking and which column header is appropriate.
        *
        *   NOTE: IF it locates a ColumnHeader and returns it to you, then
        *   ColumnHeaderFromContextOpeneing CANCELS the context menu operation
        *   from here from happening and assumes you are going to invoke the context
        *   menu yourself (which is why we conly call m_ctxmHeader.Show() when
        *   we get a columnheader back - this allows us to show our ContextMenu
        *   for our Header columns instead of the context menu for the rest of the
        *   listview)
        *
        *   ALSO NOTE that we squirrel away the matched columnheader into the first
        *   menu item in the context menu -- in our case, that's the
        *   "Remove this column" menu item, so it follows that it needs to know
        *   what "this" column is.  (Other routings may choose to look here for this
        *   information, so let's make sure to clear the Tag in times when we aren't
        *   matched...)
        *  ----------------------------------------------------------------------------*/
        private void HandleContextOpening(object sender, CancelEventArgs e)
        {
            if (m_hs == null)
            {
                m_hs = new HeaderSupp();
            }

            ColumnHeader ch = m_hs.ColumnHeaderFromContextOpening(m_lvLog, sender, e);

            if (ch != null)
            {
                m_ctxmHeader.Tag           = ch;
                m_ctxmHeader.Items[0].Text = "Remove column " + ch.Text;
                m_ctxmHeader.Show(Control.MousePosition);
            }
            else
            {
                // we aren't in the column headers. now customize our context menu
                Point        ptLocal = m_lvLog.PointToClient(Cursor.Position);
                ListViewItem lvi     = m_lvLog.GetItemAt(ptLocal.X, ptLocal.Y);
                AzLogEntry   azle    = (AzLogEntry)lvi.Tag;

                ch = TCore.ListViewSupp.HeaderSupp.ColumnFromPoint(m_lvLog, ptLocal.X);
                AzLogViewSettings.AzLogViewColumn azlvc = m_azlvs.AzlvcFromName((string)ch.Tag);
                ContextMenuContext cmc = new ContextMenuContext();
                cmc.azle = azle;
                cmc.lc   = azlvc.DataColumn;
                m_ctxmListViewLog.Items[0].Tag  = cmc;
                m_ctxmListViewLog.Items[0].Text = String.Format("Filter to this {0}", ch.Text);
                m_ctxmListViewLog.Items[1].Tag  = cmc;
                m_ctxmListViewLog.Items[1].Text = String.Format("Filter out this {0}", ch.Text);
                m_ctxmListViewLog.Items[2].Tag  = cmc;
                m_ctxmListViewLog.Items[2].Text = String.Format("Color this {0}", ch.Text);
            }
        }
Exemplo n.º 2
0
        /* H A N D L E  C O N T E X T  O P E N I N G */
        /*----------------------------------------------------------------------------
            %%Function: HandleContextOpening
            %%Qualified: AzLog.AzLogWindow.HandleContextOpening
            %%Contact: rlittle

            This is going to get executed every time they go to open a context menu.
            We want to know *where* they are invoking from, so we do some clever
            hacker in HeaderSup.ColumnHeaderFromContextOpening(...) -- it figures out
            (based on the client rects of the column header items) where they are
            clicking and which column header is appropriate.

            NOTE: IF it locates a ColumnHeader and returns it to you, then
            ColumnHeaderFromContextOpeneing CANCELS the context menu operation
            from here from happening and assumes you are going to invoke the context
            menu yourself (which is why we conly call m_ctxmHeader.Show() when
            we get a columnheader back - this allows us to show our ContextMenu
            for our Header columns instead of the context menu for the rest of the
            listview)

            ALSO NOTE that we squirrel away the matched columnheader into the first
            menu item in the context menu -- in our case, that's the
            "Remove this column" menu item, so it follows that it needs to know
            what "this" column is.  (Other routings may choose to look here for this
            information, so let's make sure to clear the Tag in times when we aren't
            matched...)
        ----------------------------------------------------------------------------*/
        private void HandleContextOpening(object sender, CancelEventArgs e)
        {
            if (m_hs == null)
                m_hs = new HeaderSupp();

            ColumnHeader ch = m_hs.ColumnHeaderFromContextOpening(m_lvLog, sender, e);

            if (ch != null)
                {
                m_ctxmHeader.Tag = ch;
                m_ctxmHeader.Items[0].Text = "Remove column " + ch.Text;
                m_ctxmHeader.Show(Control.MousePosition);
                }
            else
                {
                // we aren't in the collumn headers. now customize our context menu
                Point ptLocal = m_lvLog.PointToClient(Cursor.Position);
                ListViewItem lvi = m_lvLog.GetItemAt(ptLocal.X, ptLocal.Y);
                AzLogEntry azle = (AzLogEntry) lvi.Tag;

                ch = TCore.ListViewSupp.HeaderSupp.ColumnFromPoint(m_lvLog, ptLocal.X);
                AzLogViewSettings.AzLogViewColumn azlvc = m_azlvs.AzlvcFromName((string)ch.Tag);
                ContextMenuContext cmc = new ContextMenuContext();
                cmc.azle = azle;
                cmc.lc = azlvc.DataColumn;
                m_ctxmListViewLog.Items[0].Tag = cmc;
                m_ctxmListViewLog.Items[0].Text = String.Format("Filter to this {0}", ch.Text);
                }
        }