Пример #1
0
        // Owner is the Control that we're calling.  This callback will be disable when the
        // control is unloaded, and we won't call it if it's the same control that fired
        // the change via FireConfigurationChanged.
        //
        // In addition, the callback is called when the control is Loaded, to load the initial
        // state.
        public OnInputChange(Control owner, LoadFromConfigDelegate callback)
        {
            Owner    = owner;
            Callback = callback;

            // This is available when the application is running, but will be null in the XAML designer.
            if (CurrentSMXDevice.singleton == null)
            {
                return;
            }

            Owner.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                CurrentSMXDevice.singleton.ConfigurationChanged += ConfigurationChanged;
                Refresh();
            };

            Owner.Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                CurrentSMXDevice.singleton.ConfigurationChanged -= ConfigurationChanged;
            };
        }
Пример #2
0
        // Owner is the Control that we're calling.  This callback will be disable when the
        // control is unloaded, and we won't call it if it's the same control that fired
        // the change via FireConfigurationChanged.
        //
        // In addition, the callback is called when the control is Loaded, to load the initial
        // state.
        public OnConfigChange(Control owner, LoadFromConfigDelegate callback)
        {
            Owner    = owner;
            Callback = callback;

            Owner.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                if (CurrentSMXDevice.singleton != null)
                {
                    CurrentSMXDevice.singleton.ConfigurationChanged += ConfigurationChanged;
                }
                Refresh();
            };

            Owner.Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                if (CurrentSMXDevice.singleton != null)
                {
                    CurrentSMXDevice.singleton.ConfigurationChanged -= ConfigurationChanged;
                }
            };
        }