void IView.SetData(string title, KeyValuePair <string, ModelColor?>[] actionComboBoxOptions, string [] typesOptions, DialogValues values) { Window.Title = title; SetNameEditProperties(values.NameEditBoxProperties); actionComboxBox.RemoveAllItems(); actionComboxBox.AddItems(actionComboBoxOptions.Select(i => i.Key).ToArray()); foreach (var i in actionComboxBox.Items().ZipWithIndex()) { var opt = actionComboBoxOptions[i.Key]; if (opt.Value == null) { continue; } var dict = new NSMutableDictionary(); dict.SetValueForKey(opt.Value.Value.ToColor().ToNSColor(), NSStringAttributeKey.BackgroundColor); var attrStr = new NSAttributedString(opt.Key, dict); i.Value.AttributedTitle = attrStr; } actionComboxBox.SelectItem(values.ActionComboBoxValue); enabledCheckbox.State = values.EnabledCheckboxValue ? NSCellStateValue.On : NSCellStateValue.Off; templateEditBox.StringValue = values.TemplateEditValue; matchCaseCheckbox.State = values.MatchCaseCheckboxValue ? NSCellStateValue.On : NSCellStateValue.Off; regexCheckbox.State = values.RegExpCheckBoxValue ? NSCellStateValue.On : NSCellStateValue.Off; wholeWordCheckbox.State = values.WholeWordCheckboxValue ? NSCellStateValue.On : NSCellStateValue.Off; for (int t = 0; t < Math.Min(typesOptions.Length, severityCheckboxes.Length); ++t) { severityCheckboxes[t].Title = typesOptions[t]; severityCheckboxes[t].State = values.TypesCheckboxesValues[t] ? NSCellStateValue.On : NSCellStateValue.Off; } scopeViewContainer.Hidden = values.ScopeItems == null; scopeUnsupportedLabel.Hidden = values.ScopeItems != null; if (values.ScopeItems != null) { scopeDataSource.Items.Clear(); scopeDataSource.Items.AddRange(values.ScopeItems.Select(i => new ScopeViewItem() { IsChecked = i.Value, PresentationObject = i.Key, EventsHandler = eventsHandler })); scopeView.ReloadData(); } }
void IView.SetData( string title, KeyValuePair <string, ModelColor?>[] actionComboBoxOptions, string[] typesOptions, DialogValues values ) { var d = dialog.Value; d.eventsHandler = eventsHandler; d.Text = title; SetNameEditProperties(values.NameEditBoxProperties); d.enabledCheckBox.Checked = values.EnabledCheckboxValue; d.templateTextBox.Text = values.TemplateEditValue; d.matchCaseCheckbox.Checked = values.MatchCaseCheckboxValue; d.regExpCheckBox.Checked = values.RegExpCheckBoxValue; d.wholeWordCheckbox.Checked = values.WholeWordCheckboxValue; d.actionComboBoxOptions = actionComboBoxOptions; d.actionComboBox.Items.Clear(); d.actionComboBox.Items.AddRange(actionComboBoxOptions.Select(a => a.Key).ToArray()); d.actionComboBox.SelectedIndex = values.ActionComboBoxValue; d.scopeNotSupportedLabel.Visible = values.ScopeItems == null; d.threadsCheckedListBox.Items.Clear(); if (values.ScopeItems != null) { foreach (var i in values.ScopeItems) { d.threadsCheckedListBox.Items.Add(new ScopeItemWrap() { item = i.Key }, i.Value); } } d.messagesTypesCheckedListBox.Items.Clear(); for (var i = 0; i < typesOptions.Length; ++i) { d.messagesTypesCheckedListBox.Items.Add(typesOptions[i], values.TypesCheckboxesValues[i]); } }