Ejemplo n.º 1
0
        private void NewMessagesHandler(MessagesLog obj)
        {
            MessagesItem = obj;
            Thread thread = new Thread(AddItem);

            thread.Start();
        }
Ejemplo n.º 2
0
        private bool MessageFilter(object obj)
        {
            MessagesLog messages = (MessagesLog)obj;

            if (UserId != 0)
            {
                return(messages.UserId == UserId);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public BotWindowViewModel()
        {
            this.client       = new Client(token);
            this.repository   = new Repository();
            this.MessagesItem = new MessagesLog();
            ClientsList       = repository.GetUsers();
            MessagesList      = repository.GetMessages();

            ViewMessage = (ListCollectionView)CollectionViewSource.GetDefaultView(MessagesList);
            ViewClient  = (ListCollectionView)CollectionViewSource.GetDefaultView(ClientsList);
            ViewClient.CurrentChanged  += new EventHandler(ViewClient_CurrentChanged);
            ViewMessage.CurrentChanged += new EventHandler(Message_CurrentChanged);
            ViewMessage.Filter          = new Predicate <object>(MessageFilter);

            MessagesLog.CreateItems += NewMessagesHandler;
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            MessagesLog mes = (MessagesLog)item;

            if (mes.FromId != 0)
            {
                if (mes.MessageType == "Photo")
                {
                    return(imageAdmin);
                }
                else if (mes.MessageType == "Audio")
                {
                    return(audioAdmin);
                }
                else if (mes.MessageType == "Video")
                {
                    return(videoAdmin);
                }
                else
                {
                    return(messageAdmin);
                }
            }
            else
            {
                if (mes.MessageType == "Photo")
                {
                    return(imageClient);
                }
                else if (mes.MessageType == "Audio")
                {
                    return(audioClient);
                }
                else if (mes.MessageType == "Video")
                {
                    return(videoClient);
                }
                else
                {
                    return(messageClien);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Добавление нового сообщения
        /// </summary>
        /// <param name="messages">Модель данных MessagesLog</param>
        public void Add(MessagesLog messages)
        {
            try
            {
                if (messages != null)
                {
                    messages.Id         = IdMessageGenerator();
                    messages.CreateDate = DateTime.Now;
                    messages.CreateTime = DateTime.Now.ToShortTimeString();
                    MessagesList.Add(messages);

                    SerializeData.SaveItems(MessagesList, Path.MessagesLog);

                    AddUser(messages.UserId, messages.Name);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }