示例#1
0
        /* ----------------------------------------------------------------- */
        ///
        /// BindCore
        ///
        /// <summary>
        /// Invokes the binding settings.
        /// </summary>
        ///
        /// <param name="vm">VM object to bind.</param>
        ///
        /* ----------------------------------------------------------------- */
        private void BindCore(CompressSettingViewModel vm)
        {
            var src = Behaviors.Hook(new BindingSource(vm, ""));

            src.Bind(nameof(vm.Executable), ExecuteButton, nameof(Enabled));
            src.Bind(nameof(vm.Destination), DestinationTextBox, nameof(TextBox.Text));
            src.Bind(nameof(vm.Format), FormatComboBox, nameof(ComboBox.SelectedValue));
            src.Bind(nameof(vm.CompressionLevel), CompressionLevelComboBox, nameof(ComboBox.SelectedValue));
            src.Bind(nameof(vm.CompressionMethod), CompressionMethodComboBox, nameof(ComboBox.SelectedValue));
            src.Bind(nameof(vm.ThreadCount), ThreadNumeric, nameof(NumericUpDown.Value));
            src.Bind(nameof(vm.MaximumThreadCount), ThreadNumeric, nameof(ThreadNumeric.Maximum));
            src.Bind(nameof(vm.EncryptionSupported), EncryptionGroupBox, nameof(Enabled));
            src.Bind(nameof(vm.EncryptionEnabled), EncryptionCheckBox, nameof(CheckBox.Checked));
            src.Bind(nameof(vm.EncryptionEnabled), EncryptionPanel, nameof(Enabled));
            src.Bind(nameof(vm.EncryptionMethod), EncryptionMethodComboBox, nameof(ComboBox.SelectedValue));
            src.Bind(nameof(vm.EncryptionMethodEnabled), EncryptionMethodComboBox, nameof(Enabled));
            src.Bind(nameof(vm.Password), PasswordTextBox, nameof(TextBox.Text));
            src.Bind(nameof(vm.PasswordConfirmation), ConfirmTextBox, nameof(TextBox.Text));
            src.Bind(nameof(vm.PasswordVisible), ShowPasswordCheckBox, nameof(CheckBox.Checked));

            FormatComboBox.Bind(Resource.Formats);
            EncryptionMethodComboBox.Bind(Resource.EncryptionMethods);
            CompressionLevelComboBox.Bind(Resource.CompressionLevels);
            CompressionMethodComboBox.Bind(Resource.GetCompressionMethods(vm.Format));
            CompressionMethodComboBox.SelectedIndex = 0;
            PathToolTip.ToolTipTitle = Properties.Resources.MessageInvalidChars;
        }
示例#2
0
        /* ----------------------------------------------------------------- */
        ///
        /// PasswordSettingWindow
        ///
        /// <summary>
        /// Initializes a new instance of the PasswordSettingWindow class.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public PasswordSettingWindow()
        {
            InitializeComponent();

            IconPictureBox.Image = StockIcon.Warning.GetImage(IconSize.Large);

            Behaviors.Add(new ClickEventBehavior(ExecuteButton, Close));
            Behaviors.Add(new ClickEventBehavior(ExitButton, Close));

            var obj = Behaviors.Hook(new PasswordLintBehavior(PasswordTextBox, ConfirmTextBox, ShowPasswordCheckBox));

            obj.Updated += (s, e) => ExecuteButton.Enabled = obj.Valid;
        }
        /* ----------------------------------------------------------------- */
        ///
        /// BindCore
        ///
        /// <summary>
        /// Invokes the binding settings.
        /// </summary>
        ///
        /// <param name="vm">VM object to bind.</param>
        ///
        /* ----------------------------------------------------------------- */
        private void BindCore(SettingViewModel vm)
        {
            // General
            var s0 = vm;
            var b0 = Behaviors.Hook(new BindingSource(s0, ""));

            b0.Bind(nameof(s0.Filters), FilterTextBox, nameof(TextBox.Text));
            b0.Bind(nameof(s0.ToolTip), ToolTipCheckBox, nameof(CheckBox.Checked));
            b0.Bind(nameof(s0.ToolTip), ToolTipNumeric, nameof(Enabled));
            b0.Bind(nameof(s0.ToolTipCount), ToolTipNumeric, nameof(NumericUpDown.Value));
            b0.Bind(nameof(s0.AlphaFS), IoHandlerComboBox, nameof(ComboBox.SelectedValue));
            b0.Bind(nameof(s0.Temp), TempTextBox, nameof(TextBox.Text));
            b0.Bind(nameof(s0.CheckUpdate), UpdateCheckBox, nameof(CheckBox.Checked));
            IoHandlerComboBox.Bind(Resource.IoHandlers);

            // File association
            var b1 = Behaviors.Hook(new BindingSource(vm.Associate, ""));

            BindAssociate(b1, 0);

            // Context menu
            var s2 = vm.Menu;
            var b2 = Behaviors.Hook(new BindingSource(s2, ""));

            b2.Bind(nameof(s2.UsePreset), ContextPresetPanel, nameof(Enabled));
            b2.Bind(nameof(s2.Compress), ContextCompressCheckBox, nameof(CheckBox.Checked));
            b2.Bind(nameof(s2.Compress), ContextCompressPanel, nameof(Enabled));
            b2.Bind(nameof(s2.Extract), ContextExtractCheckBox, nameof(CheckBox.Checked));
            b2.Bind(nameof(s2.Extract), ContextExtractPanel, nameof(Enabled));
            BindContext(b2, 0);

            // Desktop shortcut
            var s3 = vm.Shortcut;
            var b3 = Behaviors.Hook(new BindingSource(s3, ""));

            b3.Bind(nameof(s3.Compress), ShortcutCompressCheckBox, nameof(CheckBox.Checked));
            b3.Bind(nameof(s3.Compress), ShortcutCompressComboBox, nameof(Enabled));
            b3.Bind(nameof(s3.CompressOptions), ShortcutCompressComboBox, nameof(ComboBox.SelectedValue));
            b3.Bind(nameof(s3.Extract), ShortcutExtractCheckBox, nameof(CheckBox.Checked));
            b3.Bind(nameof(s3.Settings), ShortcutSettingsCheckBox, nameof(CheckBox.Checked));
            ShortcutCompressComboBox.Bind(Resource.Shortcuts);

            // Compression
            var s4 = vm.Compress;
            var b4 = Behaviors.Hook(new BindingSource(s4, ""));

            b4.Bind(nameof(s4.SaveSource), CompressSaveSourceRadioButton, nameof(RadioButton.Checked));
            b4.Bind(nameof(s4.SaveQuery), CompressSaveQueryRadioButton, nameof(RadioButton.Checked));
            b4.Bind(nameof(s4.SaveOthers), CompressSaveRadioButton, nameof(RadioButton.Checked));
            b4.Bind(nameof(s4.SaveOthers), CompressSaveButton, nameof(Enabled));
            b4.Bind(nameof(s4.SaveOthers), CompressSaveTextBox, nameof(Enabled));
            b4.Bind(nameof(s4.SaveDirectory), CompressSaveTextBox, nameof(TextBox.Text));
            b4.Bind(nameof(s4.Filtering), CompressFilterCheckBox, nameof(CheckBox.Checked));
            b4.Bind(nameof(s4.UseUtf8), CompressUtf8CheckBox, nameof(CheckBox.Checked));
            b4.Bind(nameof(s4.OverwritePrompt), CompressOverwriteCheckBox, nameof(CheckBox.Checked));
            b4.Bind(nameof(s4.OpenDirectory), CompressOpenCheckBox, nameof(CheckBox.Checked));
            b4.Bind(nameof(s4.OpenDirectory), CompressOpenSmartCheckBox, nameof(Enabled));
            b4.Bind(nameof(s4.SkipDesktop), CompressOpenSmartCheckBox, nameof(CheckBox.Checked));

            // Extracting
            var s5 = vm.Extract;
            var b5 = Behaviors.Hook(new BindingSource(s5, ""));

            b5.Bind(nameof(s5.SaveSource), ExtractSaveSourceRadioButton, nameof(RadioButton.Checked));
            b5.Bind(nameof(s5.SaveQuery), ExtractSaveQueryRadioButton, nameof(RadioButton.Checked));
            b5.Bind(nameof(s5.SaveOthers), ExtractSaveRadioButton, nameof(RadioButton.Checked));
            b5.Bind(nameof(s5.SaveOthers), ExtractSaveButton, nameof(Enabled));
            b5.Bind(nameof(s5.SaveOthers), ExtractSaveTextBox, nameof(Enabled));
            b5.Bind(nameof(s5.SaveDirectory), ExtractSaveTextBox, nameof(TextBox.Text));
            b5.Bind(nameof(s5.Filtering), ExtractFilterCheckBox, nameof(CheckBox.Checked));
            b5.Bind(nameof(s5.DeleteSource), ExtractDeleteCheckBox, nameof(CheckBox.Checked));
            b5.Bind(nameof(s5.Bursty), ExtractBurstCheckBox, nameof(CheckBox.Checked));
            b5.Bind(nameof(s5.CreateDirectory), ExtractCreateCheckBox, nameof(CheckBox.Checked));
            b5.Bind(nameof(s5.CreateDirectory), ExtractCreateSmartCheckBox, nameof(Enabled));
            b5.Bind(nameof(s5.SkipSingleDirectory), ExtractCreateSmartCheckBox, nameof(CheckBox.Checked));
            b5.Bind(nameof(s5.OpenDirectory), ExtractOpenCheckBox, nameof(CheckBox.Checked));
            b5.Bind(nameof(s5.OpenDirectory), ExtractOpenSmartCheckBox, nameof(Enabled));
            b5.Bind(nameof(s5.SkipDesktop), ExtractOpenSmartCheckBox, nameof(CheckBox.Checked));
        }