예제 #1
0
        private void InsertInfoFromRecordList(ContentConversation conConversation, bool lastDayRecords)
        {
            Font forIdName = new System.Drawing.Font("Arial", 10, FontStyle.Bold);
            Font forMessage = new System.Drawing.Font("Arial", 10, FontStyle.Regular);
            List<MessageRecord> myList = conConversation.mRec;

            textBox1.Clear();

            foreach (MessageRecord mRecord in myList)
            {

                //get data
                string id_name = mRecord.GetUsername();
                string message = mRecord.GetMessage();
                DateTime now = mRecord.GetReceivedTime();

                if (lastDayRecords == false)
                {

                    textBox1.SelectionColor = Color.Red;
                    textBox1.SelectedText = now.ToString();

                    if (id_name == "Eu")
                    {
                        textBox1.SelectionColor = Color.Gray;
                    }
                    else
                    {
                        textBox1.SelectionColor = Color.Blue;
                    }
                    textBox1.SelectionFont = forIdName;
                    textBox1.SelectedText = id_name +": ";

                    textBox1.SelectionColor = Color.Black;
                    textBox1.SelectionFont = forMessage;
                    textBox1.SelectedText = message + "\n";

                }
                else//true
                {
                    if (now.DayOfYear == DateTime.Now.DayOfYear)
                    {

                        textBox1.SelectionColor = Color.Red;
                        textBox1.SelectedText = now.ToString();

                        if (id_name == "Eu")
                        {
                            textBox1.SelectionColor = Color.Gray;
                        }
                        else
                        {
                            textBox1.SelectionColor = Color.Blue;
                        }
                        textBox1.SelectionFont = forIdName;
                        textBox1.SelectedText = id_name + ": ";

                        textBox1.SelectionColor = Color.Black;
                        textBox1.SelectionFont = forMessage;
                        textBox1.SelectedText = message + "\n";

                    }
                }
            }
        }
예제 #2
0
        private void Conversation_Load(object sender, EventArgs e)
        {
            conConversation = new ContentConversation();
            string filename = this.Text + ".data";
            if(File.Exists(filename))
            if (true)
            {
                FileStream flStream = null;
                try
                {
                    flStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    BinaryFormatter binFormatter = new BinaryFormatter();
                    conConversation = (ContentConversation)binFormatter.Deserialize(flStream);
                    if (conConversation != null) InsertInfoFromRecordList(conConversation, true);
                    //textBox1.Text = conConversation.GetAllMessages();
                    //cum setez pozitia
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Ex: " + ex);
                }
                finally
                {
            //                    hasText = 0;
                    if(flStream != null)
                        flStream.Close();

                }
            }
        }