public void MyClickHandler(object sender, EventArgs e) { CharacterProperties charProps = richEditControl.Document.BeginUpdateCharacters(richEditControl.Document.Selection); charProps.BackColor = System.Drawing.Color.Yellow; richEditControl.Document.EndUpdateCharacters(charProps); }
public static void SetTextWatermark(RichEditControl richEditControl, string text) { Section section = richEditControl.Document.Sections[0]; SubDocument subDocument = section.BeginUpdateHeader(); subDocument.Delete(subDocument.Range); Shape shape = subDocument.Shapes.InsertTextBox(subDocument.Range.Start); shape.ShapeFormat.TextBox.Document.AppendText(text); CharacterProperties cp = shape.ShapeFormat.TextBox.Document.BeginUpdateCharacters(shape.ShapeFormat.TextBox.Document.Range); cp.FontName = "Comic Sans MS"; cp.FontSize = 32; cp.ForeColor = Color.Red; Font measureFont = new Font(cp.FontName, cp.FontSize.Value); shape.ShapeFormat.TextBox.Document.EndUpdateCharacters(cp); shape.RotationAngle = -45; Size sizeInPixels = TextRenderer.MeasureText(text, measureFont); shape.Size = new SizeF(Units.PixelsToDocumentsF(sizeInPixels.Width, richEditControl.DpiX), Units.PixelsToDocumentsF(sizeInPixels.Height, richEditControl.DpiY)); shape.ShapeFormat.TextBox.HeightRule = TextBoxSizeRule.Auto; shape.Offset = new PointF(section.Page.Width / 2 - shape.Size.Width / 2, section.Page.Height / 2 - shape.Size.Height / 2); section.EndUpdateHeader(subDocument); }
public void TestTriStateBooleanProperty_Construction() { CharacterProperties cp = new CharacterProperties(); Assert.IsNotNull(cp.Bold); Assert.IsTrue(cp.Bold.IsDefault()); Assert.IsFalse(cp.Bold); }
public void LoadCharacterProperties() { _baseProperties = new CharacterProperties(int.Parse(SplitDataFromServe._heroCurrentPLay.idh), SplitDataFromServe._heroCurrentPLay.idcode, SplitDataFromServe._heroCurrentPLay.idclass, SplitDataFromServe._heroCurrentPLay.name, int.Parse(SplitDataFromServe._heroCurrentPLay.level), double.Parse(SplitDataFromServe._heroCurrentPLay.exp), 0, 0, 0, double.Parse(SplitDataFromServe._heroCurrentPLay.skillpoint), int.Parse(SplitDataFromServe._heroCurrentPLay.point), int.Parse(SplitDataFromServe._heroCurrentPLay.levelmap), double.Parse(SplitDataFromServe._heroCurrentPLay.gold), int.Parse(SplitDataFromServe._heroCurrentPLay.diamond), int.Parse(SplitDataFromServe._heroCurrentPLay.slotchest), int.Parse(SplitDataFromServe._heroCurrentPLay.type), int.Parse(SplitDataFromServe._heroCurrentPLay.hp), float.Parse(SplitDataFromServe._heroCurrentPLay.strength), float.Parse(SplitDataFromServe._heroCurrentPLay.intelligence), float.Parse(SplitDataFromServe._heroCurrentPLay.vitality), float.Parse(SplitDataFromServe._heroCurrentPLay.focus), float.Parse(SplitDataFromServe._heroCurrentPLay.luck), float.Parse(SplitDataFromServe._heroCurrentPLay.endurance), float.Parse(SplitDataFromServe._heroCurrentPLay.blessing), float.Parse(SplitDataFromServe._heroCurrentPLay.fighting)); _myEquipments = SplitDataFromServe._equipmentCurrentHero; _currentHP = (int)_baseProperties.hp; UpdatePropertiesFromEquipment(_myEquipments, _baseProperties); _skillPoints = 0; _statPoints = 0; _actionPoints = 0; _damaged = 0; MainMenuUI._instance.UpdateTextValue(); }
private void SearchForTOCEntries(TOCEntryFound callback) { for (int i = 0; i < Document.Paragraphs.Count; i++) { DocumentRange range = Document.CreateRange(Document.Paragraphs[i].Range.Start, 1); CharacterProperties cp = Document.BeginUpdateCharacters(range); int level = 0; if (cp.FontSize.Equals(14f)) { level = 1; } if (cp.FontSize.Equals(13f)) { level = 2; } if (cp.FontSize.Equals(11f)) { level = 3; } Document.EndUpdateCharacters(cp); if (level != 0) { callback(range.Start, level); } } }
private static void FormatList(SnapList list) { // Customize the list header. SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } }
private void Heading1Button_Click(object sender, EventArgs e) //heading 1 { DocumentRange range = MainRichTextBox.Document.Selection; CharacterProperties crp = MainRichTextBox.Document.BeginUpdateCharacters(range); crp.FontName = crp.FontName; crp.FontSize = 16; crp.ForeColor = Color.Blue; if (crp.Bold == true) { crp.Bold = false; } if (crp.Italic == true) { crp.Italic = false; } if (crp.Underline == UnderlineType.Single) { crp.Underline = UnderlineType.None; } if (crp.Strikeout == StrikeoutType.Single) { crp.Strikeout = StrikeoutType.None; } MainRichTextBox.Document.EndUpdateCharacters(crp); }
void SetLineRangeFormatting(DocumentRange currentLineRange, System.Drawing.Color rangeColor) { CharacterProperties cp = richEditControl1.Document.BeginUpdateCharacters(currentLineRange); cp.BackColor = rangeColor; richEditControl1.Document.EndUpdateCharacters(cp); }
// Start is called before the first frame update void Start() { if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P1Side == "Left") { P1Prop = GameObject.Find("Player1").transform.GetComponentInChildren <CharacterProperties>(); P2Prop = GameObject.Find("Player2").transform.GetComponentInChildren <CharacterProperties>(); P1hit = GameObject.Find("Player1").transform.GetComponentInChildren <HitDetector>(); P2hit = GameObject.Find("Player2").transform.GetComponentInChildren <HitDetector>(); } else { P1Prop = GameObject.Find("Player2").transform.GetComponentInChildren <CharacterProperties>(); P2Prop = GameObject.Find("Player1").transform.GetComponentInChildren <CharacterProperties>(); P1hit = GameObject.Find("Player2").transform.GetComponentInChildren <HitDetector>(); P2hit = GameObject.Find("Player1").transform.GetComponentInChildren <HitDetector>(); } combotimer1.fillAmount = 0; combotimer2.fillAmount = 0; Player1Combo.text = ""; Player2Combo.text = ""; regen = Animator.StringToHash("Regen"); shatter = Animator.StringToHash("Shatter"); P1HitsPos = Player1Hits.rectTransform.anchoredPosition; P1ComboPos = Player1Combo.rectTransform.anchoredPosition; P2HitsPos = Player2Hits.rectTransform.anchoredPosition; P2ComboPos = Player2Combo.rectTransform.anchoredPosition; SetCharacterPortrait(); }
private void NormalButton_Click(object sender, EventArgs e) //normal button { DocumentRange range = MainRichTextBox.Document.Selection; CharacterProperties crp = MainRichTextBox.Document.BeginUpdateCharacters(range); crp.FontName = "Arial"; crp.FontSize = 12; crp.ForeColor = Color.Black; crp.BackColor = Color.White; if (crp.Bold == true) { crp.Bold = false; } if (crp.Italic == true) { crp.Italic = false; } if (crp.Underline == UnderlineType.Single) { crp.Underline = UnderlineType.None; } if (crp.Strikeout == StrikeoutType.Single) { crp.Strikeout = StrikeoutType.None; } MainRichTextBox.Document.EndUpdateCharacters(crp); }
static void EditEndnote(Document document) { #region #EditEndnote document.LoadDocument("Documents//Grimm.docx"); //Access the first endnote's content: SubDocument endnote = document.Endnotes[0].BeginUpdate(); //Exclude the reference mark and the space after it from the range to be edited: DocumentRange noteTextRange = endnote.CreateRange(endnote.Range.Start.ToInt() + 2, endnote.Range.Length - 2); //Access the range's character properties: CharacterProperties characterProperties = endnote.BeginUpdateCharacters(noteTextRange); characterProperties.ForeColor = System.Drawing.Color.Red; characterProperties.Italic = true; //Finalize the character options update: endnote.EndUpdateCharacters(characterProperties); //Finalize the endnote update: document.Endnotes[0].EndUpdate(endnote); #endregion #EditEndnote }
private void ApplyRTFModification(RichEditDocumentServer server) { // Apply default formatting server.Document.DefaultCharacterProperties.FontName = "Arial"; server.Document.DefaultCharacterProperties.FontSize = 9; server.Document.DefaultCharacterProperties.ForeColor = Color.FromArgb(120, 120, 120); server.Document.DefaultParagraphProperties.Alignment = ParagraphAlignment.Center; // Remove whitespaces from the end of RTF content DocumentRange[] dots = server.Document.FindAll(".", SearchOptions.None); DocumentPosition lastDot = dots[dots.Length - 1].End; server.Document.Delete(server.Document.CreateRange(lastDot, server.Document.Range.End.ToInt() - lastDot.ToInt())); // Append formatted word DocumentRange range = server.Document.InsertText(server.Document.Range.End, " [Approved]"); CharacterProperties cp = server.Document.BeginUpdateCharacters(range); cp.FontName = "Courier New"; cp.FontSize = 10; cp.ForeColor = Color.Red; cp.Underline = UnderlineType.Single; cp.UnderlineColor = Color.Red; server.Document.EndUpdateCharacters(cp); }
public void TestTriStateShortProperty_Construction() { CharacterProperties cp = new CharacterProperties(); Assert.IsNotNull(cp.SubscriptPosition); Assert.IsTrue(cp.SubscriptPosition.IsDefault()); Assert.AreEqual(0, cp.SubscriptPosition); }
static void EditSeparator(Document document) { #region #EditSeparator document.LoadDocument("Documents//Grimm.docx"); //Check whether the footnotes already have a separator: if (document.Footnotes.HasSeparator(NoteSeparatorType.Separator)) { //Initiate the update session: SubDocument noteSeparator = document.Footnotes.BeginUpdateSeparator(NoteSeparatorType.Separator); //Clear the separator range: noteSeparator.Delete(noteSeparator.Range); //Append a new text: noteSeparator.AppendText("***"); CharacterProperties characterProperties = noteSeparator.BeginUpdateCharacters(noteSeparator.Range); characterProperties.ForeColor = System.Drawing.Color.Blue; noteSeparator.EndUpdateCharacters(characterProperties); //Finalize the update: document.Footnotes.EndUpdateSeparator(noteSeparator); } #endregion #EditSeparator }
static void AddSyndicationItem(Document document, SyndicationItem item) { Paragraph paragraph = document.Paragraphs.Append(); paragraph.LineSpacing = 1f; paragraph.ListIndex = 0; paragraph.SpacingAfter = 3; DocumentRange range = document.InsertText(paragraph.Range.Start, item.Title.Text); CharacterProperties properties = document.BeginUpdateCharacters(range); properties.FontSize = 12f; properties.FontName = "Segoe UI"; document.EndUpdateCharacters(properties); if (item.Links.Count > 0) { Hyperlink hyperlink = document.Hyperlinks.Create(range); hyperlink.NavigateUri = item.Links[0].Uri.ToString(); } range = document.InsertText(range.End, String.Format("{0}Published {1}", Characters.LineBreak, item.PublishDate.DateTime)); properties = document.BeginUpdateCharacters(range); properties.FontSize = 8f; properties.FontName = "Segoe UI"; properties.ForeColor = Color.Gray; document.EndUpdateCharacters(properties); }
private void AddColumn(SnapList list, string columnName, string caption) { SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables[0]; listHeaderTable.TableLayout = TableLayoutType.Fixed; TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; TableCell columnHeader = listHeaderCells.InsertAfter(listHeaderCells.Count - 1); listHeader.InsertText(columnHeader.ContentRange.Start, caption); CharacterProperties prop = listHeader.BeginUpdateCharacters(columnHeader.ContentRange); prop.Bold = true; prop.ForeColor = Color.YellowGreen; listHeader.EndUpdateCharacters(prop); SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables[0]; listRowTable.TableLayout = TableLayoutType.Fixed; TableCellCollection listRowTableCells = listRowTable.FirstRow.Cells; TableCell column = listRowTableCells.InsertAfter(listRowTableCells.Count - 1); listRow.CreateSnText(column.ContentRange.Start, columnName); }
/** * Creates a CharacterProperties object from a chpx stored in the * StyleDescription at the index istd in the StyleDescription array. The * CharacterProperties object is placed in the StyleDescription at istd after * its been Created. Not every StyleDescription will contain a chpx. In these * cases this function does nothing. * * @param istd The index of the StyleDescription to create the * CharacterProperties object from. */ private void CreateChp(int istd) { StyleDescription sd = _styleDescriptions[istd]; CharacterProperties chp = sd.GetCHP(); byte[] chpx = sd.GetCHPX(); int baseIndex = sd.GetBaseStyle(); if (baseIndex == istd) { // Oh dear, this isn't allowed... // The word file seems to be corrupted // Switch to using the nil style so that // there's a chance we can read it baseIndex = NIL_STYLE; } // Build and decompress the Chp if required if (chp == null && chpx != null) { CharacterProperties parentCHP = new CharacterProperties(); if (baseIndex != NIL_STYLE) { parentCHP = _styleDescriptions[baseIndex].GetCHP(); if (parentCHP == null) { CreateChp(baseIndex); parentCHP = _styleDescriptions[baseIndex].GetCHP(); } } chp = CharacterSprmUncompressor.UncompressCHP(parentCHP, chpx, 0); sd.SetCHP(chp); } }
private IEnumerator DelayCharacterSpawn(int amt, int i, int j) { for (int k = 0; k < amt; k++) { int tempCardNum = settings.area[areaNum].subStage[stageNum].stageSettings[i].unitSettings[j].unitCardNum; int tempCardLevel = settings.area[areaNum].subStage[stageNum].stageSettings[i].unitSettings[j].unitLevel; CharacterProperties.UnitType tempUnitType; team = settings.area[areaNum].subStage[stageNum].stageSettings[i].unitSettings[j].unitTeam; if (tempCardNum > 0) { tempUnitType = GetUnitTypeByCardNumber(tempCardNum); } else { CharacterProperties.UnitType tempUnitType2 = settings.area[areaNum].subStage[stageNum].stageSettings[i].unitSettings[j].unitType; int tempRarity = settings.area[areaNum].subStage[stageNum].stageSettings[i].unitSettings[j].rarity; CharacterProperties prop = GetUnitByClassAndRarity(tempUnitType2, tempRarity); tempCardNum = characterSettings.characterProperties.IndexOf(prop) + 1; tempUnitType = prop.unitType; } defObj.SpawnCharacter(damageApplyDeck, tempCardNum, tempCardLevel, tempUnitType, team); yield return(new WaitForSeconds(Random.Range(0.3f, 1f))); } }
public void ProcessTurnIconClick(int characterBattleId) { //get character properties and set up panel CharacterProperties characterProperties = GameController.Instance.FindCharacter(characterBattleId).Properties; CharacterPanelRef.ShowPanel(characterProperties); }
void AppendColorFormattedMessage(DevExpress.Xpf.RichEdit.RichEditControl richEditControl, string formattedMessage, Color color) { try { //doc.BeginUpdate(); //// This updates the entire document, sigh //doc.DefaultCharacterProperties.ForeColor = Color.Red; //doc.AppendText(formattedMessage); //doc.EndUpdate(); Document doc = richEditControl.Document; DocumentRange newRange = doc.AppendText(formattedMessage); CharacterProperties charProp = doc.BeginUpdateCharacters(newRange); charProp.ForeColor = color; doc.EndUpdateCharacters(charProp); } catch (Exception ex) { string exception = ex.ToString(); string innerException = ex.InnerException.ToString(); } }
private void btn_LinkedStyle_Click(object sender, EventArgs e) { #region #linkedparstyle Document doc = richEditControl1.Document; ParagraphStyle pstyle = doc.ParagraphStyles["MyLinkedParagraphStyle"]; CharacterStyle cstyle = doc.CharacterStyles["MyLinkedCharStyle"]; if (pstyle == null && cstyle == null) { cstyle = doc.CharacterStyles.CreateNew(); cstyle.Name = "MyLinkedCharStyle"; doc.CharacterStyles.Add(cstyle); pstyle = doc.ParagraphStyles.CreateNew(); pstyle.LinkedStyle = cstyle; pstyle.Name = "MyLinkedParagraphStyle"; pstyle.Parent = doc.ParagraphStyles["Normal"]; pstyle.Alignment = ParagraphAlignment.Center; pstyle.LineSpacingType = ParagraphLineSpacing.Single; pstyle.ForeColor = Color.DarkGreen; pstyle.Underline = UnderlineType.None; pstyle.FontName = "Script"; doc.ParagraphStyles.Add(pstyle); } DocumentRange range = doc.Selection; CharacterProperties charProps = doc.BeginUpdateCharacters(range); charProps.Style = cstyle; doc.EndUpdateCharacters(charProps); #endregion #linkedparstyle }
public void UpdateTurnIcon(int characterBattleId, CharacterProperties properties) { //if this character take step now TurnIcon turnIcon = null; if (characterBattleId == CurrentTurnIcon.ChainedCharacterBattleId) { CurrentTurnIcon.UpdateIcon(properties); } foreach (var icon in TurnIcons) { if (characterBattleId == icon.ChainedCharacterBattleId) { turnIcon = icon; break; } } //update icon if it was found if (turnIcon != null) { turnIcon.UpdateIcon(properties); } }
void HighlightSyntax(TokenCollection tokens) { commentProperties = new SyntaxHighlightProperties(); commentProperties.ForeColor = syntaxColors.CommentColor; keywordProperties = new SyntaxHighlightProperties(); keywordProperties.ForeColor = syntaxColors.KeywordColor; stringProperties = new SyntaxHighlightProperties(); stringProperties.ForeColor = syntaxColors.StringColor; xmlCommentProperties = new SyntaxHighlightProperties(); xmlCommentProperties.ForeColor = syntaxColors.XmlCommentColor; textProperties = new SyntaxHighlightProperties(); textProperties.ForeColor = syntaxColors.TextColor; if (tokens == null || tokens.Count == 0) { return; } Document document = syntaxEditor.Document; CharacterProperties cp = document.BeginUpdateCharacters(0, 1); List <SyntaxHighlightToken> syntaxTokens = new List <SyntaxHighlightToken>(tokens.Count); foreach (Token token in tokens) { HighlightCategorizedToken((CategorizedToken)token, syntaxTokens); } document.ApplySyntaxHighlight(syntaxTokens); document.EndUpdateCharacters(cp); }
private List <string> GetUsedFonts() { List <string> fonts = new List <string>(); Document document = richEditControl1.Document; document.BeginUpdate(); int length = richEditControl1.Document.Range.Length; for (int i = 0; i <= length - 2; i++) { DocumentRange range = document.CreateRange(i, 1); CharacterProperties cp = document.BeginUpdateCharacters(range); if (!fonts.Contains(cp.FontName)) { fonts.Add(cp.FontName); } document.EndUpdateCharacters(cp); } document.EndUpdate(); return(fonts); }
private void customHighlightItem_ItemClick(object sender, ItemClickEventArgs e) { CharacterProperties charProps = richEdit.Document.BeginUpdateCharacters(richEdit.Document.Selection); charProps.BackColor = System.Drawing.Color.Yellow; richEdit.Document.EndUpdateCharacters(charProps); }
private void CommentRichEdit_TextChanged(object sender, EventArgs e) { RichEditControl richEdit = sender as RichEditControl; if (richEdit == null) { return; } DocumentRange[] ranges = null; ranges = richEdit.Document.FindAll(new Regex(@"\[[^\[\]]+\]", RegexOptions.Compiled)); if (ranges == null || ranges.Length == 0) { return; } richEdit.BeginUpdate(); foreach (DocumentRange range in ranges) { CharacterProperties characterProperty = richEdit.Document.BeginUpdateCharacters(range); characterProperty.ForeColor = Color.DarkRed; characterProperty.Bold = true; richEdit.Document.EndUpdateCharacters(characterProperty); } richEdit.Document.CaretPosition = richEdit.Document.Range.End; richEdit.ScrollToCaret(); richEdit.EndUpdate(); }
void Start() { if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P1Side == "Left") { p1Start = new Vector3(-1f, 1.127f, -3); } else { p1Start = new Vector3(1f, 1.127f, -3); } if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P2Side == "Right") { p2Start = new Vector3(1f, 1.127f, -3); } else { p2Start = new Vector3(-1f, 1.127f, -3); } if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode != "Practice" && GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode != "Tutorial") { //Setting private character property variables to their appropriate player 1 and 2 child respectively P1Prop = GameObject.Find("Player1").transform.GetComponentInChildren <CharacterProperties>(); P2Prop = GameObject.Find("Player2").transform.GetComponentInChildren <CharacterProperties>(); //Setting AcceptInputs to lock them on transitions P1Inputs = GameObject.Find("Player1").transform.GetComponentInChildren <AcceptInputs>(); P2Inputs = GameObject.Find("Player2").transform.GetComponentInChildren <AcceptInputs>(); //Setting private menu child game obejcts to their appropriate menu children respectively child1 = p1menu.transform.GetChild(0).gameObject; child2 = p2menu.transform.GetChild(0).gameObject; //Setting timers to an arbitrarily picked -2 for standby endTimer = -2; replayTimer = -2; overtimeTimer = -2; //Setting round timer to 99 (eventually will make it into a public variable for easier manipulation/access) roundTimer = 99; roundCount = 1; //Setting text variables to proper win text for each player //Telling round not to start yet gameActive = false; lockInputs = true; dizzyKO = false; matchOver = false; } else if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode == "Practice" || GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode == "Tutorial") { //Setting private character property variables to their appropriate player 1 and 2 child respectively P1Prop = GameObject.Find("Player1").transform.GetComponentInChildren <CharacterProperties>(); P2Prop = GameObject.Find("Player2").transform.GetComponentInChildren <CharacterProperties>(); gameActive = true; roundCount = 0; startReady = true; } holdpositions = false; }
private void ChangeHeaderCharacterProeprties(DocumentRange headerRange) { CharacterProperties cp = richEditControl1.Document.BeginUpdateCharacters(headerRange); cp.Bold = true; cp.ForeColor = Color.Blue; richEditControl1.Document.EndUpdateCharacters(cp); }
private static Character CreateCharacterFromDatabase(string name, int id) { SqliteRow characterData = GameData.Conn.GetCharacterData(name); CharacterProperties properties = GetCharacterProperties(characterData); List <Ability> abilities = AbilityFactory.CreateAndInitiateAbilitiesFromDatabase(name); return(new Character(name, id, properties, abilities)); }
void OnEnable() { characterProperties = GameObject.Find("Character").GetComponent<CharacterProperties>(); if(characterProperties.skinColor == skinColor) { GetComponent<ImageManager>().OnPressed(); } }
public void Battle(CharacterProperties dataPlayer1, CharacterProperties dataPlayer2) { Init(); player1 = new CharacterBattleData(dataPlayer1); player2 = new CharacterBattleData(dataPlayer2); RegenHpAndMp(player1); RegenHpAndMp(player2); }
void HighlightParagraph(int paragraphIndex) { Document doc = this.control.Document; Paragraph paragraph = doc.Paragraphs[paragraphIndex]; DocumentRange paragraphRange = paragraph.Range; int paragraphStart = paragraphRange.Start.ToInt(); string text = doc.GetText(paragraphRange); int hash = text.GetHashCode(); if (paragraphIndex < paragraphHashes.Count && paragraphHashes[paragraphIndex] == hash) { return; } int length = text.Length; int prevWhiteSpaceIndex = -1; for (int i = 0; i <= length; i++) { char ch; if (i < length) { ch = text[i]; } else { ch = ' '; } if (Char.IsWhiteSpace(ch) || Char.IsPunctuation(ch)) { int wordLength = i - prevWhiteSpaceIndex - 1; if (wordLength > 0) { int wordStart = prevWhiteSpaceIndex + 1; string word = text.Substring(wordStart, wordLength); int index = Array.BinarySearch(str, word); DocumentRange range = doc.CreateRange(paragraphStart + wordStart, wordLength); CharacterProperties cp = doc.BeginUpdateCharacters(range); if (index >= 0) { cp.ForeColor = Color.Blue; } else { cp.ForeColor = Color.Black; } doc.EndUpdateCharacters(cp); } prevWhiteSpaceIndex = i; } } for (int i = paragraphHashes.Count; i <= paragraphIndex; i++) { paragraphHashes.Add(String.Empty.GetHashCode()); } paragraphHashes[paragraphIndex] = hash; }
public static void ToBold(this RichEditControl richEditControl) { var txt = richEditControl.Document; DocumentRange res = txt.Selection; CharacterProperties cp = txt.BeginUpdateCharacters(res); cp.Bold = cp.Bold != true; txt.EndUpdateCharacters(cp); }
public void TestTriStateBooleanProperty_ExplicitAssignment() { CharacterProperties cp = new CharacterProperties(); cp.Bold = true; Assert.IsFalse(cp.Bold.IsDefault()); Assert.IsTrue(cp.Bold); cp.Bold = false; Assert.IsFalse(cp.Bold.IsDefault()); Assert.IsFalse(cp.Bold); }
public void TestTriStateShortProperty_ExplicitAssignment() { CharacterProperties cp = new CharacterProperties(); cp.SubscriptPosition = 3; Assert.IsFalse(cp.SubscriptPosition.IsDefault()); Assert.AreEqual(3, cp.SubscriptPosition); cp.SubscriptPosition = 5; Assert.IsFalse(cp.SubscriptPosition.IsDefault()); Assert.AreEqual(5, cp.SubscriptPosition); }
public void TestTriStateBooleanProperty_Apply() { CharacterProperties cp = new CharacterProperties(); CharacterProperties cpBold = new CharacterProperties(); cpBold.Bold = true; cp.Apply(cpBold); Assert.IsFalse(cp.Bold.IsDefault()); Assert.IsTrue(cp.Bold); CharacterProperties cpUnbold = new CharacterProperties(); cpUnbold.Bold = false; cp.Apply(cpUnbold); Assert.IsFalse(cp.Bold.IsDefault()); Assert.IsFalse(cp.Bold); }
public void TestTriStateStringProperty_Construction() { CharacterProperties cp = new CharacterProperties(); Assert.IsNull(cp.FontHighlight); }
public void TestTriStateShortProperty_Apply() { CharacterProperties cp = new CharacterProperties(); cp.SubscriptPosition = 4; CharacterProperties cpHigher = new CharacterProperties(); cp.SubscriptPosition = 6; cp.Apply(cpHigher); Assert.IsFalse(cp.SubscriptPosition.IsDefault()); Assert.AreEqual(6, cp.SubscriptPosition); CharacterProperties cpLower = new CharacterProperties(); cpLower.SubscriptPosition = 2; cp.Apply(cpLower); Assert.IsFalse(cp.SubscriptPosition.IsDefault()); Assert.AreEqual(2, cp.SubscriptPosition); }
public void TestTriStateStringProperty_Apply() { CharacterProperties cp = new CharacterProperties(); CharacterProperties cpRed = new CharacterProperties(); cpRed.FontHighlight = "FF0000"; cp.Apply(cpRed); Assert.AreEqual("FF0000", cp.FontHighlight); CharacterProperties cpGreen = new CharacterProperties(); cpGreen.FontHighlight = "00FF00"; cp.Apply(cpGreen); Assert.AreEqual("00FF00", cp.FontHighlight); CharacterProperties cpDefault = new CharacterProperties(); cpDefault.FontHighlight = null; cp.Apply(cpDefault); Assert.AreEqual("00FF00", cp.FontHighlight); CharacterProperties cpNoColor = new CharacterProperties(); cpNoColor.FontHighlight = string.Empty; cp.Apply(cpNoColor); Assert.AreEqual(string.Empty, cp.FontHighlight); }
void Start() { characterProperties = GameObject.Find("Character").GetComponent<CharacterProperties>(); }