예제 #1
0
        internal static void SelectNodePageFromNavigatedUrl(Form1 form, Uri url, String guidePath)
        {
            TreeView indexTreeView = form.indexTreeView;

            String culture = OptionManager.GetLanguage(form);

            try
            {
                String nodeNameUrl = url.ToString().Remove(0, guidePath.Length + 9).Replace("/", "\\");
                if (indexTreeView.Nodes.ContainsKey(nodeNameUrl))
                {
                    indexTreeView.SelectedNode = indexTreeView.Nodes[indexTreeView.Nodes.IndexOfKey(nodeNameUrl)];
                    return;
                }

                foreach (TreeNode node in indexTreeView.Nodes)
                {
                    if (node.Nodes.Count == 0 || !node.Nodes.ContainsKey(nodeNameUrl))
                    {
                        continue;
                    }

                    indexTreeView.SelectedNode = node.Nodes[node.Nodes.IndexOfKey(nodeNameUrl)];
                    return;
                }
            }
            catch (Exception exception)
            {
                WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorGetting", className, culture), exception, OptionManager.GetLanguage(form));
            }
        }
예제 #2
0
        internal static void CloseGuide(Form1 form, bool newOpening)
        {
            TreeView         indexTreeView       = form.indexTreeView;
            WebBrowser       helpWebBrowser      = (WebBrowser)form.splitContainer1.Panel2.Controls["helpWebBrowser"]; //form.helpWebBrowser;
            ToolStripTextBox urlToolStripTextBox = form.urlToolStripTextBox;

            if (helpWebBrowser.Document == null)
            {
                return;
            }

            form.Text = LanguageUtil.GetCurrentLanguageString("Title", form.Name, OptionManager.GetLanguage(form));
            indexTreeView.Nodes.Clear();
            urlToolStripTextBox.Text = String.Empty;
            ReplaceHelpWebBrowser(form);

            if (!newOpening)
            {
                WindowManager.DisableInterface(form);
            }
        }
예제 #3
0
        internal static void OpenGuide(Form1 form)
        {
            OpenFileDialog openFileDialog = form.openFileDialog;

            try
            {
                WindowManager.EnableInterface(form);

                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    WindowManager.DisableInterface(form);
                    return;
                }

                String fileName = openFileDialog.FileName;
                GuideManager.ReadHelpGuide(form, fileName);
            }
            catch (Exception exception)
            {
                WindowManager.DisableInterface(form);
                WindowManager.ShowErrorBox(form, exception.Message, exception, OptionManager.GetLanguage(form));
            }
        }
예제 #4
0
        internal static void ReadHelpGuide(Form1 form, String pathAndFileName)
        {
            TreeView indexTreeView = form.indexTreeView;

            String culture = OptionManager.GetLanguage(form);

            CloseGuide(form, true);                                                                         //indexTreeView.Nodes.Clear();

            WebBrowser helpWebBrowser = (WebBrowser)form.splitContainer1.Panel2.Controls["helpWebBrowser"]; //form.helpWebBrowser;

            String guidePath = Path.GetDirectoryName(pathAndFileName);

            try
            {
                form.GuidePath = guidePath;

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(pathAndFileName);

                form.Text = String.Format("{0} - {1}", LanguageUtil.GetCurrentLanguageString("Title", "Form1", culture), xmldoc.GetElementsByTagName("guide").Item(0).Attributes["format"].Value);

                XmlNodeList indexList = xmldoc.GetElementsByTagName("index");
                XmlNode     indexNode = indexList[0];
                TreeNode    newIndex  = new TreeNode(indexNode.Attributes["title"].Value);
                newIndex.ImageIndex         = 0;
                newIndex.SelectedImageIndex = 0;
                newIndex.Name = indexNode.Attributes["file"].Value;
                indexTreeView.Nodes.Add(newIndex);

                String homeFile = Path.Combine(guidePath, indexNode.Attributes["file"].Value);
                helpWebBrowser.Url         = new Uri(homeFile);
                form.Home                  = homeFile;
                indexTreeView.SelectedNode = newIndex;

                XmlNodeList chapterList = xmldoc.GetElementsByTagName("chapter");
                foreach (XmlNode nodeChapter in chapterList)
                {
                    TreeNode newChapter = new TreeNode(nodeChapter.Attributes["title"].Value)
                    {
                        ImageIndex         = 1,
                        SelectedImageIndex = 1,
                        Name = nodeChapter.Attributes["file"].Value
                    };
                    indexTreeView.Nodes.Add(newChapter);

                    XmlNodeList pageList = nodeChapter.ChildNodes;
                    foreach (XmlNode nodePage in pageList)
                    {
                        TreeNode newPage = new TreeNode(nodePage.Attributes["title"].Value)
                        {
                            ImageIndex         = 2,
                            SelectedImageIndex = 2,
                            Name = nodePage.Attributes["file"].Value
                        };
                        newChapter.Nodes.Add(newPage);
                    }
                }
            }
            catch (XmlException exception)
            {
                form.GuidePath = String.Empty;
                form.Home      = String.Empty;
                WindowManager.DisableInterface(form);
                WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className, culture), exception, OptionManager.GetLanguage(form));
            }
        }