/// <summary> /// This method is made Internal for testing purposes. /// </summary> internal void HighlightStartingMatch(TextBlock textBlock, string userInput, HighlightStyle styleInfo) { string text = textBlock.Text; if (!text.StartsWith(userInput, this.comparisonMode)) { return; } textBlock.Inlines.Clear(); Run firstRun = SuggestionItem.GetRunFromStyle(styleInfo); firstRun.Text = text.Substring(0, userInput.Length); textBlock.Inlines.Add(firstRun); this.highlightedRuns.Add(new KeyValuePair <Run, HighlightStyle>(firstRun, styleInfo)); int remainingLength = text.Length - userInput.Length; if (remainingLength != 0) { Run secondRun = new Run(); secondRun.Text = text.Substring(userInput.Length, remainingLength); textBlock.Inlines.Add(secondRun); } }
/// <summary> /// Draws the limit line (if it contains at least 2 positions) /// </summary> /// <param name="display">The display to draw to</param> internal void Render(ISpatialDisplay display) { if (m_Limit == null || m_Limit.Count == 0 || m_Mouse == null) { return; } // Draw dotted line from the last point on the limit line to the last known mouse position int lastIndex = m_Limit.Count - 1; IPosition last = m_Limit[lastIndex]; DottedStyle dottedLine = new DottedStyle(Color.Gray); dottedLine.Render(display, new IPosition[] { last, m_Mouse }); // If we have two or more positions, draw an additional dotted line to the start of // the limit line. if (m_Limit.Count >= 2) { dottedLine.Render(display, new IPosition[] { m_Mouse, m_Limit[0] }); } // Draw the limit line if (m_Limit.Count > 1) { dottedLine.Render(display, m_Limit.ToArray()); } // Draw any limit line selection if (m_LimSel.Count > 0) { HighlightStyle style = new HighlightStyle(); style.ShowLineEndPoints = false; new SpatialSelection(m_LimSel).Render(display, style); } }
/// <summary> /// Does any painting that this dialog does. /// </summary> /// <param name="display">The display to draw to</param> internal void Render(ISpatialDisplay display) { // Draw the original path (in pale gray) IDrawStyle gray = new DrawStyle(Color.LightGray); m_pop.Render(display, gray, true); // Draw the current path (in magenta). PathInfo p = new PathInfo(m_pop.StartPoint, m_pop.EndPoint, GetLegs()); p.Render(display); // Highlight the currently selected line. int index = distancesListBox.SelectedIndex; if (index >= 0 && index < m_FaceSections.Length) { IDrawStyle style = new HighlightStyle(); ILineGeometry geom = m_FaceSections[index]; if (geom is IClockwiseCircularArcGeometry) { style.Render(display, (IClockwiseCircularArcGeometry)geom); } else { style.Render(display, new IPosition[] { geom.Start, geom.End }); } } }
private void addKeyWord(string word, HighlightStyle color) { if (!KeyWords.ContainsKey(word)) { KeyWords.Add(word, color); } }
public FormattedText DrawDocument(DocumentBlock doc) { HighlightStyle style = null; if (doc.DocumentType == DocumentTypeEnum.Comment) { style = CommentStyle; } else if (doc.DocumentType == DocumentTypeEnum.Keyword) { style = KeywordStyle; } else { style = DefaultStyle; } return(new FormattedText( doc.Content, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(style.FontName), style.FontSize, new SolidColorBrush(style.FontColor))); }
public void loadColors() { XmlSetup tmpSetup = new XmlSetup(); tmpSetup.setFileName(this.styleFileName); tmpSetup.loadXml(); this.getSavedStyle(tmpSetup, "script_color_object", ObjectStyle); this.getSavedStyle(tmpSetup, "script_color_object_ref", ObjectStyleReferenz); this.getSavedStyle(tmpSetup, "script_color_var1", VaribalesStyle); this.getSavedStyle(tmpSetup, "script_color_var2", VarStyle); this.getSavedStyle(tmpSetup, "script_color_keyword", KeyWordStyle); this.getSavedStyle(tmpSetup, "script_color_command", CommandStyle); this.getSavedStyle(tmpSetup, "script_color_ref", ReferenzStyle); this.getSavedStyle(tmpSetup, "script_color_comment", CommentStyle); this.getSavedStyle(tmpSetup, "script_color_string", TextStyle); this.getSavedStyle(tmpSetup, "script_color_number", NumberStyle); HighlightStyle defaultStyle = new HighlightStyle(); defaultStyle.BackColor = HighlightStyle.defaultColor; defaultStyle.Font = new Font(this.defaultFontName, this.fontDefaultSize, FontStyle.Regular); this.getSavedStyle(tmpSetup, "script_color_default", defaultStyle); this.fontDefaultSize = (int)defaultStyle.Font.Size; this.defaultFontName = defaultStyle.Font.Name; HighlightStyle.defaultColor = defaultStyle.BackColor; this.RtfColors.numberStyle = this.NumberStyle; }
public void saveColors(string fileName) { XmlSetup tmpSetup = new XmlSetup(); tmpSetup.setFileName(fileName); tmpSetup.loadXml(); tmpSetup.addSetting("script_color_object", ObjectStyle.toSetupValue()); tmpSetup.addSetting("script_color_object_ref", ObjectStyleReferenz.toSetupValue()); tmpSetup.addSetting("script_color_var1", VaribalesStyle.toSetupValue()); tmpSetup.addSetting("script_color_var2", VarStyle.toSetupValue()); tmpSetup.addSetting("script_color_keyword", KeyWordStyle.toSetupValue()); tmpSetup.addSetting("script_color_command", CommandStyle.toSetupValue()); tmpSetup.addSetting("script_color_ref", ReferenzStyle.toSetupValue()); tmpSetup.addSetting("script_color_comment", CommentStyle.toSetupValue()); tmpSetup.addSetting("script_color_string", TextStyle.toSetupValue()); tmpSetup.addSetting("script_color_number", NumberStyle.toSetupValue()); HighlightStyle defaultStyle = new HighlightStyle(); defaultStyle.BackColor = HighlightStyle.defaultColor; defaultStyle.Font = new Font(this.defaultFontName, this.fontDefaultSize, FontStyle.Regular); tmpSetup.addSetting("script_color_default", defaultStyle.toSetupValue()); tmpSetup.saveXml(); }
public void CopyPresentationFrom(Scriptable item, bool noOverwriteExisting) { // see Item if (HighlightStyle == null) { HighlightStyle = new HighlightStyleC(); } HighlightStyle.CopyFrom(item.HighlightStyle); if (!noOverwriteExisting || Sound == null) { Sound = item.Sound?.Clone(); } if (!noOverwriteExisting || string.IsNullOrEmpty(OutputText)) { OutputText = item.OutputText; } OutputAsDisplay = item.OutputAsDisplay; if (!noOverwriteExisting || string.IsNullOrEmpty(SpeechText)) { SpeechText = item.SpeechText; } SpeechAsDisplay = item.SpeechAsDisplay; if (!noOverwriteExisting || string.IsNullOrEmpty(PromptText)) { PromptText = item.PromptText; } }
public override void Save(DataWriter writer) { base.Save(writer); writer.Write(Element); writer.Write(SAWID); writer.Write(Popup); writer.Write(Shown); writer.Write(AutoRepeat); writer.Write(NotVisited); if (writer.Version >= 123) { writer.Write(RepeatTimeout); } // for each script a boolean is written first to indicate if it exists (true), or is null (false) for (int i = 0; i < Scripts.Length; i++) { writer.Write(Scripts[i] != null); Scripts[i]?.Write(writer); } if (writer.Version >= 129) { HighlightStyle.Save(writer); writer.Write(Sound?.ID ?? Guid.Empty); writer.WriteBufferedString(OutputText ?? ""); writer.Write(OutputAsDisplay); writer.Write(SpeechText ?? ""); writer.Write(SpeechAsDisplay); writer.Write(PromptText ?? ""); } }
public override void Assign(RepositoryItem repositoryItem_0) { RepositoryItemTreeViewComboBoxEdit repositoryItem0 = repositoryItem_0 as RepositoryItemTreeViewComboBoxEdit; this.BeginUpdate(); try { base.Assign(repositoryItem_0); if (repositoryItem0 != null) { this.DataAccessLayerBaseClass = repositoryItem0.DataAccessLayerBaseClass; this.IDFieldName = repositoryItem0.IDFieldName; this.TableName = repositoryItem0.TableName; this.ParentIDFieldName = repositoryItem0.ParentIDFieldName; this.NameFieldName = repositoryItem0.NameFieldName; this.CodeFieldName = repositoryItem0.CodeFieldName; this.bool_0 = repositoryItem0.ShowAllItemVisible; this.highlightStyle_0 = repositoryItem0.highlightStyle_0; this.char_0 = repositoryItem0.SeparatorChar; this.bool_1 = repositoryItem0.SynchronizeEditValueWithCheckedItems; this.collectionChanged = true; this.type_0 = repositoryItem0.type_0; this.string_0 = repositoryItem0.ShowAllItemCaption; } } finally { this.EndUpdate(); } }
public HighlightStyle HighlightState(FullSubentityPath subId) { createInstance(); HighlightStyle HighlightS = BaseEntity.HighlightState(subId); tr.Dispose(); return(HighlightS); }
private void getSavedStyle(XmlSetup setup, string name, HighlightStyle toThis) { String val = setup.getValue(name); if (val != null) { toThis.getStyleFromvalueString(val); } }
/// <summary> /// This method is made Internal for testing purposes. /// </summary> internal void HighlightAllMatches(TextBlock textBlock, string userInput, HighlightStyle styleInfo) { string text = textBlock.Text; int indexOfOccurance = text.IndexOf(userInput, this.comparisonMode); if (indexOfOccurance == -1) { return; } textBlock.Inlines.Clear(); int portionStart = 0; while (indexOfOccurance != -1) { string firstTextPortion = text.Substring(portionStart, indexOfOccurance - portionStart); if (!string.IsNullOrEmpty(firstTextPortion)) { Run firstRun = new Run(); firstRun.Text = firstTextPortion; textBlock.Inlines.Add(firstRun); } Run highLightedRun = SuggestionItem.GetRunFromStyle(styleInfo); highLightedRun.Text = text.Substring(indexOfOccurance, userInput.Length); textBlock.Inlines.Add(highLightedRun); this.highlightedRuns.Add(new KeyValuePair <Run, HighlightStyle>(highLightedRun, styleInfo)); int nextOccuranceIndex = text.IndexOf(userInput, indexOfOccurance + userInput.Length, this.comparisonMode); if (nextOccuranceIndex == -1) { int lastPortionStart = indexOfOccurance + userInput.Length; string lastPortion = text.Substring(lastPortionStart, text.Length - lastPortionStart); if (!string.IsNullOrEmpty(lastPortion)) { Run lastRun = new Run(); lastRun.Text = lastPortion; textBlock.Inlines.Add(lastRun); } } else { portionStart = indexOfOccurance + userInput.Length; } indexOfOccurance = nextOccuranceIndex; } }
private Color GetColorOfAtom(IDictionary <IAtom, string> symbolRemap, IAtomColorer coloring, Color foreground, HighlightStyle style, IAtom atom, Color?highlight) { // atom is highlighted...? if (highlight != null && style == HighlightStyle.Colored) { return(highlight.Value); } // abbreviations default to foreground color if (symbolRemap.ContainsKey(atom)) { return(foreground); } // use the atom colorer return(coloring.GetAtomColor(atom)); }
public void HighlightTile(Tile t, HighlightStyle style, Color color) { SpriteRenderer renderer = t.TileHighlightObject.GetComponent <SpriteRenderer>(); if (style == HighlightStyle.None) { Debug.LogError("Tile Highlight: Should not use this style, use ClearTileHighlight(Tile) if trying to clear the highlight!"); return; } renderer.sprite = styleSprites[(int)style - 1]; renderer.color = color; highlightedTiles.Add(t); }
/// <summary> /// Highlights a line. /// </summary> /// <param name="line">The line to highlight</param> void Highlight(LineFeature line) { ISpatialDisplay display = ActiveDisplay; // Create thick pen (we want a line that is 1mm wide, corresponding // to the pick aperture). DrawStyle style = new HighlightStyle(); style.LineColor = m_LineColor; double scale = display.MapScale; float pxwid = display.LengthToDisplay(scale * 0.001); style.Pen.Width = pxwid; // Do the draw line.Render(display, style); }
public CodeView(MainForm f, string fname, HighlightStyle style) : base() { Init(); style.SetStyle(text); using (StreamReader txt = new StreamReader(fname)) { string content = txt.ReadToEnd(); if (content == "") { content = " "; // bug in scintillaNET: freaks out if you give it an empty string. :P } text.Text = content; } Text = fname; }
/// <summary> /// Do any command-specific drawing. /// </summary> /// <param name="point">The specific point (if any) that the parent window has drawn.</param> internal override void Paint(PointFeature point) { HighlightStyle style = new HighlightStyle(); if (m_Orient != null) { style.ShowLineEndPoints = false; m_Orient.Render(ActiveDisplay, style); } if (m_IsAutoPos && m_Polygon != null) { if (m_AutoPosition == null) { m_AutoPosition = m_Polygon.GetLabelPosition(Width, Height); } DrawText(m_AutoPosition); } else { base.Paint(point); } if (IsValidPolygon()) { m_Polygon.Render(ActiveDisplay, style); // If the polygon actually contains a label that is drawn on the current editing // layer, take this opportunity to draw it in gray. TextFeature label = m_Polygon.Label; if (label != null) { label.Draw(ActiveDisplay, Color.Gray); } } }
private static Run GetRunFromStyle(HighlightStyle style) { Run runToHighlight = new Run(); if (style == null) { return(runToHighlight); } if (style.ReadLocalValue(HighlightStyle.FontWeightProperty) != DependencyProperty.UnsetValue) { runToHighlight.FontWeight = FontWeightNameHelper.GetFontWeight(style.FontWeight); } if (style.ReadLocalValue(HighlightStyle.ForegroundProperty) != DependencyProperty.UnsetValue) { runToHighlight.Foreground = style.Foreground; } if (style.ReadLocalValue(HighlightStyle.FontStyleProperty) != DependencyProperty.UnsetValue) { runToHighlight.FontStyle = style.FontStyle; } if (style.ReadLocalValue(HighlightStyle.FontSizeProperty) != DependencyProperty.UnsetValue) { runToHighlight.FontSize = style.FontSize; } if (style.ReadLocalValue(HighlightStyle.FontFamilyProperty) != DependencyProperty.UnsetValue) { runToHighlight.FontFamily = style.FontFamily; } return(runToHighlight); }
public CodeView(MainForm f, HighlightStyle style) : base() { Init(); style.SetStyle(text); Text = "Untitled Script"; }
public void PushHighlight(FullSubentityPath subId, HighlightStyle highlightStyle) { createInstance(); BaseEntity.PushHighlight(subId, highlightStyle); tr.Dispose(); }
public int reDraw(Boolean reNewElements) { this.RtfColors.setMode(this.drawMode); try { if (this.assignedRtf.Text.Length < 1) { return(0); } } catch (Exception ex) { return(0); } Stopwatch watch = new Stopwatch(); watch.Start(); this.drawingRtf.Rtf = this.assignedRtf.Rtf; this.drawingRtf.highlighting = true; int startpos = this.assignedRtf.SelectionStart; int endPos = this.assignedRtf.SelectionLength; int start = this.assignedRtf.GetCharIndexFromPosition(new Point(0, 0)); int end = this.assignedRtf.GetCharIndexFromPosition(new Point(this.assignedRtf.ClientSize.Width, this.assignedRtf.ClientSize.Height)); this.RtfColors.reAssign(this.drawingRtf); this.RtfColors.startLine = this.startLine; this.RtfColors.startPosition = this.startPos; if (reNewElements == true || this.elementsReaded == false) { if (this.markLine < 0) { this.getElements(); } } if (this.markLine < 0) { this.drawingRtf.Select(this.startPos, this.drawingRtf.TextLength); this.drawingRtf.SelectionColor = drawingRtf.ForeColor; this.drawingRtf.SelectionBackColor = HighlightStyle.defaultColor; foreach (DictionaryEntry de in this.KeyWords) { string word = de.Key.ToString(); HighlightStyle setColor = (HighlightStyle)de.Value; this.RtfColors.markWordsAll(word, setColor); } // must be at the end foreach (String keyWord in Projector.Script.RefScriptMaskMatch.KeyWords) { this.RtfColors.markTextLine(keyWord, KeyWordStyle); } //if (this.drawMode == RtfColoring.MODE_DIRECT) { }; string[] variables = new String[this.Srcipt.getAllStrings().Count]; int it = 0; foreach (DictionaryEntry de in this.Srcipt.getAllStrings()) { string word = de.Value.ToString(); string keyWord = de.Key.ToString(); if (this.drawMode == RtfColoring.MODE_DIRECT) { this.RtfColors.markTextLine("\"" + word + "\"", TextStyle); } //this.RtfColors.markTextLine(keyWord, VaribalesStyle); variables[it] = keyWord; it++; } watch.Stop(); this.preRuntime = watch.ElapsedMilliseconds.ToString(); this.runtimeValue = watch.ElapsedMilliseconds; watch.Restart(); this.RtfColors.markWordsAll(variables, VaribalesStyle); this.RtfColors.wordMode(); // full lines works in booth modes as the same foreach (int lino in this.Srcipt.getCommentLines()) { this.RtfColors.markFullLine(lino, CommentStyle); } foreach (ScriptErrors err in this.Srcipt.getAllErrors()) { if (err.wordPosition < 1) { this.RtfColors.markFullLine(err.lineNumber, ErrorStyle, true, false, err.errorMessage + " @" + err.lineNumber); } else { this.RtfColors.markFullLine(err.lineNumber, InProgressStyle, true, false, err.errorMessage + " @" + err.lineNumber, err.wordPosition); } } } // marks an line if (this.markLine > -1) { if (multiMarkLine) { if (!this.LastExecutedLines.ContainsKey(markLine)) { this.LastExecutedLines.Add(markLine, 10); } else { this.LastExecutedLines[markLine] = 10; } Hashtable copyThat = new Hashtable(); foreach (DictionaryEntry lastExecs in this.LastExecutedLines) { int execCount = (int)lastExecs.Value; execCount--; if (execCount > 0) { copyThat.Add(lastExecs.Key, execCount); if (execCount > 8) { this.RtfColors.markFullLine((int)lastExecs.Key, executionStyle, true, false); } else { HighlightStyle hStyle = new HighlightStyle(); hStyle.ForeColor = execColors[(int)lastExecs.Value]; this.RtfColors.markFullLine((int)lastExecs.Key, hStyle, true, false); } } } LastExecutedLines = copyThat; } else { this.RtfColors.markFullLine(markLine, executionStyle, true, false); } if (assignedRtf is RichBox) { RichBox rbt = (RichBox)assignedRtf; if (!rbt.selectionIsVisible()) { this.assignedRtf.ScrollToCaret(); } } else { this.assignedRtf.ScrollToCaret(); } } watch.Stop(); this.runtime = watch.ElapsedMilliseconds.ToString(); watch.Restart(); // ------------ end drawing ---------------- this.drawingRtf.highlighting = false; this.assignedRtf.Rtf = this.drawingRtf.Rtf; if (assignedRtf is RichBox) { RichBox rbt = (RichBox)assignedRtf; rbt.LineMarker = drawingRtf.LineMarker; } // try to scroll last visible position if (this.markLine < 0) { this.assignedRtf.SelectionLength = 0; this.assignedRtf.SelectionStart = end; if (this.updateScrols) { this.assignedRtf.ScrollToCaret(); } this.assignedRtf.SelectionStart = start + this.assignedRtf.Lines[this.assignedRtf.GetLineFromCharIndex(start)].Length + 1; if (this.updateScrols) { this.assignedRtf.ScrollToCaret(); } this.assignedRtf.SelectionStart = startpos; this.assignedRtf.SelectionLength = endPos; } else { int index = this.assignedRtf.GetFirstCharIndexFromLine(this.markLine); if (index > -1) { this.assignedRtf.SelectionStart = index; this.assignedRtf.SelectionLength = 1; if (this.updateScrols) { this.assignedRtf.ScrollToCaret(); } } } watch.Stop(); this.postRuntime = watch.ElapsedMilliseconds.ToString(); return(1); }
public void PushHighlight(FullSubentityPath subId, HighlightStyle highlightStyle) { createInstance(); BaseEntity.PushHighlight(subId,highlightStyle); tr.Dispose(); }