コード例 #1
0
ファイル: Rule.cs プロジェクト: MShaffar19/bion
        public override int GetHashCode()
        {
            int result = 17;

            unchecked
            {
                if (Id != default(string))
                {
                    result = (result * 31) + Id.GetHashCode();
                }

                if (Guid != default(String))
                {
                    result = (result * 31) + Guid.GetHashCode();
                }

                if (HelpUri != default(Uri))
                {
                    result = (result * 31) + HelpUri.GetHashCode();
                }

                if (RelatedRules != default(IList <Rule>))
                {
                    result = (result * 31) + RelatedRules.GetHashCode();
                }
            }

            return(result);
        }
コード例 #2
0
        public bool Generate()
        {
            GUILayout.Label(ErrorLabelContent, _errorLabelStyle.Get);

            var helpClicked = GenerateHelpButton();

            if (helpClicked && Event.current.button == 0)
            {
                Application.OpenURL(HelpUri.ToString());
            }

            return(helpClicked);
        }
コード例 #3
0
        private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            string url = e.Url.OriginalString;

            if (!url.StartsWith("about:blank?"))
            {
                return;
            }

            string  target = url.Substring(12);
            HelpUri link   = new HelpUri(target);

            if (!viewModel.NavigateTo(link))
            {
                MessageBox.Show("Cannot resolve link: " + target);
                e.Cancel = true;
            }
        }
コード例 #4
0
        protected override string FormatUri(HelpTopic source, HelpUri uri)
        {
            switch (uri.Type)
            {
            case HelpUriType.Context:
            case HelpUriType.GlobalContext:
            case HelpUriType.LocalContext:
            {
                HelpTopic target = system.ResolveUri(source.Database, uri);
                if (target != null)
                {
                    if (target.Database == source.Database)
                    {
                        return(string.Format("T{0:X4}.html", target.TopicIndex));
                    }
                    else
                    {
                        return(string.Format("../{0}/T{1:X4}.html",
                                             GetDatabasePath(target.Database),
                                             target.TopicIndex));
                    }
                }
                else
                {
                    Console.WriteLine("Warning: cannot resolve context string '{0}'", uri);
                }
            }
            break;

            case HelpUriType.LocalTopic:
                return(string.Format("T{0:X4}.html", uri.TopicIndex));

            case HelpUriType.Command:
            case HelpUriType.File:
            default:
                // TODO: would be better if we have the source location.
                Console.WriteLine("Warning: cannot convert link: {0}", uri);
                break;
            }
            return("?" + uri.ToString());
        }
コード例 #5
0
        public bool NavigateTo(HelpUri uri)
        {
            if (uri.Type == HelpUriType.Command)
            {
                if (uri.Target == "!B")
                {
                    if (history.Count >= 2)
                    {
                        history.RemoveAt(history.Count - 1);
                        ActiveTopic = history[history.Count - 1];
                        return(true);
                    }
                }
                return(false);
            }

            HelpTopic topic = system.ResolveUri(activeDatabase, uri);

            if (topic == null)
            {
                if (uri.Type == HelpUriType.GlobalContext &&
                    system.FindDatabase(uri.DatabaseName) == null)
                {
                    string fileName = FindFile(activeDatabase, uri.DatabaseName);
                    if (fileName != null)
                    {
                        LoadDatabases(fileName);
                        topic = system.ResolveUri(activeDatabase, uri);
                    }
                }
            }
            if (topic != null)
            {
                ActiveTopic = topic;
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        private static void DecodeLineHyperlink(HelpLine line, BufferReader reader)
        {
            // Read link location.
            int linkStartIndex = reader.ReadByte(); // one-base, inclusive
            int linkEndIndex   = reader.ReadByte(); // one-base, inclusive

            if (linkStartIndex == 0 || linkStartIndex > linkEndIndex)
            {
                throw new InvalidDataException("Invalid link location.");
            }
            if (linkEndIndex > line.Length)
            {
                System.Diagnostics.Debug.WriteLine(string.Format(
                                                       "WARNING: Link end {0} is past line end {1}.",
                                                       linkEndIndex, line.Length));
                linkEndIndex = line.Length;
            }
            //if (linkStartIndex

            // Read NULL-terminated context string.
            string context = reader.ReadNullTerminatedString();

            if (context == "")                        // link is WORD topic index
            {
                int numContext = reader.ReadUInt16(); // 0x8000 | topicIndex
                context = "@L" + numContext.ToString("X4");
            }

            // Add hyperlink to the line.
            HelpUri link = new HelpUri(context);

            for (int j = linkStartIndex; j <= linkEndIndex; j++)
            {
                line.Attributes[j - 1] = new TextAttribute(line.Attributes[j - 1].Style, link);
            }
        }
コード例 #7
0
        public override int GetHashCode()
        {
            int result = 17;

            unchecked
            {
                if (Id != null)
                {
                    result = (result * 31) + Id.GetHashCode();
                }

                if (Name != null)
                {
                    result = (result * 31) + Name.GetHashCode();
                }

                if (ShortDescription != null)
                {
                    result = (result * 31) + ShortDescription.GetHashCode();
                }

                if (FullDescription != null)
                {
                    result = (result * 31) + FullDescription.GetHashCode();
                }

                if (MessageFormats != null)
                {
                    // Use xor for dictionaries to be order-independent.
                    int xor_0 = 0;
                    foreach (var value_0 in MessageFormats)
                    {
                        xor_0 ^= value_0.Key.GetHashCode();
                        if (value_0.Value != null)
                        {
                            xor_0 ^= value_0.Value.GetHashCode();
                        }
                    }

                    result = (result * 31) + xor_0;
                }

                if (HelpUri != null)
                {
                    result = (result * 31) + HelpUri.GetHashCode();
                }

                if (Properties != null)
                {
                    // Use xor for dictionaries to be order-independent.
                    int xor_1 = 0;
                    foreach (var value_1 in Properties)
                    {
                        xor_1 ^= value_1.Key.GetHashCode();
                        if (value_1.Value != null)
                        {
                            xor_1 ^= value_1.Value.GetHashCode();
                        }
                    }

                    result = (result * 31) + xor_1;
                }

                if (Tags != null)
                {
                    foreach (var value_2 in Tags)
                    {
                        result = result * 31;
                        if (value_2 != null)
                        {
                            result = (result * 31) + value_2.GetHashCode();
                        }
                    }
                }
            }

            return(result);
        }
コード例 #8
0
 protected override string FormatUri(HelpTopic topic, HelpUri uri)
 {
     return("?" + Escape(uri.ToString()));
 }
コード例 #9
0
ファイル: HtmlFormatter.cs プロジェクト: zoomosis/DosHelp
 /// <summary>
 /// Formats the given help uri for the HTML href attribute.
 /// </summary>
 protected abstract string FormatUri(HelpTopic topic, HelpUri uri);
コード例 #10
0
ファイル: HtmlFormatter.cs プロジェクト: zoomosis/DosHelp
        private int FormatLineSegment(StringBuilder html, HelpTopic topic, HelpLine line, int startIndex)
        {
            HelpUri link = line.Attributes[startIndex].Link;

            if (link != null)
            {
                html.AppendFormat("<a href=\"{0}\">", FormatUri(topic, link));
            }

            Stack <TextStyle> openTags = new Stack <TextStyle>();
            int index = startIndex;

            while (index < line.Length && line.Attributes[index].Link == link)
            {
                TextAttribute oldAttrs = (index == startIndex) ?
                                         TextAttribute.Default : line.Attributes[index - 1];
                TextAttribute newAttrs       = line.Attributes[index];
                TextStyle     stylesToAdd    = newAttrs.Style & ~oldAttrs.Style;
                TextStyle     stylesToRemove = oldAttrs.Style & ~newAttrs.Style;

                while (stylesToRemove != TextStyle.None)
                {
                    TextStyle top = openTags.Pop();
                    FormatRemovedStyles(html, top);
                    if ((stylesToRemove & top) != 0)
                    {
                        stylesToRemove &= ~top;
                    }
                    else
                    {
                        stylesToAdd |= top;
                    }
                }

                if ((stylesToAdd & TextStyle.Bold) != 0)
                {
                    html.Append("<b>");
                    openTags.Push(TextStyle.Bold);
                }
                if ((stylesToAdd & TextStyle.Italic) != 0)
                {
                    html.Append("<i>");
                    openTags.Push(TextStyle.Italic);
                }
                if ((stylesToAdd & TextStyle.Underline) != 0)
                {
                    html.Append("<u>");
                    openTags.Push(TextStyle.Underline);
                }

                html.Append(Escape("" + line.Text[index]));
                index++;
            }

            while (openTags.Count > 0)
            {
                FormatRemovedStyles(html, openTags.Pop());
            }
            if (link != null)
            {
                html.Append("</a>");
            }

            return(index);
        }