Пример #1
0
        public void displayCategory(ContentManager2 cm)
        {
            try
            {
                myFilesList2.Clear();
                AllFileList2.ItemsSource = null;
                AllFileList2.Items.Clear();

                //테스트를 위해 FileData 리스트 받아오기
                ContentManager.FileData[] fileDatas = cm.addValue();

                for (int i = 0; i < fileDatas.Length; i++)
                {
                    string filePath = fileDatas[i].FullPathStr;

                    if ((File.GetAttributes(filePath) & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        string fileName = filePath.Split('\\').Last();
                        string nickName = "";

                        //파일명 줄임표
                        if (fileName.Length > 25)
                        {
                            nickName = fileName.Substring(0, 22) + "...";
                        }
                        else
                        {
                            nickName = fileName;
                        }

                        myFilesList2.Add(new FileData { FileName = fileName, NickName = nickName, FileIcon = folderIcon, FullPathStr = filePath });
                    }
                    else
                    {
                        string fName = System.IO.Path.GetFileName(filePath);
                        FileToImageIconConverter some = new FileToImageIconConverter(filePath);
                        ImageSource imgSource = some.Icon;
                        string nName = "";
                        if (fName.Length > 25)
                        {
                            nName = fName.Substring(0, 22) + "..." + fName.Substring(fName.Length - 4, 4);
                        }
                        else
                        {
                            nName = fName;
                        }

                        myFilesList2.Add(new FileData { FileName = fName, NickName = nName, FileIcon = imgSource, FullPathStr = filePath });
                    }

                }
                AllFileList2.ItemsSource = myFilesList2;
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
            
        }
Пример #2
0
        //private async void initLogin()
        //{ 
        //    //로그인창 띄우기
        //    if (isLogin == false)
        //    {
        //        try
        //        {
        //            LoginDialogData result = await this.ShowLoginAsync("로그인", "아이디와 비밀번호를 입력해주세요",
        //            new LoginDialogSettings
        //            {
        //                ColorScheme = MetroDialogColorScheme.Accented,
        //                UsernameWatermark = "ID",
        //                PasswordWatermark = "Password",
        //                NegativeButtonVisibility = Visibility.Visible,
        //               // NegativeButtonText = join
        //            });
        //        }
        //        catch (InvalidOperationException eee)
        //        {
        //            MessageBox.Show(eee.Message);
        //        }
        //    }
        //    else
        //    {
        //        isLogin = false;
        //        LoginBtn.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/img/login.png", UriKind.Absolute)));

        //        //테스트
        //        MessageBox.Show("로그아웃");

        //    }
            
        //}
        //GroupBox Refresh
        public void Refresh(string FullPath)
        {
            BackPath(FullPath);

            if (defaultPath.Equals(nowPath) == true)
            {
                backButton.Opacity = 0;
            }
            else if (defaultPath.Equals(nowPath) == false)
            {
                backButton.Opacity = 1;
            }

            string[] rtoken = defaultPath.Split('\\');
            string[] ftoken = FullPath.Split('\\');

            if (entry.Root != null)
            {
                EntryElement target = entry.Root;

                for (int i = rtoken.Length; i < ftoken.Length; i++)
                {
                    target = (EntryElement)target.NamedChildren[ftoken[i]];
                }

                entry.CurrentRoot = target;
            }
            //entry.moveDirectory(); //뒤로가기버튼 클릭 시, 널참조 에러발생

            string[] directoryEntries = System.IO.Directory.GetFileSystemEntries(FullPath, "*", System.IO.SearchOption.TopDirectoryOnly);
            myFilesList.Clear(); //myFileList를 안비워줘서 문제생겼음


            AllFileList.ItemsSource = null;
            AllFileList.Items.Clear();

            //Refresh()를 category에서도 사용할 때
            //if (defaultModeFlag)
            //{
            //    AllFileList.ItemsSource = null;
            //    AllFileList.Items.Clear();
            //}
            //else
            //{
            //    AllFileList2.ItemsSource = null;
            //    AllFileList2.Items.Clear();
            //}
            
            
            
            int cnt = directoryEntries.Length;
            for(int i=0; i< cnt; i++) //(string filePath in directoryEntries)
            {
                string filePath = directoryEntries[i];
                //Folder
                if ((File.GetAttributes(filePath) & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    string fileName = filePath.Split('\\').Last();//filePath.Replace(System.IO.Path.GetDirectoryName(filePath) + "\\", "");
                    string nickName = "";
                   
                    //파일명 줄임표
                    if (fileName.Length > 25)
                    {
                        nickName = fileName.Substring(0, 22) + "...";
                    }
                    else 
                    {
                        nickName = fileName;
                    }
                    myFilesList.Add(new FileData { FileName = fileName, NickName = nickName, FileIcon = folderIcon, FullPathStr = filePath });
                }
                //File
                else
                {
                    string fName = System.IO.Path.GetFileName(filePath);
                    FileToImageIconConverter some = new FileToImageIconConverter(filePath);
                    ImageSource imgSource = some.Icon;
                    string nName = "";
                    if (fName.Length > 25) {
                        nName = fName.Substring(0, 18) + "..." + fName.Substring(fName.Length-4,4);
                    }
                    else
                    {
                        nName = fileName;
                    }
                    
                    myFilesList.Add(new FileData { FileName = fName, NickName=nName, FileIcon = imgSource, FullPathStr = filePath });
                }
            }
            
            AllFileList.ItemsSource = myFilesList;
            //if (defaultModeFlag)
            //{
            //    AllFileList.ItemsSource = myFilesList;
            //}
            //else 
            //{
            //    AllFileList2.ItemsSource = myFilesList;
            //} 
             
        }