Esempio n. 1
0
        private void tsmiSaveTab_Click(object sender, EventArgs e)
        {
            frmSaveTabBundle frm = new frmSaveTabBundle();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    TabBox box = new TabBox();
                    box.name.Text = frm.txtNameText;
                    TabControl.TabPageCollection tpc = tabBrowser.TabPages;
                    foreach (TabPage tp in tpc)
                    {
                        WebBrowser wb = (WebBrowser)tp.Controls[0];
                        box.list.Text += wb.DocumentTitle + '\n';
                        box.list.Tag  += wb.Url.ToString() + '\n';
                    }

                    File.WriteAllText(setupPath + "TabBundle\\" + frm.txtNameText + ".txt", box.list.Text);
                    File.WriteAllText(setupPath + "TabBundle\\" + frm.txtNameText + "URL.txt", box.list.Tag.ToString());

                    if (TabBundleCount % 2 == 0)
                    {
                        box.back1.Location = new Point(30 + TabBundleCount / 2 * 380, 70);
                        box.back2.Location = new Point(25 + TabBundleCount / 2 * 380, 75);
                        box.list.Location  = new Point(20 + TabBundleCount / 2 * 380, 105);
                    }
                    else
                    {
                        box.back1.Location = new Point(30 + TabBundleCount / 2 * 380, 370);
                        box.back2.Location = new Point(25 + TabBundleCount / 2 * 380, 375);
                        box.list.Location  = new Point(20 + TabBundleCount / 2 * 380, 405);
                    }

                    box.name.Location    = new Point(box.list.Location.X, box.list.Location.Y - 25);
                    box.list.Click      += new EventHandler(tabBundleBox_Click); // 이미지 클릭 시 페이지 이동 핸들러 발동
                    box.name.MouseEnter += new EventHandler(boxName_MouseEnter);
                    box.name.MouseLeave += new EventHandler(boxName_MouseLeave);
                    box.name.Click      += delegate { TabBundleRemove(box); }; // 이름 누르면 삭제
                    TabBundleCount++;
                    pnlTabBundle.Controls.Add(box.list);
                    pnlTabBundle.Controls.Add(box.name);
                    pnlTabBundle.Controls.Add(box.back2);
                    pnlTabBundle.Controls.Add(box.back1);
                }
                catch
                {
                    MessageBox.Show("저장에 실패했습니다. 이름을 확인하세요.");
                }
            }
        }
Esempio n. 2
0
        private void TabBundleRemove(TabBox box)
        {
            string fileName = box.name.Text.Substring(0, box.name.Text.Length - 1);

            box.list.Text = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            box.back1.Dispose();
            box.back2.Dispose();
            box.name.Dispose();
            box.list.Dispose();
            File.Delete(setupPath + "TabBundle\\" + fileName + "URL.txt");
            File.Delete(setupPath + "TabBundle\\" + fileName + ".txt");
        }
Esempio n. 3
0
        public frmGoraniBrowser()
        {
            regeditIE11();
            InitializeComponent();
            wbBrowser.ScriptErrorsSuppressed = true;    // 자바 스크립트 오류 창 안뜨게하기
            DirectoryInfo di = new DirectoryInfo(setupPath);

            // Setup 폴더 없으면 생성
            if (di.Exists == false)
            {
                di.Create();
                di = new DirectoryInfo(setupPath + "Favorite\\");
                di.Create();
                di = new DirectoryInfo(setupPath + "OfflinePage\\");
                di.Create();
                di = new DirectoryInfo(setupPath + "TabBundle\\");
                di.Create();
                File.Create(setupPath + "history.txt");
                File.WriteAllText(setupPath + "homepage.txt", "https://www.google.com/"); // 첫 홈페이지 구글로 초기화
            }
            // Setup 폴더가 존재하면
            else
            {
                // 저장된 즐겨찾기 목록 가져오기
                di = new DirectoryInfo(setupPath + "Favorite\\");
                foreach (FileInfo fi in di.GetFiles())
                {
                    if (fi.Extension.ToLower() == ".jpg")
                    {
                        PageBox box = new PageBox();
                        // PageBox 이미지 PictureBox 설정
                        box.pic.Image = Image.FromFile(fi.FullName);                                                                    // 저장된 이미지 가져오기
                        box.pic.Tag   = File.ReadAllText(setupPath + "Favorite\\" + fi.Name.Substring(0, fi.Name.Length - 4) + ".txt"); // PictureBox 태그로 URL 저장
                        // PageBox 이름 Label 설정
                        box.name.Text = fi.Name.Substring(0, fi.Name.Length - 4);                                                       // 확장자 제외한 파일 이름으로 PageBox 이름 텍스트 설정
                        // 정렬
                        if (favoriteCount % 2 == 0)
                        {
                            box.pic.Location = new Point(20 + favoriteCount / 2 * 380, 80);
                        }
                        else
                        {
                            box.pic.Location = new Point(20 + favoriteCount / 2 * 380, 380);
                        }
                        box.name.Location    = new Point(box.pic.Location.X, box.pic.Location.Y - 25);
                        box.pic.Click       += new EventHandler(favoriteBox_Click); // 이미지 클릭 시 페이지 이동 핸들러 발동
                        box.name.MouseEnter += new EventHandler(boxName_MouseEnter);
                        box.name.MouseLeave += new EventHandler(boxName_MouseLeave);
                        box.name.Click      += delegate { FavoriteRemove(box); }; // 이름 누르면 삭제
                        favoriteCount++;
                        // 컨트롤에 추가
                        pnlFavorite.Controls.Add(box.name);
                        pnlFavorite.Controls.Add(box.pic);
                    }
                }

                // 저장된 탭묶음 목록 가져오기
                di = new DirectoryInfo(setupPath + "TabBundle\\");
                foreach (FileInfo fi in di.GetFiles())
                {
                    if (fi.Name.Length >= 7 && fi.Name.Substring(fi.Name.Length - 7, 3) == "URL")
                    {
                        TabBox box = new TabBox();
                        box.name.Text = fi.Name.Substring(0, fi.Name.Length - 7);
                        box.list.Text = File.ReadAllText(setupPath + "TabBundle\\" + fi.Name.Substring(0, fi.Name.Length - 7) + ".txt");
                        box.list.Tag  = File.ReadAllText(fi.FullName);

                        if (TabBundleCount % 2 == 0)
                        {
                            box.back1.Location = new Point(30 + TabBundleCount / 2 * 380, 70);
                            box.back2.Location = new Point(25 + TabBundleCount / 2 * 380, 75);
                            box.list.Location  = new Point(20 + TabBundleCount / 2 * 380, 105);
                        }
                        else
                        {
                            box.back1.Location = new Point(30 + TabBundleCount / 2 * 380, 370);
                            box.back2.Location = new Point(25 + TabBundleCount / 2 * 380, 375);
                            box.list.Location  = new Point(20 + TabBundleCount / 2 * 380, 405);
                        }
                        box.name.Location    = new Point(box.list.Location.X, box.list.Location.Y - 25);
                        box.list.Click      += new EventHandler(tabBundleBox_Click); // 이미지 클릭 시 페이지 이동 핸들러 발동
                        box.name.MouseEnter += new EventHandler(boxName_MouseEnter);
                        box.name.MouseLeave += new EventHandler(boxName_MouseLeave);
                        box.name.Click      += delegate { TabBundleRemove(box); }; // 이름 누르면 삭제
                        TabBundleCount++;
                        pnlTabBundle.Controls.Add(box.list);
                        pnlTabBundle.Controls.Add(box.name);
                        pnlTabBundle.Controls.Add(box.back2);
                        pnlTabBundle.Controls.Add(box.back1);
                    }
                }

                // 저장된 오프라인페이지 목록 가져오기
                di = new DirectoryInfo(setupPath + "OfflinePage\\");
                foreach (FileInfo fi in di.GetFiles())
                {
                    if (fi.Extension.ToLower() == ".jpg")
                    {
                        PageBox box = new PageBox();
                        // PageBox의 이미지 PictureBox 설정
                        box.pic.Image = Image.FromFile(fi.FullName);                                // 저장된 이미지 가져오기
                        box.pic.Tag   = fi.FullName.Substring(0, fi.FullName.Length - 4) + ".html"; // PictureBox 태그로 html 파일 경로 저장
                        // PageBox의 이름 Label 설정
                        box.name.Text = "☻ " + fi.Name.Substring(0, fi.Name.Length - 4);            // 확장자 제외한 파일 이름으로 PageBox 이름 텍스트 설정
                        // 정렬
                        if (offlineCount % 2 == 0)
                        {
                            box.pic.Location = new Point(20 + offlineCount / 2 * 380, 80);
                        }
                        else
                        {
                            box.pic.Location = new Point(20 + offlineCount / 2 * 380, 380);
                        }
                        box.name.Location    = new Point(box.pic.Location.X, box.pic.Location.Y - 25);
                        box.pic.Click       += new EventHandler(offlineBox_Click); // 이미지 클릭 시 페이지 이동 핸들러 발동
                        box.name.MouseEnter += new EventHandler(boxName_MouseEnter);
                        box.name.MouseLeave += new EventHandler(boxName_MouseLeave);
                        box.name.Click      += delegate { OfflinePageRemove(box); }; // 이름 누르면 삭제
                        offlineCount++;
                        pnlOffline.Controls.Add(box.name);
                        pnlOffline.Controls.Add(box.pic);
                    }
                }

                // 저장된 방문기록 목록 가져오기
                var history = File.ReadAllLines(setupPath + "history.txt");
                for (int i = 0; i + lvwHistory.Columns.Count - 1 < history.Length; i += lvwHistory.Columns.Count)
                {
                    lvwHistory.Items.Add(new ListViewItem(new[]
                    {
                        history[i], history[i + 1], history[i + 2]
                    }));
                }
            }
            homepage = File.ReadAllText(setupPath + "homepage.txt"); // homepage.txt 내용으로 homepage 설정
            GoWebSite(homepage);
            AddHistory();
        }