Ejemplo n.º 1
0
 private void DESTestForm_Load(object sender, EventArgs e)
 {
     try
     {
         label6.Text = "";
         label7.Text = "";
         label8.Text = "";
         //if (!CheckJreInstalled())
         //{
         //    MessageBox.Show("本功能需要安装Jre环境");
         //    this.DialogResult = DialogResult.No;
         //}
         String key = XMLUtil.getValue("Key");
         String iv  = XMLUtil.getValue("Iv");
         txtKey.Text = key;
         txtIV.Text  = iv;
     }
     catch (Exception ex)
     {
         String startPath = Application.StartupPath;
         MessageBox.Show(ex.Message);
         this.DialogResult = DialogResult.No;
     }
 }
Ejemplo n.º 2
0
 /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
 /// <param name="esd">用于重新构造权限的 XML 编码。</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="esd" /> 参数为 null。</exception>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="esd" /> 参数不是有效的权限元素。- 或 -<paramref name="esd" /> 参数的版本号无效。</exception>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, (IPermission)this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.SetUnrestricted(true);
     }
     else
     {
         this.m_windowFlag    = UIPermissionWindow.NoWindows;
         this.m_clipboardFlag = UIPermissionClipboard.NoClipboard;
         string str1 = esd.Attribute("Window");
         if (str1 != null)
         {
             this.m_windowFlag = (UIPermissionWindow)Enum.Parse(typeof(UIPermissionWindow), str1);
         }
         string str2 = esd.Attribute("Clipboard");
         if (str2 == null)
         {
             return;
         }
         this.m_clipboardFlag = (UIPermissionClipboard)Enum.Parse(typeof(UIPermissionClipboard), str2);
     }
 }
Ejemplo n.º 3
0
        /// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
        /// <param name="level">The policy level context for resolving named permission set references. </param>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        // Token: 0x06002AD5 RID: 10965 RVA: 0x0009EFD8 File Offset: 0x0009D1D8
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (this.m_value == null && this.m_element != null)
            {
                this.ParseHashValue();
            }
            if (this.m_hashAlg == null && this.m_element != null)
            {
                this.ParseHashAlgorithm();
            }
            SecurityElement securityElement = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(securityElement, base.GetType(), "System.Security.Policy.HashMembershipCondition");
            securityElement.AddAttribute("version", "1");
            if (this.m_value != null)
            {
                securityElement.AddAttribute("HashValue", Hex.EncodeHexString(this.HashValue));
            }
            if (this.m_hashAlg != null)
            {
                securityElement.AddAttribute("HashAlgorithm", this.HashAlgorithm.GetType().FullName);
            }
            return(securityElement);
        }
Ejemplo n.º 4
0
        public void AddToElement(SXL.XElement parent, int ix)
        {
            var el = XMLUtil.CreateVisioSchema2003Element("Para");

            el.SetAttributeValueInt("IX", ix);
            el.Add(this.IndFirst.ToXml("IndFirst"));
            el.Add(this.IndLeft.ToXml("IndLeft"));
            el.Add(this.IndRight.ToXml("IndRight"));

            el.Add(this.SpLine.ToXml("SpLine"));
            el.Add(this.SpBefore.ToXml("SpBefore"));
            el.Add(this.SpAfter.ToXml("SpAfter"));

            el.Add(this.HorzAlign.ToXml("HorzAlign"));
            el.Add(this.Bullet.ToXml("Bullet"));
            el.Add(this.BulletStr.ToXml("BulletStr"));
            el.Add(this.BulletFont.ToXml("BulletFont"));
            el.Add(this.LocalizeBulletFont.ToXml("LocalizeBulletFont"));
            el.Add(this.BulletFontSize.ToXml("BulletFontSize"));
            el.Add(this.TextPosAfterBullet.ToXml("TextPosAfterBullet"));
            el.Add(this.Flags.ToXml("Flags"));

            parent.Add(el);
        }
Ejemplo n.º 5
0
    public static bool ExportKeystoning(RUISKeystoning.KeystoningCorners keystoningCorners, XmlElement xmlElement)
    {
        XmlElement topLeft = xmlElement.OwnerDocument.CreateElement("topLeft");

        XMLUtil.WriteVector2ToXmlElement(topLeft, keystoningCorners[0]);
        xmlElement.AppendChild(topLeft);

        XmlElement topRight = xmlElement.OwnerDocument.CreateElement("topRight");

        XMLUtil.WriteVector2ToXmlElement(topRight, keystoningCorners[1]);
        xmlElement.AppendChild(topRight);

        XmlElement bottomRight = xmlElement.OwnerDocument.CreateElement("bottomRight");

        XMLUtil.WriteVector2ToXmlElement(bottomRight, keystoningCorners[2]);
        xmlElement.AppendChild(bottomRight);

        XmlElement bottomLeft = xmlElement.OwnerDocument.CreateElement("bottomLeft");

        XMLUtil.WriteVector2ToXmlElement(bottomLeft, keystoningCorners[3]);
        xmlElement.AppendChild(bottomLeft);

        return(true);
    }
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.m_unrestricted = true;
     }
     else
     {
         this.m_unrestricted = false;
         this.m_read         = null;
         this.m_write        = null;
         string str = esd.Attribute("Read");
         if (str != null)
         {
             this.m_read = new EnvironmentStringExpressionSet(str);
         }
         str = esd.Attribute("Write");
         if (str != null)
         {
             this.m_write = new EnvironmentStringExpressionSet(str);
         }
     }
 }
Ejemplo n.º 7
0
        public XmlElement asXML(XmlDocument doc)
        {
            XmlElement element = doc.CreateElement("beingController");

            element.SetAttribute("entranceMS", entranceMS.ToString());
            element.SetAttribute("startDepth", startDepth.ToString());
            element.SetAttribute("animationName", animationController.name);
            element.AppendChild(XMLUtil.asXMLVector2(doc, startLocation, "startLocation"));
            XmlElement timeAnimationStructsElement = doc.CreateElement("timeAnimationStructs");

            foreach (TimeAnimationStruct timeAnimation in animations)
            {
                timeAnimationStructsElement.AppendChild(timeAnimation.asXML(doc));
            }
            element.AppendChild(timeAnimationStructsElement);
            XmlElement actionElement = doc.CreateElement("action");

            foreach (ActionStruct action in actions)
            {
                actionElement.AppendChild(action.asXML(doc));
            }
            element.AppendChild(actionElement);
            return(element);
        }
Ejemplo n.º 8
0
 public override string this[string key] {
     set {
         base[key] = XMLUtil.EscapeXML(value, false);
     }
 }
Ejemplo n.º 9
0
 /**
  * Add a language.
  */
 public void AddLanguage(String language, String value)
 {
     this[language] = XMLUtil.EscapeXML(value, false);
 }
Ejemplo n.º 10
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            String et;

            if (XMLUtil.IsUnrestricted(esd))
            {
                m_unrestricted = true;
                return;
            }


            m_unrestricted = false;

            et = esd.Attribute("Read");
            if (et != null)
            {
                m_read = new FileIOAccess(et);
            }
            else
            {
                m_read = null;
            }

            et = esd.Attribute("Write");
            if (et != null)
            {
                m_write = new FileIOAccess(et);
            }
            else
            {
                m_write = null;
            }

            et = esd.Attribute("Append");
            if (et != null)
            {
                m_append = new FileIOAccess(et);
            }
            else
            {
                m_append = null;
            }

            et = esd.Attribute("PathDiscovery");
            if (et != null)
            {
                m_pathDiscovery = new FileIOAccess(et);
                m_pathDiscovery.PathDiscovery = true;
            }
            else
            {
                m_pathDiscovery = null;
            }

            et = esd.Attribute("ViewAcl");
            if (et != null)
            {
                m_viewAcl = new FileIOAccess(et);
            }
            else
            {
                m_viewAcl = null;
            }

            et = esd.Attribute("ChangeAcl");
            if (et != null)
            {
                m_changeAcl = new FileIOAccess(et);
            }
            else
            {
                m_changeAcl = null;
            }
        }
Ejemplo n.º 11
0
 public void UpdateDataGrid()
 {
     XMLUtil.UpdateDataGrid(XmlTableName);
 }
Ejemplo n.º 12
0
    public void SaveFloorData(string filename, RUISDevice device, Vector3 normal, float distance)
    {
        string wrapperElementName = device.ToString();

        XmlNode calibrationMatrixElement;

        XmlDocument xmlDoc = XMLUtil.LoadAndValidateXml(filename, coordinateSchema);
        XmlNode     groupElement;

        if (xmlDoc != null)
        {
            calibrationMatrixElement = xmlDoc.DocumentElement;
            groupElement             = calibrationMatrixElement.SelectSingleNode("FloorData");
            if (groupElement == null)
            {
                groupElement = xmlDoc.CreateElement("FloorData");
            }
        }
        else
        {
            xmlDoc = new XmlDocument();
            xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
            calibrationMatrixElement = xmlDoc.CreateElement("ns2", "RUISClibrationMatrix", "http://ruisystem.net/m2k");
            xmlDoc.AppendChild(calibrationMatrixElement);
            groupElement = xmlDoc.CreateElement("FloorData");
        }
        calibrationMatrixElement.AppendChild(groupElement);

        XmlElement wrapperElement = xmlDoc.CreateElement(wrapperElementName);

        groupElement.AppendChild(wrapperElement);

        XmlElement kinectFloorNormalElement = xmlDoc.CreateElement("floorNormal");

        kinectFloorNormalElement.SetAttribute("x", normal.x.ToString());
        kinectFloorNormalElement.SetAttribute("y", normal.y.ToString());
        kinectFloorNormalElement.SetAttribute("z", normal.z.ToString());
        wrapperElement.AppendChild(kinectFloorNormalElement);

        XmlElement kinectDistanceFromFloorElement = xmlDoc.CreateElement("distanceFromFloor");

        kinectDistanceFromFloorElement.SetAttribute("value", distance.ToString());

        wrapperElement.AppendChild(kinectDistanceFromFloorElement);

        XmlNode groupNode = xmlDoc.DocumentElement.SelectSingleNode("FloorData");
        XmlNode testNode  = groupNode.SelectSingleNode(wrapperElementName);

        // Element not found
        if (testNode == null)
        {
            groupNode.AppendChild(wrapperElement);
        }
        else
        {
            // Element already exists
            var oldElem = testNode;
            groupNode.ReplaceChild(wrapperElement, oldElem);
        }

        FileStream   xmlFileStream = File.Open(filename, FileMode.Create);
        StreamWriter streamWriter  = new StreamWriter(xmlFileStream);

        xmlDoc.Save(streamWriter);
        streamWriter.Flush();
        streamWriter.Close();
        xmlFileStream.Close();
    }
Ejemplo n.º 13
0
    public void SaveTransformDataToXML(string filename, RUISDevice device1, RUISDevice device2)
    {
        string wrapperElementName = device1.ToString() + "-" + device2.ToString();

        XmlNode calibrationMatrixElement;

        XmlDocument xmlDoc = XMLUtil.LoadAndValidateXml(filename, coordinateSchema);
        XmlNode     groupElement;

        if (xmlDoc != null)
        {
            calibrationMatrixElement = xmlDoc.DocumentElement;
            groupElement             = calibrationMatrixElement.SelectSingleNode("Transforms");
            if (groupElement == null)
            {
                groupElement = xmlDoc.CreateElement("Transforms");
            }
        }
        else
        {
            xmlDoc = new XmlDocument();
            xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
            calibrationMatrixElement = xmlDoc.CreateElement("ns2", "RUISClibrationMatrix", "http://ruisystem.net/m2k");
            xmlDoc.AppendChild(calibrationMatrixElement);
            groupElement = xmlDoc.CreateElement("Transforms");
        }
        calibrationMatrixElement.AppendChild(groupElement);

        XmlElement wrapperElement = xmlDoc.CreateElement(wrapperElementName);

        groupElement.AppendChild(wrapperElement);

        XmlElement translateElement = xmlDoc.CreateElement("translate");

        translateElement.SetAttribute("x", deviceToRootTransform[0, 3].ToString());
        translateElement.SetAttribute("y", deviceToRootTransform[1, 3].ToString());
        translateElement.SetAttribute("z", deviceToRootTransform[2, 3].ToString());

        wrapperElement.AppendChild(translateElement);

        XmlElement rotateElement = xmlDoc.CreateElement("rotate");

        rotateElement.SetAttribute("r00", deviceToRootTransform[0, 0].ToString());
        rotateElement.SetAttribute("r01", deviceToRootTransform[0, 1].ToString());
        rotateElement.SetAttribute("r02", deviceToRootTransform[0, 2].ToString());
        rotateElement.SetAttribute("r10", deviceToRootTransform[1, 0].ToString());
        rotateElement.SetAttribute("r11", deviceToRootTransform[1, 1].ToString());
        rotateElement.SetAttribute("r12", deviceToRootTransform[1, 2].ToString());
        rotateElement.SetAttribute("r20", deviceToRootTransform[2, 0].ToString());
        rotateElement.SetAttribute("r21", deviceToRootTransform[2, 1].ToString());
        rotateElement.SetAttribute("r22", deviceToRootTransform[2, 2].ToString());

        wrapperElement.AppendChild(rotateElement);

        XmlNode groupNode = xmlDoc.DocumentElement.SelectSingleNode("Transforms");
        XmlNode testNode  = groupNode.SelectSingleNode(wrapperElementName);

        // Element not found
        if (testNode == null)
        {
            groupNode.AppendChild(wrapperElement);
        }
        else
        {
            // Element already exists
            var oldElem = testNode;
            groupNode.ReplaceChild(wrapperElement, oldElem);
        }

        FileStream   xmlFileStream = File.Open(filename, FileMode.Create);
        StreamWriter streamWriter  = new StreamWriter(xmlFileStream);

        xmlDoc.Save(streamWriter);
        streamWriter.Flush();
        streamWriter.Close();
        xmlFileStream.Close();
    }
Ejemplo n.º 14
0
        /// <summary>
        /// Realiza el proceso de firmado
        /// </summary>
        /// <param name="input"></param>
        /// <param name="parameters"></param>
        public SignatureDocument Sign(Stream input, SignatureParameters parameters)
        {
            if (parameters.Signer == null)
            {
                throw new Exception("Es necesario un certificado válido para la firma");
            }

            if (input == null && string.IsNullOrEmpty(parameters.ExternalContentUri))
            {
                throw new Exception("No se ha especificado ningún contenido a firmar");
            }

            SignatureDocument signatureDocument = new SignatureDocument();

            _dataFormat = new DataObjectFormat();

            switch (parameters.SignaturePackaging)
            {
            case SignaturePackaging.INTERNALLY_DETACHED:
                if (parameters.DataFormat == null || string.IsNullOrEmpty(parameters.DataFormat.MimeType))
                {
                    throw new NullReferenceException("Se necesita especificar el tipo MIME del elemento a firmar.");
                }

                _dataFormat.MimeType = parameters.DataFormat.MimeType;

                if (parameters.DataFormat.MimeType == "text/xml")
                {
                    _dataFormat.Encoding = "UTF-8";
                }
                else
                {
                    _dataFormat.Encoding = "http://www.w3.org/2000/09/xmldsig#base64";
                }

                if (!string.IsNullOrEmpty(parameters.ElementIdToSign))
                {
                    SetContentInternallyDetached(signatureDocument, XMLUtil.LoadDocument(input), parameters.ElementIdToSign);
                }
                else
                {
                    SetContentInternallyDetached(signatureDocument, input);
                }
                break;

            case SignaturePackaging.HASH_INTERNALLY_DETACHED:
                if (parameters.DataFormat == null || string.IsNullOrEmpty(parameters.DataFormat.MimeType))
                {
                    _dataFormat.MimeType = "application/octet-stream";
                }
                else
                {
                    _dataFormat.MimeType = parameters.DataFormat.MimeType;
                }
                _dataFormat.Encoding = "http://www.w3.org/2000/09/xmldsig#base64";
                SetContentInternallyDetachedHashed(signatureDocument, input);
                break;

            case SignaturePackaging.ENVELOPED:
                _dataFormat.MimeType = "text/xml";
                _dataFormat.Encoding = "UTF-8";
                SetContentEnveloped(signatureDocument, XMLUtil.LoadDocument(input));
                break;

            case SignaturePackaging.ENVELOPING:
                _dataFormat.MimeType = "text/xml";
                _dataFormat.Encoding = "UTF-8";
                XmlDocument inputXml = XMLUtil.LoadDocument(input);

                if (inputXml.FirstChild.Name == "Manifest" &&
                    inputXml.FirstChild.NamespaceURI == XadesSignedXml.XmlDsigNamespaceUrl)
                {
                    XmlNode idAttribute = inputXml.FirstChild.Attributes.GetNamedItem("Id");
                    if (idAttribute == null)
                    {
                        throw new Exception("Se requiere un identificador para el objeto manifest");
                    }

                    SetContentEveloping(signatureDocument, inputXml, idAttribute.Value, XadesSignedXml.XmlDsigManifestType);
                }
                else
                {
                    SetContentEveloping(signatureDocument, inputXml, null, XadesSignedXml.XmlDsigObjectType);
                }
                break;

            case SignaturePackaging.EXTERNALLY_DETACHED:
                SetContentExternallyDetached(signatureDocument, parameters.ExternalContentUri);
                break;
            }

            if (parameters.DataFormat != null)
            {
                if (!string.IsNullOrEmpty(parameters.DataFormat.TypeIdentifier))
                {
                    _dataFormat.ObjectIdentifier = new ObjectIdentifier();
                    _dataFormat.ObjectIdentifier.Identifier.IdentifierUri = parameters.DataFormat.TypeIdentifier;
                }

                _dataFormat.Description = parameters.DataFormat.Description;
            }

            SetSignatureId(signatureDocument.XadesSignature);

            if (signatureDocument.Document == null)
            {
                signatureDocument.Document = new XmlDocument();
            }

            PrepareSignature(signatureDocument, parameters);

            signatureDocument.XadesSignature.ComputeSignature();

            UpdateXadesSignature(signatureDocument);

            return(signatureDocument);
        }
Ejemplo n.º 15
0
        [System.Security.SecurityCritical]  // auto-generated
        internal SecurityElement ToXml(PolicyLevel level, String policyClassName)
        {
            if (m_membershipCondition == null && m_element != null)
            {
                ParseMembershipCondition();
            }

            if (m_children == null)
            {
                ParseChildren();
            }

            if (m_policy == null && m_element != null)
            {
                ParsePolicy();
            }

            SecurityElement e = new SecurityElement("CodeGroup");

            System.Security.Util.XMLUtil.AddClassAttribute(e, this.GetType(), policyClassName);
            // If you hit this assert then most likely you are trying to change the name of this class.
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert(this.GetType().FullName.Equals(policyClassName), "Incorrect class name passed in! Was: " + policyClassName + " Should be " + this.GetType().FullName);

            e.AddAttribute("version", "1");

            e.AddChild(m_membershipCondition.ToXml(level));

            // Grab the inerts of the policy statement's xml and just stick it
            // into the code group xml directly. We do this to hide the policy statement from
            // users in the config file.

            if (m_policy != null)
            {
                PermissionSet      permSet      = m_policy.GetPermissionSetNoCopy();
                NamedPermissionSet namedPermSet = permSet as NamedPermissionSet;

                if (namedPermSet != null && level != null && level.GetNamedPermissionSetInternal(namedPermSet.Name) != null)
                {
                    e.AddAttribute("PermissionSetName", namedPermSet.Name);
                }
                else
                {
                    if (!permSet.IsEmpty())
                    {
                        e.AddChild(permSet.ToXml());
                    }
                }

                if (m_policy.Attributes != PolicyStatementAttribute.Nothing)
                {
                    e.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), m_policy.Attributes));
                }
            }

            if (m_children.Count > 0)
            {
                lock (this)
                {
                    IEnumerator enumerator = m_children.GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        e.AddChild(((CodeGroup)enumerator.Current).ToXml(level));
                    }
                }
            }

            if (m_name != null)
            {
                e.AddAttribute("Name", SecurityElement.Escape(m_name));
            }

            if (m_description != null)
            {
                e.AddAttribute("Description", SecurityElement.Escape(m_description));
            }

            CreateXml(e, level);

            return(e);
        }
Ejemplo n.º 16
0
    public static bool ExportInputManager(RUISInputManager inputManager, string filename)
    {
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");

        XmlElement inputManagerRootElement = xmlDoc.CreateElement("ns2", "RUISInputManager", "http://ruisystem.net/RUISInputManager");

        xmlDoc.AppendChild(inputManagerRootElement);

        XmlComment booleanComment = xmlDoc.CreateComment("Boolean values always with a lower case, e.g. \"true\" or \"false\"");

        inputManagerRootElement.AppendChild(booleanComment);

        XmlElement psMoveSettingsElement = xmlDoc.CreateElement("PSMoveSettings");

        inputManagerRootElement.AppendChild(psMoveSettingsElement);

        XmlElement psMoveEnabledElement = xmlDoc.CreateElement("enabled");

        psMoveEnabledElement.SetAttribute("value", inputManager.enablePSMove.ToString().ToLowerInvariant());
        psMoveSettingsElement.AppendChild(psMoveEnabledElement);

        XmlElement psMoveIPElement = xmlDoc.CreateElement("ip");

        psMoveIPElement.SetAttribute("value", inputManager.PSMoveIP.ToString());
        psMoveSettingsElement.AppendChild(psMoveIPElement);

        XmlElement psMovePortElement = xmlDoc.CreateElement("port");

        psMovePortElement.SetAttribute("value", inputManager.PSMovePort.ToString());
        psMoveSettingsElement.AppendChild(psMovePortElement);

        XmlElement psMoveAutoConnectElement = xmlDoc.CreateElement("autoConnect");

        psMoveAutoConnectElement.SetAttribute("value", inputManager.connectToPSMoveOnStartup.ToString().ToLowerInvariant());
        psMoveSettingsElement.AppendChild(psMoveAutoConnectElement);

        XmlElement psMoveEnableInGameCalibration = xmlDoc.CreateElement("enableInGameCalibration");

        psMoveEnableInGameCalibration.SetAttribute("value", inputManager.enableMoveCalibrationDuringPlay.ToString().ToLowerInvariant());
        psMoveSettingsElement.AppendChild(psMoveEnableInGameCalibration);

        XmlElement psMoveMaxControllersElement = xmlDoc.CreateElement("maxControllers");

        psMoveMaxControllersElement.SetAttribute("value", inputManager.amountOfPSMoveControllers.ToString());
        psMoveSettingsElement.AppendChild(psMoveMaxControllersElement);



        XmlElement kinectSettingsElement = xmlDoc.CreateElement("KinectSettings");

        inputManagerRootElement.AppendChild(kinectSettingsElement);

        XmlElement kinectEnabledElement = xmlDoc.CreateElement("enabled");

        kinectEnabledElement.SetAttribute("value", inputManager.enableKinect.ToString().ToLowerInvariant());
        kinectSettingsElement.AppendChild(kinectEnabledElement);

        XmlElement maxKinectPlayersElement = xmlDoc.CreateElement("maxPlayers");

        maxKinectPlayersElement.SetAttribute("value", inputManager.maxNumberOfKinectPlayers.ToString());
        kinectSettingsElement.AppendChild(maxKinectPlayersElement);

        XmlElement kinectFloorDetectionElement = xmlDoc.CreateElement("floorDetection");

        kinectFloorDetectionElement.SetAttribute("value", inputManager.kinectFloorDetection.ToString().ToLowerInvariant());
        kinectSettingsElement.AppendChild(kinectFloorDetectionElement);

        XmlElement jumpGestureElement = xmlDoc.CreateElement("jumpGestureEnabled");

        jumpGestureElement.SetAttribute("value", inputManager.jumpGestureEnabled.ToString().ToLowerInvariant());
        kinectSettingsElement.AppendChild(jumpGestureElement);

        XmlElement kinect2SettingsElement = xmlDoc.CreateElement("Kinect2Settings");

        inputManagerRootElement.AppendChild(kinect2SettingsElement);

        XmlElement kinect2EnabledElement = xmlDoc.CreateElement("enabled");

        kinect2EnabledElement.SetAttribute("value", inputManager.enableKinect2.ToString().ToLowerInvariant());
        kinect2SettingsElement.AppendChild(kinect2EnabledElement);

        XmlElement kinect2FloorDetectionElement = xmlDoc.CreateElement("floorDetection");

        kinect2FloorDetectionElement.SetAttribute("value", inputManager.kinect2FloorDetection.ToString().ToLowerInvariant());
        kinect2SettingsElement.AppendChild(kinect2FloorDetectionElement);

        XmlElement razerSettingsElement = xmlDoc.CreateElement("RazerSettings");

        inputManagerRootElement.AppendChild(razerSettingsElement);

        XmlElement razerEnabledElement = xmlDoc.CreateElement("enabled");

        razerEnabledElement.SetAttribute("value", inputManager.enableRazerHydra.ToString().ToLowerInvariant());
        razerSettingsElement.AppendChild(razerEnabledElement);



        XmlElement riftDriftSettingsElement = xmlDoc.CreateElement("OculusDriftSettings");

        inputManagerRootElement.AppendChild(riftDriftSettingsElement);

        //XmlElement magnetometerDriftCorrectionElement = xmlDoc.CreateElement("magnetometerDriftCorrection");
        //magnetometerDriftCorrectionElement.SetAttribute("value", System.Enum.GetName(typeof(RUISInputManager.RiftMagnetometer), inputManager.riftMagnetometerMode));
        //riftDriftSettingsElement.AppendChild(magnetometerDriftCorrectionElement);

        XmlElement kinectDriftCorrectionElement = xmlDoc.CreateElement("kinectDriftCorrectionIfAvailable");

        kinectDriftCorrectionElement.SetAttribute("value", inputManager.kinectDriftCorrectionPreferred.ToString().ToLowerInvariant());
        riftDriftSettingsElement.AppendChild(kinectDriftCorrectionElement);

        XMLUtil.SaveXmlToFile(filename, xmlDoc);

        return(true);
    }
Ejemplo n.º 17
0
 private void raHibernate_CheckedChanged(object sender, EventArgs e)
 {
     isHibernate = raHibernate.Checked;
     XMLUtil.setValue("isHibernate", isHibernate.ToString());
 }
Ejemplo n.º 18
0
        private void CreateBeanForm_Load(object sender, EventArgs e)
        {
            String exportPath = XMLUtil.getValue("BeanPath");

            txtPath.Text = exportPath.Trim();

            try
            {
                raHibernate.Checked = isHibernate;
                raMybatis.Checked   = !isHibernate;

                reloadSettingDT();
                lbConnStr.Text = "";
                lbState.Text   = "";

                String host     = XMLUtil.getValue("Host");
                String port     = XMLUtil.getValue("Port");
                String userName = XMLUtil.getValue("DBUserName");
                String passWord = XMLUtil.getValue("PassWord");
                if (host.Length != 0 && port.Length != 0 && userName.Length != 0 && passWord.Length != 0)
                {
                    String connStr = MySqlUtil.getConnectionStr(host, port, userName, passWord);
                    this.connStr = connStr;
                    DataTable dataBases = MySqlUtil.getSchema(connStr, "Databases");
                    DataRow[] rows      = dataBases.Select("database_name in ('performance_schema','information_schema','mysql')");
                    foreach (DataRow row in rows)
                    {
                        dataBases.Rows.Remove(row);
                    }
                    DataTable tables = MySqlUtil.getSchema(connStr, "Tables");
                    rows = tables.Select("TABLE_SCHEMA in ('performance_schema','information_schema','mysql')");
                    foreach (DataRow row in rows)
                    {
                        tables.Rows.Remove(row);
                    }
                    DataTable columns = MySqlUtil.getSchema(connStr, "Columns");
                    rows = columns.Select("TABLE_SCHEMA in ('performance_schema','information_schema','mysql')");
                    foreach (DataRow row in rows)
                    {
                        columns.Rows.Remove(row);
                    }
                    Session.put("dataBases", dataBases);

                    Session.put("tables", tables);
                    Session.put("columns", columns);
                    isConnected = true;
                }
                if (Session.check("dataBases"))
                {
                    DataTable dataBases = Session.get("dataBases") as DataTable;
                    cboDataBase.ComboBox.DataSource    = dataBases;
                    cboDataBase.ComboBox.DisplayMember = "database_name";
                    cboDataBase.ComboBox.ValueMember   = "database_name";

                    lbConnStr.Text = connStr.Substring(0, connStr.LastIndexOf("password"));


                    DataRow[] rows = dataBases.Select("database_name = '" + selectedDataBase + "'");
                    if (rows.Length > 0)
                    {
                        int index = dataBases.Rows.IndexOf(rows[0]);
                        cboDataBase.SelectedIndex = index;
                    }
                    else if (dataBases.Rows.Count > 0)
                    {
                        cboDataBase.SelectedIndex = 0;
                    }
                    String schemaName = cboDataBase.Text;
                    InitTree(schemaName, "");
                }

                lbDbConnState.Text      = isConnected ? "已连接" : "未连接";
                lbDbConnState.ForeColor = isConnected ? Color.Green : Color.Red;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 19
0
 public CreateBeanForm()
 {
     selectedDataBase = XMLUtil.getValue("SelectedDataBase");
     InitializeComponent();
 }
Ejemplo n.º 20
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag,
         * java.util.List, com.itextpdf.text.Document)
         */
        public override IList <IElement> End(IWorkerContext ctx, Tag tag, IList <IElement> currentContent)
        {
            IDictionary <String, String> attributes = tag.Attributes;
            String src;

            attributes.TryGetValue(HTML.Attribute.SRC, out src);
            iTextSharp.text.Image img = null;
            IList <IElement>      l   = new List <IElement>(1);

            if (!string.IsNullOrEmpty(src))
            {
                src = XMLUtil.UnescapeXML(src);
                src = src.Trim();
                // check if the image was already added once
                try {
                    if (logger.IsLogging(Level.TRACE))
                    {
                        logger.Trace(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.HTML_IMG_USE), src));
                    }
                    try {
                        img = new ImageRetrieve(GetHtmlPipelineContext(ctx).GetImageProvider()).RetrieveImage(src);
                    } catch (NoImageProviderException) {
                        img = new ImageRetrieve().RetrieveImage(src);
                    }
                } catch (IOException e) {
                    if (logger.IsLogging(Level.ERROR))
                    {
                        logger.Error(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.HTML_IMG_RETRIEVE_FAIL), src), e);
                    }
                } catch (NoImageException e) {
                    if (logger.IsLogging(Level.ERROR))
                    {
                        logger.Error("", e);
                    }
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
                }
                if (null != img)
                {
                    img.ScaleToFitLineWhenOverflow = true;
                    String width;
                    attributes.TryGetValue(HTML.Attribute.WIDTH, out width);
                    float  widthInPoints = utils.ParsePxInCmMmPcToPt(width);
                    String height;
                    attributes.TryGetValue(HTML.Attribute.HEIGHT, out height);
                    float heightInPoints = utils.ParsePxInCmMmPcToPt(height);
                    if (widthInPoints > 0 && heightInPoints > 0)
                    {
                        img.ScaleAbsolute(widthInPoints, heightInPoints);
                    }
                    else if (widthInPoints > 0)
                    {
                        heightInPoints = img.Height * widthInPoints / img.Width;
                        img.ScaleAbsolute(widthInPoints, heightInPoints);
                    }
                    else if (heightInPoints > 0)
                    {
                        widthInPoints = img.Width * heightInPoints / img.Height;
                        img.ScaleAbsolute(widthInPoints, heightInPoints);
                    }
                    try {
                        HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                        l.Add(GetCssAppliers().Apply(new Chunk((iTextSharp.text.Image)GetCssAppliers().Apply(img, tag, htmlPipelineContext), 0, 0, true), tag, htmlPipelineContext));
                    } catch (NoCustomContextException e) {
                        throw new RuntimeWorkerException(e);
                    }
                }
            }
            return(l);
        }
Ejemplo n.º 21
0
 private string ToXML()
 {
     return(XMLUtil.XmlSerialize <ClientRequest>(this));
 }
Ejemplo n.º 22
0
        public static ClientRequest GetRequestFromXML(string XML)
        {
            ClientRequest crRequest = XMLUtil.XmlDeserialize <ClientRequest>(XML);

            return(crRequest);
        }
 /// <summary>
 /// Carga un archivo de firma.
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public SignatureDocument[] Load(Stream input)
 {
     return(Load(XMLUtil.LoadDocument(input)));
 }
Ejemplo n.º 24
0
 protected override void CreateXml(SecurityElement element, PolicyLevel level)
 {
     element.AddAttribute("Access", XMLUtil.BitFieldEnumToString(typeof(FileIOPermissionAccess), m_access));
 }
Ejemplo n.º 25
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (testForm() && testConnection())
                {
                    DataTable dataBases = MySqlUtil.getSchema(connStr, "Databases");
                    DataRow[] rows      = dataBases.Select("database_name in ('performance_schema','information_schema','mysql')");
                    foreach (DataRow row in rows)
                    {
                        dataBases.Rows.Remove(row);
                    }
                    DataTable tables = MySqlUtil.getSchema(connStr, "Tables");
                    rows = tables.Select("TABLE_SCHEMA in ('performance_schema','information_schema','mysql')");
                    foreach (DataRow row in rows)
                    {
                        tables.Rows.Remove(row);
                    }
                    DataTable columns = MySqlUtil.getSchema(connStr, "Columns");
                    rows = columns.Select("TABLE_SCHEMA in ('performance_schema','information_schema','mysql')");
                    foreach (DataRow row in rows)
                    {
                        columns.Rows.Remove(row);
                    }
                    SessionUtil.Session.put("dataBases", dataBases);

                    SessionUtil.Session.put("tables", tables);
                    SessionUtil.Session.put("columns", columns);

                    string    passsword   = txtPassWord.Text.Trim();
                    string    ip          = txtIP.Text.Trim();
                    String    userName    = txtUserName.Text.Trim();
                    string    port        = txtPort.Text.Trim();
                    String    settingName = "@" + ip + ":" + port;
                    DataTable setting     = cboSetting.Tag as DataTable;
                    DataRow[] result      = setting.Select("password = '******'" +
                                                           " AND userName = '******'"
                                                           + " AND port = '" + port + "'" +
                                                           " AND ip = '" + ip + "'");
                    if (result.Length == 0)
                    {
                        StringBuilder sbSql = new StringBuilder();
                        sbSql.Append(" INSERT INTO tb_database (dbName, password, ip, userName, port, settingName) VALUES ( ");
                        sbSql.Append("   :dbName, :password, :ip, :userName, :port, :settingName ");
                        sbSql.Append(" ) ");


                        Dictionary <String, Object> parameters = new Dictionary <string, object>();
                        parameters.Add("dbName", "");
                        parameters.Add("password", txtPassWord.Text.Trim());
                        parameters.Add("ip", txtIP.Text.Trim());
                        parameters.Add("userName", txtUserName.Text.Trim());
                        parameters.Add("port", txtPort.Text.Trim());
                        parameters.Add("settingName", settingName);
                        SqliteHelper.excuteNoQuery(sbSql.ToString(), parameters);
                    }

                    XMLUtil.setValue("Host", ip);
                    XMLUtil.setValue("Port", port);
                    XMLUtil.setValue("DBUserName", userName);
                    XMLUtil.setValue("PassWord", passsword);
                    XMLUtil.setValue("SelectedDbSetting", settingName);

                    this.DialogResult = DialogResult.Yes;
                }
                else
                {
                    this.DialogResult = DialogResult.No;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 26
0
        private void txtIV_TextChanged(object sender, EventArgs e)
        {
            String iv = txtIV.Text.Trim();

            XMLUtil.setValue("Iv", iv);
        }
Ejemplo n.º 27
0
 /**
  * @param content
  * @return
  */
 public static String Escape(String content)
 {
     return(XMLUtil.EscapeXML(content, false));
 }
Ejemplo n.º 28
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                String packageName = txtPackageName.Text.Trim();
                if (packageName.Length == 0)
                {
                    txtPackageName.Focus();
                    throw new Exception("包名不能为空!");
                }
                XMLUtil.setValue("JobPackageName", packageName);
                dgvMain.EndEdit();
                String springConfigTemplet  = readTemplet("QuartzSpringConfigTemplet.temp");
                String simpleTriggerTemplet = readTemplet("QuartzBeanSimpleTriggerTemplet.temp");
                String cronTriggerTemplet   = readTemplet("QuartzBeanCronTriggerTemplet.temp");

                DataGridViewRowCollection rows        = dgvMain.Rows;
                List <String>             triggerList = new List <String>();
                StringBuilder             jobConfig   = new StringBuilder();
                foreach (DataGridViewRow row in rows)
                {
                    if (row.Cells["JobClass"].Value == null || row.Cells["QuartzType"].Value == null || row.Cells["ExcuteParameter"].Value == null)
                    {
                        continue;
                    }
                    String jobClass        = row.Cells["JobClass"].Value.ToString().Trim();
                    String quartzType      = row.Cells["QuartzType"].Value.ToString().Trim();
                    String excuteParameter = row.Cells["ExcuteParameter"].Value.ToString().Trim();
                    String description     = row.Cells["Description"].Value.ToString().Trim();
                    description = description.Length == 0 ? jobClass : description;
                    Int32 repeatInterval = 0;
                    bool  isNumber       = Int32.TryParse(excuteParameter, out repeatInterval);
                    if (!isNumber && quartzType.Equals("SimpleTrigger"))
                    {
                        throw new Exception("[" + jobClass + "] 的执行方式为间隔时间,他的执行参数应为数字!");
                    }
                    else if (isNumber && quartzType.Equals("CronTrigger"))
                    {
                        throw new Exception("[" + jobClass + "] 的执行方式为Cron表达式,他的执行参数应为字符串!");
                    }
                    String className = jobClass;
                    if (jobClass.ToLower().EndsWith("job"))
                    {
                        jobClass = jobClass.Substring(0, jobClass.ToLower().LastIndexOf("job"));
                        jobClass = jobClass.Substring(0, 1).ToLower() + jobClass.Substring(1);
                    }

                    String jobName        = jobClass + "Job";
                    String classFullName  = packageName.EndsWith(".") ? packageName + className : packageName + "." + className;
                    String jobDetailName  = jobClass + "JobDetail";
                    String jobTriggerName = jobClass + "JobTrigger";

                    String triggerTemplet = cronTriggerTemplet;
                    if (quartzType.Equals("SimpleTrigger"))
                    {
                        triggerTemplet  = simpleTriggerTemplet;
                        excuteParameter = (repeatInterval * 1000).ToString();
                    }
                    String triggerConfig = triggerTemplet.Replace("$[jobName]", jobName).Replace("$[classFullName]", classFullName).Replace("$[jobDetailName]", jobDetailName).Replace("$[jobTriggerName]", jobTriggerName).Replace("$[ExcuteParameter]", excuteParameter).Replace("$[Description]", description);
                    jobConfig.AppendLine(triggerConfig);
                    triggerList.Add(jobTriggerName);
                }
                StringBuilder refTriggerConfig = new StringBuilder();
                String        blank            = "				      ";
                foreach (String triggerName in triggerList)
                {
                    refTriggerConfig.Append(blank).AppendLine("<ref bean=\"" + triggerName + "\"/>");
                }
                String springConfig = springConfigTemplet.Replace("$[triggers]", refTriggerConfig.ToString()).Replace("$[beans]", jobConfig.ToString());
                txtConfig.Text = springConfig.Trim();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 29
0
 /**
  * Escapes a string with the appropriated XML codes.
  * @param s the string to be escaped
  * @param onlyASCII codes above 127 will always be escaped with &amp;#nn; if <CODE>true</CODE>
  * @return the escaped string
  */
 public static String EscapeXML(String s, bool onlyASCII)
 {
     return(XMLUtil.EscapeXML(s, onlyASCII));
 }
Ejemplo n.º 30
0
    public bool LoadMultiXML(string filename)
    {
        XmlDocument xmlDoc = XMLUtil.LoadAndValidateXml(filename, coordinateSchema);

        if (xmlDoc != null)
        {
            foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
            {
                Vector3    vector3 = new Vector3(0, 0, 0);
                Matrix4x4  device1ToDevice2Transform = new Matrix4x4();
                Quaternion quaternion = new Quaternion();

                if (node.Name == "Transforms")
                {
                    foreach (XmlNode groupElement in node.ChildNodes)
                    {
                        XmlNode translationElement = groupElement.SelectSingleNode("translate");
                        float   x = float.Parse(translationElement.Attributes["x"].Value);
                        float   y = float.Parse(translationElement.Attributes["y"].Value);
                        float   z = float.Parse(translationElement.Attributes["z"].Value);
                        vector3 = new Vector3(x, y, z);
                        device1ToDevice2Transform.SetColumn(3, new Vector4(x, y, z, 1.0f));

                        XmlNode rotationElement = groupElement.SelectSingleNode("rotate");

                        device1ToDevice2Transform.m00 = float.Parse(rotationElement.Attributes["r00"].Value);
                        device1ToDevice2Transform.m01 = float.Parse(rotationElement.Attributes["r01"].Value);
                        device1ToDevice2Transform.m02 = float.Parse(rotationElement.Attributes["r02"].Value);
                        device1ToDevice2Transform.m10 = float.Parse(rotationElement.Attributes["r10"].Value);
                        device1ToDevice2Transform.m11 = float.Parse(rotationElement.Attributes["r11"].Value);
                        device1ToDevice2Transform.m12 = float.Parse(rotationElement.Attributes["r12"].Value);
                        device1ToDevice2Transform.m20 = float.Parse(rotationElement.Attributes["r20"].Value);
                        device1ToDevice2Transform.m21 = float.Parse(rotationElement.Attributes["r21"].Value);
                        device1ToDevice2Transform.m22 = float.Parse(rotationElement.Attributes["r22"].Value);

                        List <Vector3> rotationVectors = MathUtil.Orthonormalize(MathUtil.ExtractRotationVectors(device1ToDevice2Transform));
                        Matrix4x4      rotationMatrix  = new Matrix4x4();
                        rotationMatrix.SetColumn(0, rotationVectors[0]);
                        rotationMatrix.SetColumn(1, rotationVectors[1]);
                        rotationMatrix.SetColumn(2, rotationVectors[2]);

                        quaternion = MathUtil.QuaternionFromMatrix(rotationMatrix);

                        RUISCalibrationResultsInVector3[groupElement.Name]    = vector3;
                        RUISCalibrationResultsIn4x4Matrix[groupElement.Name]  = device1ToDevice2Transform;
                        RUISCalibrationResultsInQuaternion[groupElement.Name] = quaternion;

                        // Inverses
                        string[] parts       = groupElement.Name.Split('-');
                        string   inverseName = parts[1] + "-" + parts[0];
                        RUISCalibrationResultsInVector3[inverseName]    = -vector3;
                        RUISCalibrationResultsIn4x4Matrix[inverseName]  = device1ToDevice2Transform.inverse;
                        RUISCalibrationResultsInQuaternion[inverseName] = Quaternion.Inverse(quaternion);
                    }
                }

                if (node.Name == "FloorData")
                {
                    foreach (XmlNode groupElement in node.ChildNodes)
                    {
                        Quaternion floorPitchRotation = Quaternion.identity;
                        float      distanceFromFloor  = 0;
                        foreach (XmlNode element in groupElement.ChildNodes)
                        {
                            switch (element.Name)
                            {
                            case "floorNormal":
                                float xValue = float.Parse(element.Attributes["x"].Value);
                                float yValue = float.Parse(element.Attributes["y"].Value);
                                float zValue = float.Parse(element.Attributes["z"].Value);
                                floorPitchRotation = Quaternion.Inverse(Quaternion.FromToRotation(new Vector3(xValue, yValue, zValue), Vector3.up));
                                break;

                            case "distanceFromFloor":
                                distanceFromFloor = float.Parse(element.Attributes["value"].Value);
                                break;
                            }
                        }

                        RUISCalibrationResultsFloorPitchRotation[(RUISDevice)System.Enum.Parse(typeof(RUISDevice), groupElement.Name, true)] = floorPitchRotation;
                        RUISCalibrationResultsDistanceFromFloor[(RUISDevice)System.Enum.Parse(typeof(RUISDevice), groupElement.Name, true)]  = distanceFromFloor;
                    }
                }
            }
        }
        else
        {
            return(false);
        }

        /*
         * // For debug
         * foreach (string key in RUISCalibrationResultsInVector3.Keys)
         * {
         *      print("Key: " + key + ": Value: " + RUISCalibrationResultsInVector3[key].ToString());
         * }
         * foreach (string key in RUISCalibrationResultsIn4x4Matrix.Keys)
         * {
         *      print("Key: " + key + ": Value: " + RUISCalibrationResultsIn4x4Matrix[key].ToString());
         * }
         * foreach (string key in RUISCalibrationResultsInVector3.Keys)
         * {
         *      print("Key: " + key + ": Value: " + RUISCalibrationResultsInQuaternion[key].ToString());
         * }
         * foreach (RUISDevice key in RUISCalibrationResultsFloorNormal.Keys)
         * {
         *      print("Key: " + key.ToString() + ": Value: " + RUISCalibrationResultsFloorNormal[key].ToString());
         * }
         * foreach (RUISDevice key in RUISCalibrationResultsDistanceFromFloor.Keys)
         * {
         *      print("Key: " + key.ToString() + ": Value: " + RUISCalibrationResultsDistanceFromFloor[key].ToString());
         * }
         */
        return(true);
    }