Exemplo n.º 1
0
 private static string ConvertValue(String value)
 {
     Dictionary<String, String> replacements = new Dictionary<string, string>();
     replacements.Add("&sp;", " ");
     replacements.Add("&1uc;", "{-|}");
     replacements.Add("&amp;", "&");
     replacements.Add("&bs;", "{# BackSpace}");
     replacements.Add("&cr;", "{# Return}");
     replacements.Add("&uc;", "{MODE:CAPS}");
     replacements.Add("&lc;", "{MODE:LOWER}");
     replacements.Add("&dw;", "{# Control_L(BackSpace)}");
     replacements.Add("\\", "\\\\");
     replacements.Add("\"", "\\\"");
     foreach (string key in replacements.Keys.OrderByDescending(_k=>_k.Length))
     {
         value = value.Replace(key, replacements[key]);
     }
     if (value.Contains("&+i;"))
     {
         value = String.Format("{0}{{^}}", value.Replace("&+i;", ""));
     }
     if (value.Contains("&rb;"))
     {
         value = String.Format("{{^}}{0}", value.Replace("&rb;", ""));
     }
     return value.Trim();
 }
Exemplo n.º 2
0
        public Hokuyo(LidarID lidar)
        {
            //trameDetails = "VV\n00P\n";
            this.lidar = lidar;
            semLock = new Semaphore(1, 1);

            switch (lidar)
            {
                case LidarID.LidarSol: model = "URG-04LX-UG01"; break;
            }

            if (model.Contains("UBG-04LX-F01"))//Hokuyo bleu
            {
                nbPoints = 725;
                angleMesurable = new Angle(240, AnglyeType.Degre);
                offsetPoints = 44;
            }
            else if (model.Contains("URG-04LX-UG01")) //Petit hokuyo
            {
                nbPoints = 725;
                angleMesurable = new Angle(240, AnglyeType.Degre);
                offsetPoints = 44;
            }
            else if (model.Contains("BTM-75LX")) // Grand hokuyo
            {
                nbPoints = 1080;
                angleMesurable = new Angle(270, AnglyeType.Degre);
                offsetPoints = 0;
            }

            position = Robots.GrosRobot.Position;

            Robots.GrosRobot.PositionChange += GrosRobot_PositionChange;
        }
Exemplo n.º 3
0
        public static void GenerateIntoClass(
            String targetFile, String @namespace, String classDeclaration, Action<StringBuilder> logic)
        {
            var buffer = new StringBuilder();
            logic(buffer);

            using (var targetFileWriter = new StreamWriter(targetFile))
            {
                targetFileWriter.WriteLine(Constants.CodegenDisclaimer);
                targetFileWriter.WriteLine();

                var textGeneratedIntoClass = typeof(Helpers).Assembly.ReadAllText("Truesight.TextGenerators.Core.TextGeneratedIntoClass.template");
                textGeneratedIntoClass = textGeneratedIntoClass
                    .Replace("%NAMESPACE_NAME%", @namespace)
                    .Replace("%CLASS_DECLARATION%", classDeclaration)
                    .Replace("%GENERATED_TEXT%", buffer.ToString());

                if (classDeclaration.Contains("enum") || classDeclaration.Contains("interface"))
                {
                    textGeneratedIntoClass = textGeneratedIntoClass
                        .Replace("    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]" + Environment.NewLine, "");
                }

                targetFileWriter.Write(textGeneratedIntoClass);
            }
        }
Exemplo n.º 4
0
 /*
 //[DllImport("Backend.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
 DEPRECATED DLL USAGE
 [DllImport("Backend.dll")]
 public static extern void getEncrypted(StringBuilder expression, StringBuilder key, bool isFile);
 [DllImport("Backend.dll")]
 public static extern void getDecrypted(StringBuilder expression, StringBuilder key, bool isFile);
 */
 /*
 public static String encryptExpression(String expression, String key)
 {
     string encryptedBuffer = new string(expression.Length * 10);
     //creates a string pointer(mutable) that my DLL can use to write the string.
     getEncrypted(expression, key, encryptedBuffer, expression.Length * 10);
     //TODO: fix string buffer size issues(look into how to make it resizeable?)
     //TODO: fix issue where random characters are sometimes returned at the end of the string
     return encryptedBuffer.ToString();
 }
 public static String decryptExpression(String ciphertext, String key)
 {
     string decryptedBuffer = new string(ciphertext.Length);
     getDecrypted(ciphertext, key, decryptedBuffer, ciphertext.Length);
     return decryptedBuffer.ToString();
 }
 */
 public static String encryptExpression(String expression, String key)
 {
     //using (FileStream stream = File.Create("return")) { } //create file and close stream automatically
     if (key.Contains("steg") && !key.Contains(Program.mediaFilePath)) //check if file is specified in key
         key += "=" + Program.mediaFilePath;
     #region Create headless backend exe process
     Process backend = createBackendProcess("\"" + expression + "\" \"" + key + "\" 1 " + (Program.usingFile ? "1" : "0"));
     backend.Start();
     backend.WaitForExit();
     #endregion
     //getEncrypted(expressionData, keyData, Program.usingFile);
     String errors = backend.StandardError.ReadToEnd();
     if(!errors.Equals(""))
     {
         if (MessageBox.Show("An error occured during your last encryption run. Display the message?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
             MessageBox.Show(errors, "Error Details");
     }
     return backend.StandardOutput.ReadToEnd();
     /*
     string encrypted;
     using (StreamReader read = new StreamReader(File.OpenRead("return"), Encoding.Default, true))
         encrypted = read.ReadToEnd();
     File.Delete("return");
     return encrypted;
     */
 }
Exemplo n.º 5
0
        // This method is made only for not having to remake the bar codes on the cards for the review 3
        // NP sets are called tvm_xxx while the cards show token xxx
        public static String transform_to_review3_tvmTokens(String scannedToken)
        {

            
            if (scannedToken.Contains("sammy"))
            {
                return "tvm_sammy";
            }
            else if (scannedToken.Contains("lara"))
            {
                return "tvm_lara";
            }
            else if (scannedToken.Contains("jasmin"))
            {
                return "tvm_valdimir"; ;
            }
            else if (scannedToken.Contains("vladimir"))
            {
                return "tvm_valdimir";
            }
            else
            {
                return "logout";
            }
        }
Exemplo n.º 6
0
 /** Used to figure out whether a Contains search will use an Ordinal or OrdinalIgnoreCase
  *  Default int of 0 is to ignore case (and return more search findings).
  **/
 public static Boolean foundBySpecifiedCase(String toFind, String toSearchIn, int caseSensitive)
 {
     if (caseSensitive == 0)
         return toSearchIn.Contains(toFind, StringComparison.OrdinalIgnoreCase);
     else
         return toSearchIn.Contains(toFind);
 }
Exemplo n.º 7
0
      public void processCommand(String c, MainWindow main)
        {

            c = c.ToLower();
            main.log.Items.Add(DateTime.Now + ": " + c);


            if (!c.Contains("xbox")) //Because I have a xbox one (Prevents jarvis from picking up xbox commands)
  
      if (c.Contains("sleep"))
          {
              ExecuteCommand("C:/nircmd.exe monitor off");
          }
      else
      {
          if (JarvisData.isOff != "true")
          {
              t = new Thread(ProcessCommand2);
              t.Start(c);
          }
         
      }
          
          
        }
        /// <summary>
        /// Creates a new NonBooleanConstraint for a expression. The expression have to consist binary and numeric options and operators such as "+,*,>=,<=,>,<, and =" only. 
        /// Where all binary and numeric options have to be defined in the variability model. 
        /// </summary>
        /// <param name="unparsedExpression"></param>
        /// <param name="varModel"></param>
        public NonBooleanConstraint(String unparsedExpression, VariabilityModel varModel)
        {
            if (unparsedExpression.Contains(">="))
            {
                comparator = ">=";
            }
            else if (unparsedExpression.Contains("<="))
            {
                comparator = "<=";
            }
            else if (unparsedExpression.Contains("="))
            {
                comparator = "=";
            }
            else if (unparsedExpression.Contains(">"))
            {
                comparator = ">";
            }
            else if (unparsedExpression.Contains("<"))
            {
                comparator = "<";
            }

            String[] parts = unparsedExpression.Split(comparator.ToCharArray());
            leftHandSide = new InfluenceFunction(parts[0], varModel);
            rightHandSide = new InfluenceFunction(parts[parts.Length-1], varModel);
        }
Exemplo n.º 9
0
        public void ParseJson(String jstring)
        {
            if (jstring.Contains("recording"))
            {
                if (jstring.Contains("true"))
                {
                    Console.WriteLine("Starting!");
                    recording = true;
                }
                else
                {
                    Console.WriteLine("Stopping!");
                    List<WriterAction> nactions = new List<WriterAction>(actions.Count);
                    actions.ForEach(nactions.Add);
                    new Thread(GUI.StartGui).Start(nactions);
                    actions.Clear();
                    recording = false;
                }
                return;
            }
            var json = new DataContractJsonSerializer(typeof (UserAction));
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(jstring));
            UserAction act = json.ReadObject(stream) as UserAction;
            stream.Close();

            if (recording)
            {
                Console.WriteLine(act.ToString());
                actions.Add(act);
            }
        }
        public string addLinksToString(String myString)
        {
            string[] temp = myString.Split(' '); //split into words
            if (myString.Contains("http:") || myString.Contains("www."))
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i].Contains("www.") && (!temp[i].Contains("http")))
                    {
                        temp[i] = "<a href=\"http://" + temp[i] + "\">" + temp[i] + "</a>";
                    }
                    else if (temp[i].Contains("http://"))
                    {
                        temp[i] = "<a href=\"" + temp[i] + "\">" + temp[i] + "</a>";
                    }
                }

            }
            string result = "";
            foreach (string item in temp)
            {
                result += item + " ";
            }
            return result;
        }
 public String cDataCheck(String input)
 {
     if (input.Contains("&") || input.Contains(">") || input.Contains("<"))
     {
         input = "<![CDATA[" + input + "]]>";
     }
     return input;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Checks the string input for script and html tags. This is a very rough check!
        /// </summary>
        /// <param name="value"></param>
        /// <returns>1 - Clean string | 2 - Scripts detected</returns>
        static public bool IsNotScript(String value)
        {
            if (value.Contains("<script>") || value.Contains("<html>"))
            {
                return false;
            }

            return true;
        }
Exemplo n.º 13
0
        public String getNL(String hand)
        {
            //only nl200
            String[] temp = hand.Split('(');
            String[] temp2 = temp[1].ToString().Split(')');

            if (hand.Contains("0.01/") && hand.Contains("0.02"))
            {
                return "2";
            }
            if (hand.Contains("0.02/") && hand.Contains("0.05"))
            {
                return "5";
            }
            if (hand.Contains("0.05/") && hand.Contains("0.10"))
            {
                return "10";
            }
            if (hand.Contains("0.08/") && hand.Contains("0.16"))
            {
                return "16";
            }
            if (temp2[0].Contains("0.10/") && temp2[0].Contains("0.20"))
            {
                return "20";
            }
            if (hand.Contains("0.10/") && hand.Contains("0.25"))
            {
                return "25";
            }
            if (hand.Contains("0.15/") && hand.Contains("0.30"))
            {
                return "30";
            }
            if (hand.Contains("0.25/") && hand.Contains("0.50"))
            {
                return "50";
            }
            if (hand.Contains("0.50/") && hand.Contains("1.00"))
            {
                return "100";
            }
            if (temp2[0].Contains("1/") && temp2[0].Contains("2") && !temp2[0].Contains("."))
            {
                return "200";
            }
            if (temp2[0].Contains("2/") && temp2[0].Contains("4") && !temp2[0].Contains("."))
            {
                return "400";
            }
            if (hand.Contains("2.50/") && hand.Contains("5.00"))
            {
                return "500";
            }
            return "_";
        }
Exemplo n.º 14
0
        private static String ExtractValuableInfo( String inLine )
        {
            String retVal = "";

              // detect what we would like to find..
              if ( inLine.Contains( "Log Started" ) ) return String.Format("\t{0}\n", inLine);
              if ( inLine.Contains( "ProductVersion" ) ) return String.Format( "\t{0}\n", inLine );
              if ( inLine.Contains( "> Creating" ) ) return String.Format( "\t{0}\n", inLine );
              return retVal;
        }
Exemplo n.º 15
0
        public static float ToFloat(String str)
        {
            if(!str.Contains(',') && !str.Contains('.')) 
                return float.Parse(str);

            string realSep = (float.Parse("0.5") == 0.5f) ? "." : ",";
            string strSep = str.Contains(".") ? "." : ",";

            return float.Parse(str.Replace(strSep, realSep));
        }
Exemplo n.º 16
0
        public String GetPage(String path)
        {
            using (WebClient webClient = new WebClient())
            {
                if (!(path.Contains("steam") || path.Contains("roxen")))
                    webClient.Encoding = Encoding.UTF8;

                return webClient.DownloadString(path);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Cleaning string so it would fit format of CSV file
 /// </summary>
 /// <param name="str">str is string that we want to clean</param>
 /// <returns>return is that same string but cleaned</returns>
 public String cleanString(String str)
 {
     if (str.Contains(",") || str.Contains("\""))
     {
         str = "\"" + str + "\"";
     }
     str = str.Replace('"', '\0');
     str = str.Replace("\n", "\\n");
     return str;
 }
Exemplo n.º 18
0
        public static void Main(String[] args)
        {
            // This fixes the current directory in case it is run from outside the launcher path.
            Environment.CurrentDirectory = Path.GetDirectoryName(typeof(SharpCraftApplication).Assembly.Location);

            if (args.Contains("-game") || args.Contains("-editor"))
                StartDirect(args);
            else
                StartLauncher(args);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Checks wether a given path points to a file or a folder. Always returns path to the folder.
 /// </summary>
 public static String GetPath(String path)
 {
     if (path.Contains(".mkv") || path.Contains(".mp4") || path.Contains(".avi"))
     {
         // Path points directly to a file:
         String newPath = path.Substring(0, (path.Length - Path.GetFileName(path).Length) - 1);
         return newPath + @"\";
     }
     // Path already points to a folder:
     return path;
 }
Exemplo n.º 20
0
        /// <summary>
        /// The application's entry point.
        /// </summary>
        /// <param name="args">An array containing the application's command line arguments.</param>
        public static void Main(String[] args)
        {
            using (var game = new Game())
            {
                game.resolveContent = args.Contains("-resolve:content");
                game.compileContent = args.Contains("-compile:content");
                game.compileExpressions = args.Contains("-compile:expressions");

                game.Run();
            }
        }
Exemplo n.º 21
0
        public static String RemoveArgumentFromPath(String path)
        {
            if (path.Contains("/")) {
               path = path.Substring(0, path.LastIndexOf("/") );

               }
               if (path.Contains("-")) {
               path = path.Substring(0, path.LastIndexOf("-"));
               }
               return path;
        }
Exemplo n.º 22
0
 private Boolean isValidValue(String value)
 {
     if (value != null && !value.Contains("#NE#") && !value.Contains("#NULL#"))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 23
0
 public static void checkEmail(String check)
 {
     int atindex = check.IndexOf("@");
     int dotindex = check.IndexOf(".");
     if((check.Contains("@")) && (check.Contains("."))) {
         if((atindex > 0) && (dotindex < (check.Length - 2))&&(atindex < dotindex)){
             Console.WriteLine("Email verified");
         }
         else {
             Console.WriteLine("Email declined");
         }
     }
 }
Exemplo n.º 24
0
		/**
	     * Populate the given {@link TextView} with the requested text, formatting
	     * through {@link Html#fromHtml(String)} when applicable. Also sets
	     * {@link TextView#setMovementMethod} so inline links are handled.
	     */
		public static void SetTextMaybeHtml (TextView view, String text)
		{
			if (TextUtils.IsEmpty (text)) {
				view.Text = "";
				return;
			}
			if (text.Contains ("<") && text.Contains (">")) {
				view.TextFormatted = Html.FromHtml (text);
				view.MovementMethod = Android.Text.Method.LinkMovementMethod.Instance;
			} else {
				view.Text = text;
			}
		}
Exemplo n.º 25
0
 public void RewardPlayers(String resource, int playerID, int amount)
 {
     if (resource.Contains("bricks"))
         players[playerID].bricks += amount;
     if (resource.Contains("wheat"))
         players[playerID].wheat += amount;
     if (resource.Contains("ore"))
         players[playerID].ore += amount;
     if (resource.Contains("wool"))
         players[playerID].wool += amount;
     if (resource.Contains("lumber"))
         players[playerID].lumber += amount;
 }
Exemplo n.º 26
0
    public void SendMail(String SMTPServerName, int PortNumber, String SMTPServerEmailId, String SMTPServerEmailPassword, String SendToEmailId, String Subject, string Body, bool BodyHtml, String[] Attachment)
    {
        try
        {
            SmtpClient smtpclient;
            if (PortNumber == 0)
            {
                smtpclient = new SmtpClient(SMTPServerName);
            }
            else
            {
                smtpclient = new SmtpClient(SMTPServerName,PortNumber );
            }

            smtpclient.UseDefaultCredentials = true;
            smtpclient.Credentials = new NetworkCredential(SMTPServerEmailId, SMTPServerEmailPassword);
            MailMessage Message = new MailMessage(SMTPServerEmailId, SendToEmailId);
            Message.Subject = Subject;
            Message.Body = Body;
            Message.Priority = System.Net.Mail.MailPriority.High;
            Message.IsBodyHtml = BodyHtml ;
            string[] StrAttachment = Attachment;

            System.Net.Mail.Attachment MyAttachement;

            if (StrAttachment.Length > 0)
            {
                foreach (string strfile in StrAttachment)
                {

                    Message.Attachments.Add(new Attachment(strfile));
                }
            }
            if (SMTPServerName.Contains("gmail") == true || SMTPServerName.Contains("live") == true || SMTPServerName.Contains("hotmail") == true)
            {
                smtpclient.EnableSsl = true;
            }
            else
            {
                smtpclient.EnableSsl = false;
            }
            smtpclient.Send(Message);
        }
        catch
        {
        }
        finally
        {

        }
    }
Exemplo n.º 27
0
        private void GlobalKeyIntercepted(String keys)
        {
            if (topBlue.Keys.ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartTopBlue();
                return;
            }

            if (bottomBlue.Keys.ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartBottomBlue();
                return;
            }

            if (topRed.Keys.ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartTopRed();
                return;
            }

            if (bottomRed.Keys.ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartBottomRed();
                return;
            }

            if (dragon.Keys.ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartDragon();
                return;
            }

            if (baron.Keys.ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartBaron();
                return;
            }

            if (Properties.Settings.Default.InitGame.Split('#').ToList().TrueForAll(x => keys.Contains(x)))
            {
                StartGame();
                return;
            }

            if (Properties.Settings.Default.Reset.Split('#').ToList().TrueForAll(x => keys.Contains(x)))
            {
                ResetTimer();
                return;
            }
        }
Exemplo n.º 28
0
 public Tratamiento(Int16 Id, String Nombre, Int16 Duracion, Int16 Costo, String Descripcion, String Explicacion, String Estado)
 {
     this._Id = Id;
     this._Nombre = Nombre;
     this._Duracion = Duracion;
     this._Costo = Costo;
     this._Descripcion = Descripcion;
     this._Explicacion = Explicacion;
     this._Estado = Estado;
     if (Estado.Contains("Activo"))
         _Estate = true;
     else if (Estado.Contains("Inactivo"))
         _Estate = false;
 }
Exemplo n.º 29
0
		public static HttpClient GetHttpClient (String endpoint, bool formData)
		{
			var client = new HttpClient ();
			client.BaseAddress = new Uri (Endpoint.BaseURL);

			client.Timeout = (endpoint == Endpoint.BaseURL + "/post") ? TimeSpan.FromSeconds(30) : TimeSpan.FromSeconds (10);

			if (!endpoint.Contains ("/register") && !endpoint.Contains ("forgotPassword") && !endpoint.Contains ("resetPassword")) {
				var authHeaderValue = Convert.ToBase64String (Encoding.UTF8.GetBytes (string.Format ("{0}:{1}", Globe.SharedInstance.User.username, Globe.SharedInstance.User.password)));
				client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue ("Basic", authHeaderValue);
				System.Diagnostics.Debug.WriteLine(authHeaderValue);

			}
			return client;
		}
Exemplo n.º 30
0
        public static ValidationErrors TestFieldValue(SearchFields field, String value)
        {
            if (value.Contains('[') || value.Contains(']'))
                return ValidationErrors.ContainsBraces;

            String[] colours = { "Black", "White", "Blue", "Green", "Red" };
            switch (field)
            {
                // Generic text-fields
                case SearchFields.Name:
                case SearchFields.RulesText:
                case SearchFields.Expansion:
                case SearchFields.Format:
                case SearchFields.Types:
                case SearchFields.Subtypes:
                case SearchFields.FlavorText:
                case SearchFields.Mark:
                case SearchFields.Artist:
                case SearchFields.UserComment:
              //case SearchFields.UserName:
                case SearchFields.Block:
                case SearchFields.Rarity:
                    if (value.Contains(' ') && (!value.StartsWith("\"") || !value.EndsWith("\"")))
                        return ValidationErrors.UnquotedString;
                    else
                        return ValidationErrors.NoErrors;

                case SearchFields.CMC:
                case SearchFields.Power:
                case SearchFields.Toughness:
                case SearchFields.CommunityRating:
                case SearchFields.ManaCost:
                case SearchFields.HandModifier:
                case SearchFields.LifeModifier:
                    Double tmp;
                    if (!Double.TryParse(value, out tmp))
                        return ValidationErrors.NonNumericValue;
                    else
                        return ValidationErrors.NoErrors;

                case SearchFields.Colors:
                    if (colours.Contains(value))
                        return ValidationErrors.NoErrors;
                    else
                        return ValidationErrors.UnknownColour;
            }
            throw new ArgumentException("Unknown field");
        }
 /// <summary>
 /// Determines what OS is running and calls platform-specific Initialize function.
 /// </summary>
 private void InitializeController()
 {
     if (OperatingSystem.Contains("Mac"))
     {
         Debug.Log("Mac OS.");
         InitializeForMac();
     }
     else if (OperatingSystem.Contains("Windows"))
     {
         Debug.Log("Windows OS.");
         InitializeForWindows();
     }
     else if (OperatingSystem.Contains("Linux"))
     {
         Debug.Log("Linux OS.");
         InitializeForLinux();
     }
     else
     {
         Debug.Log("Unknown OS.");
     }
 }
Exemplo n.º 32
0
 public static System.Decimal ToDecimal(System.String AValue)
 {
     if (AValue.Contains(","))
     {
         AValue = AValue.Replace(".", "");
     }
     else
     {
         AValue = AValue.Replace(".", ",");
     }
     System.Decimal NewValue;
     if (!DecimalUtils.IsValid(AValue, out NewValue))
     {
         return(0);
     }
     else
     {
         return(NewValue);
     }
 }
Exemplo n.º 33
0
        /*
         * Event.LOADSCENE handler - comes here when 3D scene loaded.
         * If a user interface scene is loaded (name contains "ui_")
         * bind the UI scene to the Selector for picking outfits.
         */
        public override void OnSceneLoad(SharedWorld world, Scene scene, String scenefile)
        {
            System.String name = scene.Name.ToLower();

            if (name.Contains("ui_"))
            {
                Model iconRoot = uiRoot.Find(".selectable", Group.FIND_DESCEND | Group.FIND_END) as Model;
                SharedWorld.Trace("Loaded " + name);
                if (iconRoot != null)
                {
                    RaiseSceneLoadEvent(name, scenefile);
                    if (outfitSelector != null)
                    {
                        outfitSelector.SetTarget(iconRoot);
                    }
                    return;
                }
            }
            base.OnSceneLoad(world, scene, scenefile);
        }
Exemplo n.º 34
0
        public static string BytesToNBNSQuery(byte[] field)
        {
            string nbnsUTF8 = BitConverter.ToString(field);

            nbnsUTF8 = nbnsUTF8.Replace("-00", String.Empty);
            string[] nbnsArray = nbnsUTF8.Split('-');
            string   nbnsQuery = "";

            foreach (string character in nbnsArray)
            {
                nbnsQuery += new System.String(Convert.ToChar(Convert.ToInt16(character, 16)), 1);
            }

            if (nbnsQuery.Contains("CA"))
            {
                nbnsQuery = nbnsQuery.Substring(0, nbnsQuery.IndexOf("CA"));
            }

            int    i = 0;
            string nbnsQuerySubtracted = "";

            do
            {
                byte nbnsQuerySub = (byte)Convert.ToChar(nbnsQuery.Substring(i, 1));
                nbnsQuerySub        -= 65;
                nbnsQuerySubtracted += Convert.ToString(nbnsQuerySub, 16);
                i++;
            }while (i < nbnsQuery.Length);

            i = 0;
            string nbnsQueryHost = "";

            do
            {
                nbnsQueryHost += (Convert.ToChar(Convert.ToInt16(nbnsQuerySubtracted.Substring(i, 2), 16)));
                i             += 2;
            }while (i < nbnsQuerySubtracted.Length - 1);

            return(nbnsQueryHost);
        }
Exemplo n.º 35
0
        /// <summary>
        /// This the call back function which will be invoked when the socket
        /// detects any client writing of data on the stream
        /// </summary>
        /// <param name="asyn"></param>
        private void OnDataReceived(IAsyncResult asyn)
        {
            SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
            int          iRx       = 0;
            bool         success   = false;

            try
            {
                iRx     = theSockId.m_currentSocket.EndReceive(asyn);
                success = true;
            }
            catch
            {
            }

            if (success)
            {
                char[] chars          = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String szData = new System.String(chars);

                // switch the recording of images on or off
                if (szData.StartsWith("Record"))
                {
                    bool valid_path = false;
                    if (szData.Contains(" "))
                    {
                        string[] parts = szData.Split(' ');
                        if (parts.Length > 1)
                        {
                            if ((parts[1].ToLower() != "false") &&
                                (parts[1].ToLower() != "off"))
                            {
                                string directory_str = "";
                                char[] ch            = parts[1].ToCharArray();
                                for (int i = 0; i < ch.Length; i++)
                                {
                                    if ((ch[i] != 10) &&
                                        (ch[i] != 13) &&
                                        (ch[i] != 0))
                                    {
                                        directory_str += ch[i];
                                    }
                                }

                                if (directory_str.Contains("/"))
                                {
                                    if (!directory_str.EndsWith("/"))
                                    {
                                        directory_str += "/";
                                    }
                                }

                                if (Directory.Exists(directory_str))
                                {
                                    // start recording
                                    if (vision != null)
                                    {
                                        Console.WriteLine("Start recording images in " + parts[1]);
                                        vision.Record = true;
                                        vision.recorded_images_path = directory_str;
                                    }
                                    else
                                    {
                                        Console.WriteLine("No vision object");
                                    }
                                    valid_path = true;
                                }
                                else
                                {
                                    Console.WriteLine("Directory " + directory_str + " not found");
                                }
                            }
                        }
                    }

                    if (!valid_path)
                    {
                        // stop recording
                        Console.WriteLine("Stop recording images");
                        if (vision != null)
                        {
                            vision.Record = false;
                        }
                    }
                }
            }

            WaitForData(theSockId.m_currentSocket, theSockId.m_clientNumber);
        }
Exemplo n.º 36
0
 private bool contains(VTDNav vn)
 {
     System.String s1 = argumentList.e.evalString(vn);
     System.String s2 = argumentList.next.e.evalString(vn);
     return(s1.Contains(s2));
 }
Exemplo n.º 37
0
        /*!
         * @param world	current world
         * @param scene	scene which finished loading
         *
         * Called when a 3D content file has finished loading. This event
         * will always come before OnSetScene but this function is not
         * guaranteed to be called before th 3D scene has been replaced.
         * This function always invokes the LoadSceneEvent handler.
         */
        public virtual void OnSceneLoad(SharedWorld world, Scene scene, String scenefile)
        {
            System.String name = scene.Name.ToLower();

            if (name.EndsWith(".scene"))
            {
                name = name.Substring(0, name.Length - 6);
            }
            SharedWorld.Trace("Loaded " + name);
            if (LoadSceneEvent != null)
            {
                LoadSceneEvent(name, scenefile);
            }
            if (scenefile.Contains("avatar"))
            {
                OnAvatarLoad(world, scene);
                return;
            }
            if (name.Contains("hair"))
            {
                ConnectHair(world, scene);
                return;
            }
            else if (!sceneLoaded && (interiorRoot.FileName == scenefile))
            {
                sceneLoaded = true;
                world.SuspendScene();
                Camera mainCam = world.GetScene().Camera;
                Box3   vvol    = scene.Camera.ViewVol;
                float  aspect  = mainCam.Aspect;
                mainCam.Copy(scene.Camera);
                mainCam.Aspect = aspect;
                if (cameraController != null)
                {
                    cameraController.Target = mainCam;
                }
                world.ResumeScene();
                if (scriptor != null)
                {
                    scriptor.LoadScript(scenefile.Substring(0, scenefile.Length - 3) + "scp");
                }
                return;
            }

            /*
             * Not background or avatar, assume it is clothing
             */
            if (closet == null)
            {
                return;
            }
            world.SuspendScene();
            dynamic g = closet.OnLoad(scene, world, config.avatar);

            if (g == null)
            {
                world.ResumeScene();
                return;
            }
            if (g.script != null)
            {
                PlayAnimation(g.script, 0);
            }
            if (g.ClothSim != null)
            {
                if (g.ClothSim.Parent() == null)
                {
                    physics.Append(g.ClothSim);
                }
                if (typeof(ClothSim).IsAssignableFrom(g.ClothSim.GetType()))
                {
                    ((ClothSim)g.ClothSim).GroundPlane = groundPlane;
                }
            }
            currentGarment = g;
            world.ResumeScene();
            if (LoadGarmentEvent != null)
            {
                LoadGarmentEvent(g.name, scenefile);
            }
        }