int age, mID, tID;//main id & this id
        public StrangerPage(int mid, int tid)
        {
            mID = mid;
            tID = tid;
            sql = new SqlAction();
            sql.GetData(tID);
            InitializeComponent();
            fileName     = null;
            LBN.Content += sql.GetData(tID)[0] + " " + sql.GetData(tID)[1];
            LBA.Content += Convert.ToString(sql.GetData(tID)[2]);
            LBC.Content += sql.GetData(tID)[3];
            AbMe.Text    = sql.GetData(tID)[4];
            //if (sql.GetData(Fname, Lname, Descript, age, Photo, Country, ID)[5] != "NULL")
            SetPict(sql.GetData(tID)[5]);
            if (sql.isFriend(mID, tID))
            {
                ToFriend.Content = "Remove from friend";
            }
            if (sql.isBlackList(mID, tID))
            {
                BL.Content = "Remove from black List";
            }

            if (sql.isBlackList(tID, mID))
            {
                MSG.IsEnabled      = false;
                ToFriend.IsEnabled = false;

                ToFriend.Content = "Add to friend";
            }
        }
        public void newChat(object sender, EventArgs e)//обновление окна сообщений
        {
            LBA.Items.Clear();
            sql              = new SqlAction();
            Persons          = new List <Pers>();
            IDofExistMembers = new List <System.Windows.Controls.Label>();
            Tmp              = sql.StateOf(ID, 2);
            //sql.GetPeople();
            for (int i = 0; i < Tmp.Length; i++)
            {
                Persons.Add(Tmp[i]);
            }
            Array.Sort(Tmp);
            AvaOfPers   = new List <Image>();
            NameOfPers  = new List <TextBlock>();
            SP          = new List <StackPanel>();
            IDofMembers = new List <System.Windows.Controls.Label>();
            for (int i = 0; i < Persons.Count; i++)
            {
                if (sql.isBlackList(ID, Persons[i].id) || sql.isBlackList(Persons[i].id, ID))
                {
                    sql.Action(ID, Persons[i].id, 2, false);
                }

                if (Persons[i].id != ID && (!sql.isBlackList(ID, Persons[i].id) && !sql.isBlackList(Persons[i].id, ID)))
                {
                    SP.Add(new StackPanel());
                    AvaOfPers.Add(new Image());
                    NameOfPers.Add(new TextBlock());
                    IDofMembers.Add(new System.Windows.Controls.Label());

                    NameOfPers[i].Text = " " + Persons[i].FullNameToStr;
                    try
                    {
                        AvaOfPers[i].Source = (new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(Persons[i].id))[5])));
                    }
                    catch
                    {
                        AvaOfPers[i].Source = (new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Empty.png")));
                    }
                    IDofMembers[i].Content     = Convert.ToString(Persons[i].id);
                    IDofMembers[i].Visibility  = Visibility.Hidden;
                    SP[i].Orientation          = System.Windows.Controls.Orientation.Horizontal;
                    AvaOfPers[i].Height        = 30;
                    AvaOfPers[i].Width         = 50;
                    AvaOfPers[i].Margin        = new Thickness(0, 0, 0, 0);
                    NameOfPers[i].Width        = 200;
                    NameOfPers[i].Height       = Double.NaN;
                    NameOfPers[i].TextWrapping = TextWrapping.Wrap;
                    SP[i].Children.Add(AvaOfPers[i]);
                    SP[i].Children.Add(NameOfPers[i]);
                    SP[i].Children.Add(IDofMembers[i]);
                    LBA.Items.Add(SP[i]);
                }
            }
        }
        //Стоит сделать ее 1-й фнкцией т к повторяется 4 раза
        public void Refresh(object sender, EventArgs e)//обновление окна сообщений
        {
            LBF.Items.Clear();
            sql = new SqlAction();
            Pers[] Persons = sql.StateOf(ID, 2);
            Array.Sort(Persons);
            Ava        = new List <Image>();
            NameOfPers = new List <TextBlock>();
            SP         = new List <StackPanel>();
            image1     = new List <BitmapImage>();
            KeepID     = new List <System.Windows.Controls.Label>();
            for (int i = 0; i < Persons.Length; i++)
            {
                if (sql.isBlackList(ID, Persons[i].id) || sql.isBlackList(Persons[i].id, ID))
                {
                    sql.Action(ID, Persons[i].id, 2, false);
                }

                if (Persons[i].id != ID && (!sql.isBlackList(ID, Persons[i].id) && !sql.isBlackList(Persons[i].id, ID)))
                {
                    SP.Add(new StackPanel());
                    Ava.Add(new Image());
                    NameOfPers.Add(new TextBlock());
                    KeepID.Add(new System.Windows.Controls.Label());

                    NameOfPers[i].Text = " " + Persons[i].FullNameToStr;
                    try
                    {
                        image1.Add(new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(Persons[i].id))[5])));
                    }
                    catch
                    {
                        image1.Add(new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Empty.png")));
                    }
                    Ava[i].Source              = image1[i];
                    KeepID[i].Content          = Convert.ToString(Persons[i].id);
                    SP[i].Orientation          = System.Windows.Controls.Orientation.Horizontal;
                    Ava[i].Height              = 30;
                    Ava[i].Width               = 50;
                    Ava[i].Margin              = new Thickness(0, 0, 0, 0);
                    NameOfPers[i].Width        = 200;
                    NameOfPers[i].Height       = Double.NaN;
                    NameOfPers[i].TextWrapping = TextWrapping.Wrap;
                    SP[i].Children.Add(Ava[i]);
                    SP[i].Children.Add(NameOfPers[i]);
                    LBF.Items.Add(SP[i]);
                }
            }
        }
Beispiel #4
0
        public Profile(int id)
        {
            ID = id;
            SqlAction sql = new SqlAction();

            sql.GetData(ID);
            InitializeComponent();
            fileName     = null;
            LBN.Content += Name = sql.GetData(ID)[0] + " " + sql.GetData(ID)[1];
            LBA.Content += Convert.ToString(age = Convert.ToInt32(sql.GetData(ID)[2]));
            LBC.Content += Country = sql.GetData(ID)[3];
            AbMe.Text    = About = sql.GetData(ID)[4];
            //if (sql.GetData(Fname, Lname, Descript, age, Photo, Country, ID)[5] != "NULL")
            SetPict(Photo = sql.GetData(ID)[5]);
        }
Beispiel #5
0
        //private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        //{

        //}

        void ToListBox()
        {
            for (; i < TextToListBox.Length; i++)
            {
                //
                SP.Add(new StackPanel());
                Ava.Add(new Image());
                Msg.Add(new TextBlock());
                time.Add(new System.Windows.Controls.Label());
                int LI = TextToListBox[i].LastIndexOf("&");
                int IO = TextToListBox[i].IndexOf("&");

                // System.Windows.MessageBox.Show(Convert.ToString(TextToListBox[i].Length), TextToListBox[i][TextToListBox[i].Length-1]+"a");
                string GetTime = TextToListBox[i].Substring(LI + 1, TextToListBox[i].Length - (LI + 1));//время и дата

                bool   hasFile;
                string GetId;
                if (TextToListBox[i].IndexOf("|") == -1)
                {
                    hasFile = false;
                }
                else
                {
                    hasFile = true;
                }

                string extend = null;
                Guid   StrmID = new Guid();
                if (!hasFile)
                {
                    GetId = TextToListBox[i].Substring(0, IO);
                }
                else
                {
                    GetId = TextToListBox[i].Substring(TextToListBox[i].IndexOf("|") + 1, IO - (TextToListBox[i].IndexOf("|") + 1));
                    //-узнаем расширение, чтобы если этот файл окажется изображением, музыкой или видео прогрузить соответствующую пиктограмму
                    extend = TextToListBox[i].Substring(TextToListBox[i].IndexOf("&"), TextToListBox[i].LastIndexOf("&") - TextToListBox[i].IndexOf("|"));
                    extend = extend.Substring(extend.LastIndexOf("."), (extend.LastIndexOf("&")) - (extend.LastIndexOf(".")));
                    StrmID = new Guid(TextToListBox[i].Substring(0, TextToListBox[i].IndexOf("|")));
                    //
                }
                time[i].Content  = GetTime;
                TextToListBox[i] = TextToListBox[i].Remove(TextToListBox[i].LastIndexOf('&'));
                TextToListBox[i] = TextToListBox[i].Substring(TextToListBox[i].IndexOf('&') + 1);//идентификатор-аватарка

                Msg[i].Text = " " + TextToListBox[i];
                try
                {
                    image1.Add(new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(GetId))[5])));
                }
                catch (Exception)
                {
                    image1.Add(new BitmapImage(new Uri(@"file:///D:/Desktop/WPFMessanger/WpfApplication3/Resources/Empty.png")));
                }
                Ava[i].Source = image1[i];

                SP[i].Orientation   = System.Windows.Controls.Orientation.Horizontal;
                Ava[i].Height       = Double.NaN;
                Ava[i].Width        = 50;
                Msg[i].Width        = 260;
                Msg[i].Height       = Double.NaN;
                Msg[i].TextWrapping = TextWrapping.Wrap;
                //time[i].Foreground = new SolidColorBrush(Colors.Red);
                time[i].Foreground = Brushes.Gray;
                //time[i].HorizontalAlignment = Left;
                //time[i].Color = "grey";
                //


                SP[i].Children.Add(Ava[i]);
                if (hasFile == true)
                {
                    FilePic.Add(new Image());
                    MediaTimer.Add(new System.Windows.Forms.Timer());

                    if (extend == ".jpg" || extend == ".png" || extend == ".bmp" || extend == ".jepg")
                    {
                        try
                        {
                            System.IO.MemoryStream stream = new System.IO.MemoryStream(sql.GetPicture(StrmID));
                            var image = new BitmapImage();
                            image.BeginInit();
                            image.StreamSource = stream;
                            image.EndInit();
                            FilePic[j].Source = image;
                        }
                        catch (System.ArgumentNullException)
                        {
                            FilePic[j].Source = new BitmapImage(new Uri(@"file:///D:/Desktop/WPFMessanger/WpfApplication3/Resources/Null.png"));
                        }

                        //GIF не работает :с
                        //FilePic[i].SetAnimatedSource(img, image);
                        //ImageBehavior.SetRepeatBehavior(img, new RepeatBehavior(0));
                        //ImageBehavior.SetRepeatBehavior(img, RepeatBehavior.Forever);
                        FilePic[j].Height = Double.NaN;
                        FilePic[j].Width  = 260;
                        Msg[i].Text       = " ";
                        Msg[i].Width      = 0;
                        FilePic[j].Margin = new Thickness(10, 0, 0, 0);
                    }
                    else if (extend == ".mp3" || extend == ".m4a" || extend == ".aud" || extend == ".aif" || extend == ".amr" || extend == ".wma" || extend == ".wav" || extend == ".mid")
                    {
                        try
                        {
                            MediaTimer[mediaIndex].Interval = 400;
                            MediaTimer[mediaIndex].Tick    += timer_Tick;
                            TimerState.Add(false);
                            state.Add(false);

                            media.Add(new MediaElement());
                            PauseResume.Add(new System.Windows.Controls.Button());
                            Restart.Add(new System.Windows.Controls.Button());
                            rewind.Add(new Slider());
                            mediaPanel.Add(new StackPanel());

                            media[mediaIndex].MediaOpened += new RoutedEventHandler(media_MediaOpened);
                            //media[mediaIndex].MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(media_MediaFailed);


                            System.IO.MemoryStream stream = new System.IO.MemoryStream(sql.GetPicture(StrmID));
                            FilePic[j].Source = new BitmapImage(new Uri("Resources/music.png", UriKind.RelativeOrAbsolute));;

                            System.IO.File.WriteAllBytes("temp/temp" + mediaIndex + extend, sql.GetPicture(StrmID));
                            media[mediaIndex].Source           = (new Uri(AppDomain.CurrentDomain.BaseDirectory + "temp/temp" + mediaIndex + extend));
                            media[mediaIndex].LoadedBehavior   = MediaState.Manual;
                            media[mediaIndex].UnloadedBehavior = MediaState.Close;
                            media[mediaIndex].Play();
                            media[mediaIndex].Stop();
                            // media.Pause();


                            media[mediaIndex].Name          = "Media_" + mediaIndex;
                            rewind[mediaIndex].Name         = "Slider_" + mediaIndex;
                            Restart[mediaIndex].Name        = "Restart_" + mediaIndex;
                            PauseResume[mediaIndex].Name    = "Pause_" + mediaIndex;
                            Restart[mediaIndex].Content     = "Restart";
                            PauseResume[mediaIndex].Content = "Pause";
                            Restart[mediaIndex].Click      += new RoutedEventHandler(ToRestart);
                            PauseResume[mediaIndex].Click  += new RoutedEventHandler(ToResumePause);

                            //Thumb thumb = this.GetTemplateChild(rewind[mediaIndex].Name) as Thumb;
                            //thumb.DragStarted += new DragStartedEventHandler(sld_DragStarted);
                            //thumb.DragCompleted += new DragCompletedEventHandler(sld_DragCompleted);
                            //rewind[mediaIndex].OnThumbDragStarted += new RoutedEventHandler(sld_DragStarted);
                            //rewind[mediaIndex].DragLeave += new System.Windows.RoutedEventHandler(sld_DragCompleted);
                            //rewind[mediaIndex].ValueChanged += new RoutedPropertyChangedEventHandler<double>(sld_ValueChanged);

                            media[mediaIndex].MediaOpened += new RoutedEventHandler(media_MediaOpened);

                            mediaPanel[mediaIndex].Children.Add(media[mediaIndex]);
                            mediaPanel[mediaIndex].Children.Add(rewind[mediaIndex]);
                            mediaPanel[mediaIndex].Children.Add(PauseResume[mediaIndex]);
                            mediaPanel[mediaIndex].Children.Add(Restart[mediaIndex]);


                            FilePic[j].Height = Double.NaN;
                            FilePic[j].Width  = 0;
                            Msg[i].Text       = " ";
                            Msg[i].Width      = 0;

                            //media.Width = 250;
                            //media.Height = Double.NaN;
                            mediaPanel[mediaIndex].Orientation = System.Windows.Controls.Orientation.Vertical;
                            PauseResume[mediaIndex].Width      = 50;
                            PauseResume[mediaIndex].Height     = Double.NaN;
                            Restart[mediaIndex].Width          = 50;
                            Restart[mediaIndex].Height         = Double.NaN;
                            mediaPanel[mediaIndex].Width       = 260;
                            mediaPanel[mediaIndex].Height      = Double.NaN;
                            mediaPanel[mediaIndex].Margin      = new Thickness(10, 0, 0, 0);
                            rewind[mediaIndex].Width           = 260;


                            FilePic[j].Height = 40;
                            FilePic[j].Width  = Double.NaN;
                            Msg[i].Width      = 220;
                            FilePic[j].Margin = new Thickness(10, 0, 0, 0);

                            //System.IO.MemoryStream stream = new System.IO.MemoryStream(sql.GetPicture(StrmID));
                            media[mediaIndex].Width      = 0;
                            rewind[mediaIndex].IsEnabled = false;

                            SP[i].Children.Add(mediaPanel[mediaIndex]);
                            mediaIndex++;
                        }
                        catch (System.ArgumentNullException)
                        {
                            FilePic[j].Source = new BitmapImage(new Uri(@"file:///D:/Desktop/WPFMessanger/WpfApplication3/Resources/Null.png"));
                            FilePic[j].Height = Double.NaN;
                            FilePic[j].Width  = 260;
                            Msg[i].Text       = " ";
                            Msg[i].Width      = 0;
                            FilePic[j].Margin = new Thickness(10, 0, 0, 0);
                        }
                    }
                    else if (extend == ".mp4" || extend == ".3gp" || extend == ".3g2" || extend == ".asf" || extend == ".asx" || extend == ".avi" || extend == ".flv" || extend == ".mpg" || extend == ".webm" || extend == ".wmv" || extend == ".gif")
                    {
                        MediaTimer[mediaIndex].Interval = 400;
                        MediaTimer[mediaIndex].Tick    += timer_Tick;
                        TimerState.Add(false);
                        state.Add(false);

                        media.Add(new MediaElement());
                        PauseResume.Add(new System.Windows.Controls.Button());
                        Restart.Add(new System.Windows.Controls.Button());
                        rewind.Add(new Slider());
                        mediaPanel.Add(new StackPanel());
                        try
                        {
                            //media[mediaIndex].MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(media_MediaFailed);

                            //System.IO.MemoryStream stream = new System.IO.MemoryStream(sql.GetPicture(StrmID));



                            System.IO.File.WriteAllBytes("temp/temp" + mediaIndex + extend, sql.GetPicture(StrmID));
                            //var mediaPlayer = new MediaPlayer();
                            //mediaPlayer.Open(new Uri(@"\\Desktop - 3e0rm1s\mssqlserver\ChatNetwork\SendFile\odessa.mp4", UriKind.RelativeOrAbsolute));
                            //mediaPlayer.Play();
                            media[mediaIndex].Source           = (new Uri(AppDomain.CurrentDomain.BaseDirectory + "temp/temp" + mediaIndex + extend));
                            media[mediaIndex].LoadedBehavior   = MediaState.Manual;
                            media[mediaIndex].UnloadedBehavior = MediaState.Close;
                            media[mediaIndex].ScrubbingEnabled = true;
                            media[mediaIndex].Play();
                            media[mediaIndex].Stop();
                            //media.Pause();4


                            media[mediaIndex].Name          = "Media_" + mediaIndex;
                            rewind[mediaIndex].Name         = "Slider_" + mediaIndex;
                            Restart[mediaIndex].Name        = "Restart_" + mediaIndex;
                            PauseResume[mediaIndex].Name    = "Pause_" + mediaIndex;
                            Restart[mediaIndex].Content     = "Restart";
                            PauseResume[mediaIndex].Content = "Pause";
                            Restart[mediaIndex].Click      += new RoutedEventHandler(ToRestart);
                            PauseResume[mediaIndex].Click  += new RoutedEventHandler(ToResumePause);

                            //rewind[mediaIndex].DragEnter += new System.Windows.DragEventHandler(sld_DragStarted);
                            //rewind[mediaIndex].DragLeave += new System.Windows.DragEventHandler(sld_DragCompleted);
                            //rewind[mediaIndex].ValueChanged += new RoutedPropertyChangedEventHandler<double>(sld_ValueChanged);

                            media[mediaIndex].MediaOpened += new RoutedEventHandler(media_MediaOpened);

                            mediaPanel[mediaIndex].Children.Add(media[mediaIndex]);
                            mediaPanel[mediaIndex].Children.Add(rewind[mediaIndex]);
                            mediaPanel[mediaIndex].Children.Add(PauseResume[mediaIndex]);
                            mediaPanel[mediaIndex].Children.Add(Restart[mediaIndex]);


                            FilePic[j].Height = Double.NaN;
                            FilePic[j].Width  = 0;
                            Msg[i].Text       = " ";
                            Msg[i].Width      = 0;

                            //media.Width = 250;
                            //media.Height = Double.NaN;
                            mediaPanel[mediaIndex].Orientation = System.Windows.Controls.Orientation.Vertical;
                            PauseResume[mediaIndex].Width      = 50;
                            PauseResume[mediaIndex].Height     = Double.NaN;
                            Restart[mediaIndex].Width          = 50;
                            Restart[mediaIndex].Height         = Double.NaN;
                            media[mediaIndex].Width            = 260;
                            media[mediaIndex].Height           = Double.NaN;
                            mediaPanel[mediaIndex].Width       = 260;
                            mediaPanel[mediaIndex].Height      = Double.NaN;
                            mediaPanel[mediaIndex].Margin      = new Thickness(10, 0, 0, 0);
                            rewind[mediaIndex].Width           = 260;
                            rewind[mediaIndex].IsEnabled       = false;

                            SP[i].Children.Add(mediaPanel[mediaIndex]);//media
                            mediaIndex++;
                        }
                        catch (System.ArgumentNullException)
                        {
                            FilePic[j].Source = new BitmapImage(new Uri(@"file:///D:/Desktop/WPFMessanger/WpfApplication3/Resources/Null.png"));
                            FilePic[j].Height = Double.NaN;
                            FilePic[j].Width  = 260;
                            Msg[i].Text       = " ";
                            Msg[i].Width      = 0;
                            FilePic[j].Margin = new Thickness(10, 0, 0, 0);
                        }
                    }

                    else
                    {
                        FilePic[j].Source = new BitmapImage(new Uri("Resources/file.png", UriKind.RelativeOrAbsolute));
                        FilePic[j].Height = 40;
                        FilePic[j].Width  = Double.NaN;
                        Msg[i].Width      = 210;
                        FilePic[j].Margin = new Thickness(10, 0, 0, 0);
                    }
                    SP[i].Children.Add(FilePic[j]);

                    j++;
                }
                SP[i].Children.Add(Msg[i]);
                SP[i].Children.Add(time[i]);
                LBDialog.Items.Add(SP[i]);

                //
                //LBDialog.Items.Add(TextToListBox[i]);



                //LBDialog.SelectedIndex = LBDialog.Items.Count - 1;//Проскролить в конец
                //LBDialog.ScrollIntoView(LBDialog.SelectedItem);
                LBDialog.ScrollIntoView(LBDialog.Items[LBDialog.Items.Count - 1]);
            }
        }
Beispiel #6
0
        List <System.Windows.Controls.Label> KeepID;//невидимый лейбл, который будет хранить айди
        public Search(int id)
        {
            sql = new SqlAction();
            ID  = id;
            InitializeComponent();


            //string[] PeopleName = sql.GetPeople();
            //for (int i = 0; i < PeopleName.Length; i++)
            //    LBS.Items.Add(PeopleName[i]);


            //Стоит сделать ее 1-й фнкцией т к повторяется 3 раза
            Pers[] Persons = sql.GetPeople();
            Array.Sort(Persons);

            Ava        = new List <Image>();
            NameOfPers = new List <TextBlock>();
            SP         = new List <StackPanel>();
            image1     = new List <BitmapImage>();
            KeepID     = new List <System.Windows.Controls.Label>();
            int j = 0;

            for (int i = 0; i < Persons.Length; i++)
            {
                if (Persons[i].id != ID)
                {
                    SP.Add(new StackPanel());
                    Ava.Add(new Image());
                    NameOfPers.Add(new TextBlock());
                    KeepID.Add(new System.Windows.Controls.Label());

                    NameOfPers[j].Text = " " + Persons[i].FullNameToStr;
                    try
                    {
                        image1.Add(new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(Persons[i].id))[5])));
                    }
                    catch
                    {
                        image1.Add(new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Empty.png")));
                    }
                    Ava[j].Source     = image1[j];
                    KeepID[j].Content = Convert.ToString(Persons[i].id);

                    SP[j].Orientation          = System.Windows.Controls.Orientation.Horizontal;
                    Ava[j].Height              = 30;
                    Ava[j].Width               = 50;
                    Ava[j].Margin              = new Thickness(0, 0, 0, 0);
                    NameOfPers[j].Width        = 200;
                    NameOfPers[j].Height       = Double.NaN;
                    NameOfPers[j].TextWrapping = TextWrapping.Wrap;
                    //time[i].Foreground = new SolidColorBrush(Colors.Red);

                    //time[i].HorizontalAlignment = Left;
                    //time[i].Color = "grey";

                    SP[j].Children.Add(Ava[j]);
                    SP[j].Children.Add(NameOfPers[j]);
                    LBS.Items.Add(SP[j]);

                    //LBP.Items.Add(Persons[i]);
                    // LBP.DisplayMemberPath = "FullNameToStr";

                    //for (int i = 0; i < Persons.Length; i++)
                    //    {
                    //        LBS.Items.Add(Persons[i]);
                    //        LBS.DisplayMemberPath = "FullNameToStr";
                    //    }
                    j++;
                }
            }
            //for (int i = 0; i < Persons.Length; i++)
            //{
            //    LBS.Items.Add(Persons[i]);
            //    //Persons[i].FullNameToStr = Persons[i].FirstName + " " + Persons[i].LastName;
            //    LBS.DisplayMemberPath = "FullNameToStr";
            //}
            //ListCollectionView view = new ListCollectionView(Persons);
            //view.SortDescriptions.Add(new System.ComponentModel.SortDescription("FirstName",
            // System.ComponentModel.ListSortDirection.Ascending));
            //view.SortDescriptions.Add(new System.ComponentModel.SortDescription("LastName",
            //  System.ComponentModel.ListSortDirection.Ascending));

            //view.Refresh();
        }
Beispiel #7
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            string ToSearch = Name.Text;

            int[] id = (sql.Search(ToSearch)).ToArray();

            // MessageBox.Show(Convert.ToString(ID), Convert.ToString(ID));

            LBS.Items.Clear();
            Pers[] Persons = sql.GetPeople(id);
            Array.Sort(Persons);
            //for (int i = 0; i < Persons.Length; i++)
            ////LBS.Items.Add(Persons[i].FirstName+" "+ Persons[i].LastName);
            //{
            //    LBS.Items.Add(Persons[i]);
            //    //Persons[i].FullNameToStr = Persons[i].FirstName +" "+ Persons[i].LastName;
            //    LBS.DisplayMemberPath = "FullNameToStr";
            //    //LBS.SelectedValuePath = "FirstName";
            //    //LBS.SelectedValuePath = Persons[i].LastName;
            //}
            //LBS.Items.Insert(2,PeopleName[2]+"!");
            Ava        = new List <Image>();
            NameOfPers = new List <TextBlock>();
            SP         = new List <StackPanel>();
            image1     = new List <BitmapImage>();
            KeepID     = new List <System.Windows.Controls.Label>();
            int j = 0;

            for (int i = 0; i < Persons.Length; i++)
            {
                if (Persons[i].id != ID)
                {
                    SP.Add(new StackPanel());
                    Ava.Add(new Image());
                    NameOfPers.Add(new TextBlock());
                    KeepID.Add(new System.Windows.Controls.Label());

                    NameOfPers[j].Text = " " + Persons[i].FullNameToStr;
                    try
                    {
                        image1.Add(new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(Persons[i].id))[5])));
                    }
                    catch
                    {
                        image1.Add(new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Empty.png")));
                    }
                    Ava[j].Source     = image1[j];
                    KeepID[j].Content = Convert.ToString(Persons[i].id);

                    SP[j].Orientation          = System.Windows.Controls.Orientation.Horizontal;
                    Ava[j].Height              = 30;
                    Ava[j].Width               = 50;
                    Ava[j].Margin              = new Thickness(0, 0, 0, 0);
                    NameOfPers[j].Width        = 200;
                    NameOfPers[j].Height       = Double.NaN;
                    NameOfPers[j].TextWrapping = TextWrapping.Wrap;
                    //time[i].Foreground = new SolidColorBrush(Colors.Red);

                    //time[i].HorizontalAlignment = Left;
                    //time[i].Color = "grey";

                    SP[j].Children.Add(Ava[j]);
                    SP[j].Children.Add(NameOfPers[j]);
                    LBS.Items.Add(SP[j]);

                    //LBP.Items.Add(Persons[i]);
                    // LBP.DisplayMemberPath = "FullNameToStr";

                    //for (int i = 0; i < Persons.Length; i++)
                    //    {
                    //        LBS.Items.Add(Persons[i]);
                    //        LBS.DisplayMemberPath = "FullNameToStr";
                    //    }
                    j++;
                }
            }


            //ListCollectionView view = new ListCollectionView(Persons);
            //view.SortDescriptions.Add(new System.ComponentModel.SortDescription("FirstName",
            // System.ComponentModel.ListSortDirection.Ascending));
            //view.SortDescriptions.Add(new System.ComponentModel.SortDescription("LastName",
            //  System.ComponentModel.ListSortDirection.Ascending));

            //view.Refresh();
            //LBS.Items.SortDescriptions.Add(new SortDescription("", ListSortDirection.Ascending));
            //MessageBox.Show(Convert.ToString(LBS.Items[0]), Convert.ToString(LBS.Items[0]));
        }
Beispiel #8
0
        void Refresh(object sender, EventArgs e)
        {
            LBC.Items.Clear();
            LBP.Items.Clear();
            Persons = sql.StateOf(ID, 1);
            Array.Sort(Persons);
            chats = sql.GetChats(ID);
            Array.Sort(chats);
            //for (int i = 0; i < Persons.Length; i++)
            //{
            //    if(Persons[i].id!= ID)
            //    {
            //    LBP.Items.Add(Persons[i]);
            //    //Persons[i].FullNameToStr = Persons[i].FirstName + " " + Persons[i].LastName;
            //    LBP.DisplayMemberPath = "FullNameToStr";
            //    }
            //}
            Ava        = new List <Image>();
            NameOfPers = new List <TextBlock>();
            SP         = new List <StackPanel>();
            image      = new List <BitmapImage>();
            KeepID     = new List <System.Windows.Controls.Label>();

            ChatAva  = new List <Image>();
            ChatName = new List <TextBlock>();
            SP2      = new List <StackPanel>();
            ChatId   = new List <System.Windows.Controls.Label>();
            for (int i = 0; i < Persons.Length; i++)
            {
                //

                if (Persons[i].id != ID)
                {
                    SP.Add(new StackPanel());
                    Ava.Add(new Image());
                    NameOfPers.Add(new TextBlock());
                    KeepID.Add(new System.Windows.Controls.Label());

                    NameOfPers[i].Text = " " + Persons[i].FullNameToStr;
                    try
                    {
                        image.Add(new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(Persons[i].id))[5])));
                    }
                    catch
                    {
                        image.Add(new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Empty.png")));
                    }
                    Ava[i].Source     = image[i];
                    KeepID[i].Content = Convert.ToString(Persons[i].id);

                    SP[i].Orientation          = System.Windows.Controls.Orientation.Horizontal;
                    Ava[i].Height              = 30;
                    Ava[i].Width               = 50;
                    Ava[i].Margin              = new Thickness(0, 0, 0, 0);
                    NameOfPers[i].Width        = 200;
                    NameOfPers[i].Height       = Double.NaN;
                    NameOfPers[i].TextWrapping = TextWrapping.Wrap;
                    //time[i].Foreground = new SolidColorBrush(Colors.Red);

                    //time[i].HorizontalAlignment = Left;
                    //time[i].Color = "grey";

                    SP[i].Children.Add(Ava[i]);
                    SP[i].Children.Add(NameOfPers[i]);
                    LBP.Items.Add(SP[i]);

                    //LBP.Items.Add(Persons[i]);
                    // LBP.DisplayMemberPath = "FullNameToStr";
                }
                //for (int i = 0; i < Persons.Length; i++)
                //    {
                //        LBS.Items.Add(Persons[i]);
                //        LBS.DisplayMemberPath = "FullNameToStr";
                //    }
            }
            //ListCollectionView view = new ListCollectionView(Persons);
            //view.SortDescriptions.Add(new System.ComponentModel.SortDescription("FirstName",
            // System.ComponentModel.ListSortDirection.Ascending));
            //view.SortDescriptions.Add(new System.ComponentModel.SortDescription("LastName",
            //  System.ComponentModel.ListSortDirection.Ascending));

            //view.Refresh();
            SP2.Add(new StackPanel());
            ChatAva.Add(new Image());
            ChatName.Add(new TextBlock());
            ChatId.Add(new System.Windows.Controls.Label());
            image = new List <BitmapImage>();
            for (int i = 0; i < chats.Length; i++)
            {
                ChatName[i].Text = " " + chats[i].Name;
                try
                {
                    image.Add(new BitmapImage(new Uri(chats[i].PathToPhoto)));
                }
                catch
                {
                    image.Add(new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Empty.png")));
                }
                ChatAva[i].Source        = image[i];
                ChatId[i].Content        = Convert.ToString(chats[i].ID);
                SP2[i].Orientation       = System.Windows.Controls.Orientation.Horizontal;
                ChatAva[i].Height        = 30;
                ChatAva[i].Width         = 50;
                ChatAva[i].Margin        = new Thickness(0, 0, 0, 0);
                ChatName[i].Width        = 200;
                ChatName[i].Height       = Double.NaN;
                ChatName[i].TextWrapping = TextWrapping.Wrap;
                SP2[i].Children.Add(ChatAva[i]);
                SP2[i].Children.Add(ChatName[i]);
                LBC.Items.Add(SP2[i]);
            }
        }
Beispiel #9
0
        //private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        //{

        //}

        void ToListBox()
        {
            int j = 0;

            for (int i = 0; i < TextToListBox.Length; i++)
            {
                //
                SP.Add(new StackPanel());
                Ava.Add(new Image());
                Msg.Add(new TextBlock());
                time.Add(new System.Windows.Controls.Label());
                int LI = TextToListBox[i].LastIndexOf("&");
                int IO = TextToListBox[i].IndexOf("&");

                // System.Windows.MessageBox.Show(Convert.ToString(TextToListBox[i].Length), TextToListBox[i][TextToListBox[i].Length-1]+"a");
                string GetTime = TextToListBox[i].Substring(LI + 1, TextToListBox[i].Length - (LI + 1));//время и дата

                bool   hasFile;
                string GetId;
                if (TextToListBox[i].IndexOf("|") == -1)
                {
                    hasFile = false;
                }
                else
                {
                    hasFile = true;
                }

                if (!hasFile)
                {
                    GetId = TextToListBox[i].Substring(0, IO);
                }
                else
                {
                    GetId = TextToListBox[i].Substring(TextToListBox[i].IndexOf("|") + 1, IO - (TextToListBox[i].IndexOf("|") + 1));
                }
                //GetId = TextToListBox[i].Substring(0,TextToListBox[i].IndexOf("|"));


                time[i].Content  = GetTime;                                                       //DateTime.Now;
                TextToListBox[i] = TextToListBox[i].Remove(TextToListBox[i].LastIndexOf('&'));
                TextToListBox[i] = TextToListBox[i].Substring(TextToListBox[i].IndexOf('&') + 1); //идентификатор-аватарка

                Msg[i].Text = " " + TextToListBox[i];
                image1.Add(new BitmapImage(new Uri(sql.GetData(Convert.ToInt32(GetId))[5])));
                Ava[i].Source = image1[i];

                //


                //
                SP[i].Orientation   = System.Windows.Controls.Orientation.Horizontal;
                Ava[i].Height       = Double.NaN;
                Ava[i].Width        = 50;
                Ava[i].Margin       = new Thickness(0, 0, 0, 0);
                Msg[i].Width        = 250;
                Msg[i].Height       = Double.NaN;
                Msg[i].TextWrapping = TextWrapping.Wrap;
                //time[i].Foreground = new SolidColorBrush(Colors.Red);
                time[i].Foreground = Brushes.Gray;
                //time[i].HorizontalAlignment = Left;
                //time[i].Color = "grey";


                SP[i].Children.Add(Ava[i]);
                if (hasFile == true)
                {
                    FilePic.Add(new Image());
                    FilePic[j].Source = new BitmapImage(new Uri("Resources/file.png", UriKind.RelativeOrAbsolute));
                    FilePic[j].Height = 40;
                    FilePic[j].Width  = Double.NaN;
                    FilePic[j].Margin = new Thickness(0, 0, 0, 0);
                    SP[i].Children.Add(FilePic[j]);
                    j++;
                }
                SP[i].Children.Add(Msg[i]);
                SP[i].Children.Add(time[i]);
                LBDialog.Items.Add(SP[i]);

                //
                //LBDialog.Items.Add(TextToListBox[i]);



                //LBDialog.SelectedIndex = LBDialog.Items.Count - 1;//Проскролить в конец
                //LBDialog.ScrollIntoView(LBDialog.SelectedItem);
                LBDialog.ScrollIntoView(LBDialog.Items[LBDialog.Items.Count - 1]);
            }
        }