示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        public static void DoubleBuffered(this Control control, bool enable)
        {
            var doubleBufferPropertyInfo = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);

            doubleBufferPropertyInfo.SetValue(control, enable, null);
        }