Esempio n. 1
0
        }         // WindowClosing

        // ----------------------------------------------------------------------
        private static void OnFrameworkElementSettingsChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement frameworkElement = dependencyObject as FrameworkElement;

            if (frameworkElement == null)
            {
                Debug.WriteLine("FrameworkElementSettings: invalid framework element");
                return;
            }

            if (frameworkElement.GetValue(DependencyPropertySetting.ApplicationSettingsProperty) != null)
            {
                return;                 // framework-element contains already an application setting
            }

            string settingsKey = e.NewValue as string;

            if (string.IsNullOrEmpty(settingsKey))
            {
                Debug.WriteLine("FrameworkElementSettings: missing framework element settings key");
                return;
            }

            // create and attach the application settings to the framework-element
            FrameworkElementSettings frameworkElementSettings = new FrameworkElementSettings(frameworkElement, settingsKey);

            frameworkElement.SetValue(DependencyPropertySetting.ApplicationSettingsProperty, frameworkElementSettings);
        }         // OnFrameworkElementSettingsChanged
Esempio n. 2
0
        }         // OnFrameworkElementSettingsChanged

        // ----------------------------------------------------------------------
        private static void OnCollectedSettingChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement frameworkElement = dependencyObject as FrameworkElement;

            if (frameworkElement == null)
            {
                Debug.WriteLine("FrameworkElementSettings: invalid framework element");
                return;
            }

            DependencyProperty dependencyProperty = e.NewValue as DependencyProperty;

            if (dependencyProperty == null)
            {
                Debug.WriteLine("FrameworkElementSettings: missing dependency property");
                return;
            }

            // search the framework element settings
            FrameworkElementSettings frameworkElementSettings =
                frameworkElement.ReadLocalValue(DependencyPropertySetting.ApplicationSettingsProperty) as FrameworkElementSettings;

            if (frameworkElementSettings == null)
            {
                Debug.WriteLine("FrameworkElementSettings: missing framework element settings in element " + frameworkElement);
                return;
            }

            DependencyPropertySettingCollector collector =
                new DependencyPropertySettingCollector(frameworkElement, dependencyProperty);

            frameworkElementSettings.SettingCollectors.Add(collector);
        }         // OnCollectedSettingChanged
Esempio n. 3
0
		// ----------------------------------------------------------------------
		public SettingListBox()
		{
			if ( DesignerProperties.GetIsInDesignMode( this ) )
			{
				return;
			}
			FrameworkElementSettings listBoxSettings = new FrameworkElementSettings( this );
			listBoxSettings.Settings.Add( new DependencyPropertySetting( this, SelectedIndexProperty ) );
		} // SettingListBox
Esempio n. 4
0
		} // WindowClosing

		// ----------------------------------------------------------------------
		private static void OnFrameworkElementSettingsChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e )
		{
			FrameworkElement frameworkElement = dependencyObject as FrameworkElement;
			if ( frameworkElement == null )
			{
				Debug.WriteLine( "FrameworkElementSettings: invalid framework element" );
				return;
			}

			if ( frameworkElement.GetValue( DependencyPropertySetting.ApplicationSettingsProperty ) != null )
			{
				return; // framework-element contains already an application setting
			}

			string settingsKey = e.NewValue as string;
			if ( string.IsNullOrEmpty( settingsKey ) )
			{
				Debug.WriteLine( "FrameworkElementSettings: missing framework element settings key" );
				return;
			}

			// create and attach the application settings to the framework-element
			FrameworkElementSettings frameworkElementSettings = new FrameworkElementSettings( frameworkElement, settingsKey );
			frameworkElement.SetValue( DependencyPropertySetting.ApplicationSettingsProperty, frameworkElementSettings );
		} // OnFrameworkElementSettingsChanged