public void SetSequence(TextSequence sequence) { IndexPieces = 0; Sequence = sequence; foreach (TextPiece piece in sequence.Sequence) { foreach (TextButton btn in piece.Buttons) { btn.SetDialog(DialogSystem); } } }
/// <summary> /// Creates the text sequence. /// </summary> /// <param name="document">The document.</param> /// <param name="node">The node.</param> /// <returns></returns> public TextSequence CreateTextSequence(IDocument document, XElement node) { try { TextSequence textSequence = new TextSequence(document, node); return(textSequence); } catch (Exception ex) { throw new AODLException("Exception while trying to create a TextSequence.", ex); } }
private static CrawlContext GetCrawlContext(string sequenceType, string start, long max, int pause) { ISequence<string> sequence; QueryType queryType; if (sequenceType.Equals("NN")) { var innerSequence = new NaturalNumberSequence(); innerSequence.Seek(long.Parse(start)); sequence = new TextSequence<long>(innerSequence); queryType = QueryType.IdCardNumber; } else if (sequenceType.Equals("N")) { sequence = new NameSequence(); sequence.Seek(start); queryType = QueryType.Name; } else if (sequenceType.Equals("RICN")) { sequence = new RandomIdCardNumberSequence(); queryType = QueryType.IdCardNumber; } else if (sequenceType.Equals("RN1")) { sequence = new RandomNameSequence(1); queryType = QueryType.Name; } else if (sequenceType.Equals("RN2")) { sequence = new RandomNameSequence(2); queryType = QueryType.Name; } else { throw new ArgumentException("Invalid sequence type: " + sequenceType); } sequence.Initialize(); return new CrawlContext { Sequence = sequence, SequenceType = sequenceType, MaximumTry = max, QueryType = queryType, Pause = pause, }; }
public void TestCrawler() { var innerSequence = new NaturalNumberSequence(); innerSequence.Seek(9); var sequence = new TextSequence <long>(innerSequence); var crawler = new Crawler(sequence); crawler.AfterCrawl += (sender, e) => { var progress = e.Progress; Console.WriteLine( "[{0}/{1} keyword={2}] {3}", progress.Current, progress.Total, progress.CurrentKeyword, progress.Message); }; crawler.Crawl(3, QueryType.IdCardNumber); }
/// <summary> /// Creates the text sequence. /// </summary> /// <param name="document">The document.</param> /// <param name="node">The node.</param> /// <returns></returns> public TextSequence CreateTextSequence(IDocument document, XmlNode node) { try { TextSequence textSequence = new TextSequence(document, node); return(textSequence); } catch (Exception ex) { AODLException exception = new AODLException("Exception while trying to create a TextSequence."); exception.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); exception.Node = node; exception.OriginalException = ex; throw exception; } }
/// <summary> /// Builds the illustration frame. /// </summary> /// <param name="document">The document.</param> /// <param name="frameStyleName">Name of the frame style.</param> /// <param name="graphicName">Name of the graphic.</param> /// <param name="pathToGraphic">The path to graphic.</param> /// <param name="illustrationText">The illustration text.</param> /// <param name="illustrationNumber">The illustration number.</param> /// <returns> /// A new Frame object containing a DrawTextBox which contains the /// illustration Graphic object and a text sequence representing /// the displayed illustration text. /// </returns> public static Frame BuildIllustrationFrame(IDocument document, string frameStyleName, string graphicName, string pathToGraphic, string illustrationText, int illustrationNumber) { DrawTextBox drawTextBox = new DrawTextBox(document); Frame frameTextBox = new Frame(document, frameStyleName); frameTextBox.DrawName = frameStyleName + "_" + graphicName; frameTextBox.ZIndex = "0"; Paragraph pIllustration = ParagraphBuilder.CreateStandardTextParagraph(document); pIllustration.StyleName = "Illustration"; Frame frame = new Frame(document, "InnerFrame_" + frameStyleName, graphicName, pathToGraphic); frame.ZIndex = "1"; pIllustration.Content.Add(frame); //add Illustration as text pIllustration.TextContent.Add(new SimpleText(document, "Illustration")); //add TextSequence TextSequence textSequence = new TextSequence(document); textSequence.Name = "Illustration"; textSequence.NumFormat = "1"; textSequence.RefName = "refIllustration" + illustrationNumber.ToString(); textSequence.Formula = "ooow:Illustration+1"; textSequence.TextContent.Add(new SimpleText(document, illustrationNumber.ToString())); pIllustration.TextContent.Add(textSequence); //add the ilustration text pIllustration.TextContent.Add(new SimpleText(document, illustrationText)); //add the Paragraph to the DrawTextBox drawTextBox.Content.Add(pIllustration); frameTextBox.SvgWidth = frame.SvgWidth; drawTextBox.MinWidth = frame.SvgWidth; drawTextBox.MinHeight = frame.SvgHeight; frameTextBox.Content.Add(drawTextBox); return(frameTextBox); }
internal static void FormatTextBlock(TextSequence sequence, ref TextBlock textBlock) { bool isBold = false, isItalic = false; foreach (var seq in sequence.Instructions) { switch (seq.Command) { case Command.TextStyle: var styleCmd = (StyleCommand)seq; switch (styleCmd.TextStyle) { case TextStyle.Bold: isBold = !isBold; break; case TextStyle.Italic: isItalic = !isItalic; break; } break; case Command.Text: var textCmd = (TextCommand)seq; var run = new Run(textCmd.Text); if (isBold) { run.FontWeight = FontWeights.Bold; } if (isItalic) { run.FontStyle = FontStyles.Italic; } textBlock.Inlines.Add(run); break; } } }
public static TextSequence[] CreateTextSequences(PeptideDocNode nodePep, SrmSettings settings, string label, IDeviceContext g, ModFontHolder fonts) { // Store text and font information for all label types bool heavyMods = false; var listTypeSequences = new List <TextSequence> { CreateTypeTextSequence(nodePep, settings, IsotopeLabelType.light, fonts) }; foreach (var labelType in settings.PeptideSettings.Modifications.GetHeavyModificationTypes()) { // Only color for the label types actually measured in this peptide if (!nodePep.HasChildType(labelType)) { continue; } var textSequence = CreateTypeTextSequence(nodePep, settings, labelType, fonts); listTypeSequences.Add(textSequence); heavyMods = (heavyMods || textSequence != null); } // Calculate text sequence values for the peptide display string var listTextSequences = new List <TextSequence>(); if (nodePep.Peptide.IsCustomMolecule) { listTextSequences.Add(CreatePlainTextSequence(label, fonts)); } // If no modifications, use a single plain text sequence else if (!heavyMods && !listTypeSequences[0].Text.Contains(@"[")) // For identifying modifications { listTextSequences.Add(CreatePlainTextSequence(label, fonts)); } else { var peptideFormatter = PeptideFormatter.MakePeptideFormatter(settings, nodePep, fonts); peptideFormatter.DisplayModificationOption = DisplayModificationOption.Current; peptideFormatter.DeviceContext = g; string pepSequence = peptideFormatter.UnmodifiedSequence; int startPep = label.IndexOf(pepSequence, StringComparison.Ordinal); int endPep = startPep + pepSequence.Length; IEnumerable <TextSequence> rawTextSequences = new TextSequence[0]; // Add prefix plain-text if necessary if (startPep > 0) { string prefix = label.Substring(0, startPep); rawTextSequences = rawTextSequences.Append(CreatePlainTextSequence(prefix, fonts)); } rawTextSequences = rawTextSequences.Concat(Enumerable.Range(0, pepSequence.Length).Select(aaIndex => peptideFormatter.GetTextSequenceAtAaIndex(aaIndex))); if (endPep < label.Length) { string suffix = label.Substring(endPep); rawTextSequences = rawTextSequences.Append(CreatePlainTextSequence(suffix, fonts)); } listTextSequences.AddRange(TextSequence.Coalesce(rawTextSequences)); } if (g != null) { // Calculate placement for each text sequence int textRectWidth = 0; foreach (var textSequence in listTextSequences) { Size sizeMax = new Size(int.MaxValue, int.MaxValue); textSequence.Position = textRectWidth; textSequence.Width = TextRenderer.MeasureText(g, textSequence.Text, textSequence.Font, sizeMax, FORMAT_TEXT_SEQUENCE). Width; textRectWidth += textSequence.Width; } } return(listTextSequences.ToArray()); }
/// <summary> /// Returns a <see cref="TextSequence" /> object with variable substitutions performed. /// </summary> /// <param name="textSequence">A <see cref="TextSequence" /> object to perform substitutions on.</param> /// <param name="storyData">The <see cref="Data" /> object associated with the active story.</param> /// <returns>A <see cref="TextSequence" /> with variable substitutions performed.</returns> protected TextSequence DisplayText(TextSequence textSequence, Data storyData) { var newSequence = new TextSequence(); foreach (var instruction in textSequence.Instructions) { switch (instruction.Command) { case Command.TextStyle: case Command.Text: newSequence.Instructions.Add(instruction); break; case Command.Substitution: var substitution = (SubstitutionCommand)instruction; var newInstruction = new TextCommand(); var value = storyData.GetVariable(substitution.Variable); // Handle flag settings. switch (substitution.Flag) { case FlagProperty.TrueFalse: newInstruction.Text = value != 0 ? "true" : "false"; break; case FlagProperty.YesNo: newInstruction.Text = value != 0 ? "yes" : "no"; break; case FlagProperty.OneZero: newInstruction.Text = value; break; default: throw new ArgumentOutOfRangeException(); } // Handle transformation (if applicable). if (newInstruction.Text.Length > 0) { switch (substitution.Caps) { case CapsProperty.First: newInstruction.Text = newInstruction.Text.First().ToString().ToUpper() + newInstruction.Text.Substring(1); break; case CapsProperty.Lower: newInstruction.Text = newInstruction.Text.ToLower(); break; case CapsProperty.Upper: newInstruction.Text = newInstruction.Text.ToUpper(); break; } } newSequence.Instructions.Add(newInstruction); break; } } return(newSequence); }
protected PageObject() { Style = DefaultStyle; FormattedText = new TextSequence(); }