Пример #1
0
        }// ExecuteCommand(int, bool)

        static private int GetResultNum(CNode node, StringCollection scResults)
        {
            // See if we can bail on this really quickly
            if (scResults.Count == 0)
            {
                return(-1);
            }

            // Grab the columnresultview interface
            IColumnResultView crv = (IColumnResultView)node;

            int iNumRows = crv.getNumRows();

            // Let's start looking through the result items until we find the one we want
            for (int i = 0; i < iNumRows; i++)
            {
                // We have a good chance at a match
                int j;
                for (j = 0; j < scResults.Count; j++)
                {
                    String sResultString = crv.getValues(i, j);
                    if (!scResults[j].Equals(sResultString))
                    {
                        break;
                    }
                }
                if (j == scResults.Count)
                {
                    // We found our match!
                    return(i);
                }
            }
            // We couldn't find the item.
            return(-1);
        }// GetResultNum
Пример #2
0
        }// IgnoreCommandForHistory

        static internal void CommandExecuted(CDO cdo, int iMenuCommand)
        {
            // See if we actually care about this command
            if (IgnoreCommandForHistory(iMenuCommand))
            {
                return;
            }

            // If this is a command on a result item, but we don't have an
            // index number, then we can't create a shortcut for this item
            if (cdo.Data != null && !(cdo.Data is int))
            {
                return;
            }


            // Pull the data we need out of the CDO interface
            CNode node       = cdo.Node;
            int   iResultNum = cdo.Data == null?-1:(int)cdo.Data;

            // Let's build the string of what the user actually did
            String sAction = TranslateMenuCommandToString(node, iResultNum, iMenuCommand);

            if (sAction == null)
            {
                // We don't know how to represent this command as a string... let's bail
                return;
            }

            // IncrementCommand will return false if we don't know about this command.
            if (!IncrementCommand(sAction))
            {
                // We need to add this command
                CommandHistory ch = new CommandHistory();
                ch.scPathToNode = BuildPathToNode(cdo.Node);
                ch.iNumHits     = 3;
                ch.iMenuCommand = iMenuCommand;
                ch.sCommand     = sAction;

                // Let's get the result item name
                ch.scResultItem = new StringCollection();
                if (iResultNum != -1)
                {
                    // We're dealing with a result item here
                    IColumnResultView crv = (IColumnResultView)node;
                    int iNumCols          = crv.getNumColumns();

                    // iResultNum needs to be zero-based
                    for (int i = 0; i < iNumCols; i++)
                    {
                        ch.scResultItem.Add(crv.getValues(iResultNum - 1, i));
                    }
                }

                m_olCommands.Add(ch);
            }
        }// CommandExecuted
Пример #3
0
        }// GetDisplayInfo

        //-------------------------------------------------
        // GetResultDisplayInfo
        //
        // This function will provide MMC with information on how
        // to display data items in the result pane. This function
        // is used to get data both for a column view and a list view.
        //-------------------------------------------------
        internal void GetResultDisplayInfo(ref RESULTDATAITEM ResultDataItem)
        {
            IColumnResultView crv = null;

            // See if we have info to display a column-view result
            if (m_oResults is IColumnResultView)
            {
                crv = (IColumnResultView)m_oResults;
            }

            // If we need a display name
            if ((ResultDataItem.mask & RDI.STR) > 0)
            {
                // See if MMC is requesting an item for the column view
                if (crv != null && (ResultDataItem.lParam >> 16) > 0)
                {
                    ResultDataItem.str = Marshal.StringToCoTaskMemUni(crv.getValues((ResultDataItem.lParam >> 16) - 1, ResultDataItem.nCol));
                }
                // Nope, it's just looking for the display name for the node
                else
                {
                    ResultDataItem.str = Marshal.StringToCoTaskMemUni(m_sDisplayName);
                }
            }
            // This snapin was set up so the node's image index is the
            // same as the node's cookie unless we're getting an image for a listview
            if ((ResultDataItem.mask & RDI.IMAGE) > 0)
            {
                if (crv != null && (ResultDataItem.lParam >> 16) > 0)
                {
                    ResultDataItem.nImage = crv.GetImageIndex((ResultDataItem.lParam >> 16) - 1);
                }
                else
                {
                    ResultDataItem.nImage = CResourceStore.GetIconCookie(IconHandle);
                }
            }

            if ((ResultDataItem.mask & RDI.PARAM) > 0)
            {
                ResultDataItem.lParam = m_iCookie;
            }

            // Don't know what this field is for, MSDN isn't clear
            // on it... just set it to 0 if we need to
            if ((ResultDataItem.mask & (uint)RDI.INDEX) > 0)
            {
                ResultDataItem.nIndex = 0;
            }

            // Reserved
            if ((ResultDataItem.mask & (uint)RDI.INDENT) > 0)
            {
                ResultDataItem.iIndent = 0;
            }
        }// GetResultDisplayInfo
Пример #4
0
        }// Leaving

        private IColumnResultView GetColumnResultView()
        {
            IColumnResultView crv = null;

            if (m_oResults is IColumnResultView)
            {
                crv = (IColumnResultView)m_oResults;
            }
            else
            {
                // We want to do this if we're trying to pop up a result item's property
                // page when the result view currently is showing HTML.
                // This can occur from a menu item or from the most-often used commands
                crv = (IColumnResultView)this;
            }
            return(crv);
        }// GetIColumnResultView
Пример #5
0
        }// DoesResultHavePropertyPage

        internal void CreateResultPropertyPages(IPropertySheetCallback lpProvider, IntPtr handle, Object oResultData)
        {
            IColumnResultView crv = GetColumnResultView();

            if (crv != null)
            {
                // Grab onto the handle that MMC gives us
                m_hPropertyPageRouter = handle;
                // If we don't have a router handle yet, store one.
                if (CNodeManager.GoodRouterHandle == (IntPtr)(-1))
                {
                    CNodeManager.GoodRouterHandle = handle;
                }

                CPropPage[] ppages = crv.CreateNewPropPages(oResultData);

                int iLen = ppages.Length;
                for (int i = 0; i < iLen; i++)
                {
                    ppages[i].Init(Cookie, handle);
                    CreateSinglePropertyPage(lpProvider, ppages[i]);
                }
            }
        }// CreateResultPropertyPages
Пример #6
0
        }// GetIColumnResultView

        //-------------------------------------------------
        // onShow
        //
        // This function will be used only if a column view is
        // to be presented in the result pane.
        //-------------------------------------------------
        internal void onShow(IConsole2 Console, IntPtr arg, IntPtr param)
        {
            if ((int)arg == 0)
            {
                Leaving();
            }

            // Let's make sure we do have a list view item to display
            if ((int)arg > 0 && m_oResults != null && m_oResults is IColumnResultView)
            {
                IColumnResultView crv = (IColumnResultView)m_oResults;

                // If we're here then we have stuff to add to the result
                // view (beyond the standard view)

                // Query the Conole for a couple interfaces to use
                IHeaderCtrl HeaderCtrl = (IHeaderCtrl)Console;
                IResultData ResultData = (IResultData)Console;

                // Add/Remove Multi-Select ability
                if (m_fAllowMultiSelectResults)
                {
                    ResultData.ModifyViewStyle(0, MMC.SINGLESEL);
                }
                else
                {
                    ResultData.ModifyViewStyle(MMC.SINGLESEL, 0);
                }


                // Let's put in the column titles and find out how wide
                // each column should be
                int iNumCols = crv.getNumColumns();
                int iNumRows = crv.getNumRows();
                for (int i = 0; i < iNumCols; i++)
                {
                    int iMaxLength = crv.getColumnTitles(i).Length;
                    for (int j = 0; j < iNumRows; j++)
                    {
                        if (crv.getValues(j, i) != null)
                        {
                            int iTempLength = crv.getValues(j, i).Length;
                            if (iTempLength > iMaxLength)
                            {
                                iMaxLength = iTempLength;
                            }
                        }
                    }
                    int nWidth = GetColumnWidth(i, iMaxLength);
                    HeaderCtrl.InsertColumn(i, crv.getColumnTitles(i), LVCFMT.LEFT, nWidth);
                }
                RESULTDATAITEM rdi = new RESULTDATAITEM();
                for (int n = 0; n < iNumRows; n++)
                {
                    rdi.mask = RDI.STR |
                               RDI.PARAM;

                    rdi.nImage = crv.GetImageIndex(n);
                    // If we have a valid image, tell MMC to display it.
                    if (rdi.nImage != -1)
                    {
                        rdi.mask |= RDI.IMAGE;
                    }

                    rdi.str  = (IntPtr)(-1);
                    rdi.nCol = 0;

                    // We're doing the lParam a little differently. The low word contains the cookie
                    // for this node, while the high word contains the row number + 1 we're inserting
                    rdi.lParam = m_iCookie | ((n + 1) << 16);

                    ResultData.InsertItem(ref rdi);
                }
            }
        }// onShow