예제 #1
0
        /// <summary>
        /// Handles the object event add.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void HandleObjectEventAdd(BotEngine sender, EventObjectAddArgs e)
        {
            //Console.ForegroundColor = ConsoleColor.Green;
            ConsoleHelpers.WriteLine(string.Format("object {0} with id {1} added.", e.Model.ModelName, e.Model.Id));
            //Console.ForegroundColor = ConsoleColor.White;

            if (e.Model.Action.Contains("@change"))
            {
                string htmlColor = ColorTranslator.ToHtml(Color.FromArgb(255, r.Next(255), r.Next(255), (byte)r.Next(255))).Substring(1);
                var    model     = e.Model;
                model.Action      = "create color " + htmlColor + ";@change";
                model.Description = DateTime.Now.ToLongTimeString();
                sender.ChangeObject(model);
            }

            //// perform some unit tests, these are invoked by the object description.
            //switch (e.Model.Action)
            //{
            //    case "@remove" :
            //        sender.DeleteObject(e.Model);
            //        break;
            //    case "@change" :
            //        var model = e.Model;
            //        model.Description = DateTime.Now.ToLongTimeString();
            //        sender.ChangeObject(model);
            //        ConsoleHelpers.WriteLine(string.Format("Changed model {0}.",model.Id));
            //        break;
            //}
        }