private void SetStyle(string name) { var defStyle = configSvc .GetDefaultPreferences() .Where(s => s.Name == name) .Single(); var snames = this.SettingNames[name]; float.TryParse(defStyle.PaddingTop, out float padTop); float.TryParse(defStyle.PaddingLeft, out float padLeft); float.TryParse(defStyle.PaddingBottom, out float padBottom); float.TryParse(defStyle.PaddingRight, out float padRight); var uiStyle = new UiStyle { Name = snames.Name, Foreground = GetBrush((string)settingsSvc.Get(snames.ForeColor, defStyle.ForeColor)), Background = GetBrush((string)settingsSvc.Get(snames.BackColor, defStyle.BackColor)), Font = GetFont((string)settingsSvc.Get(snames.FontName, defStyle.FontName)), Width = string.IsNullOrEmpty(defStyle.Width) ? default(int?) : Convert.ToInt32(defStyle.Width), PaddingLeft = padLeft, PaddingTop = padTop, PaddingRight = padRight, PaddingBottom = padBottom, }; AddStyle(uiStyle); }
public void SetUiStyle(UiStyle style) { _ = style switch { UiStyle.Dark => UiThemeDark.Setup(), _ => throw new NotImplementedException(), }; }
private Cursor GetCursor(string styleSelector) { UiStyle style = GetStyle(styleSelector); if (style != null && style.Cursor != null) { return(style.Cursor); } return(Cursors.Default); }
private Brush GetBackground(string styleSelector) { UiStyle style = GetStyle(styleSelector); if (style != null && style.Background != null) { return(style.Background); } return(CacheBrush(ref bgBrush, new SolidBrush(BackColor))); }
private Color GetForegroundColor(string styleSelector) { UiStyle style = GetStyle(styleSelector); if (style != null && style.Foreground != null) { return(style.Foreground.Color); } return(ForeColor); }
private Brush GetForeground(string styleSelector) { UiStyle style = GetStyle(styleSelector); if (style != null && style.Foreground != null) { return(style.Foreground); } return(CacheBrush(ref fgBrush, new SolidBrush(ForeColor))); }
/// <summary> /// Computes the size of a text span. /// </summary> /// <remarks> /// The span is first asked to measure itself, then the current style is /// allowed to override the size. /// </remarks> /// <param name="span"></param> /// <param name="text"></param> /// <param name="font"></param> /// <param name="g"></param> /// <returns></returns> private SizeF GetSize(TextSpan span, string text, Font font, Graphics g) { var size = span.GetSize(text, font, g); UiStyle style = GetStyle(span.Style); if (style != null && style.Width.HasValue) { size.Width = style.Width.Value; } return(size); }
/// <summary>获取基础设置参数 /// /// </summary> /// <returns></returns> private BaseParameter GetBaseParameter() { #region 获取参数 GetFileds(out m_strQueryColumns, lstQueryFileds); GetFileds(out m_strShowColumns, lstShowFileds); GetFileds(out m_strEditColumns, lstEditShowFileds); GetFileds(out m_strCheckInputColumns, lstCheckInputFileds); GetFileds(out m_strDontRepeatColumns, lstDontRepeatFileds); m_frameworkType = GetFrameworkType(); m_uiStyle = GetUiStyle(); m_listBindType = GetListBindType(); #endregion switch (m_codeGenType) { #region WinFromSimpleQuery case CodeGenType.WinFromSimpleQuery: m_baseParameter = new SimpleQueryParameter { QueryColumns = m_strQueryColumns, ShowColumns = m_strShowColumns, CodeGenType = m_codeGenType, DatabaseTable = m_databaseTable, FrameworkType = m_frameworkType, UiStyle = m_uiStyle, ListBindType = m_listBindType }; break; #endregion #region WinFromEditWithDialog case CodeGenType.WinFromEditWithDialog: m_baseParameter = new EditDialogParameter { QueryColumns = m_strQueryColumns, ShowColumns = m_strShowColumns, CodeGenType = m_codeGenType, DatabaseTable = m_databaseTable, FrameworkType = m_frameworkType, DontRepeatColumns = m_strDontRepeatColumns, CheckInputColumns = m_strCheckInputColumns, EditColumns = m_strEditColumns, UiStyle = m_uiStyle, ListBindType = m_listBindType }; break; #endregion #region WinFromTreeEditWithDialog case CodeGenType.WinFromTreeEditWithDialog: m_baseParameter = new TreeEditDialogParameter { QueryColumns = m_strQueryColumns, ShowColumns = m_strShowColumns, CodeGenType = m_codeGenType, DatabaseTable = m_databaseTable, FrameworkType = m_frameworkType, DontRepeatColumns = m_strDontRepeatColumns, CheckInputColumns = m_strCheckInputColumns, EditColumns = m_strEditColumns, UiStyle = m_uiStyle, ListBindType = m_listBindType, KeyId = txtKey.Text.Trim(), ParentId = txtParentKey.Text.Trim() }; break; #endregion } return(m_baseParameter); }
private void AddStyle(UiStyle s) { Styles[s.Name] = s; }
private void SetGlobal(BaseParameter baseParameter) { switch (baseParameter.CodeGenType) { #region WinFromSimpleQuery case CodeGenType.WinFromSimpleQuery: SimpleQueryParameter simpleQueryParameter = baseParameter as SimpleQueryParameter; if (simpleQueryParameter != null) { m_strQueryColumns = simpleQueryParameter.QueryColumns; m_strShowColumns = simpleQueryParameter.ShowColumns; m_databaseTable = simpleQueryParameter.DatabaseTable; m_codeGenType = simpleQueryParameter.CodeGenType; m_frameworkType = simpleQueryParameter.FrameworkType; m_uiStyle = simpleQueryParameter.UiStyle; m_listBindType = simpleQueryParameter.ListBindType; gridVEdit.Visible = false; tabPageEdit.Parent = null; tabPageEdit.Hide(); gridVShow.Visible = true; tabPageShow.Parent = tabControl1; tabPageShow.Show(); } break; #endregion #region WinFromEditWithDialog/WinFromTreeEditWithDialog case CodeGenType.WinFromEditWithDialog: case CodeGenType.WinFromTreeEditWithDialog: EditDialogParameter editDialogParameter = baseParameter as EditDialogParameter; if (editDialogParameter != null) { m_strQueryColumns = editDialogParameter.QueryColumns; m_strShowColumns = editDialogParameter.ShowColumns; m_databaseTable = editDialogParameter.DatabaseTable; m_codeGenType = editDialogParameter.CodeGenType; m_frameworkType = editDialogParameter.FrameworkType; m_uiStyle = editDialogParameter.UiStyle; m_listBindType = editDialogParameter.ListBindType; m_strEditColumns = editDialogParameter.EditColumns; m_strCheckInputColumns = editDialogParameter.CheckInputColumns; m_strDontRepeatColumns = editDialogParameter.DontRepeatColumns; gridVEdit.Visible = true; tabPageEdit.Parent = tabControl1; tabPageEdit.Show(); gridVShow.Visible = true; tabPageShow.Parent = tabControl1; tabPageShow.Show(); } break; #endregion #region WinFromNestQuery case CodeGenType.WinFromNestQuery: NestQueryParameter nestQueryParameter = baseParameter as NestQueryParameter; if (nestQueryParameter != null) { m_strQueryColumns = nestQueryParameter.QueryColumns; m_codeGenType = nestQueryParameter.CodeGenType; gridVEdit.Visible = false; tabPageShow.Parent = null; tabPageShow.Hide(); gridVShow.Visible = false; tabPageEdit.Parent = null; tabPageEdit.Hide(); } break; #endregion #region WinFromParentChildEditWithDialog case CodeGenType.WinFromParentChildEditWithDialog: ParentChildEditDialogParameter parentChildDialogParameter = baseParameter as ParentChildEditDialogParameter; if (parentChildDialogParameter != null) { m_databaseTable = parentChildDialogParameter.DatabaseTable; m_codeGenType = parentChildDialogParameter.CodeGenType; m_frameworkType = parentChildDialogParameter.FrameworkType; m_uiStyle = parentChildDialogParameter.UiStyle; m_listBindType = parentChildDialogParameter.ListBindType; m_strQueryColumns = parentChildDialogParameter.QueryColumns; m_strShowColumns = parentChildDialogParameter.ShowColumns; m_strEditColumns = parentChildDialogParameter.EditColumns; m_strCheckInputColumns = parentChildDialogParameter.CheckInputColumns; m_strDontRepeatColumns = parentChildDialogParameter.DontRepeatColumns; m_strShowColumnsDetail = parentChildDialogParameter.ShowColumnsDetail; m_strEditColumnsDetail = parentChildDialogParameter.EditColumnsDetail; m_strCheckInputColumnsDetail = parentChildDialogParameter.CheckInputColumnsDetail; m_strDontRepeatColumnsDetail = parentChildDialogParameter.DontRepeatColumnsDetail; m_databaseTableDetail = parentChildDialogParameter.DatabaseTableDetail; m_strKeyMaster = parentChildDialogParameter.KeyMaster; m_strKeyDetail = parentChildDialogParameter.KeyDetail; gridVEdit.Visible = true; tabPageEdit.Parent = tabControl1; tabPageEdit.Show(); gridVShow.Visible = true; tabPageShow.Parent = tabControl1; tabPageShow.Show(); } break; #endregion } if (baseParameter.CodeGenType != CodeGenType.WinFromParentChildEditWithDialog) { tabPageEditDetail.Parent = null; tabPageShowDetail.Parent = null; tabPageEditDetail.Hide(); tabPageShowDetail.Hide(); } else { tabPageEditDetail.Parent = tabControl1; tabPageShowDetail.Parent = tabControl1; tabPageEditDetail.Show(); tabPageShowDetail.Show(); } }
protected override void InitStyle(UiStyle style) { base.InitStyle(style); this.font = style.Font; this.textScale = style.TextScale; }