Beispiel #1
0
 public ChatMessage(IUser sender, FontOptions font, string text, DateTime timestamp)
 {
     Sender    = sender;
     Font      = font;
     Text      = text;
     Timestamp = timestamp;
 }
 public ChatEventArgs(IUser user, FontOptions font, string body, DateTime timestamp)
 {
     User      = user;
     Font      = font;
     Body      = body;
     Timestamp = timestamp;
 }
 public ChatMessage(IUser sender, FontOptions font, string text, DateTime timestamp)
 {
     Sender = sender;
     Font = font;
     Text = text;
     Timestamp = timestamp;
 }
Beispiel #4
0
        public void SendMessage(string message, FontOptions font, DateTime timestamp)
        {
            if (IsGroup)
            {
                client.ChatGroup(Name, font, message, timestamp, null);
            }
            else
            {
                client.ChatUser(Name, font, message, timestamp, null);
            }

            AddMessage(new ChatMessage(client.Me, font, message, timestamp));
        }
Beispiel #5
0
        private void Chat(string messageTarget, string to, FontOptions font, string chatMessage, DateTime timestamp, EventHandler <ReplyEventArgs> callback)
        {
            VerifyLoggedIn();

            string colorString = string.Format("#{0}{1}{2}", font.Color.R.ToString("x2"), font.Color.G.ToString("x2"), font.Color.B.ToString("x2"));

            var message = protocol.CreateMessage("chat." + messageTarget);

            message["to"]             = to;
            message["font"]           = new JObject();
            message["font"]["family"] = font.Family;
            message["font"]["color"]  = colorString;
            message["font"]["style"]  =
                (font.Style.HasFlag(FontStyle.Bold) ? "b" : "") +
                (font.Style.HasFlag(FontStyle.Italic) ? "i" : "") +
                (font.Style.HasFlag(FontStyle.Underline) ? "u" : "");
            message["body"]      = Convert.ToBase64String(Encoding.UTF8.GetBytes(chatMessage));
            message["timestamp"] = timestamp.ToString("o");

            protocol.SendMessage(message, (messageName, result, reply) =>
            {
                ReplyEventArgs args;
                switch (result)
                {
                case Network.ReplyResult.Success:
                    args = new ReplyEventArgs(Convert.ToInt32(reply["result"]), Convert.ToString(reply["result_message"]));
                    break;

                case Network.ReplyResult.Fail:
                    args = new ReplyEventArgs((int)ResultCode.NotSent, MessageNotSentString);
                    break;

                case Network.ReplyResult.Expired:
                    args = new ReplyEventArgs((int)ResultCode.NoReply, NoReplyString);
                    break;

                default:
                    throw new Exception("This should not happen");
                }
                if (callback != null)
                {
                    callback(this, args);
                }
            });
        }
 public UserChatEventArgs(IUser user, FontOptions font, string body, DateTime timestamp)
     : base(user, font, body, timestamp)
 {
 }
Beispiel #7
0
 public void SendMessage(string message, FontOptions font)
 {
     SendMessage(message, font, DateTime.UtcNow);
 }
Beispiel #8
0
        public void ChatGroup(string groupname, FontOptions font, string chatMessage, DateTime timestamp, EventHandler <ReplyEventArgs> callback)
        {
            Contract.Requires(protocol != null);

            Chat("group", groupname, font, chatMessage, timestamp, callback);
        }
Beispiel #9
0
        private void Chat(string messageTarget, string to, FontOptions font, string chatMessage, DateTime timestamp, EventHandler<ReplyEventArgs> callback)
        {
            VerifyLoggedIn();

            string colorString = string.Format("#{0}{1}{2}", font.Color.R.ToString("x2"), font.Color.G.ToString("x2"), font.Color.B.ToString("x2"));

            var message = protocol.CreateMessage("chat." + messageTarget);
            message["to"] = to;
            message["font"] = new JObject();
            message["font"]["family"] = font.Family;
            message["font"]["color"] = colorString;
            message["font"]["style"] =
                (font.Style.HasFlag(FontStyle.Bold) ? "b" : "") +
                (font.Style.HasFlag(FontStyle.Italic) ? "i" : "") +
                (font.Style.HasFlag(FontStyle.Underline) ? "u" : "");
            message["body"] = Convert.ToBase64String(Encoding.UTF8.GetBytes(chatMessage));
            message["timestamp"] = timestamp.ToString("o");

            protocol.SendMessage(message, (messageName, result, reply) =>
                {
                    ReplyEventArgs args;
                    switch (result)
                    {
                        case Network.ReplyResult.Success:
                            args = new ReplyEventArgs(Convert.ToInt32(reply["result"]), Convert.ToString(reply["result_message"]));
                            break;

                        case Network.ReplyResult.Fail:
                            args = new ReplyEventArgs((int) ResultCode.NotSent, MessageNotSentString);
                            break;

                        case Network.ReplyResult.Expired:
                            args = new ReplyEventArgs((int) ResultCode.NoReply, NoReplyString);
                            break;

                        default:
                            throw new Exception("This should not happen");
                    }
                    if (callback != null)
                        callback(this, args);
                });
        }
        void OnFontChanged(object sender, EventArgs e)
        {
            font = App.Current.ClientFont;

            TextDecorations = new TextDecorationCollection();
            if (font.Style.HasFlag(Protocol.FontStyle.Underline))
                TextDecorations.Add(System.Windows.TextDecorations.Underline);

            NotifyPropertyChanged("FontFamily");
            NotifyPropertyChanged("FontWeight");
            NotifyPropertyChanged("FontStyle");
            NotifyPropertyChanged("FontColor");
            NotifyPropertyChanged("TextDecorations");
        }
        public void SendMessage(string message, FontOptions font, DateTime timestamp)
        {
            if (IsGroup)
                client.ChatGroup(Name, font, message, timestamp, null);
            else
                client.ChatUser(Name, font, message, timestamp, null);

            AddMessage(new ChatMessage(client.Me, font, message, timestamp));
        }
 public void SendMessage(string message, FontOptions font)
 {
     SendMessage(message, font, DateTime.UtcNow);
 }
Beispiel #13
0
 public UserChatEventArgs(IUser user, FontOptions font, string body, DateTime timestamp)
     : base(user, font, body, timestamp)
 {
 }
Beispiel #14
0
 public GroupChatEventArgs(IGroup group, IUser user, FontOptions font, string body, DateTime timestamp)
     : base(user, font, body, timestamp)
 {
     Group = group;
 }
Beispiel #15
0
 public ChatEventArgs(IUser user, FontOptions font, string body, DateTime timestamp)
 {
     User = user;
     Font = font;
     Body = body;
     Timestamp = timestamp;
 }
Beispiel #16
0
 public GroupChatEventArgs(IGroup group, IUser user, FontOptions font, string body, DateTime timestamp)
     : base(user, font, body, timestamp)
 {
     Group = group;
 }
Beispiel #17
0
        protected override void OnStartup(StartupEventArgs e)
        {
            log.Info("========= Application Startup =========");

            emoticonManager.LoadEmoticons();

            string DefaultFontFamily = "Segoe UI";
            Color DefaultFontColor = Colors.Black;

            var settings = Client.Properties.Settings.Default;
            var fontFamily = settings.FontFamily;
            if (Fonts.SystemFontFamilies.FirstOrDefault(family => family.Source == fontFamily) == null)
                fontFamily = DefaultFontFamily;

            Color fontColor = DefaultFontColor;
            try
            {
                fontColor = ColorConverter.ConvertFromString(settings.FontColor) as Color? ?? Colors.Black;
            }
            catch (FormatException) // If the font color from settings is invalid, we stick with the default
            { }

            FontStyle fontStyle = (settings.FontBold ? FontStyle.Bold : 0) | (settings.FontItalic ? FontStyle.Italic : 0) | (settings.FontUnderline ? FontStyle.Underline : 0);

            ClientFont = new FontOptions(fontFamily, fontColor, fontStyle);

            if (statusBrushMap.Count == 0)
            {
                statusBrushMap.Add(UserStatus.Available, Resources["AvailableBrush"] as SolidColorBrush);
                statusBrushMap.Add(UserStatus.Away, Resources["AwayBrush"] as SolidColorBrush);
                statusBrushMap.Add(UserStatus.Busy, Resources["BusyBrush"] as SolidColorBrush);
                statusBrushMap.Add(UserStatus.Offline, Resources["OfflineBrush"] as SolidColorBrush);
                statusBrushMap.Add(UserStatus.Unknown, Resources["OfflineBrush"] as SolidColorBrush);
            }

            IViewController views = this as IViewController;
            views.Navigate(views.CreateLoginView());

            base.OnStartup(e);
        }
Beispiel #18
0
        public void ChatUser(string username, FontOptions font, string chatMessage, DateTime timestamp, EventHandler<ReplyEventArgs> callback)
        {
            Contract.Requires(protocol != null);

            Chat("user", username, font, chatMessage, timestamp, callback);
        }