public TextInformation GetInformation(TextCommand command) { var result = new TextInformation() { TextCommand = command }; var indexOfTextCommand = Commands.IndexOf(command); for (var i = indexOfTextCommand; i >= 0; i--) { var currentCommand = Commands[i]; if (currentCommand is TextColour colorCommand && result.ColorCommand == null) { result.ColorCommand = colorCommand; continue; } if (currentCommand is CharacterHeight heightCommand && result.HeightCommand == null) { result.HeightCommand = heightCommand; } if (result.HeightCommand != null && result.ColorCommand != null) { break; } } return(result); }
void UpdateInfoText(string text, bool append = false) { if (!append) { TextInformation.Text = ""; } foreach (string infoText in Regex.Split(text, "\\[Font")) { if (infoText.StartsWith("Chs]")) { TextInformation.SelectionFont = Utility.Configuration.Config.UI.MainFont; TextInformation.AppendText(infoText.Substring(4)); } else if (infoText.StartsWith("Jpn]")) { TextInformation.SelectionFont = Utility.Configuration.Config.UI.JapFont; TextInformation.AppendText(infoText.Substring(4)); } else // firstline always in Japanese { TextInformation.SelectionFont = Utility.Configuration.Config.UI.JapFont; TextInformation.AppendText(infoText); } } }
public void AddAndGetTestMethod() { var text = new TextInformation(); text.Add("Мир нужен для того, чтобы в нем жить", "Мир и жизнь"); text.Add("Поговорим о любви", "Любовь"); Assert.AreEqual("Мир нужен для того, чтобы в нем жить", text.GetText("Мир и жизнь")); Assert.AreEqual("Поговорим о любви", text.GetText("Любовь")); }
private void UpdatePrivacyFromSelectedTextBox(TextInformation info) { if (info.Target == "presentationSpace") Dispatcher.adopt(delegate { string setPrivacy = info.IsPrivate ? "private" : "public"; Commands.SetPrivacy.ExecuteAsync(setPrivacy); }); }
private void update(TextInformation info) { fontSize.SelectedItem = info.size; fontFamily.SelectedItem = info.family.ToString(); TextBoldButton.IsChecked = info.bold; TextItalicButton.IsChecked = info.italics; TextUnderlineButton.IsChecked = info.underline; TextStrikethroughButton.IsChecked = info.strikethrough; }
private void SetInformation() { Name = new TextInformation("Name", "Mountain"); FoodExtraction = new ResourcesInformation("FoodExtraction", 1); PassageDifficulty = new ResourcesInformation("PassageDifficulty", 4); ProtectionBonus = new ResourcesInformation("ProtectionBonus", 4); ProtectionDecline = new ResourcesInformation("ProtectionDecline", -2); SurveyRangeBonus = new ResourcesInformation("SurveyRangeBonus", 3); ShotRangeBonus = new ResourcesInformation("ShotRangeBonus", 2); OreQuantity = new ResourcesInformation("OreQuantity", 5); }
private void SetInformation() { Name = new TextInformation("Name", "Undergrowth"); FoodExtraction = new ResourcesInformation("FoodExtraction", 1); PassageDifficulty = new ResourcesInformation("PassageDifficulty", 1); ProtectionBonus = new ResourcesInformation("ProtectionBonus", 1); ProtectionDecline = new ResourcesInformation("ProtectionDecline", -1); SurveyRangeBonus = new ResourcesInformation("SurveyRangeBonus", 0); ShotRangeBonus = new ResourcesInformation("ShotRangeBonus", 0); OreQuantity = new ResourcesInformation("OreQuantity", 1); }
private void updateStyling(TextInformation info) { try { currentColor = info.Color; currentFamily = info.Family; currentSize = info.Size; if (myTextBox != null) { var caret = myTextBox.CaretIndex; var currentTextBox = Clone(myTextBox); var oldInfo = getInfoOfBox(currentTextBox); Action undo = () => { ClearAdorners(); var currentInfo = oldInfo; var activeTextbox = ((MeTLTextBox) Children.ToList().Where( c => ((MeTLTextBox)c).tag().id == currentTextBox.tag().id). FirstOrDefault()); activeTextbox.TextChanged -= SendNewText; applyStylingTo(activeTextbox, currentInfo); Commands.TextboxFocused.ExecuteAsync(currentInfo); addAdorners(); sendTextWithoutHistory(activeTextbox, currentTextBox.tag().privacy); activeTextbox.TextChanged += SendNewText; }; Action redo = () => { ClearAdorners(); var currentInfo = info; var activeTextbox = ((MeTLTextBox) Children.ToList().FirstOrDefault(c => ((MeTLTextBox)c).tag().id == currentTextBox.tag().id)); activeTextbox.TextChanged -= SendNewText; applyStylingTo(activeTextbox, currentInfo); Commands.TextboxFocused.ExecuteAsync(currentInfo); addAdorners(); sendTextWithoutHistory(activeTextbox, currentTextBox.tag().privacy); activeTextbox.TextChanged += SendNewText; }; UndoHistory.Queue(undo, redo); redo(); myTextBox.GotFocus -= textboxGotFocus; myTextBox.CaretIndex = caret; myTextBox.Focus(); myTextBox.GotFocus += textboxGotFocus; } else if (GetSelectedElements().Count > 0) { var originalElements = GetSelectedElements().ToList().Select(tb => Clone((MeTLTextBox)tb)); Action undo = () => { ClearAdorners(); foreach (var originalElement in originalElements) { dirtyTextBoxWithoutHistory(originalElement); sendTextWithoutHistory(originalElement, originalElement.tag().privacy); } addAdorners(); }; Action redo = () => { ClearAdorners(); var ids = originalElements.Select(b => b.tag().id); var selection = Children.ToList().Where(b => ids.Contains(((MeTLTextBox)b).tag().id)); foreach (MeTLTextBox currentTextBox in selection) { applyStylingTo(currentTextBox, info); sendTextWithoutHistory(currentTextBox, currentTextBox.tag().privacy); } addAdorners(); }; UndoHistory.Queue(undo, redo); redo(); } } catch (Exception e) { Logger.Fixed(string.Format("There was an ERROR:{0} INNER:{1}, it is now fixed", e, e.InnerException)); } }
private void updateTools() { var info = new TextInformation { Family = defaultFamily, Size = defaultSize, Bold = false, Italics = false, Strikethrough = false, Underline = false, Color = Colors.Black }; if (myTextBox != null) { info = new TextInformation { Family = myTextBox.FontFamily, Size = myTextBox.FontSize, Bold = myTextBox.FontWeight == FontWeights.Bold, Italics = myTextBox.FontStyle == FontStyles.Italic, Color = ((SolidColorBrush)myTextBox.Foreground).Color }; if (myTextBox.TextDecorations.Count > 0) { info.Strikethrough = myTextBox.TextDecorations.First().Location.ToString().ToLower() == "strikethrough"; info.Underline = myTextBox.TextDecorations.First().Location.ToString().ToLower() == "underline"; } info.IsPrivate = myTextBox.tag().privacy.ToLower() == "private" ? true : false; } Commands.TextboxFocused.ExecuteAsync(info); }
private void resetText(MeTLTextBox box) { RemovePrivacyStylingFromElement(box); currentColor = Colors.Black; box.FontWeight = FontWeights.Normal; box.FontStyle = FontStyles.Normal; box.TextDecorations = new TextDecorationCollection(); box.FontFamily = new FontFamily("Arial"); box.FontSize = 24; box.Foreground = Brushes.Black; var info = new TextInformation { Family = box.FontFamily, Size = box.FontSize, }; Commands.TextboxFocused.ExecuteAsync(info); sendTextWithoutHistory(box, box.tag().privacy); }
private static void applyStylingTo(MeTLTextBox currentTextBox, TextInformation info) { currentTextBox.FontStyle = info.Italics ? FontStyles.Italic : FontStyles.Normal; currentTextBox.FontWeight = info.Bold ? FontWeights.Bold : FontWeights.Normal; currentTextBox.TextDecorations = new TextDecorationCollection(); if(info.Underline) currentTextBox.TextDecorations = TextDecorations.Underline; else if(info.Strikethrough) currentTextBox.TextDecorations= TextDecorations.Strikethrough; currentTextBox.FontSize = info.Size; currentTextBox.FontFamily = info.Family; currentTextBox.Foreground = new SolidColorBrush(info.Color); }
private void update(TextInformation info) { fontSize.SelectedItem = info.size; fontFamily.SelectedItem = info.family.ToString(); }
private void updateTools() { bool strikethrough = false; bool underline = false; var focussedBox = (TextBox)FocusManager.GetFocusedElement(this); if (focussedBox == null) return; if (focussedBox.TextDecorations.Count > 0) { strikethrough = focussedBox.TextDecorations.First().Location.ToString().ToLower() == "strikethrough"; underline = focussedBox.TextDecorations.First().Location.ToString().ToLower() == "underline"; } var info = new TextInformation { family = focussedBox.FontFamily, size = focussedBox.FontSize, bold = focussedBox.FontWeight == FontWeights.Bold, italics = focussedBox.FontStyle == FontStyles.Italic, strikethrough = strikethrough, underline = underline }; Commands.TextboxFocused.ExecuteAsync(info); }