/// <summary> /// загрузить свойство окна из реестра. /// </summary> /// <param name="window"></param> /// <param name="propertyName">имя свойства. такое же как в window</param> public static void LoadValue(System.Windows.Controls.Control window, string propertyName) { if (String.IsNullOrEmpty(window.GetType().Name)) { throw new Exception("Name is null!"); } var key = Registry.CurrentUser.OpenSubKey(Path.Combine(RegPath, window.GetType().Name)); LoadValue(key, window, propertyName); }
/// <summary> /// сохранить значение свойства в реестр /// </summary> public static void SaveValue(System.Windows.Controls.Control window, FrameworkContentElement control, string propertyName) { if (String.IsNullOrEmpty(window.GetType().Name) || String.IsNullOrEmpty(control.Name)) { throw new Exception("Name is null!"); } var path = Path.Combine(RegPath, window.GetType().Name, control.Name); var key = Registry.CurrentUser.CreateSubKey(path); SaveValue(key, control, propertyName); }
private Storyboard CreateFadingStoryBoard(System.Windows.Controls.Control target, double fromValue, double toValue, TimeSpan timespan, RepeatBehavior behavior) { // new TimeSpan(0, 0, 0, 0, 500); // fromValue = 1 // toValue = 0 DoubleAnimation fading = new DoubleAnimation(fromValue, toValue, timespan.Duration()); Storyboard.SetTarget(fading, target); Storyboard.SetTargetProperty(fading, new PropertyPath($"({target.GetType().Name}.Opacity)")); var result = new Storyboard() { AutoReverse = true }; if (behavior != null) { result.RepeatBehavior = behavior; } result.Children.Add(fading); return(result); }
/// <summary> /// загрузить свойство из реестра. /// </summary> /// <param name="window"></param> /// <param name="control"></param> /// <param name="propertyName">имя свойства. такое же как в control</param> public static void LoadValue(System.Windows.Controls.Control window, FrameworkElement control, string propertyName) { if (control.Name == null) { throw new Exception("Name is null!"); } var key = Registry.CurrentUser.OpenSubKey(Path.Combine(RegPath, window.GetType().Name, control.Name)); LoadValue(key, control, propertyName); }
public static void DoubleBuffered(this Control control, bool enable) { var doubleBufferPropertyInfo = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); doubleBufferPropertyInfo.SetValue(control, enable, null); }