public void SetDialog(ShareFolder sf)
        {
            this.sf = sf;

            txtDirection.Text = sf.pathname;

            txtNickname.Text = sf.nickname;
        }
Beispiel #2
0
        private void lstShare_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] path = ((string[])e.Data.GetData(DataFormats.FileDrop));

                    for (int l = 0; l < path.Length; l++)
                    {
                        FileAttributes attr     = File.GetAttributes(path[l]);
                        bool           isFolder = (attr & FileAttributes.Directory) == FileAttributes.Directory;

                        if (isFolder && Directory.Exists(path[l]))
                        {
                            //리스트에 동일한 경로가 없을 경우에만 추가한다.
                            int i = 0;
                            for (i = 0; i < lstShare.Items.Count; i++)
                            {
                                if (path[l].IndexOf((String)lstShare.Items[i]) != -1)
                                {
                                    break;
                                }
                            }
                            if (i == lstShare.Items.Count)
                            {
                                int    idx  = path[l].LastIndexOf("\\") != -1 ? path[l].LastIndexOf("\\") + 1 : 0;
                                string nick = path[l].Substring(idx);

                                lstShare.Items.Add(nick);
                                ShareFolder sf = new ShareFolder(path[l], nick, nick);
                                sf.shareUserMap = new Dictionary <string, ShareFolder.ShareUser>();
                                sf.shareUserMap.Add("guest", new ShareFolder.ShareUser("guest",
                                                                                       (int)PRVIL_NUMBER.READ, (int)PRVIL_NUMBER.DOWNLOAD,
                                                                                       (int)PRVIL_NUMBER.UPLOAD, (int)PRVIL_NUMBER.REMOVE));
                                shareFolderMap.Add(path[l], sf);

                                mainForm.ClientTree.AddNewNode(nick);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private void menuShowDialog_Click(object sender, EventArgs e)
        {
            string str = (string)lstShare.Items[lstShare.SelectedIndex];

            for (int i = 0; i < shareFolderMap.Count; i++)
            {
                if (shareFolderMap.ElementAt(i).Key.Contains(str))
                {
                    ShareFolder sf = shareFolderMap.ElementAt(i).Value;
                    privilagedlg.ShareFolder = sf;
                    privilagedlg.ShowDialog();
                    shareFolderMap[shareFolderMap.ElementAt(i).Key] = privilagedlg.ShareFolder;
                    break;
                }
            }
        }
Beispiel #4
0
        public void AddNewNode(string nodeName)
        {
            DirectoryInfo di;
            ShareFolder   sf = null;

            for (int i = 0; i < shareFolderMap.Count; i++)
            {
                if (shareFolderMap.ElementAt(i).Value.folderName.Equals(nodeName))
                {
                    sf = shareFolderMap.ElementAt(i).Value;
                    break;
                }
            }

            if (sf == null)
            {
                mainForm.DoAddText("새로운 공유폴더가 트리에 추가되지 않았습니다");
                return;
            }

            Invoke(new Action(delegate()
            {
                Nodes.Add(sf.pathname, sf.folderName);
                rootFolderPath.Add(new string[2] {
                    sf.pathname, sf.folderName
                });

                di = new DirectoryInfo(sf.pathname);
                if (di.Exists && di.GetDirectories().Length != 0)
                {
                    AddDir(di, Nodes[Nodes.Count - 1]);
                }
                else if (di.Exists)
                {
                    FileInfo[] fi = di.GetFiles();

                    for (int l = 0; l < fi.Length; l++)
                    {
                        Nodes[Nodes.Count - 1].Nodes.Add(fi[l].FullName, fi[l].Name);
                    }
                }
            }));
        }