Ejemplo n.º 1
0
 static string getAttributeFromElement(XMLSPYPLUGINLib.XMLData xnDataToSearch, string strAttributeName)
 {
     if (true == xnDataToSearch.HasChildren)
     {
         for (int iChildId = 0; iChildId < xnDataToSearch.CountChildren(); iChildId++)
         {
             XMLSPYPLUGINLib.XMLData xdAttribute = xnDataToSearch.GetChild(iChildId);
             if (XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr == xdAttribute.kind)
             {
                 if (strAttributeName == xdAttribute.Name)
                 {
                     return(xdAttribute.TextValue);
                 }
             }
         }
     }
     return("");
 }
Ejemplo n.º 2
0
        private void processAuthenticKeyboardEvent(AxXMLSPYPLUGINLib.AxAuthentic axActiveAuthenticControl, char cKeyPressed, utils.LocalWindowsHook lwhSender)
        {
            try
            {
                // find out which control is currently selected
                string strCurrentSelectedControl = "";
                if (axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.kind != XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataText)
                {
                    strCurrentSelectedControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Name;
                }
                else
                if (axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.kind != XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataText)
                {
                    strCurrentSelectedControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Name;
                }
                else
                {
                    strCurrentSelectedControl = "Error in recognizing SPYXMLDataKind";
                }
                // apply Gui Funcionality
                switch (strCurrentSelectedControl)
                {
                case "value":                       // this could be the Target DNS or IP
                    string strParentControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Name;
                    if (cKeyPressed == 0x0d)
                    {
                        // 05-Feb-07: [Dinis], This is a hack to make the Enter work with the DnsName and IP elements (which use an attribute for its value and don't work in the new version of the Authentic component)

                        // get the value of the current element which should be either DnsValue or IP
                        string strValueOfCurrentElement = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.TextValue;
                        // get the parent.parent object which should be a 'Target' Element
                        XMLSPYPLUGINLib.XMLData xdData = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Parent;
                        if (xdData.Name == "Target")
                        {
                            // Now we are going to create manually either the 'DnsValue' or the 'IP' Element (the name we need is conveiniently in strParentControl)
                            XMLSPYPLUGINLib.XMLData xdXmlDataElement = axActiveAuthenticControl.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement);
                            xdXmlDataElement.Name = strParentControl;
                            // create the atribute 'value'
                            XMLSPYPLUGINLib.XMLData xdXmlDataAttribute = axActiveAuthenticControl.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr);
                            xdXmlDataAttribute.Name = "value";
                            // add addit it to the xdXmlDataElement
                            xdXmlDataElement.AppendChild(xdXmlDataAttribute);
                            // now that we have an 'DnsValue' or 'IP' element ready we need to find the correct location to insert it (note that due to the current xsd you cannot append it at the end)
                            // Get first Child
                            XMLSPYPLUGINLib.XMLData xdChild = xdData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement);
                            // and go though all childs until we find the current one
                            for (int iChildId = 0; iChildId < xdData.CountChildren(); iChildId++)
                            {
                                // at lack of better choise we will use the 'value' attribute to try to fing the location to insert (the only problem will happen if there is a duplicate 'value' (which would be a mistake in this case))
                                if (xdChild.Name == strParentControl && getAttributeFromElement(xdChild, "value") == strValueOfCurrentElement)
                                {
                                    // This will place the new Element before the current one
                                    xdData.InsertChild(xdXmlDataElement);
                                    // xdData.AppendChild(xdXmlDataElement);   /// this one doesn't work since it all puts it at the end
                                    break;
                                }
                                // move to the next child (we need to do this so that the InsertChild works as expected
                                if (iChildId < xdData.CountChildren() - 1)                // don't go to the next child if we are on the last one
                                {
                                    xdChild = xdData.GetNextChild();
                                }
                            }
                        }
                    }
                    break;

                    switch (strParentControl)
                    {
                    case "DnsName":
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);

                        ///string strText =

                        string strParentContol2 = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Name;

                        // bool bResulta = authentic.authentic_InsertElementInCurrentSelectionPos_spyAuthenticInsertBefore(axActiveAuthenticControl, "DnsName");
                        break;

                    case "IP":
                        break;
                    }
                    break;

                case "level2":
                case "level3":
                    checkForCtrlVandInsertDataFromClipboard(axActiveAuthenticControl, cKeyPressed, false);
                    checkForEnterAndInsertNewLine(axActiveAuthenticControl, cKeyPressed);

                    //if (0x0d == cKeyPressed)			// 0x0d (13) Enter
                    //	utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl);
                    break;

                case "AdittionalDetails":
                    checkForCtrlVandInsertDataFromClipboard(axActiveAuthenticControl, cKeyPressed, true);
                    if (0x08 == cKeyPressed)                                                    // 0x08 (08) Del
                    {
                        break;
                    }
                    checkForEnterAndInsertNewLine(axActiveAuthenticControl, cKeyPressed);
                    //if (0x0d == cKeyPressed)			// 0x0d (13) Enter
                    //	utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);      // this was being thrown during normal ORG usage
            }
        }