Exemplo n.º 1
0
        private void FillPersons()
        {
            var i = 1;

            foreach (var person in Persons)
            {
                try
                {
                    var persWindow = personWindows["person" + i++];
                    persWindow.personId                 = person.id;
                    persWindow.profileName.Content      = person.name;
                    persWindow.profileAge.Content       = person.birthDate == null ? "xxx" : person.birthDate.ToString();
                    persWindow.profileImage.Source      = new BitmapImage(new Uri(person.photoUrlMax.ToString()));
                    persWindow.profileFollowers.Content = "П: " + person.followers;
                    persWindow.profileInterests.Content = "И: " + person.interests;
                    persWindow.profileCicates.Content   = "Ц: " + person.Status;
                }
                catch (Exception e)
                {
                    addConsoleMsg(e.Message, true);
                }
            }

            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                PersonChat pc = kvp.Value;
                pc.wire(this);
            }
        }
Exemplo n.º 2
0
        //HOTKEYS
        private void mainForm_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Left)
            {
                gridExpand();
            }

            if (e.Key == Key.Right)
            {
                gridNormalize();
            }
            if (Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                PersonChat ph = getActiverChat();
                if (ph == null)
                {
                    return;
                }
                if (e.Key == Key.N)
                {
                    ph.textblock.Text = ph.textblock.Text + "$name";
                }
                if (e.Key == Key.F)
                {
                    ph.textblock.Text = ph.textblock.Text + "$fullname";
                }
                if (e.Key == Key.P)
                {
                    ph.textblock.Text = ph.textblock.Text + "Хорошо, $name. Если вдруг с парнем не сложится, напиши мне потом на эту страницу, отвечу сразу же, не пожалеешь.";
                }
            }
        }
Exemplo n.º 3
0
 private void cleanSelection(object sender, RoutedEventArgs e)
 {
     foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
     {
         PersonChat pc = kvp.Value;
         pc.selected = false;
         pc.UpdateUi();
     }
 }
Exemplo n.º 4
0
        public void GNCHTA()
        {
            List <PersonChat> allchats    = new List <PersonChat>();
            List <PersonChat> notanswered = new List <PersonChat>();

            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                allchats.Add(kvp.Value);
                if (kvp.Value.lastNotAnsweredMessage != null)
                {
                    notanswered.Add(kvp.Value);
                }
            }

            PersonChat chosen = null;
            DateTime   tt     = DateTime.Now;

            foreach (PersonChat pc in notanswered)
            {
                ChatMessage ms = pc.chatMessages.Last();
                DateTime    dt = ms.time;
                if (chosen == null)
                {
                    chosen = pc;
                    tt     = dt;
                    continue;
                }
                if (dt < tt)
                {
                    chosen = pc;
                    tt     = dt;
                }
            }

            //if (chosen == null)
            //{

            //    return;
            //}

            //а теперь выбираем
            foreach (PersonChat pc in allchats)
            {
                if (chosen != null && pc.personChatId == chosen.personChatId)
                {
                    pc.isMin = false;
                    pc.maximaze();
                }
                else
                {
                    pc.isMin = true;
                    pc.normalize();
                }
            }
        }
Exemplo n.º 5
0
 private void cleanSelection(object sender, RoutedEventArgs e)
 {
     foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
     {
         PersonChat pc = kvp.Value;
         pc.selected = false;
         pc.datagrid.SelectedItem = null;
         pc.datagrid.SelectedItems.Clear();
         pc.datagrid.Items.Refresh();
         pc.UpdateUi();
     }
 }
Exemplo n.º 6
0
 public PersonChat getPersonChat(long personId)
 {
     foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
     {
         PersonChat pc = kvp.Value;
         if (pc.personId == personId)
         {
             return(pc);
         }
     }
     return(null);
 }
Exemplo n.º 7
0
        private void SendAll(string message, bool isStartUp = false)
        {
            tasks.Clear();

            int i = 1;


            foreach (PersonModel person in Persons)
            {
                string m = message;
                if (isStartUp)
                {
                    Thread.Sleep(1);
                    Random rand = new Random(unchecked ((int)(DateTime.Now.Ticks)));
                    double r    = rand.NextDouble();
                    if (r > 2)
                    {
                        m = "Привет, $name, скучно на работе сидеть. Давай пообщаемся 😈";
                    }
                }


                Thread.Sleep(12);
                ChatTask t = new ChatTask();
                t.type         = Chat.Core.TaskEnum.MESSAGE;
                t.message      = m;
                t.vkId         = person.id;
                t.timeExpared  = te.setTime(10);
                t.personChatId = "person" + i;
                t.isStopped    = false;
                t.personName   = CurrentUser.Value;

                if (isStartUp)
                {
                    PersonChat pc = personWindows[t.personChatId];
                    pc.startUpFraze = m;
                }

                string   fullname = person.name;
                string[] words    = fullname.Split(new string[] { " " }, StringSplitOptions.None);
                string   name     = words[0];


                t.message = t.message.Replace("$name", name);
                t.message = t.message.Replace("$fullname", fullname);



                tasks.Add(t);
                i++;
            }
            updateTaskList();
        }
Exemplo n.º 8
0
        //получили бан от чата
        public void ban(long vkId, long code)
        {
            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                PersonChat pc = kvp.Value;
                if (pc.personId == vkId)
                {
                    pc.banned       = true;
                    pc.isActive     = false;
                    pc.bannedString = VKERROR.getErrorString(code);

                    pc.UpdateUi();
                }
            }
        }
Exemplo n.º 9
0
        private void resizeItems()
        {
            //собираема
            List <PersonChat> allChats =
                GetVisualChilds <PersonChat>(mainCanvas as DependencyObject);
            int z = 1;

            foreach (PersonChat ch in allChats)
            {
                ch.personChatId = "person" + z;
                ch.profileChatNumber.Content = ch.personChatId;
                personWindows.Add(ch.Name, ch);
                z++;
            }

            int i      = 0;
            int j      = 0;
            int startX = -5;
            int startY = 0;

            int xSumm = 0;
            int ySumm = 0;
            int hh    = 0;

            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                PersonChat pc = kvp.Value;
                hh = pc.person_width + pc.person_width_margin;

                xSumm   = startX + i * (pc.person_width + pc.person_width_margin);
                ySumm   = startY + j * (pc.person_height + pc.person_height_margin);
                pc.left = xSumm;
                pc.top  = ySumm;
                pc.normalize();
                i++;

                if (i % 7 == 0)
                {
                    j++;
                    i = 0;
                }
                pc.wire(this);
            }
            //Canvas.SetLeft(console, xSumm + hh);
            //Canvas.SetTop(console, ySumm);
            //console.Width = hh - 5;
        }
Exemplo n.º 10
0
        private void nPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
                {
                    PersonChat pc = kvp.Value;
                    pc.isMin = true;
                    pc.normalize();
                }
            }

            if (e.Key == Key.Tab)
            {
                GNCHTA();
            }
        }
Exemplo n.º 11
0
        //отправляем сообщения всем выделенным чатам
        private void sendAllMessages(object sender, RoutedEventArgs e)
        {
            List <PersonChat> resevers = new List <PersonChat>();

            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                PersonChat pc = kvp.Value;
                if (pc.selected && !pc.banned)
                {
                    resevers.Add(pc);
                }
            }
            if (resevers.Count == 0)
            {
                return;
            }
            //List<PersonChat> resevers = new List<PersonChat> { this };
            SimpleMessageBox box = new SimpleMessageBox(this, resevers);
            bool?            res = box.ShowDialog();
        }
Exemplo n.º 12
0
        private void FillPersons()
        {
            var i = 1;

            foreach (var person in Persons)
            {
                try
                {
                    var persWindow = personWindows["person" + i++];
                    persWindow.personId                 = person.id;
                    persWindow.profileName.Content      = person.name;
                    persWindow.profileAge.Content       = person.birthDate == null ? "xxx" : person.birthDate.ToString();
                    persWindow.profileImage.Source      = new BitmapImage(new Uri(person.photoUrlMax.ToString()));
                    persWindow.profileFollowers.Content = "П: " + person.followers;
                    persWindow.profileInterests.Content = "И: " + person.interests;
                    persWindow.profileCicates.Content   = "Ц: " + person.Status;
                    //интересные для них
                    if (person.interests != null)
                    {
                        if (person.interests.Contains("кальян") || person.interests.Contains("дорам") ||
                            person.interests.Contains("аниме") ||
                            person.interests.Contains("дота") || person.interests.Contains("it") ||
                            person.interests.Contains("велоспорт"))
                        {
                            persWindow.profileName.Foreground = Brushes.Green;
                        }
                    }
                }
                catch (Exception e)
                {
                    addConsoleMsg(e.Message, true);
                }
            }

            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                PersonChat pc = kvp.Value;
                pc.wire(this);
            }
        }
Exemplo n.º 13
0
        public void UpdateUI()
        {
            DateTime localDate = DateTime.Now;

            timer.Content               = localDate.ToString("HH:mm:ss");
            button_play.IsEnabled       = stage == StageEnum.CHOSEN;
            button_search.IsEnabled     = stage == StageEnum.LOADED;
            button_update_all.IsEnabled = stage == StageEnum.LAUCHED;
            int not_answered = 0;

            foreach (KeyValuePair <string, PersonChat> kvp in personWindows)
            {
                PersonChat  pc = kvp.Value;
                ChatMessage lastNotAnswered = pc.lastNotAnsweredMessage;
                if (lastNotAnswered == null)
                {
                    pc.Background = Brushes.DarkGray;
                }
                else
                {
                    not_answered++;
                    pc.Background = Brushes.Green;
                }
            }
            if (not_answered == 0)
            {
                PageAnswered.Kind = PackIconModernKind.Page0;
            }
            if (not_answered == 1)
            {
                PageAnswered.Kind = PackIconModernKind.Page1;
            }
            if (not_answered == 2)
            {
                PageAnswered.Kind = PackIconModernKind.Page2;
            }
            if (not_answered == 3)
            {
                PageAnswered.Kind = PackIconModernKind.Page3;
            }
            if (not_answered == 4)
            {
                PageAnswered.Kind = PackIconModernKind.Page4;
            }
            if (not_answered == 5)
            {
                PageAnswered.Kind = PackIconModernKind.Page5;
            }
            if (not_answered == 6)
            {
                PageAnswered.Kind = PackIconModernKind.Page6;
            }
            if (not_answered == 7)
            {
                PageAnswered.Kind = PackIconModernKind.Page7;
            }
            if (not_answered == 8)
            {
                PageAnswered.Kind = PackIconModernKind.Page8;
            }
            if (not_answered == 9)
            {
                PageAnswered.Kind = PackIconModernKind.Page9;
            }
            if (not_answered >= 10)
            {
                PageAnswered.Kind = PackIconModernKind.PageNew;
            }
        }