Esempio n. 1
0
        /// <summary>
        /// Binds switchable file properties to a checkbox using the properties of some other ISwitchableFile.
        /// </summary>
        /// <param name="checkbox">The checkbox to bind to.</param>
        /// <param name="other"></param>
        public CheckboxSwitchableFile( CheckBox checkbox, ISwitchableFile other )
        {
            checkbox.ThrowIfNull( "checkbox" );
            other.ThrowIfNull( "other" );

            m_checkbox = checkbox;

            m_checkbox.CheckedChanged += ( object sender, EventArgs e ) =>
            {
                if ( m_checkbox.Enabled )
                {
                    m_switchIfFilesOk = m_checkbox.Checked;
                }
            };

            m_checkbox.EnabledChanged += ( object sender, EventArgs e ) =>
            {
                if ( m_checkbox.Enabled )
                {
                    m_checkbox.Checked = SwitchIfFilesOk;
                }
                else
                {
                    m_checkbox.Checked = false;
                }
            };

            AutoRefresh = false;

            FileType = other.FileType;

            Name = other.Name;
            WhetherToSwitchArg = other.WhetherToSwitchArg;
            CustomFileArg = other.CustomFileArg;
            TempFileArg = other.TempFileArg;
            DefaultCustomFile = other.DefaultCustomFile;
            DefaultTempFile = other.DefaultTempFile;
            NormalFile = other.NormalFile;
            CustomFile = other.CustomFile;
            TempFile = other.TempFile;
            RelativeRoot = other.RelativeRoot;

            SwitchIfFilesOk = other.Switch;

            AutoRefresh = true;

            Refresh();
        }