Example #1
0
        public void Filter(string message, IChatWindow window, FilterDirection direction, Action <string> onAccept)
        {
            var filteredMessage = new StringBuilder(message);

            if (Filter(filteredMessage, window, direction))
            {
                onAccept(filteredMessage.ToString());
            }
        }
Example #2
0
        private void SendMessageMenu_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <Buddy> buddies = SquiggleUtility.SelectContacts(Translation.Instance.ContactSelectWindow_Heading_InstantMessage, this);

            if (buddies.Any())
            {
                Buddy       buddy      = buddies.First();
                IChatWindow chatWindow = StartChat(buddy);
                chatWindow.Invite(buddies.Except(new[] { buddy }));
            }
        }
Example #3
0
        public bool Filter(StringBuilder message, IChatWindow window, FilterDirection direction)
        {
            foreach (IMessageFilter filter in this.Where(f => (f.Direction & direction) == direction))
            {
                if (!filter.Filter(message, window))
                {
                    return(false);
                }
            }

            return(true);
        }
        public bool Filter(StringBuilder message, IChatWindow window)
        {
            string       text    = message.ToString();
            IChatCommand command = commands.FirstOrDefault(cmd => cmd.IsMatch(text));

            if (command == null)
            {
                return(true);
            }

            command.Execute(text, window, SquiggleContext.Current);

            return(false);
        }
Example #5
0
        public bool Filter(StringBuilder message, IChatWindow window)
        {
            message.Replace("(you)", window.PrimaryBuddy.DisplayName)
            .Replace("(me)", SquiggleContext.Current.ChatClient.CurrentUser.DisplayName)
            .Replace("(now)", DateTime.Now.ToString())
            .Replace("(time)", DateTime.Now.ToLongTimeString())
            .Replace("(stime)", DateTime.Now.ToShortTimeString())
            .Replace("(date)", DateTime.Now.ToShortDateString())
            .Replace("(day)", DateTime.Now.DayOfWeek.ToString())
            .Replace("(myip)", (NetworkUtility.GetLocalIPAddress() ?? IPAddress.Loopback).ToString())
            .Replace("(ver)", AppInfo.Version.ToString());

            return(true);
        }
        public void Register(IChatWindow chatWindow)
        {
            if (chatWindow == null)
            {
                throw new ArgumentNullException(nameof(chatWindow));
            }

            if (m_ChatWindow != null)
            {
                throw new InvalidOperationException("There is already an instance of IChatWindow registered");
            }

            m_ChatWindow = chatWindow;
        }
Example #7
0
        IChatWindow StartChat(IBuddy buddy, bool sendFile, params string[] filePaths)
        {
            IChatWindow window = StartChat(buddy);

            if (sendFile)
            {
                if (filePaths == null || filePaths.Length == 0)
                {
                    window.SendFile();
                }
                else
                {
                    window.SendFiles(filePaths);
                }
            }

            return(window);
        }
Example #8
0
 public Task <IDictionary <string, object> > LaunchInviteUI(ISquiggleContext context, IChatWindow window)
 {
     throw new NotImplementedException();
 }
Example #9
0
        public override async Task <IDictionary <string, object> > LaunchInviteUI(ISquiggleContext context, IChatWindow window)
        {
            string fileName = String.Format("Screenshot_{0:yyMMddHHmmss}.jpg", DateTime.Now);

            var chatWindow = ((Window)window);

            chatWindow.WindowState = WindowState.Minimized;

            await Task.Delay(1.Seconds());

            Stream stream = CaptureScreen();

            window.Restore();

            var args = new Dictionary <string, object>()
            {
                { "name", fileName },
                { "content", stream },
                { "size", stream.Length }
            };

            stream.Seek(0, SeekOrigin.Begin);

            return(args);
        }
 public void Unregister()
 {
     m_ChatWindow = null;
 }