Ejemplo n.º 1
0
        private void ChangeLogUserInbox(object sender, EventArgs e)
        {
            ListView lvUser = (ListView)sender;
            if (lvUser.SelectedItems.Count == 1)
            {
                tbLogInbox.Clear();
                InboxUser inbox = MyHelper.GetInboxByUserID(lvUser.SelectedItems[0].Name, ListInboxUser);
                currentLogInbox = inbox;
                ListViewItem item = ((ListView)sender).SelectedItems[0];
                currentInboxLVItem = item;
                lbLogUserName.Text = inbox.UserName;
                lbLogUserId.Text = item.Name;
                pbLogUserImage.ImageLocation = Path.Combine(FB_Image.RelativeDirectory, FB_Image.UserImageDir, item.Name + ".jpg");
                //receivePass = GetMessagePassword(lbUserIdComm.Text);
                currentLogInbox.PrintLogMessages(tbLogInbox);

            }
        }
Ejemplo n.º 2
0
        private void btnManualEncode_Click(object sender, EventArgs e)
        {
            try
            {
                string pass = GetMessagePasswordNoID();
                if (pass == null)
                    return;
                if (radioManualEncode.Checked)
                {
                    string messagePath = GetMessageInput(cmbManualFileType, tbManualText, tbManualStatus);
                    if (String.IsNullOrEmpty(tbManualImage.Text))
                    {
                        return;
                    }

                    int size = GetSplitSize();
                    if (size < 0)
                        return;
                    string encodeFile = tbManualImage.Text;
                    SimplerAES aes = new SimplerAES(pass);
                    messagePath = aes.EncryptFile(messagePath);
                    List<string> a = SplitFileIntoPart(messagePath, size);
                    List<string> coverFile = new List<string>();
                    coverFile.Add(encodeFile);
                    if (!GetMoreImage(a, coverFile))
                        return;
                    List<string> FailFile = new List<string>();
                    string flag = "";
                    int count = 0;
                    string successFile = "";
                    for (int i = 0; i < a.Count; i++)
                    {
                        //string newFile = Common.AppendFileName(encodeFile, i.ToString());
                        //File.Copy(encodeFile, newFile, true);
                        bool isTest = Path.GetDirectoryName(coverFile[i]).Equals(Path.Combine(FB_Image.RelativeDirectory, "SuccessImage"));
                        flag = EncodeImage(coverFile[i], a[i], null, isTest);

                        if (flag != null)
                        {
                            string outputdir = Path.Combine(Path.Combine(FB_Image.RelativeDirectory, FB_Image.OutputDir));
                            if (!Directory.Exists(outputdir))
                            {
                                Directory.CreateDirectory(outputdir);
                            }
                            successFile = MyHelper.CopyFileTo(Path.Combine(FB_Image.BaseDirectory, flag), outputdir);
                            count++;
                        }
                        else
                        {
                            FailFile.Add(a[i]);
                        }
                    }
                    if (FailFile.Count > 0)
                    {
                        MessageBox.Show("These images are not ready for sending your message");
                    }
                    else
                    {
                        OpenFolder(successFile);
                        MessageBox.Show("Encoding Success");
                    }
                }
                else
                {
                    if (manualListFile != null && manualListFile.Length >= 1)
                    {
                        manualInbox = new InboxUser("1", "Manual");
                        foreach (string item in manualListFile)
                        {
                            byte[] content = MyHelper.GetByteFromImage(item);
                            if (content != null)
                            {
                                string s_content = CorrectErrorString(content);
                                if (s_content != null)
                                {
                                    //userInbox.Messages.Add(new FB_Message(content, new FB_Image(imageId,imagePath),createdTime,isSent));
                                    bool flag = manualInbox.AddMessageToInbox(s_content, "1", item, 0);
                                    if (flag)
                                        manualInbox.CountNew++;
                                }
                            }
                        }
                        if (manualInbox.Messages.Count >= 0)
                        {
                            foreach (FB_Message mes in manualInbox.Messages)
                            {
                                string s = "";
                                if (mes.Part.Count >= 1)
                                {
                                    s += "Images path:" + Environment.NewLine;
                                    foreach (MessagePart p in mes.Part)
                                    {
                                        s += p.ImagePath + Environment.NewLine;
                                    }
                                    s += "Message: ";
                                    string content = mes.GetContent(pass);
                                    if (content != null)
                                        s += content + Environment.NewLine;
                                    else
                                        s += "No Output" + Environment.NewLine;
                                    s += "---------------------------------" + Environment.NewLine;
                                    tbManualStatus.AppendText(s);

                                }
                            }
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                Log(ex);
            }



        }
Ejemplo n.º 3
0
 private void UpdateNewMessageLabel(ListViewItem lvItem, Label label, InboxUser inbox)
 {
     if(lvItem != null)
         lvItem.Text = GetInboxText(inbox.UserName, inbox.CountNew);
     lbReceiverNewMessage.Text = String.Format("{0} in {1}", inbox.CountNew, inbox.Messages.Count);
 }
Ejemplo n.º 4
0
 private void UpdateMessageListView(ListView listview, InboxUser inbox)
 {
     listview.Clear();
     ImageList il = new ImageList();
     il.TransparentColor = Color.Blue;
     il.ColorDepth = ColorDepth.Depth32Bit;
     il.ImageSize = new Size(50, 50);
     List<FB_Message> messages = inbox.Messages;
     for (int i = 0; i < messages.Count; i++)
     {
             il.Images.Add(Image.FromFile(messages[i].Image.FullPath));
             il.Images.SetKeyName(i, "Message_" + i);
     }
     listview.View = View.LargeIcon;
     listview.LargeImageList = il;
     for (int j = 0; j < messages.Count; j++)
     {
         if (!messages[j].IsSent)
         {
             ListViewItem item = new ListViewItem();
             item.Text = il.Images.Keys[j].ToString();
             item.Name = j.ToString();
             item.ImageIndex = j;
             listview.Items.Add(item);
             
         }
     }
     if (listview.Items.Count > 0)
     {
         listview.Items[listview.Items.Count - 1].EnsureVisible();
     }
 }
Ejemplo n.º 5
0
        private void ChangeUserInbox(object sender, EventArgs e)
        {
            ListView lvUser = (ListView)sender;
            if (lvUser.SelectedItems.Count == 1 )
            {
                InboxUser inbox = MyHelper.GetInboxByUserID(lvUser.SelectedItems[0].Name, ListInboxUser);
                UpdateMessageListView(listViewMessage, inbox);
                currentInbox = inbox;
                ListViewItem item = ((ListView)sender).SelectedItems[0];
                currentInboxLVItem = item;
                lbUserNameComm.Text = inbox.UserName;
                lbUserIdComm.Text = item.Name;
                pBoxUserComm.ImageLocation = Path.Combine(FB_Image.RelativeDirectory, FB_Image.UserImageDir, item.Name + ".jpg");
                UpdateNewMessageLabel(null, lbReceiverNewMessage, currentInbox);
                receivePass = GetMessagePassword(lbUserIdComm.Text);


            }
         
            
        }