Exemplo n.º 1
0
        private void btn_start_Click(object sender, MouseEventArgs e)
        {
            try
            {
                //해당 폼 찾기
                SendFileForm form = (SendFileForm)ChatUtils.GetParentSendFileForm((Button)sender);

                string key = form.formkey.Text;
                string filename = null;

                logWrite("파일전송시작 : formkey 값 얻어옴(" + key + ")");
                if (FileSendFormList.ContainsKey(key) && FileSendFormList[key] != null) {

                    form = (SendFileForm)FileSendFormList[key];
                    logWrite("key값에 대한 Form 찾음! ");
                } else {
                    logWrite("키값에 대한 SendFileForm 없음! key=" + key);
                }

                //전송파일 선택안한 경우
                if (form.label_filename.Text.Length == 0) {
                
                    logWrite("btn_start_Click : 전송할 파일이 없음");
                    DialogResult result = MessageBox.Show(form, "전송할 파일을 선택해 주세요", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    bool FileSelected = false;

                    if (result == DialogResult.OK) {
                    
                        DialogResult fresult = openFileDialog.ShowDialog(form);
                        if (fresult == DialogResult.OK) {
                        
                            if (openFileDialog.FileName.Length != 0) {
                            
                                filename = openFileDialog.FileName;
                                FileSelected = true;
                            }
                        }
                        if (FileSelected == true) {
                        
                            string[] filenameArray = filename.Split('\\');
                            if (filenameArray.Length > 2) {

                                form.label_filename.Text = filenameArray[0] + "\\...\\" + filenameArray[(filenameArray.Length - 1)];
                                form.label_filename.Tag = filename;
                                logWrite(" btn_start_Click()  form.label_filename.Tag = " + form.label_filename.Tag.ToString());
                            
                            } else {
                            
                                form.label_filename.Text = filename;
                            
                            }

                            ToolTip tip = new ToolTip();
                            tip.SetToolTip(form.label_filename, filename);

                            FileInfo fi = new FileInfo(filename);
                            int fsize = Convert.ToInt32(fi.Length / 1000);

                            if (fsize.ToString().Length > 3) {
                                fsize = fsize / 1000;
                                form.label_filesize.Text = fsize + " MB (" + fi.Length.ToString() + " byte)";
                            } else {
                                form.label_filesize.Text = fsize + " Kb (" + fi.Length.ToString() + " byte)";
                            }
                        }
                    }
                    //수신자 선택안한 경우
                } else if (form.txtbox_FileReceiver.Text.Length == 0) {
                
                    logWrite("btn_start_Click : 받는사람이 없음");
                    DialogResult result = MessageBox.Show(form, "파일을 받는 사람이 없습니다. 추가해 주세요.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (result == DialogResult.OK)
                    {
                        AddFileReceiver(form.formkey.Text);
                    }
                }
                else
                {
                    logWrite("btn_start_Click : 전송할 파일과 받을사람 체크 완료");
                    form.btn_start.Visible = false;
                    form.btn_cancel.Left += 40;
                    form.label_result.Text = "전송 대기중";
                    string tempname = null;
                    string tempid = null;
                    ArrayList list = new ArrayList();
                    string[] receiverArray = form.txtbox_FileReceiver.Text.Split(';');

                    //전송 상태 자세히 보기 생성
                    FileSendDetailListView view = new FileSendDetailListView();
                    view.FormClosing += new FormClosingEventHandler(FileSendDetailListView_FormClosing);

                    foreach (string receiver in receiverArray)
                    {
                        if (receiver.Length != 0)
                        {
                            string[] receiverArg = receiver.Split('(');
                            tempname = receiverArg[0];
                            string[] receiverArg1 = receiverArg[1].Split(')');
                            tempid = receiverArg1[0];
                            list.Add(tempid);

                            ListViewItem item = view.listView.Items.Add(tempid, receiver, null);
                            item.SubItems.Add("");
                            item.SubItems.Add("");
                        }
                    }
                    FileSendDetailList[form.formkey.Text] = view;
                    form.label_detail.Visible = true;
                    if (list.Count > 1)
                    {
                        view.Show();
                    }
                    FileSendRequest(list, form.label_filename.Tag.ToString(), form.formkey.Text);
                }
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// FileSendForm 내 자세히 보기 클릭시 나타나는 리스트 뷰 폼의 상태값 변경
 /// </summary>
 /// <param name="keyid">리스트 뷰의 아이템 구분 id(파일 받는 사람의 id)</param>
 /// <param name="detail">표시하고자 하는 상태값</param>
 /// <param name="view">리스트 뷰 객체</param>
 private void ShowFileSendDetail(string keyid, string detail, FileSendDetailListView view)
 {
     try
     {
         ListViewItem[] itemArray = null;
         if (keyid.Equals("server"))
         {
             foreach (ListViewItem item in view.listView.Items)
             {
                 if (item.SubItems[1].Text.Equals("서버전송"))
                 {
                     item.SubItems[1].Text = detail;
                 }
             }
         }
         else
         {
             if (view.listView.Items.ContainsKey(keyid))
             {
                 itemArray = view.listView.Items.Find(keyid, false);
             }
             if (itemArray != null)
             {
                 itemArray[0].SubItems[1].Text = detail;
             }
         }
     }
     catch (Exception exception)
     {
         logWrite(exception.ToString());
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// FileSendDetailListView 에서 모든 대상자가 전송완료 되면 FileSendForm 버튼을 변경
 /// </summary>
 /// <param name="view">FileSendDetailListView 객체</param>
 /// <returns></returns>
 private bool ShowCloseButton(FileSendDetailListView view)
 {
     bool isFinished = false;
     int num = 0;
     try
     {
         for (int i = 0; i < view.listView.Items.Count; i++)
         {
             if (!view.listView.Items[i].SubItems[1].Text.Equals("전송완료")) num++;
         }
         if (num == 0) isFinished = true;
     }
     catch (Exception exception)
     {
         logWrite(exception.ToString());
     }
     return isFinished;
 }
Exemplo n.º 4
0
        private void btn_start_Click(object sender, MouseEventArgs e)
        {
            try
            {
                Button button = (Button)sender;
                int num = button.Parent.Controls.Count;
                SendFileForm form = null;
                string key = null;
                string filename = null;

                for (int i = 0; i < num; i++)
                {
                    if ("formkey".Equals(button.Parent.Controls[i].Name))
                    {
                        Label keylabel = (Label)button.Parent.Controls[i];
                        key = keylabel.Text;
                        logWrite("btn_start_Click : formkey �� ����(" + key + ")");
                        if (FileSendFormList.ContainsKey(key) && FileSendFormList[key] != null)
                        {
                            form = (SendFileForm)FileSendFormList[key];
                            logWrite("key���� ���� Form �! ");
                        }
                        else logWrite("���� ���� SendFileForm ����! key=" + key);
                        break;
                    }
                }

                if (form.label_filename.Text.Length == 0)
                {
                    logWrite("btn_start_Click : ������ ������ ����");
                    DialogResult result = MessageBox.Show(form, "������ ������ ������ �ּ���", "�˸�", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    bool FileSelected = false;

                    if (result == DialogResult.OK)
                    {
                        DialogResult fresult = openFileDialog.ShowDialog(form);
                        if (fresult == DialogResult.OK)
                        {
                            if (openFileDialog.FileName.Length != 0)
                            {
                                filename = openFileDialog.FileName;
                                FileSelected = true;
                            }
                        }
                        if (FileSelected == true)
                        {
                            string[] filenameArray = filename.Split('\\');
                            if (filenameArray.Length > 2)
                            {
                                form.label_filename.Text = filenameArray[0] + "\\...\\" + filenameArray[(filenameArray.Length - 1)];
                                form.label_filename.Tag = filename;
                                logWrite(" btn_start_Click()  form.label_filename.Tag = " + form.label_filename.Tag.ToString());
                            }
                            else form.label_filename.Text = filename;

                            ToolTip tip = new ToolTip();
                            tip.SetToolTip(form.label_filename, filename);

                            FileInfo fi = new FileInfo(filename);
                            int fsize = Convert.ToInt32(fi.Length / 1000);
                            if (fsize.ToString().Length > 3)
                            {
                                fsize = fsize / 1000;
                                form.label_filesize.Text = fsize + " MB (" + fi.Length.ToString() + " byte)";
                            }
                            else form.label_filesize.Text = fsize + " Kb (" + fi.Length.ToString() + " byte)";
                        }
                    }
                }
                else if (form.txtbox_FileReceiver.Text.Length == 0)
                {
                    logWrite("btn_start_Click : �޴»���� ����");
                    DialogResult result = MessageBox.Show(form, "������ �޴� ����� �����ϴ�. �߰��� �ּ���.", "�˸�", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (result == DialogResult.OK)
                    {
                        AddFileReceiver(form.formkey.Text);
                    }
                }
                else
                {
                    logWrite("btn_start_Click : ������ ���ϰ� ������� üũ �Ϸ�");
                    button.Visible = false;
                    form.label_result.Text = "���� �����";
                    string tempname = null;
                    string tempid = null;
                    ArrayList list = new ArrayList();
                    string[] receiverArray = form.txtbox_FileReceiver.Text.Split(';');

                    //���� ���� �ڼ��� ���� ����
                    FileSendDetailListView view = new FileSendDetailListView();
                    view.FormClosing += new FormClosingEventHandler(FileSendDetailListView_FormClosing);

                    foreach (string receiver in receiverArray)
                    {
                        if (receiver.Length != 0)
                        {
                            if (receiver.Equals("������ü"))
                            {
                                list.Add("all");
                            }
                            else
                            {
                                string[] receiverArg = receiver.Split('(');
                                tempname = receiverArg[0];
                                string[] receiverArg1 = receiverArg[1].Split(')');
                                tempid = receiverArg1[0];
                                list.Add(tempid);
                            }

                            ListViewItem item = view.listView.Items.Add(tempid, receiver, null);
                            item.SubItems.Add("");
                            item.SubItems.Add("");
                        }
                    }
                    FileSendDetailList[form.formkey.Text] = view;
                    form.label_detail.Visible = true;
                    if (list.Count > 1)
                    {
                        view.Show();
                    }
                    FileSendRequest(list, form.label_filename.Tag.ToString(), form.formkey.Text);
                }
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }