private void LoadGroup()
        {
            try
            {
                if (openFileDialogGroup.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                Kennedy.FileWatcher.Data.FileGroup newfileGroup =
                    new Kennedy.FileWatcher.Data.FileGroup(openFileDialogGroup.FileName);

                TabFilePair[] pairs = new TabFilePair[tabPageList.Count];
                tabPageList.CopyTo(pairs);
                foreach (TabFilePair pair in pairs)
                {
                    ClosePage(pair);
                }

                for (int i = 0; i < newfileGroup.Count; i++)
                {
                    AddFile(newfileGroup[i]);
                }
                this.fileGroup = newfileGroup;
            }
            catch (Exception x)
            {
                MessageBox.Show("Error loading file group: " + x.Message, "File Content Watcher",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AddFile(string file)
        {
            string shortFile = System.IO.Path.GetFileName(file);

            if (shortFile.Length > 35)
            {
                shortFile = shortFile.Substring(0, 33) + "...";
            }

            Kennedy.FileWatcher.Controls.FileControl fileControl = null;
            Crownwood.Magic.Controls.TabPage         pageControl = null;

            fileControl = new Kennedy.FileWatcher.Controls.FileControl();
            pageControl = new Crownwood.Magic.Controls.TabPage(shortFile);

            pageControl.Controls.Add(fileControl);
            fileControl.Dock             = DockStyle.Fill;
            fileControl.WordWrapContents = this.wordWrap;

            TabFilePair pair = new TabFilePair(pageControl, fileControl);

            tabPageList.Add(pair);

            tabControlMain.TabPages.Add(pageControl);

            fileControl.FileChanged += new Kennedy.FileWatcher.Controls.FileActionHandler(fileControl_FileChanged);

            fileControl.Initialize(file);
            tabControlMain.SelectedTab = pair.PageControl;

            activeFilesControl.AddFile(file);
            fileGroup.Add(file);
        }
 private void ClosePage(TabFilePair pair)
 {
     tabControlMain.TabPages.Remove(pair.PageControl);
     pair.PageControl.Dispose();
     tabPageList.Remove(pair);
     activeFilesControl.RemoveFile(pair.FileControl.Filename);
     fileGroup.Remove(pair.FileControl.Filename);
 }
        private void activeFilesControl_FileSelected(string filename)
        {
            TabFilePair pair = GetFileControlPair(filename);

            if (pair == null)
            {
                return;
            }

            tabControlMain.SelectedTab = pair.PageControl;
        }
        private void LoadFile()
        {
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (string file in openFileDialog.FileNames)
            {
                if (FileIsLoaded(file))
                {
                    TabFilePair pair = GetFileControlPair(file);
                    tabControlMain.SelectedTab = pair.PageControl;
                }
                else
                {
                    AddFile(file);
                }
            }
        }