public override Panel CreateControl(BaseConfigurationAttribute attr, PropertyInfo prop, object configuration_instance) { var font_str = GetConfigValue(prop, configuration_instance); FontAttribute fattr = attr as FontAttribute; var panel = base.CreateControl(attr, prop, configuration_instance); var font_box = new TextBox() { Text = font_str, Width = 160, Height = 22, VerticalContentAlignment = VerticalAlignment.Center }; var button = new Button() { Content = DefaultLanguage.BUTTON_FONT, Width = 75, Margin = new Thickness(5, 0, 5, 0) }; panel.Children.Add(font_box); panel.Children.Add(button); button.Click += (s, e) => { var fontDialog = new System.Windows.Forms.FontDialog(); font_str = GetConfigValue(prop, configuration_instance); fontDialog.Font = new System.Drawing.Font(font_str, 20); if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { font_box.Text = fontDialog.Font.Name; } SetConfigValue(prop, configuration_instance, font_box.Text); }; font_box.LostFocus += (s, e) => { if (fattr.Check(font_box.Text)) { SetConfigValue(prop, configuration_instance, font_box.Text); } ConfigWindow.RequireRestart = attr.RequireRestart; }; return(panel); }
async Task <IList <ContentTranslationDto> > BreakIntoAttributeAsync(IEnumerable <ContentTranslationDto> paragraphedContents, FontAttribute attribute, string regexPattern, string attributeMarkStart, string attributeMarkEnd) { var contentBuilderParams = new ContentBuilderParameters(attribute); fontAttributeContentFormatter = new FontAttributeContentFormatter(); var contentBuilder = new ContentBuilder(contentBuilderParams, fontAttributeContentFormatter); var newContents = await contentBuilder.TranslateContentAsync(paragraphedContents, attributeMarkStart, attributeMarkEnd, regexPattern); return(newContents.ToList()); }
public ContentBuilderParameters(FontAttribute fontAttributeOption) { this.fontAttributeOption = fontAttributeOption; }
IList <ContentTranslationDto> BreakIntoAttribute(IEnumerable <ContentTranslationDto> paragraphedContents, FontAttribute attribute, string regexPattern, string attributeMarkStart, string attributeMarkEnd) { var regexSplitter = new RegexSplitter(); var newContents = new List <ContentTranslationDto>(); foreach (var content in paragraphedContents) { var contents = regexSplitter.Split(content.content, regexPattern); if (content.lineBreak) { newContents.Add(content); } foreach (var item in contents) { var hasAttribute = (item.Contains(attributeMarkStart) && item.Contains(attributeMarkEnd)); var formattedItem = item.Replace(attributeMarkStart, string.Empty).Replace(attributeMarkEnd, string.Empty); var dto = new ContentTranslationDto() { content = formattedItem, fontAttribute = hasAttribute ? attribute : FontAttribute.None }; newContents.Add(dto); } } return(newContents); }