/// <summary> /// Attaches the behavior. /// </summary> public void Attach(DependencyObject associatedObject) { this.associatedObject = associatedObject; if (!DesignModeHelper.IsInDesignMode(this)) { OnAttach(); } }
public static void InitializeAll() { DesignModeHelper.TurnOffDesignMode(); SkinManager.Default.RegisterAssembly(typeof(ZetaTestSkin).Assembly); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Below Windows Vista, use form skins. SkinManager.EnableFormSkinsIfNotVista(); //UserLookAndFeel.Default.ActiveLookAndFeel.SetSkinStyle(SkinNameDialogForms); UserLookAndFeel.Default.SetSkinStyle(SkinNameDialogForms); AppearanceObject.DefaultFont = StandardFont; _badc = new MyDefaultBarAndDockingController(); _badc.Apply(); }
static SkinHelper() { var hasMainFont = DesignModeHelper.IsFontInstalled(@"Segoe UI"); IsRealFontInstalled = hasMainFont; const int standardFontSizePixel = 13; var largeFontSizePixel = hasMainFont ? 17 : 16; const int smallFontSizePixel = 11; SmallFont = hasMainFont ? new Font(@"Segoe UI", smallFontSizePixel, GraphicsUnit.Pixel) : new Font(@"Tahoma", smallFontSizePixel, GraphicsUnit.Pixel); StandardFont = hasMainFont ? new Font(@"Segoe UI", standardFontSizePixel, GraphicsUnit.Pixel) : new Font(@"Tahoma", standardFontSizePixel, GraphicsUnit.Pixel); StandardFontBold = hasMainFont ? new Font(@"Segoe UI", standardFontSizePixel, FontStyle.Bold, GraphicsUnit.Pixel) : new Font(@"Tahoma", standardFontSizePixel, FontStyle.Bold, GraphicsUnit.Pixel); LargeFont = hasMainFont ? new Font(@"Segoe UI", largeFontSizePixel, GraphicsUnit.Pixel) : new Font(@"Tahoma", largeFontSizePixel, GraphicsUnit.Pixel); LargeFontBold = hasMainFont ? new Font(@"Segoe UI", largeFontSizePixel, FontStyle.Bold, GraphicsUnit.Pixel) : new Font(@"Tahoma", largeFontSizePixel, FontStyle.Bold, GraphicsUnit.Pixel); LargeFontUnderline = hasMainFont ? new Font(@"Segoe UI", largeFontSizePixel, FontStyle.Underline, GraphicsUnit.Pixel) : new Font(@"Tahoma", largeFontSizePixel, FontStyle.Underline, GraphicsUnit.Pixel); }
/// <summary> /// Attaches to the object. /// </summary> /// <param name="dependencyObject">The object to attach to</param> public void Attach(DependencyObject dependencyObject) { if (dependencyObject == null) { throw new ArgumentNullException(nameof(dependencyObject)); } if (!DesignModeHelper.IsInDesignMode(this)) { if (dependencyObject != this.AssociatedObject) { if (this.AssociatedObject != null) { throw new InvalidOperationException(); } base.WritePreamble(); this.associatedObject = dependencyObject; base.WritePostscript(); this.OnAttached(); } } }