/// <summary> /// Draws the current state of the game to the screen. /// </summary> /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> public static void DrawScreen(ThemeColor color) { if (MenuController.TColor == ThemeColor.Pink) { UtilityFunctions.DrawBackground(ThemeColor.Pink); } else if (MenuController.TColor == ThemeColor.Green) { UtilityFunctions.DrawBackground(ThemeColor.Green); } else { UtilityFunctions.DrawBackground(ThemeColor.Blue); } switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; /*Add Theme draw*/ case GameState.ThemeColors: MenuController.ThemeSettings(); break; /*Added Draw MusicSettings*/ case GameState.MusicSettings: MenuController.MusicSettings(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); break; //case GameState.EndingGame: // EndingGameController.DrawEndOfGame (); // break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }
private static bool IsValidThemeColor(object o) { ThemeColor color = (ThemeColor)o; return(color == ThemeColor.NormalColor || color == ThemeColor.Homestead || color == ThemeColor.Metallic); }
public static string ToBackgroundColorCss(this ThemeColor themeColor) { return(themeColor switch { ThemeColor.None => null, ThemeColor.Link => throw new NotSupportedException($"{nameof(ThemeColor)}.{nameof(ThemeColor.Link)} cannot be used as background color."), _ => "bg-" + themeColor.ToString("f").ToLower() });
/// <summary> /// Load XML theme file and pass data to new Theme instance /// </summary> public static Theme LoadTheme(string path) { // Initialize new Theme instance Theme theme = new Theme(); try { // Initialize new .xml document XmlDocument xmlDoc = new XmlDocument(); // Try load from path try { xmlDoc.Load(path); } // Try load from XML file catch { xmlDoc.LoadXml(path); } // Iterate through all possible ThemeColors foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes) { // Iterate through all ThemeColor's parameters and pass them to themeColor instance foreach (XmlNode childNode in node.ChildNodes) { // Theme color properties try { // New ThemeColor instance ThemeColor tc = new ThemeColor(); // Fills tc tc.Normal = new Hex(childNode.Attributes["Normal"].Value); tc.Hover = new Hex(childNode.Attributes["Hover"].Value); tc.Focus = new Hex(childNode.Attributes["Focus"].Value); tc.Disabled = new Hex(childNode.Attributes["Disabled"].Value); // Pass filled tc instance to current theme property (node) theme.GetType().GetProperty(node.Name).SetValue(theme, tc); } // Last theme property wich is not ThemeColor child catch { // DARK BASED property theme.GetType().GetProperty(node.Name).SetValue(theme, Convert.ToBoolean(childNode.Attributes["Value"].Value)); } } } } catch (Exception e) { // Error // Probably bad XML theme file formating MessageBox.Show("Error in reading XML theme file. " + e.Message); } // Return initialized theme instance return(theme); }
void AddThemeColor(RibbonItemCollection items, ThemeColor themeColor) { RibbonToggleButton tb = new RibbonToggleButton(); tb.Text = themeColor.ToString(); tb.Tag = themeColor; tb.ToggleGroupName = "Theme"; tb.CanDepress = false; items.Add(tb); }
/// <summary> /// Initializes a new instance of the application configuration file. /// </summary> public ConfigurationFile() { LanguageCode = "en"; ThemeColor = new ThemeColor { R = 37, G = 0, B = 64 }; }
protected void LoadTheme(Label Titulo = null, Label SubTitulo = null, Label SubTitulo2 = null) { foreach (Control control in this.Controls) { Button button; IconButton iconButton; IconPictureBox iconPictureBox; DataGridView dataGridView; if (control.GetType() == typeof(Button)) { button = (Button)control; button.BackColor = ThemeColor.Primary; button.ForeColor = ThemeColor.ChangeColorBrightness(ThemeColor.Secondary, -0.5); button.FlatAppearance.BorderColor = ThemeColor.Secondary; } if (control.GetType() == typeof(IconButton)) { iconButton = (IconButton)control; iconButton.BackColor = ThemeColor.Primary; iconButton.ForeColor = ThemeColor.ChangeColorBrightness(ThemeColor.Secondary, -0.5); iconButton.FlatAppearance.BorderColor = ThemeColor.Secondary; iconButton.IconColor = ThemeColor.Secondary; } if (control.GetType() == typeof(IconPictureBox)) { iconPictureBox = (IconPictureBox)control; iconPictureBox.BackColor = ThemeColor.Primary; iconPictureBox.ForeColor = ThemeColor.ChangeColorBrightness(ThemeColor.Secondary, -0.5); iconPictureBox.IconColor = ThemeColor.Secondary; } if (control.GetType() == typeof(DataGridView)) { dataGridView = (DataGridView)control; dataGridView.RowsDefaultCellStyle.SelectionBackColor = ThemeColor.ChangeColorBrightness(ThemeColor.Secondary, -0.5); dataGridView.RowsDefaultCellStyle.BackColor = ThemeColor.Primary; dataGridView.AlternatingRowsDefaultCellStyle.BackColor = ThemeColor.ChangeColorBrightness(ThemeColor.Primary, -0.2); dataGridView.RowHeadersDefaultCellStyle.BackColor = ThemeColor.ChangeColorBrightness(ThemeColor.Primary, -0.5); dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ThemeColor.ChangeColorBrightness(ThemeColor.Primary, -0.5); dataGridView.ColumnHeadersDefaultCellStyle.SelectionBackColor = ThemeColor.ChangeColorBrightness(ThemeColor.Primary, -0.5); } } if (Titulo != null) { Titulo.ForeColor = ThemeColor.Secondary; } if (SubTitulo != null) { SubTitulo.ForeColor = ThemeColor.Primary; } if (SubTitulo2 != null) { SubTitulo2.ForeColor = ThemeColor.Primary; } }
public override int GetHashCode() { var hashCode = -331517974; hashCode = hashCode * -1521134295 + ColorType.GetHashCode(); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Indexed ? Indexed.GetHashCode() : 0); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Theme ? ThemeColor.GetHashCode() : 0); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Theme ? ThemeTint.GetHashCode() : 0); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Color ? Color.ToArgb().GetHashCode() : 0); return(hashCode); }
private string GeneratePath(ThemeColor color, ThemeColorOpacity opacity) { var result = nameof(Theme.Brushes) + "." + color; if (opacity > ThemeColorOpacity.None) { result += Color.GetOpacityPostfix(opacity); } return(result); }
/// <inheritdoc /> public MessageCard CreateMesssageCard(ThemeColor themeColor, string title, string text, PotentialAction[] potentialActions) { return(new MessageCard { Context = _messageCardContext, Type = _type, ThemeColor = GetRgbCardColor(themeColor), Title = title, Text = text, PotentialActions = potentialActions }); }
public override IEnumerable <Tuple <object, object> > GetResourceKeyValues(ThemeColor hlColor) { if (ForegroundResourceKey != null) { Debug.Assert(hlColor.Foreground != null); yield return(new Tuple <object, object>(ForegroundResourceKey, hlColor.Foreground)); } if (BackgroundResourceKey != null) { Debug.Assert(hlColor.Background != null); yield return(new Tuple <object, object>(BackgroundResourceKey, hlColor.Background)); } }
private void ActiveButton(object btnSender) { if (btnSender != null) { if (currentButton != (Button)btnSender) { DisableButton(); currentButton = (Button)btnSender; currentButton.BackColor = ThemeColor.ChangeColorBrightness(pnlManagementMenu.BackColor, +0.2); currentButton.ForeColor = Color.White; } } }
// #FFD53333 (Red) // #FF6DD533 (Green) // #FF41B1E1 (Blue) // #FFC333FF (Purple) // #FFFFAD54 (Orange) static Brush GetBrush(ThemeColor color) { BrushConverter bc = new BrushConverter(); switch (color) { case ThemeColor.Blue: return (Brush)bc.ConvertFrom("#FF41B1E1"); case ThemeColor.Green: return (Brush)bc.ConvertFrom("#FF6DD533"); case ThemeColor.Orange: return (Brush)bc.ConvertFrom("#FFFFAD54"); case ThemeColor.Purple: return (Brush)bc.ConvertFrom("#FFC333FF"); case ThemeColor.Red: return (Brush)bc.ConvertFrom("#FFD53333"); default: return (Brush)bc.ConvertFrom("#FF41B1E1"); } }
public GtkHostUiTheme(Window parent) { Entry entry = new Entry(); entry.SetStateFlags(StateFlags.Selected, true); // Get the font and some colors directly from GTK. FontFamily = entry.PangoContext.FontDescription.Family; // Get foreground colors from the style context. var defaultForegroundColor = entry.StyleContext.GetColor(StateFlags.Normal); var selectedForegroundColor = entry.StyleContext.GetColor(StateFlags.Selected); DefaultForegroundColor = new ThemeColor((float)defaultForegroundColor.Alpha, (float)defaultForegroundColor.Red, (float)defaultForegroundColor.Green, (float)defaultForegroundColor.Blue); SelectionForegroundColor = new ThemeColor((float)selectedForegroundColor.Alpha, (float)selectedForegroundColor.Red, (float)selectedForegroundColor.Green, (float)selectedForegroundColor.Blue); ListBoxRow row = new ListBoxRow(); row.SetStateFlags(StateFlags.Selected, true); // Request the main thread to render some UI elements to an image to get an approximation for the color. // NOTE (caian): This will only take the color of the top-left corner of the background, which may be incorrect // if someone provides a custom style with a gradient or image. using (var surface = new Cairo.ImageSurface(Cairo.Format.Argb32, RenderSurfaceWidth, RenderSurfaceHeight)) using (var context = new Cairo.Context(surface)) { context.SetSourceRGBA(1, 1, 1, 1); context.Rectangle(0, 0, RenderSurfaceWidth, RenderSurfaceHeight); context.Fill(); // The background color must be from the main Window because entry uses a different color. parent.StyleContext.RenderBackground(context, 0, 0, RenderSurfaceWidth, RenderSurfaceHeight); DefaultBackgroundColor = ToThemeColor(surface.Data); context.SetSourceRGBA(1, 1, 1, 1); context.Rectangle(0, 0, RenderSurfaceWidth, RenderSurfaceHeight); context.Fill(); // Use the background color of the list box row when selected as the text box frame color because they are the // same in the default theme. row.StyleContext.RenderBackground(context, 0, 0, RenderSurfaceWidth, RenderSurfaceHeight); DefaultBorderColor = ToThemeColor(surface.Data); } // Use the border color as the text selection color. SelectionBackgroundColor = DefaultBorderColor; }
public override string ToString() { if (ColorType == XLColorType.Color) { return(Color.ToHex()); } if (ColorType == XLColorType.Theme) { return(String.Format("Color Theme: {0}, Tint: {1}", ThemeColor.ToString(), ThemeTint.ToString())); } return("Color Index: " + Indexed); }
private Color ToColor(ThemeColor color, byte?overrideAlpha = null, bool flipRgb = false) { var a = (byte)(color.A * 255); var r = (byte)(color.R * 255); var g = (byte)(color.G * 255); var b = (byte)(color.B * 255); if (flipRgb) { r = (byte)(255 - r); g = (byte)(255 - g); b = (byte)(255 - b); } return(Color.FromRgba(r, g, b, overrideAlpha.GetValueOrDefault(a))); }
public override IEnumerable <Tuple <object, object> > GetResourceKeyValues(ThemeColor hlColor) { var br = new LinearGradientBrush() { StartPoint = StartPoint, EndPoint = EndPoint, }; for (int i = 0; i < GradientOffsets.Length; i++) { var gs = new GradientStop(((SolidColorBrush)hlColor.GetBrushByIndex(i)).Color, GradientOffsets[i]); gs.Freeze(); br.GradientStops.Add(gs); } br.Freeze(); yield return(new Tuple <object, object>(ResourceKey, br)); }
/// <summary> /// Initializes a new instance of the application configuration file. /// </summary> public ConfigurationFile() { LanguageCode = "en"; ThemeColor = new ThemeColor { R = 37, G = 0, B = 64 }; PlayShortcut = -1; RecordShortcut = -1; CaptureShortcut = -1; CaptureWidth = 100; CaptureHeight = 100; Offset = "50,50"; FilePrefix = "img"; AppendScript = true; }
private void ActivateButton(object btnSender) { if (btnSender != null) { if (currentButton != (Button)btnSender) { DisableButton(); Color color = SelectThemeColor(); currentButton = (Button)btnSender; currentButton.BackColor = color; currentButton.ForeColor = Color.White; currentButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); panelTitleBar.BackColor = color; ThemeColor.PrimaryColor = color; ThemeColor.SecondaryColor = ThemeColor.ChangeColorBrightness(color, -0.3); } } }
private void ActiveButton(object btnSender) { if (btnSender != null) { if (currentBtnCategory != (Button)btnSender) { DisableButton(); currentBtnCategory = (Button)btnSender; Color color = SelectThemeColor(); currentBtnCategory.BackColor = color; currentBtnCategory.ForeColor = Color.White; currentBtnCategory.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); panelLogo.BackColor = ThemeColor.ChangeColorBrightness(color, -0.3); panelTitle.BackColor = color; lbTitle.Text = currentBtnCategory.Text; } } }
public UnderConstructionMessage(string name) { Size = new Vector2(0.3f); Child = TextContainer = new FillFlowContainer { AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Direction = FillDirection.Vertical, Children = new Drawable[] { new SpriteIcon { Icon = FontAwesome.Solid.UniversalAccess, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Size = new Vector2(50), }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = name, Colour = ThemeColor.Lighten(0.8f), Font = OsuFont.GetFont(size: 36), }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "this preview is not yet ready for use!", Font = OsuFont.GetFont(size: 20), }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "please check back a bit later.", Font = OsuFont.GetFont(size: 14), }, } }; }
//Kích Hoạt Nút Bấm - Có Đổi Màu private void ActivateButton(object btnSender) { if (btnSender != null) { if (currentButton != (Button)btnSender) { DisableButton(); Color color = SelectThemeColor(); currentButton = (Button)btnSender; currentButton.BackColor = color; currentButton.ForeColor = Color.White; currentButton.Font = new Font("Monotype Corsiva", 24F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); panelTitleBar.BackColor = color; panelLogo.BackColor = ThemeColor.ChangeColorBrightness(color, -0.3); ThemeColor.PrimaryColor = color; ThemeColor.SecondaryColor = ThemeColor.ChangeColorBrightness(color, -0.3); } } }
/// <summary> /// Applies the theme with the accent color to the specified dictionary. /// </summary> /// <param name="theme">The theme.</param> /// <param name="accent">The accent.</param> /// <param name="dictionary">The dictionary to apply. If <code>null</code> then the application's resource dictionary is used if possible.</param> /// <exception cref="System.ArgumentNullException">accent</exception> /// <exception cref="System.NotSupportedException">No application resource dictionary found.</exception> public static void ApplyTheme(ThemeColor theme, Accent accent, ResourceDictionary dictionary) { if (accent == null) { throw new ArgumentNullException("accent"); } if (dictionary == null) { if (Application.Current == null) { throw new NotSupportedException("No application resource dictionary found."); } dictionary = Application.Current.Resources; } _curAccent = accent; CurrentTheme = theme; ApplyResources(theme == ThemeColor.Light ? LIGHT_THEME : DARK_THEME, dictionary); dictionary["ModernAccent"] = accent.MainBrush; dictionary["ModernAccentDark1"] = accent.DarkBrush1; dictionary["ModernAccentDark2"] = accent.DarkBrush2; dictionary["ModernAccentDark3"] = accent.DarkBrush3; dictionary["ModernAccentDark4"] = accent.DarkBrush4; dictionary["ModernAccentLight1"] = accent.LightBrush1; dictionary["ModernAccentLight2"] = accent.LightBrush2; dictionary["ModernAccentLight3"] = accent.LightBrush3; dictionary["ModernAccentLight4"] = accent.LightBrush4; dictionary["ModernAccentAlpha1"] = accent.AlphaBrush1; dictionary["ModernAccentAlpha2"] = accent.AlphaBrush2; dictionary["ModernAccentAlpha3"] = accent.AlphaBrush3; dictionary["ModernAccentAlpha4"] = accent.AlphaBrush4; dictionary["ModernAccentAlpha5"] = accent.AlphaBrush5; dictionary["ModernAccentAlpha6"] = accent.AlphaBrush6; dictionary["ModernAccentAlpha7"] = accent.AlphaBrush7; dictionary["ModernAccentAlpha8"] = accent.AlphaBrush8; dictionary["ModernAccentAlpha9"] = accent.AlphaBrush9; }
private Color GetThemeColor(ThemeColor color) { switch (color) { case ThemeColor.Primary: return(FizzTheme.FizzThemeData.Primary); case ThemeColor.Secondary: return(FizzTheme.FizzThemeData.Secondary); case ThemeColor.Base_1: return(FizzTheme.FizzThemeData.Base_1); case ThemeColor.Base_2: return(FizzTheme.FizzThemeData.Base_2); default: return(FizzTheme.FizzThemeData.Base_2); } }
private void ActivateButton(object btnSender) { if (btnSender != null) { if (currentButton != (Button)btnSender) { DisableButton(); Color color = SelectThemeColor(); currentButton = (Button)btnSender; currentButton.BackColor = color; currentButton.ForeColor = Color.White; currentButton.Font = new System.Drawing.Font("Elianto", 15.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); panelTitleBar.BackColor = color; panelLogo.BackColor = ThemeColor.ChangeColorBrightness(color, -0.3); ThemeColor.PrimaryColor = color; ThemeColor.SecondaryColor = ThemeColor.ChangeColorBrightness(color, -0.3); btnCloseChildForm.Visible = true; } } }
/* Add method for PerformThemeMenuAction*/ public static void PerformThemeMenuAction(int button) { switch (button) { case THEME_MENU_PINK_BUTTON: GameController.DrawScreen(ThemeColor.Pink); clr = ThemeColor.Pink; break; case THEME_MENU_GREEN_BUTTON: GameController.DrawScreen(ThemeColor.Green); clr = ThemeColor.Green; break; case THEME_MENU_BLUE_BUTTON: GameController.DrawScreen(ThemeColor.Blue); clr = ThemeColor.Blue; break; } }
private void UpdateThemes() { if (themeColors == null) { var themes = Enum.GetValues(typeof(UITheme)); themeColors = new ThemeColor[themes.Length]; int i = 0; foreach (UITheme theme in themes) { themeColors[i++] = new ThemeColor(theme); } UnityEditor.EditorUtility.SetDirty(this); UnityEditor.AssetDatabase.SaveAssets(); } else { if (themeColors.Length != UIThemes.Length) { var themes = Enum.GetValues(typeof(UITheme)); var updatedThemes = new ThemeColor[themes.Length]; int i = 0; foreach (UITheme theme in themes) { var existentTheme = Find(theme, themeColors); updatedThemes[i++] = existentTheme ?? new ThemeColor(theme); } themeColors = updatedThemes; UnityEditor.EditorUtility.SetDirty(this); UnityEditor.AssetDatabase.SaveAssets(); } } }
public void SwitchTheme(ThemeColor theme) { switch (theme) { case ThemeColor.BLUE: OriginalColor = Color.DodgerBlue; SlideColor = Color.Aqua; break; case ThemeColor.RED: OriginalColor = Color.Red; SlideColor = Color.FromArgb(redSlideColor.RValue, redSlideColor.GValue, redSlideColor.BValue);; break; case ThemeColor.GREEN: OriginalColor = Color.LimeGreen; SlideColor = Color.FromArgb(greenSlideColor.RValue, greenSlideColor.GValue, greenSlideColor.BValue);; break; case ThemeColor.ORANGE: OriginalColor = Color.Orange; SlideColor = Color.FromArgb(orangeSlideColor.RValue, orangeSlideColor.GValue, orangeSlideColor.BValue); break; case ThemeColor.YELLOW: OriginalColor = Color.Gold; SlideColor = Color.FromArgb(yellowSlideColor.RValue, yellowSlideColor.GValue, yellowSlideColor.BValue);; break; default: OriginalColor = Color.DodgerBlue; SlideColor = Color.Aqua; break; } }
void Start() { instance_ = this; Base = this.BaseColors[0]; Theme = this.ThemeColors[0]; }
public static Theme GetTheme(ThemeColor color) { return (themes[(int)color]); }
public ThemeMessage(ThemeColor color) { Color = color; }
// 修改记录 02 结束 /// <summary> /// 将DataTable中的数据写入到EXCEL的WorkBook中 /// </summary> /// <param name="workBook">需要写入的workBook</param> /// <param name="dt">DataTable(数据源) 传递过来的数据从1开始算起</param> /// <param name="iSheetStart">传递过来Sheet页数,数据从1开始算起</param> /// <returns>写入后的WorkBook</returns> private Workbook FillDataExcel(Workbook workBook, DataTable dt, int iSheetStart) { // 1. 每页写入的数据 // 1.a 总的数据 long totalRows = dt.Rows.Count; // 1.b 向上取整得到共需要多少个sheet页存放数据 int sheetsCount = int.Parse(Convert.ToString(Math.Ceiling((decimal)totalRows / (decimal)EXCEL_MAX_LINE))); // 1.d 定义workSheet, Worksheet workSheet; string workSheetName = "Sheet"; bool IsDataWriteTemplate = false; //2.循环写入数据 for (int i = 0; i < sheetsCount; i++) { // (1)模板+第一页 if (iSheetStart > 0 && i == 0) { workSheet = workBook.Worksheets[iSheetStart - 1]; // 获取当前的Sheet名称 workSheetName = workSheet.Name; // 写入模板 IsDataWriteTemplate = true; } // (2)模板 + 第N页(N>1) else if (iSheetStart > 0 && i > 0) { workBook.Worksheets.Add(workSheetName + i.ToString()); workSheet = workBook.Worksheets[workSheetName + i.ToString()]; workSheet.AutoFitColumns(); // 拷贝第一行数据(即为行标题) workSheet.Cells.CopyRow(workBook.Worksheets[iSheetStart - 1].Cells, 0, 0); // 写入模板 IsDataWriteTemplate = true; } // (3) 非模板 else { try { //workBook.Worksheets.Clear(); if (workBook.Worksheets[workSheetName + (i + 1).ToString()] == null) { workBook.Worksheets.Add(workSheetName + (i + 1).ToString()); } } catch { } workSheet = workBook.Worksheets[workSheetName + (i + 1).ToString()]; workSheet.AutoFitColumns(); // 写入模板 IsDataWriteTemplate = false; } // 2.b 列索引,行索引,总列数,总行数 int colIndex = 0; int RowIndex = 0; int colCount = dt.Columns.Count; int RowCount; // 2.c 如果dt的总行数比Excel最后一页最后一笔数据的行号要小 if (dt.Rows.Count < (i + 1) * EXCEL_MAX_LINE) { RowCount = dt.Rows.Count; } else { RowCount = (i + 1) * EXCEL_MAX_LINE; } // 2.d 相关数据 // 创建数据缓存 object[,] objData; // 列 int j; // 需要写入EXCEL的其实行 int iStartRow; // (1) 写入模板 if (IsDataWriteTemplate) { // 模板中最大的行是 2000行 if (RowCount <= 2000) { objData = new object[2000, colCount]; } else { objData = new object[RowCount, colCount]; } // objData 存储数据 从0 开始 j = 0; // 写入EXCEL,从第二行开始 iStartRow = 1; } // (2) 写入EXCEL 非模板 else { objData = new object[RowCount + 1, colCount]; // 写入列数据 foreach (DataColumn dc in dt.Columns) { objData[RowIndex, colIndex++] = dc.ColumnName; } // objData 存在列标题,则存储数据 从1 开始 j = 1; // 写入EXCEL ,从第一行开始写入 iStartRow = 0; } // 获取数据 for (RowIndex = i * EXCEL_MAX_LINE; RowIndex < RowCount; RowIndex++, j++) { for (colIndex = 0; colIndex < colCount; colIndex++) { objData[j, colIndex] = "'" + dt.Rows[RowIndex][colIndex].ToString(); } } // 3.写入EXCEL workSheet.Cells.ImportTwoDimensionArray(objData, iStartRow, 0, true); // 修改记录 01 开始 // 4,非模板数据的设置列字段的显示格式 if (IsDataWriteTemplate == false) { for (int k = 0; k < dt.Columns.Count; k++) { //字段名称字体样式 Cell cell = workSheet.Cells[0, k]; Style style = new Style(); // 字体黑体 style.Font.IsBold = true; style.Font.Size = 10; // 背景色设置的颜色 ThemeColor thecolor = new ThemeColor(ThemeColorType.Accent3, 5.00); //style.ForegroundThemeColor = thecolor; //style.BackgroundThemeColor = thecolor; style.ForegroundColor = System.Drawing.Color.Orange; style.Pattern = BackgroundType.Solid; // 居中垂直对齐 style.VerticalAlignment = TextAlignmentType.Right; // 边框设置 style.Borders.DiagonalStyle = CellBorderType.None; style.Borders.SetColor(System.Drawing.Color.Black); cell.SetStyle(style); workSheet.AutoFitColumn(k);// 列宽自动调整 } } // 修改记录 01 结束 }// end of for (int i = 0; i < sheetsCount; i++) return(workBook); }
/// <summary> /// Returns a color defined on the part associated with this renderer. /// </summary> /// <param name="state">The theme state constant for which the color is defined.</param> /// <param name="color">One of the <see cref="ThemeColor"/> constants, which determines the color to return.</param> /// <returns></returns> public Color GetColor(int state, ThemeColor color) { return GetColorCore(state, (int)color); }
public ThemeViewModel(ThemeColor color) { Color = color; Brush = GetBrush(color); }
protected override void AfterLoadInternal(Stack <ObjectModel> objectModels) { base.AfterLoadInternal(objectModels); MarkupObjectModel mom = (objectModels.Pop() as MarkupObjectModel); ThemeObjectModel themes = (objectModels.Pop() as ThemeObjectModel); MarkupTagElement tagThemes = (mom.FindElement("AwesomeControls", "Theming", "Themes") as MarkupTagElement); if (tagThemes != null) { foreach (MarkupElement elTheme in tagThemes.Elements) { MarkupTagElement tagTheme = (elTheme as MarkupTagElement); if (tagTheme == null) { continue; } MarkupAttribute attThemeID = tagTheme.Attributes["ID"]; if (attThemeID == null) { continue; } Theme theme = new Theme(); UniversalEditor.Accessors.FileAccessor fa = (this.Accessor as UniversalEditor.Accessors.FileAccessor); if (fa != null) { theme.BasePath = System.IO.Path.GetDirectoryName(fa.FileName); } theme.ID = new Guid(attThemeID.Value); MarkupAttribute attInheritsThemeID = tagTheme.Attributes["InheritsThemeID"]; if (attInheritsThemeID != null) { theme.InheritsThemeID = new Guid(attInheritsThemeID.Value); } MarkupTagElement tagInformation = (tagTheme.Elements["Information"] as MarkupTagElement); if (tagInformation != null) { MarkupTagElement tagInformationTitle = (tagInformation.Elements["Title"] as MarkupTagElement); if (tagInformationTitle != null) { theme.Title = tagInformationTitle.Value; } } MarkupTagElement tagMetrics = (tagTheme.Elements["Metrics"] as MarkupTagElement); if (tagMetrics != null) { foreach (MarkupElement elMetric in tagMetrics.Elements) { MarkupTagElement tagMetric = (elMetric as MarkupTagElement); if (tagMetric == null) { continue; } MarkupAttribute attMetricName = tagMetric.Attributes["Name"]; if (attMetricName == null) { continue; } switch (tagMetric.FullName.ToLower()) { case "paddingmetric": { PaddingMetric metric = new PaddingMetric(); metric.Name = attMetricName.Value; MarkupAttribute attMetricLeft = tagMetric.Attributes["Left"]; if (attMetricLeft != null) { metric.Left = Single.Parse(attMetricLeft.Value); } MarkupAttribute attMetricTop = tagMetric.Attributes["Top"]; if (attMetricTop != null) { metric.Top = Single.Parse(attMetricTop.Value); } MarkupAttribute attMetricBottom = tagMetric.Attributes["Bottom"]; if (attMetricBottom != null) { metric.Bottom = Single.Parse(attMetricBottom.Value); } MarkupAttribute attMetricRight = tagMetric.Attributes["Right"]; if (attMetricRight != null) { metric.Right = Single.Parse(attMetricRight.Value); } theme.Metrics.Add(metric); break; } } } } MarkupTagElement tagColors = (tagTheme.Elements["Colors"] as MarkupTagElement); if (tagColors != null) { foreach (MarkupElement elColor in tagColors.Elements) { MarkupTagElement tagColor = (elColor as MarkupTagElement); if (tagColor == null) { continue; } if (tagColor.FullName != "Color") { continue; } MarkupAttribute attColorID = tagColor.Attributes["ID"]; MarkupAttribute attColorName = tagColor.Attributes["Name"]; if (attColorID == null && attColorName == null) { continue; } MarkupAttribute attColorValue = tagColor.Attributes["Value"]; if (attColorValue == null) { continue; } ThemeColor color = new ThemeColor(); if (attColorID != null) { color.ID = new Guid(attColorID.Value); } if (attColorName != null) { color.Name = attColorName.Value; } if (attColorValue != null) { color.Value = attColorValue.Value; } theme.Colors.Add(color); } } MarkupTagElement tagFonts = (tagTheme.Elements["Fonts"] as MarkupTagElement); if (tagFonts != null) { foreach (MarkupElement elFont in tagFonts.Elements) { MarkupTagElement tagFont = (elFont as MarkupTagElement); if (tagFont == null) { continue; } if (tagFont.FullName != "Font") { continue; } MarkupAttribute attFontName = tagFont.Attributes["Name"]; if (attFontName == null) { continue; } MarkupAttribute attFontValue = tagFont.Attributes["Value"]; if (attFontValue == null) { continue; } ThemeFont font = new ThemeFont(); font.Name = attFontName.Value; font.Value = attFontValue.Value; theme.Fonts.Add(font); } } MarkupTagElement tagStockImages = (tagTheme.Elements["StockImages"] as MarkupTagElement); if (tagStockImages != null) { foreach (MarkupElement elStockImage in tagStockImages.Elements) { MarkupTagElement tagStockImage = (elStockImage as MarkupTagElement); if (tagStockImage == null) { continue; } if (tagStockImage.FullName != "StockImage") { continue; } MarkupAttribute attStockImageName = tagStockImage.Attributes["Name"]; if (attStockImageName == null) { continue; } MarkupAttribute attStockImageFileName = tagStockImage.Attributes["FileName"]; if (attStockImageFileName == null) { continue; } ThemeStockImage stockImage = new ThemeStockImage(); stockImage.Name = attStockImageName.Value; stockImage.ImageFileName = attStockImageFileName.Value; theme.StockImages.Add(stockImage); } } MarkupTagElement tagProperties = (tagTheme.Elements["Properties"] as MarkupTagElement); if (tagProperties != null) { foreach (MarkupElement elProperty in tagProperties.Elements) { MarkupTagElement tagProperty = (elProperty as MarkupTagElement); if (tagProperty == null) { continue; } if (tagProperty.FullName != "Property") { continue; } MarkupAttribute attName = tagProperty.Attributes["Name"]; if (attName == null) { continue; } ThemeProperty property = new ThemeProperty(); property.Name = attName.Value; MarkupAttribute attValue = tagProperty.Attributes["Value"]; if (attValue != null) { property.Value = attValue.Value; } theme.Properties.Add(property); } } MarkupTagElement tagComponents = (tagTheme.Elements["Components"] as MarkupTagElement); if (tagComponents != null) { foreach (MarkupElement elComponent in tagComponents.Elements) { MarkupTagElement tagComponent = (elComponent as MarkupTagElement); if (tagComponent == null) { continue; } if (tagComponent.FullName != "Component") { continue; } MarkupAttribute attComponentID = tagComponent.Attributes["ID"]; if (attComponentID == null) { continue; } ThemeComponent component = new ThemeComponent(); component.ID = new Guid(attComponentID.Value); MarkupAttribute attInheritsComponentID = tagComponent.Attributes["InheritsComponentID"]; if (attInheritsComponentID != null) { component.InheritsComponentID = new Guid(attInheritsComponentID.Value); } MarkupTagElement tagComponentStates = (tagComponent.Elements["States"] as MarkupTagElement); if (tagComponentStates != null) { // if States is specified, only apply to specific states foreach (MarkupElement elState in tagComponentStates.Elements) { MarkupTagElement tagState = (elState as MarkupTagElement); if (tagState == null) { continue; } if (tagState.FullName != "State") { continue; } MarkupAttribute attStateID = tagState.Attributes["ID"]; if (attStateID == null) { continue; } ThemeComponentState state = new ThemeComponentState(); state.ID = new Guid(attStateID.Value); MarkupAttribute attStateName = tagState.Attributes["Name"]; if (attStateName != null) { state.Name = attStateName.Value; } component.States.Add(state); } } MarkupTagElement tagRenderings = (tagComponent.Elements["Renderings"] as MarkupTagElement); if (tagRenderings != null) { foreach (MarkupElement elRendering in tagRenderings.Elements) { MarkupTagElement tagRendering = (elRendering as MarkupTagElement); if (tagRendering == null) { continue; } if (tagRendering.FullName != "Rendering") { continue; } MarkupTagElement tagRenderingActions = (tagRendering.Elements["Actions"] as MarkupTagElement); if (tagRenderingActions == null) { continue; } Rendering rendering = new Rendering(); foreach (MarkupElement elRenderingAction in tagRenderingActions.Elements) { MarkupTagElement tagRenderingAction = (elRenderingAction as MarkupTagElement); if (tagRenderingAction == null) { continue; } switch (tagRenderingAction.FullName) { case "Rectangle": { MarkupAttribute attX = tagRenderingAction.Attributes["X"]; MarkupAttribute attY = tagRenderingAction.Attributes["Y"]; MarkupAttribute attWidth = tagRenderingAction.Attributes["Width"]; MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"]; RectangleRenderingAction item = new RectangleRenderingAction(); item.X = RenderingExpression.Parse(attX.Value); item.Y = RenderingExpression.Parse(attY.Value); item.Width = RenderingExpression.Parse(attWidth.Value); item.Height = RenderingExpression.Parse(attHeight.Value); item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement); item.Fill = FillFromTag(tagRenderingAction.Elements["Fill"] as MarkupTagElement); rendering.Actions.Add(item); break; } case "Line": { LineRenderingAction item = new LineRenderingAction(); MarkupAttribute attX1 = tagRenderingAction.Attributes["X1"]; if (attX1 != null) { item.X1 = RenderingExpression.Parse(attX1.Value); } MarkupAttribute attX2 = tagRenderingAction.Attributes["X2"]; if (attX2 != null) { item.X2 = RenderingExpression.Parse(attX2.Value); } MarkupAttribute attY1 = tagRenderingAction.Attributes["Y1"]; if (attY1 != null) { item.Y1 = RenderingExpression.Parse(attY1.Value); } MarkupAttribute attY2 = tagRenderingAction.Attributes["Y2"]; if (attY2 != null) { item.Y2 = RenderingExpression.Parse(attY2.Value); } item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement); rendering.Actions.Add(item); break; } case "Text": { MarkupAttribute attX = tagRenderingAction.Attributes["X"]; MarkupAttribute attY = tagRenderingAction.Attributes["Y"]; MarkupAttribute attWidth = tagRenderingAction.Attributes["Width"]; MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"]; if (attX == null || attY == null) { continue; } MarkupAttribute attHorizontalAlignment = tagRenderingAction.Attributes["HorizontalAlignment"]; MarkupAttribute attVerticalAlignment = tagRenderingAction.Attributes["VerticalAlignment"]; TextRenderingAction item = new TextRenderingAction(); item.X = RenderingExpression.Parse(attX.Value); item.Y = RenderingExpression.Parse(attY.Value); if (attWidth != null) { item.Width = RenderingExpression.Parse(attWidth.Value); } if (attWidth != null) { item.Height = RenderingExpression.Parse(attHeight.Value); } if (attHorizontalAlignment != null) { switch (attHorizontalAlignment.Value.ToLower()) { case "center": { item.HorizontalAlignment = HorizontalAlignment.Center; break; } case "justify": { item.HorizontalAlignment = HorizontalAlignment.Justify; break; } case "left": { item.HorizontalAlignment = HorizontalAlignment.Left; break; } case "right": { item.HorizontalAlignment = HorizontalAlignment.Right; break; } } } if (attVerticalAlignment != null) { switch (attVerticalAlignment.Value.ToLower()) { case "bottom": { item.VerticalAlignment = VerticalAlignment.Bottom; break; } case "middle": { item.VerticalAlignment = VerticalAlignment.Middle; break; } case "top": { item.VerticalAlignment = VerticalAlignment.Top; break; } } } MarkupAttribute attColor = tagRenderingAction.Attributes["Color"]; if (attColor != null) { item.Color = attColor.Value; } MarkupAttribute attFont = tagRenderingAction.Attributes["Font"]; if (attFont != null) { item.Font = attFont.Value; } MarkupAttribute attValue = tagRenderingAction.Attributes["Value"]; if (attValue != null) { item.Value = attValue.Value; } rendering.Actions.Add(item); break; } } } MarkupTagElement tagRenderingStates = (tagRendering.Elements["States"] as MarkupTagElement); if (tagRenderingStates != null) { // if States is specified, only apply to specific states foreach (MarkupElement elState in tagRenderingStates.Elements) { MarkupTagElement tagState = (elState as MarkupTagElement); if (tagState == null) { continue; } if (tagState.FullName != "State") { continue; } MarkupAttribute attStateID = tagState.Attributes["ID"]; if (attStateID == null) { continue; } ThemeComponentStateReference state = new ThemeComponentStateReference(); state.StateID = new Guid(attStateID.Value); rendering.States.Add(state); } } component.Renderings.Add(rendering); } } theme.Components.Add(component); } } themes.Themes.Add(theme); } } }
protected override void AfterLoadInternal(Stack<ObjectModel> objectModels) { base.AfterLoadInternal(objectModels); MarkupObjectModel mom = (objectModels.Pop() as MarkupObjectModel); ThemeObjectModel themes = (objectModels.Pop() as ThemeObjectModel); MarkupTagElement tagThemes = (mom.FindElement("AwesomeControls", "Theming", "Themes") as MarkupTagElement); if (tagThemes != null) { foreach (MarkupElement elTheme in tagThemes.Elements) { MarkupTagElement tagTheme = (elTheme as MarkupTagElement); if (tagTheme == null) continue; MarkupAttribute attThemeID = tagTheme.Attributes["ID"]; if (attThemeID == null) continue; Theme theme = new Theme(); UniversalEditor.Accessors.FileAccessor fa = (this.Accessor as UniversalEditor.Accessors.FileAccessor); if (fa != null) theme.BasePath = System.IO.Path.GetDirectoryName(fa.FileName); theme.ID = new Guid(attThemeID.Value); MarkupAttribute attInheritsThemeID = tagTheme.Attributes["InheritsThemeID"]; if (attInheritsThemeID != null) theme.InheritsThemeID = new Guid(attInheritsThemeID.Value); MarkupTagElement tagInformation = (tagTheme.Elements["Information"] as MarkupTagElement); if (tagInformation != null) { MarkupTagElement tagInformationTitle = (tagInformation.Elements["Title"] as MarkupTagElement); if (tagInformationTitle != null) theme.Title = tagInformationTitle.Value; } MarkupTagElement tagMetrics = (tagTheme.Elements["Metrics"] as MarkupTagElement); if (tagMetrics != null) { foreach (MarkupElement elMetric in tagMetrics.Elements) { MarkupTagElement tagMetric = (elMetric as MarkupTagElement); if (tagMetric == null) continue; MarkupAttribute attMetricName = tagMetric.Attributes["Name"]; if (attMetricName == null) continue; switch (tagMetric.FullName.ToLower()) { case "paddingmetric": { PaddingMetric metric = new PaddingMetric(); metric.Name = attMetricName.Value; MarkupAttribute attMetricLeft = tagMetric.Attributes["Left"]; if (attMetricLeft != null) metric.Left = Single.Parse(attMetricLeft.Value); MarkupAttribute attMetricTop = tagMetric.Attributes["Top"]; if (attMetricTop != null) metric.Top = Single.Parse(attMetricTop.Value); MarkupAttribute attMetricBottom = tagMetric.Attributes["Bottom"]; if (attMetricBottom != null) metric.Bottom = Single.Parse(attMetricBottom.Value); MarkupAttribute attMetricRight = tagMetric.Attributes["Right"]; if (attMetricRight != null) metric.Right = Single.Parse(attMetricRight.Value); theme.Metrics.Add(metric); break; } } } } MarkupTagElement tagColors = (tagTheme.Elements["Colors"] as MarkupTagElement); if (tagColors != null) { foreach (MarkupElement elColor in tagColors.Elements) { MarkupTagElement tagColor = (elColor as MarkupTagElement); if (tagColor == null) continue; if (tagColor.FullName != "Color") continue; MarkupAttribute attColorID = tagColor.Attributes["ID"]; MarkupAttribute attColorName = tagColor.Attributes["Name"]; if (attColorID == null && attColorName == null) continue; MarkupAttribute attColorValue = tagColor.Attributes["Value"]; if (attColorValue == null) continue; ThemeColor color = new ThemeColor(); if (attColorID != null) color.ID = new Guid(attColorID.Value); if (attColorName != null) color.Name = attColorName.Value; if (attColorValue != null) color.Value = attColorValue.Value; theme.Colors.Add(color); } } MarkupTagElement tagFonts = (tagTheme.Elements["Fonts"] as MarkupTagElement); if (tagFonts != null) { foreach (MarkupElement elFont in tagFonts.Elements) { MarkupTagElement tagFont = (elFont as MarkupTagElement); if (tagFont == null) continue; if (tagFont.FullName != "Font") continue; MarkupAttribute attFontName = tagFont.Attributes["Name"]; if (attFontName == null) continue; MarkupAttribute attFontValue = tagFont.Attributes["Value"]; if (attFontValue == null) continue; ThemeFont font = new ThemeFont(); font.Name = attFontName.Value; font.Value = attFontValue.Value; theme.Fonts.Add(font); } } MarkupTagElement tagStockImages = (tagTheme.Elements["StockImages"] as MarkupTagElement); if (tagStockImages != null) { foreach (MarkupElement elStockImage in tagStockImages.Elements) { MarkupTagElement tagStockImage = (elStockImage as MarkupTagElement); if (tagStockImage == null) continue; if (tagStockImage.FullName != "StockImage") continue; MarkupAttribute attStockImageName = tagStockImage.Attributes["Name"]; if (attStockImageName == null) continue; MarkupAttribute attStockImageFileName = tagStockImage.Attributes["FileName"]; if (attStockImageFileName == null) continue; ThemeStockImage stockImage = new ThemeStockImage(); stockImage.Name = attStockImageName.Value; stockImage.ImageFileName = attStockImageFileName.Value; theme.StockImages.Add(stockImage); } } MarkupTagElement tagProperties = (tagTheme.Elements["Properties"] as MarkupTagElement); if (tagProperties != null) { foreach (MarkupElement elProperty in tagProperties.Elements) { MarkupTagElement tagProperty = (elProperty as MarkupTagElement); if (tagProperty == null) continue; if (tagProperty.FullName != "Property") continue; MarkupAttribute attName = tagProperty.Attributes["Name"]; if (attName == null) continue; ThemeProperty property = new ThemeProperty(); property.Name = attName.Value; MarkupAttribute attValue = tagProperty.Attributes["Value"]; if (attValue != null) property.Value = attValue.Value; theme.Properties.Add(property); } } MarkupTagElement tagComponents = (tagTheme.Elements["Components"] as MarkupTagElement); if (tagComponents != null) { foreach (MarkupElement elComponent in tagComponents.Elements) { MarkupTagElement tagComponent = (elComponent as MarkupTagElement); if (tagComponent == null) continue; if (tagComponent.FullName != "Component") continue; MarkupAttribute attComponentID = tagComponent.Attributes["ID"]; if (attComponentID == null) continue; ThemeComponent component = new ThemeComponent(); component.ID = new Guid(attComponentID.Value); MarkupAttribute attInheritsComponentID = tagComponent.Attributes["InheritsComponentID"]; if (attInheritsComponentID != null) component.InheritsComponentID = new Guid(attInheritsComponentID.Value); MarkupTagElement tagComponentStates = (tagComponent.Elements["States"] as MarkupTagElement); if (tagComponentStates != null) { // if States is specified, only apply to specific states foreach (MarkupElement elState in tagComponentStates.Elements) { MarkupTagElement tagState = (elState as MarkupTagElement); if (tagState == null) continue; if (tagState.FullName != "State") continue; MarkupAttribute attStateID = tagState.Attributes["ID"]; if (attStateID == null) continue; ThemeComponentState state = new ThemeComponentState(); state.ID = new Guid(attStateID.Value); MarkupAttribute attStateName = tagState.Attributes["Name"]; if (attStateName != null) state.Name = attStateName.Value; component.States.Add(state); } } MarkupTagElement tagRenderings = (tagComponent.Elements["Renderings"] as MarkupTagElement); if (tagRenderings != null) { foreach (MarkupElement elRendering in tagRenderings.Elements) { MarkupTagElement tagRendering = (elRendering as MarkupTagElement); if (tagRendering == null) continue; if (tagRendering.FullName != "Rendering") continue; MarkupTagElement tagRenderingActions = (tagRendering.Elements["Actions"] as MarkupTagElement); if (tagRenderingActions == null) continue; Rendering rendering = new Rendering(); foreach (MarkupElement elRenderingAction in tagRenderingActions.Elements) { MarkupTagElement tagRenderingAction = (elRenderingAction as MarkupTagElement); if (tagRenderingAction == null) continue; switch (tagRenderingAction.FullName) { case "Rectangle": { MarkupAttribute attX = tagRenderingAction.Attributes["X"]; MarkupAttribute attY = tagRenderingAction.Attributes["Y"]; MarkupAttribute attWidth = tagRenderingAction.Attributes["Width"]; MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"]; RectangleRenderingAction item = new RectangleRenderingAction(); item.X = RenderingExpression.Parse(attX.Value); item.Y = RenderingExpression.Parse(attY.Value); item.Width = RenderingExpression.Parse(attWidth.Value); item.Height = RenderingExpression.Parse(attHeight.Value); item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement); item.Fill = FillFromTag(tagRenderingAction.Elements["Fill"] as MarkupTagElement); rendering.Actions.Add(item); break; } case "Line": { LineRenderingAction item = new LineRenderingAction(); MarkupAttribute attX1 = tagRenderingAction.Attributes["X1"]; if (attX1 != null) { item.X1 = RenderingExpression.Parse(attX1.Value); } MarkupAttribute attX2 = tagRenderingAction.Attributes["X2"]; if (attX2 != null) { item.X2 = RenderingExpression.Parse(attX2.Value); } MarkupAttribute attY1 = tagRenderingAction.Attributes["Y1"]; if (attY1 != null) { item.Y1 = RenderingExpression.Parse(attY1.Value); } MarkupAttribute attY2 = tagRenderingAction.Attributes["Y2"]; if (attY2 != null) { item.Y2 = RenderingExpression.Parse(attY2.Value); } item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement); rendering.Actions.Add(item); break; } case "Text": { MarkupAttribute attX = tagRenderingAction.Attributes["X"]; MarkupAttribute attY = tagRenderingAction.Attributes["Y"]; MarkupAttribute attWidth = tagRenderingAction.Attributes["Width"]; MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"]; if (attX == null || attY == null) continue; MarkupAttribute attHorizontalAlignment = tagRenderingAction.Attributes["HorizontalAlignment"]; MarkupAttribute attVerticalAlignment = tagRenderingAction.Attributes["VerticalAlignment"]; TextRenderingAction item = new TextRenderingAction(); item.X = RenderingExpression.Parse(attX.Value); item.Y = RenderingExpression.Parse(attY.Value); if (attWidth != null) item.Width = RenderingExpression.Parse(attWidth.Value); if (attWidth != null) item.Height = RenderingExpression.Parse(attHeight.Value); if (attHorizontalAlignment != null) { switch (attHorizontalAlignment.Value.ToLower()) { case "center": { item.HorizontalAlignment = HorizontalAlignment.Center; break; } case "justify": { item.HorizontalAlignment = HorizontalAlignment.Justify; break; } case "left": { item.HorizontalAlignment = HorizontalAlignment.Left; break; } case "right": { item.HorizontalAlignment = HorizontalAlignment.Right; break; } } } if (attVerticalAlignment != null) { switch (attVerticalAlignment.Value.ToLower()) { case "bottom": { item.VerticalAlignment = VerticalAlignment.Bottom; break; } case "middle": { item.VerticalAlignment = VerticalAlignment.Middle; break; } case "top": { item.VerticalAlignment = VerticalAlignment.Top; break; } } } MarkupAttribute attColor = tagRenderingAction.Attributes["Color"]; if (attColor != null) item.Color = attColor.Value; MarkupAttribute attFont = tagRenderingAction.Attributes["Font"]; if (attFont != null) item.Font = attFont.Value; MarkupAttribute attValue = tagRenderingAction.Attributes["Value"]; if (attValue != null) item.Value = attValue.Value; rendering.Actions.Add(item); break; } } } MarkupTagElement tagRenderingStates = (tagRendering.Elements["States"] as MarkupTagElement); if (tagRenderingStates != null) { // if States is specified, only apply to specific states foreach (MarkupElement elState in tagRenderingStates.Elements) { MarkupTagElement tagState = (elState as MarkupTagElement); if (tagState == null) continue; if (tagState.FullName != "State") continue; MarkupAttribute attStateID = tagState.Attributes["ID"]; if (attStateID == null) continue; ThemeComponentStateReference state = new ThemeComponentStateReference(); state.StateID = new Guid(attStateID.Value); rendering.States.Add(state); } } component.Renderings.Add(rendering); } } theme.Components.Add(component); } } themes.Themes.Add(theme); } } }