/// <summary> /// Initialize control with help text. /// </summary> private void _InitQuickHelpText() { HelpTopic topic = ((PageBase)this._Page).HelpTopic; if (null != topic) { QuickHelpText.Inlines.Clear(); List <Inline> inlines = new List <Inline>(); if (!string.IsNullOrEmpty(topic.QuickHelpText)) { QuickHelpText.Inlines.Add(topic.QuickHelpText.Trim()); } if (!string.IsNullOrEmpty(topic.Key) || !string.IsNullOrEmpty(topic.Path)) { if (!string.IsNullOrEmpty(topic.QuickHelpText)) { QuickHelpText.Inlines.Add(" "); } Hyperlink helpLink = new Hyperlink(new Run((string)App.Current.FindResource("QuickHelpLinkCaption"))); _command = new HelpLinkCommand(topic.Path, topic.Key); helpLink.Command = _command; QuickHelpText.Inlines.Add(helpLink); } } }
public MyCustomPage() { _helpTopic = new HelpTopic(null, "This is the custom QuickHelp for My Custom Page"); IsAllowed = true; IsRequired = true; InitializeComponent(); }
public List <HelpTopic> LoadTopics() { var helpTopics = new List <HelpTopic>(); var topic1 = new HelpTopic { Id = 1, Text = (MarkupString)"This is Topic 1" }; helpTopics.Add(topic1); var topic2 = new HelpTopic { Id = 2, Text = (MarkupString)"This is Topic 2" }; helpTopics.Add(topic2); var topic3 = new HelpTopic { Id = 3, Text = (MarkupString)"This is Topic 3" }; helpTopics.Add(topic3); return(helpTopics); }
private void ReadHelpFile() { if (_directory == null) { return; } string projectPath = Path.Combine(_directory, ProjectInfoDirectory); _topics.Clear(); _urlMap.Clear(); _ctxIdMap.Clear(); if (Directory.Exists(projectPath)) { string toc = Path.Combine(projectPath, TocFile); string topics = Path.Combine(projectPath, TopicsFile); XmlDocument doc = new XmlDocument(); doc.Load(toc); _topics = new HelpTopicList(); for (int i = 0; i < doc.DocumentElement.ChildNodes.Count; i++) { if (doc.DocumentElement.ChildNodes[i] is XmlElement) { XmlElement item = (XmlElement)doc.DocumentElement.ChildNodes[i]; HelpTopic helpTopic = ParseTopic(item); _topics.Add(helpTopic); ParseToc(helpTopic, item); } } doc.Load(topics); ParseTopics(doc); } }
private void ParseTopics(XmlDocument doc) { XmlElement root = doc.DocumentElement; for (int i = 0; i < root.ChildNodes.Count; i++) { XmlElement topic = root.ChildNodes[i] as XmlElement; if (topic != null) { string url = GetUrl(topic); if (!string.IsNullOrEmpty(url)) { if (!_urlMap.ContainsKey(url)) { _urlMap[url] = new HelpTopic(GetTitle(topic), url); } HelpTopic helpTopic = _urlMap[url]; XmlElement contextIds = topic[ContextIdsElement]; if (contextIds != null) { int ctxId = ParseContextIds(contextIds, helpTopic); if (ctxId != -1) { helpTopic.SetCtxtId(ctxId); } } } } } }
/// <summary> /// Formats the given help topic as HTML and returns the HTML source. /// </summary> public string FormatTopic(HelpTopic topic) { if (topic == null) { throw new ArgumentNullException(nameof(topic)); } StringBuilder html = new StringBuilder(); html.AppendLine("<html>"); html.AppendLine(" <head>"); html.AppendLine(string.Format(" <title>{0}</title>", Escape(topic.Title))); html.AppendLine(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"); html.Append(GetStyleSheet()); html.AppendLine(" </head>"); html.AppendLine(" <body>"); html.Append(" <pre class=\"help-content\">"); for (int i = 0; i < topic.Lines.Count; i++) { FormatLine(html, topic, topic.Lines[i]); if (i < topic.Lines.Count - 1) { html.AppendLine(); } } html.AppendLine("</pre>"); html.AppendLine(" </body>"); html.AppendLine("</html>"); return(html.ToString()); }
public void Update(HelpTopic entity) { DataCommand cmd = DataCommandManager.GetDataCommand("HelpCenter_Update"); cmd.SetParameterValue(entity); cmd.ExecuteNonQuery(); }
public ActionResult Create(string appName, string subject) { var helpTopic = new HelpTopic(); helpTopic.AppFilter = appName; var viewModel = HelpTopicViewModel.Create(HelpTopicRepository, ApplicationRepository, CurrentUser, appName, subject); viewModel.HelpTopic = helpTopic; return View(viewModel); }
public static ServerMessage Compose(HelpTopic Topic) { ServerMessage Message = new ServerMessage(OpcodesOut.HELP_TOPIC); Message.AppendUInt32(Topic.Id); Message.AppendStringWithBreak(Topic.Body); return(Message); }
private void OnActiveTopicChanged(object sender, EventArgs e) { HelpTopic topic = viewModel.ActiveTopic; if (topic == null) { return; } // ---- lstTopics ---- foreach (HelpTopicViewItem item in lstTopics.Items) { if (item.Topic == topic) { lstTopics.SelectedItem = item; break; } } // ---- Right-hand side panel ---- HtmlFormatter formatter = new EmbeddedHtmlFormatter(); formatter.FixLinks = true; string html = formatter.FormatTopic(topic); string text = TextFormatter.FormatTopic(topic); txtNoFormat.Text = text; webBrowser1.DocumentText = html; txtTopicTitle.Text = HelpTopicViewItem.GetTopicDisplayTitle(topic); if (topic.Source is string) { txtSource.Text = (string)topic.Source; } else if (topic.Source is byte[]) { txtSource.Text = FormatHexData((byte[])topic.Source); } else { txtSource.Text = ""; } // Special handling for commands. if (topic.IsHidden && !string.IsNullOrEmpty(topic.ExecuteCommand)) { if (topic.ExecuteCommand[0] == 'P') { // TODO: parse mark string redirectTarget = topic.ExecuteCommand.Substring(2); if (MessageBox.Show(this, "Redirect to " + redirectTarget + "?", "Redirect", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { viewModel.NavigateTo(new HelpUri(redirectTarget)); } } } }
public SendRoutesPage() { _helpTopic = new HelpTopic(null, Properties.Resources.SendRoutesPageQuickHelp); InitializeComponent(); IsRequired = true; IsAllowed = true; this.Loaded += new RoutedEventHandler(SendRoutesPage_Loaded); }
public void parse(GameClient Session, ClientMessage Event) { uint uint_ = Event.PopWiredUInt(); HelpTopic @class = PhoenixEnvironment.GetGame().GetHelpTool().GetTopic(uint_); if (@class != null) { Session.SendMessage(PhoenixEnvironment.GetGame().GetHelpTool().SerializeTopic(@class)); } }
public void Handle(GameClient Session, ClientMessage Event) { uint uint_ = Event.PopWiredUInt(); HelpTopic @class = GoldTree.GetGame().GetHelpTool().method_4(uint_); if (@class != null) { Session.SendMessage(GoldTree.GetGame().GetHelpTool().method_9(@class)); } }
/// <summary> /// Formats a help line as HTML and returns the HTML source. /// </summary> /// <remarks> /// This method produces properly structured HTML. That is, it avoids /// markup such as /// /// ...<b>...<i>...</b>...</i>... /// /// The generated HTML is not the most compact possible, but is quite /// compact in practice. /// /// For a formal discussion about unpaired tags, see /// http://www.w3.org/html/wg/drafts/html/master/syntax.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser /// </remarks> private void FormatLine(StringBuilder html, HelpTopic topic, HelpLine line) { if (this.FixLinks) { line = FixLine(line); } for (int index = 0; index < line.Length;) { index = FormatLineSegment(html, topic, line, index); } }
private void OnSetTopic(HelpTopic helpTopic) { try { _dispatcher.BeginInvoke(() => this.SetValue(HelpProvider.HelpTopicProperty, helpTopic)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public static void ShowHelp(Control parent, HelpTopic topic) { string topicText = GetTopic(topic); if (topicText == null) { Logger.Warn("There is no help topic for {0}", topic); return; } ShowHelp(parent, topicText + ".html"); }
private void ParseToc(HelpTopic helpTopic, XmlElement item) { for (int i = 0; i < item.ChildNodes.Count; i++) { if (item.ChildNodes[i].NodeType == XmlNodeType.Element) { XmlElement topic = (XmlElement)item.ChildNodes[i]; HelpTopic sub = ParseTopic(topic); helpTopic.SubTopics.Add(sub); ParseToc(sub, topic); } } }
public void DumpHierarchy() { HelpTopic root = system.ResolveUri(null, new HelpUri("h.contents")); if (root == null) { return; } //TopicHierarchy tree = new TopicHierarchy(); //tree.Build(system, root); //tree.Dump(); }
private void lstErrors_SelectedIndexChanged(object sender, EventArgs e) { HelpTopicErrorViewItem item = lstErrors.SelectedItem as HelpTopicErrorViewItem; if (item == null) { return; } HelpTopic topic = item.Topic; viewModel.ActiveTopic = topic; }
internal void ViewHelpTopic() { uint TopicId = Request.PopWiredUInt(); HelpTopic Topic = ButterflyEnvironment.GetGame().GetHelpTool().GetTopic(TopicId); if (Topic == null) { return; } Session.SendMessage(HelpTool.SerializeTopic(Topic)); }
private void button1_Click(object sender, RoutedEventArgs e) { var comment = new HelpTopic() { HelpTopicCommnet = textBox1.Text, HelpTopicTypeID = Mediator.Instance.ActivePageType, DateAdded = DateTime.Now , UserName = WebContext.Current.User.DisplayName ?? WebContext.Current.User.Name }; DataAccesLayerService.AddHelpTopic(comment); DataAccesLayerService.SaveChanges(exception => { DataAccesLayerService.GetCommentsForPageType(Mediator.Instance.ActivePageType, LoadHelpTopics); }); }
public int Select(string message,colorstring top_border,colorstring bottom_border,List<colorstring> strings,bool no_ask,bool no_cancel,bool easy_cancel,bool help_key,HelpTopic help_topic) { return Select(message,top_border,bottom_border,strings,no_ask,no_cancel,easy_cancel,false,help_key,help_topic); }
private static int TopicAddedDateComparer(HelpTopic x, HelpTopic y) { if(x.DateAdded>y.DateAdded)return -1; if (x.DateAdded < y.DateAdded) return 1; return 0; }
public ActionResult Edit(int id, HelpTopic helpTopic, string appName, string passedSubject) { var topic = HelpTopicRepository.GetNullableById(id); if (topic == null) { Message = "Help Topic not found"; return this.RedirectToAction(a => a.Index(appName, passedSubject)); } topic = Copiers.HelpTopic(topic, helpTopic); topic.TransferValidationMessagesTo(ModelState); if (ModelState.IsValid) { HelpTopicRepository.EnsurePersistent(topic); Message = "Help Topic saved"; return this.RedirectToAction(a => a.Index(appName, passedSubject)); } var viewModel = HelpTopicViewModel.Create(HelpTopicRepository, ApplicationRepository, CurrentUser, appName, passedSubject); viewModel.HelpTopic = topic; return View(viewModel); }
/// <summary> /// Determines whether [is user authorized] [the specified help topic]. /// </summary> /// <param name="helpTopic">The help topic.</param> /// <param name="currentUser">The current user.</param> /// <param name="appName">Name of the app.</param> /// <returns> /// <c>true</c> if [is user authorized] [the specified help topic]; otherwise, <c>false</c>. /// </returns> private static bool IsUserAuthorized(HelpTopic helpTopic, IPrincipal currentUser, string appName) { var isUserAuthorized = currentUser.IsInRole(RoleNames.Admin) || currentUser.IsInRole(RoleNames.User); var isUserAdmin = currentUser.IsInRole(RoleNames.Admin); if (isUserAdmin) { return true; } else if (isUserAuthorized) { if (string.IsNullOrEmpty(appName)) { return helpTopic.IsActive && (string.IsNullOrEmpty(helpTopic.AppFilter) || helpTopic.AppFilter == StaticValues.STR_HelpRequest); } else { return helpTopic.IsActive && (string.IsNullOrEmpty(helpTopic.AppFilter) || helpTopic.AppFilter == appName); } } else { if (string.IsNullOrEmpty(appName)) { return helpTopic.AvailableToPublic && helpTopic.IsActive && (string.IsNullOrEmpty(helpTopic.AppFilter) || helpTopic.AppFilter == StaticValues.STR_HelpRequest); } else { return helpTopic.AvailableToPublic && helpTopic.IsActive && (string.IsNullOrEmpty(helpTopic.AppFilter) || helpTopic.AppFilter == appName); } } }
public int Select(string message,colorstring top_border,colorstring bottom_border,List<colorstring> strings,bool no_ask,bool no_cancel,bool easy_cancel,bool never_redraw_map,bool help_key,HelpTopic help_topic) { if(!no_ask){ MouseUI.PushButtonMap(); } MouseUI.AutomaticButtonsFromStrings = true; int result = -2; while(result == -2){ Screen.WriteMapString(0,0,top_border); char letter = 'a'; int i=1; foreach(colorstring s in strings){ Screen.WriteMapString(i,0,new colorstring("[",Color.Gray,letter.ToString(),Color.Cyan,"] ",Color.Gray)); Screen.WriteMapString(i,4,s); if(s.Length() < COLS-4){ Screen.WriteMapString(i,s.Length()+4,"".PadRight(COLS - (s.Length()+4))); } letter++; i++; } Screen.WriteMapString(i,0,bottom_border); if(i < ROWS-1){ Screen.WriteMapString(i+1,0,"".PadRight(COLS)); } if(no_ask){ B.DisplayNow(message); if(!no_ask){ MouseUI.PopButtonMap(); } MouseUI.AutomaticButtonsFromStrings = false; return -1; } else{ result = GetSelection(message,strings.Count,no_cancel,easy_cancel,help_key); if(result == -2){ MouseUI.AutomaticButtonsFromStrings = false; Help.DisplayHelp(help_topic); MouseUI.AutomaticButtonsFromStrings = true; } else{ if(!never_redraw_map && result != -1){ M.Redraw(); } if(!no_ask){ MouseUI.PopButtonMap(); } MouseUI.AutomaticButtonsFromStrings = false; return result; } } } if(!no_ask){ MouseUI.PopButtonMap(); } MouseUI.AutomaticButtonsFromStrings = false; return -1; }
public async Task<int> Select(string message, colorstring top_border, colorstring bottom_border, List<colorstring> strings, bool no_ask, bool no_cancel, bool easy_cancel, bool help_key, HelpTopic help_topic) { int result = -2; while (result == -2) { Screen.WriteMapString(0, 0, top_border); char letter = 'a'; int i = 1; foreach (colorstring s in strings) { Screen.WriteMapString(i, 0, new colorstring("[", Color.Gray, (string)letter, Color.Cyan, "] ", Color.Gray)); Screen.WriteMapString(i, 4, s); letter++; i++; } Screen.WriteMapString(i, 0, bottom_border); if (i < ROWS - 1) { Screen.WriteMapString(i + 1, 0, "".PadRight(COLS)); } if (no_ask) { B.DisplayNow(message); return -1; } else { result = await GetSelection(message, strings.Count, no_cancel, easy_cancel, help_key); if (result == -2) { await Help.DisplayHelp(help_topic); } else { M.RedrawWithStrings(); return result; } } } return -1; }
static void AddTypeToTopics(String name, String standardKind, Object type, List<HelpTopic> topics) { var entry = new HelpEntry { Name = name, Instance = type }; var kind = standardKind; var decl = type.GetType().GetCustomAttributes(typeof(KindAttribute), false); if (decl.Length > 0) { kind = (decl[0] as KindAttribute).Kind; } foreach (var topic in topics) { if (topic.Kind.Equals(kind)) { entry.Topic = topic; topic.Add(entry); return; } } var ht = new HelpTopic(kind); entry.Topic = ht; ht.Add(entry); topics.Add(ht); }
public static async Task DisplayHelp(HelpTopic h){ Game.Console.CursorVisible = false; Screen.Blank(); int num_topics = GetHelpTopics().Length; Screen.WriteString(5,4,"Topics:",Color.Yellow); for(int i=0;i<num_topics+1;++i){ Screen.WriteString(i+7,0,"[ ]"); Screen.WriteChar(i+7,1,(char)(i+'a'),Color.Cyan); } Screen.WriteString(num_topics+7,4,"Quit"); Screen.WriteString(0,16,"".PadRight(61,'-')); Screen.WriteString(23,16,"".PadRight(61,'-')); List<string> text = HelpText(h); int startline = 0; ConsoleKeyInfo command; string ch; for(bool done=false;!done;){ foreach (HelpTopic help in GetHelpTopics()) { if(h == help){ Screen.WriteString(7+(int)help,4,Enum.ToString(typeof(HelpTopic),help),Color.Yellow); } else{ Screen.WriteString(7 + (int)help, 4, Enum.ToString(typeof(HelpTopic), help)); } } if(startline > 0){ Screen.WriteString(0,77,new colorstring("[",Color.Yellow,"-",Color.Cyan,"]",Color.Yellow)); } else{ Screen.WriteString(0,77,"---"); } bool more = false; if(startline + 22 < text.Count){ more = true; } if(more){ Screen.WriteString(23,77,new colorstring("[",Color.Yellow,"+",Color.Cyan,"]",Color.Yellow)); } else{ Screen.WriteString(23,77,"---"); } for(int i=1;i<=22;++i){ if(text.Count - startline < i){ Screen.WriteString(i,16,"".PadRight(64)); } else{ Screen.WriteString(i,16,text[i+startline-1].PadRight(64)); } } command = await Game.Console.ReadKey(true); int ck = command.Key; if(ck == ConsoleKey.Backspace || ck == ConsoleKey.PageUp){ ch = string.FromCharCode((char)8); } else{ if(ck == ConsoleKey.PageDown){ ch = " "; } else{ ch = Actor.ConvertInput(command); } } switch(ch){ case "a": if(h != HelpTopic.Overview){ h = HelpTopic.Overview; text = HelpText(h); startline = 0; } break; case "b": if(h != HelpTopic.Skills){ h = HelpTopic.Skills; text = HelpText(h); startline = 0; } break; case "c": if(h != HelpTopic.Feats){ h = HelpTopic.Feats; text = HelpText(h); startline = 0; } break; case "d": if(h != HelpTopic.Spells){ h = HelpTopic.Spells; text = HelpText(h); startline = 0; } break; case "e": if(h != HelpTopic.Items){ h = HelpTopic.Items; text = HelpText(h); startline = 0; } break; case "f": if(h != HelpTopic.Commands){ h = HelpTopic.Commands; text = HelpText(h); startline = 0; } break; case "g": if(h != HelpTopic.Advanced){ h = HelpTopic.Advanced; text = HelpText(h); startline = 0; } break; case "h": if(h != HelpTopic.Tips){ h = HelpTopic.Tips; text = HelpText(h); startline = 0; } break; case "i": case "\u001B": done = true; break; case "8": case "-": case "_": if(startline > 0){ --startline; } break; case "2": case "+": case "=": if(more){ ++startline; } break; case "\u0008": if(startline > 0){ startline -= 22; if(startline < 0){ startline = 0; } } break; case " ": case "\u000D": if(text.Count > 22){ startline += 22; if(startline + 22 > text.Count){ startline = text.Count - 22; } } break; default: break; } } Screen.Blank(); }
public static List<string> HelpText(HelpTopic h){ string path = ""; int startline = 0; int num_lines = -1; //-1 means read until end switch(h){ case HelpTopic.Overview: path = "help.txt"; num_lines = 54; break; case HelpTopic.Commands: path = "help.txt"; /*if(Option(OptionType.VI_KEYS)){ startline = 85; } else{*/ startline = 56; //} num_lines = 26; break; case HelpTopic.Items: path = "item_help.txt"; break; case HelpTopic.Skills: path = "feat_help.txt"; num_lines = 19; break; case HelpTopic.Feats: path = "feat_help.txt"; startline = 21; break; case HelpTopic.Spells: path = "spell_help.txt"; break; case HelpTopic.Advanced: path = "advanced_help.txt"; break; default: path = "feat_help.txt"; break; } List<string> result = new List<string>(); if(h == HelpTopic.Tips){ //these aren't read from a file result.Add("Viewing all tutorial tips:"); result.Add(""); result.Add(""); result.Add(""); foreach(TutorialTopic topic in GetTutorialTopics()){ foreach(string s in TutorialText(topic)){ result.Add(s); } result.Add(""); result.Add(""); result.Add(""); } return result; } if(path != ""){ /* StreamReader file = new StreamReader(path); for(int i=0;i<startline;++i){ file.ReadLine(); } for(int i=0;i<num_lines || num_lines == -1;++i){ if(file.Peek() != -1){ result.Add(file.ReadLine()); } else{ break; } } file.Close();*/ } return result; }