Пример #1
0
        private void Ping(string[] parameters, ClientInfo sender)
        {
            Message m = new Message("Server", MessageType.Message);

            m.SetContent("Pong!");
            m.SetColor(NColor.FromRGB(0, 255, 21));

            sender.Send(m);
        }
Пример #2
0
 public string ChangeTagColor(byte R, byte G, byte B)
 {
     if (R >= 0 && R <= 255 && R >= 0 && G <= 255 && R >= 0 && B <= 255)
     {
         this.TagColor = NColor.FromRGB(R, G, B);
         PrintToLog("Changing tag color to (" + R.ToString() + ", " + G.ToString() + ", " + B.ToString() + ")", Color.Teal);
         return("(" + R.ToString() + ", " + G.ToString() + ", " + B.ToString() + ")");
     }
     PrintToLog("Invalid Color", Color.Red);
     return("Invalid Color");
 }
Пример #3
0
        /// <summary>
        /// Creates a section title paragraph
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private NParagraph CreateSecondaryTitleParagraph(string text)
        {
            NParagraph paragraph = new NParagraph();

            NTextInline textInline = new NTextInline();

            textInline.FontSize = 12;
            textInline.Fill     = new NColorFill(NColor.FromRGB(89, 76, 46));
            paragraph.Inlines.Add(textInline);

            return(paragraph);
        }
Пример #4
0
        private static NColor ColorFromValue(double value)
        {
            NColor beginColor = NColor.LightBlue;
            NColor endColor   = NColor.DarkSlateBlue;

            float factor         = (float)(value / 650.0f);
            float oneMinusFactor = 1.0f - factor;

            return(NColor.FromRGB((byte)((float)beginColor.R * factor + (float)endColor.R * oneMinusFactor),
                                  (byte)((float)beginColor.G * factor + (float)endColor.G * oneMinusFactor),
                                  (byte)((float)beginColor.B * factor + (float)endColor.B * oneMinusFactor)));
        }
Пример #5
0
        private NColor ColorFromVector(double dx, double dy)
        {
            double length = Math.Sqrt(dx * dx + dy * dy);

            double sq2 = Math.Sqrt(2);

            int r = (int)((255 / sq2) * length);
            int g = 20;
            int b = (int)((255 / sq2) * (sq2 - length));

            return(NColor.FromRGB((byte)r, (byte)g, (byte)b));
        }
Пример #6
0
        public Tcp_Client(string[] args)
        {
            foreach (string argument in args)
            {
                if (argument.ToLower() == "/debug")
                {
                    debug = true;
                }
            }
            InitializeComponent();

            print("Welcome to the Nova Chat Client. Please enter an IP address above and click 'Connect' to begin.\n" +
                  "Press 'Delete' when focused in this box to clear it, or use the 'Clear History' button in the menu.", Chat);

            notifications  = new NotificationManager(this, ref settings);
            SettingsWindow = new Settings(this, ref settings, notifications);
            TagColor       = NColor.FromRGB(rnd.Next(256), rnd.Next(256), rnd.Next(256));
        }
Пример #7
0
 static NColor ColorToNColor(Color color)
 {
     return(NColor.FromRGB(color.R, color.G, color.B));
 }
Пример #8
0
 private void SendMessage()
 {
     try
     {
         if (chatBox.Text.ToLower().StartsWith("/whisper"))
         {
             string[] text = chatBox.Text.Split('"', '"');
             try
             {
                 user.CreateWhisper(text[3], TagColor, text[1]);
                 print(nameBox.Text + ": " + "Message privately sent to " + text[1], Chat, NColorToColor(TagColor));
             }
             catch (Exception ex)
             {
                 print("Couldn't run command", Chat, Color.Red);
                 PrintToLog("Couldn't run command -> " + ex.Message, Color.Red);
             }
         }
         else if (chatBox.Text.StartsWith("/color"))
         {
             string[] text = chatBox.Text.Replace("/color ", "").Split(' ');
             if (text.Length > 1)
             {
                 TagColor = NColor.FromRGB(int.Parse(text[0]), int.Parse(text[1]), int.Parse(text[2]));
             }
             else
             {
                 TagColor = ColorToNColor(Color.FromName(text[0]));
             }
         }
         else if (chatBox.Text.StartsWith("/info"))
         {
             string[] command = chatBox.Text.Replace("/info ", "").Split(' ');
             if (command[0] == "users")
             {
                 user.CreateInformation(InfomationType.ConnectedUsers);
             }
             else if (command[0] == "time")
             {
                 user.CreateInformation(InfomationType.ConnectTime);
             }
             else if (command[0] == "sent")
             {
                 user.CreateInformation(InfomationType.MessagesSent);
             }
             else if (command[0] == "uptime")
             {
                 user.CreateInformation(InfomationType.ServerUptime);
             }
             else if (command[0] == "rooms")
             {
                 user.CreateInformation(InfomationType.Rooms);
             }
             else
             {
                 print("Unknown Parameter", Chat);
             }
         }
         else if (chatBox.Text.StartsWith("/changeroom"))
         {
             string room = chatBox.Text.Replace("/changeroom ", "");
             user.CreateStatus(StatusType.ChangeRoom, room);
         }
         else
         {
             if (user != null)
             {
                 print(nameBox.Text + ": " + chatBox.Text, Chat, NColorToColor(TagColor));
                 user.CreateMessage(chatBox.Text, TagColor);
             }
         }
     }
     catch (Exception ex)
     {
         print("Error Sending Message -> " + ex.Message, Log, Color.Red);
     }
     chatBox.Clear();
 }
Пример #9
0
        public static JsonMessage Deserialize(string json)
        {
            JsonTextReader reader = new JsonTextReader(new StringReader(json));
            JsonMessage    m      = null;
            string         name   = "";

            while (reader.Read())
            {
                if (reader.Value != null)
                {
                    string value = reader.Value.ToString();
                    if (value == "Name")
                    {
                        name = reader.ReadAsString();
                    }
                    else if (value == "MessageType")
                    {
                        m = new JsonMessage(name, (MessageType)reader.ReadAsInt32());
                    }
                    else if (value == "Content")
                    {
                        m.SetContent(reader.ReadAsString());
                    }
                    else if (value == "R")
                    {
                        int r = (int)reader.ReadAsInt32();

                        reader.Read();
                        int g = (int)reader.ReadAsInt32();

                        reader.Read();
                        int b = (int)reader.ReadAsInt32();

                        m.SetColor(NColor.FromRGB(r, g, b));
                    }
                    else if (value == "EndPoint")
                    {
                        m.SetEndpoint(reader.ReadAsString());
                    }
                    else if (value == "StatusType")
                    {
                        m.SetStatusType((StatusType)reader.ReadAsInt32());
                    }
                    else if (value == "InformationType")
                    {
                        m.SetInformationType((InfomationType)reader.ReadAsInt32());
                    }
                    else if (value == "RequestType")
                    {
                        m.SetRequestType((RequestType)reader.ReadAsInt32());
                    }
                    else if (value == "Color")
                    {
                    }
                    else
                    {
                        Console.WriteLine("Unknown Attribute");
                    }
                }
            }
            return(m);
        }