/// <summary> /// Constructor /// </summary> public PresetVoiLutOperationComponentContainerControl(PresetVoiLutOperationsComponentContainer component) :base(component) { _component = component; InitializeComponent(); BindingSource source = new BindingSource(); source.DataSource = _component; _keyStrokeComboBox.DataSource = _component.AvailableKeyStrokes; _keyStrokeComboBox.DataBindings.Add("Value", source, "SelectedKeyStroke", true, DataSourceUpdateMode.OnPropertyChanged); _okButton.DataBindings.Add("Enabled", source, "AcceptEnabled", true, DataSourceUpdateMode.OnPropertyChanged); IApplicationComponentView customEditView; try { customEditView = _component.ComponentHost.ComponentView; Size sizeBefore = _tableLayoutPanel.Size; _tableLayoutPanel.Controls.Add(customEditView.GuiElement as Control); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); Size sizeAfter = _tableLayoutPanel.Size; this.Size += (sizeAfter - sizeBefore); } catch(NotSupportedException) { } base.AcceptButton = _okButton; base.CancelButton = _cancelButton; _cancelButton.Click += delegate { _component.Cancel(); }; _okButton.Click += delegate { _component.OK(); }; }
public void SetComponent(IApplicationComponent component) { _component = (PresetVoiLutOperationsComponentContainer)component; }
public void OnEditSelected() { if (!EditEnabled) { return; } if (this.SelectedPresetVoiLut == null) { this.Host.DesktopWindow.ShowMessageBox(SR.MessagePleaseSelectAnItemToEdit, MessageBoxActions.Ok); return; } try { PresetVoiLutConfiguration configuration = this.SelectedPresetOperation.GetConfiguration(); IPresetVoiLutOperationComponent editComponent = this.SelectedPresetOperation.SourceFactory.GetEditComponent(configuration); editComponent.EditContext = EditContext.Edit; PresetVoiLutOperationsComponentContainer container = new PresetVoiLutOperationsComponentContainer(GetUnusedKeyStrokes(this.SelectedPresetVoiLut), editComponent); container.SelectedKeyStroke = this.SelectedPresetVoiLut.KeyStroke; if (ApplicationComponentExitCode.Accepted != ApplicationComponent.LaunchAsDialog(this.Host.DesktopWindow, container, SR.TitleEditPreset)) { return; } PresetVoiLut preset = container.GetPresetVoiLut(); Platform.CheckForNullReference(preset, "preset"); List <PresetVoiLut> conflictingItems = CollectionUtils.Select <PresetVoiLut>(_voiLutPresets.Items, delegate(PresetVoiLut test){ return(preset.Equals(test)); }); if (conflictingItems.Count == 0 || (conflictingItems.Count == 1 && conflictingItems[0].Equals(this.SelectedPresetVoiLut))) { PresetVoiLut selected = this.SelectedPresetVoiLut; int index = _voiLutPresets.Items.IndexOf(selected); _voiLutPresets.Items.Remove(selected); if (index < _voiLutPresets.Items.Count) { _voiLutPresets.Items.Insert(index, preset); } else { _voiLutPresets.Items.Add(preset); } Selection = null; this.Modified = true; } else { this.Host.DesktopWindow.ShowMessageBox(SR.MessageNameOrKeystrokeConflictsWithExistingPreset, MessageBoxActions.Ok); } } catch (Exception e) { ExceptionHandler.Report(e, SR.MessageFailedToEditPreset, this.Host.DesktopWindow); } }