private void OnPropertyGridPropertyValueChanged(object s, PropertyValueChangedEventArgs e) { this._applyButton.Enabled = true; if (e.ChangedItem.PropertyDescriptor.Name == "DataMember") { string viewName = (string)e.ChangedItem.Value; MenuItemBinding binding = (MenuItemBinding)this._bindingsListView.Items[this._bindingsListView.SelectedIndex]; this._bindingsListView.Items[this._bindingsListView.SelectedIndex] = binding; this._bindingsListView.Refresh(); IDataSourceViewSchema schema = this.FindViewSchema(viewName, binding.Depth); if (schema != null) { ((IDataSourceViewSchemaAccessor)binding).DataSourceViewSchema = schema; } this._propertyGrid.SelectedObject = binding; this._propertyGrid.Refresh(); } else if (e.ChangedItem.PropertyDescriptor.Name == "Depth") { int level = (int)e.ChangedItem.Value; MenuItemBinding binding2 = (MenuItemBinding)this._bindingsListView.Items[this._bindingsListView.SelectedIndex]; IDataSourceViewSchema schema2 = this.FindViewSchema(binding2.DataMember, level); if (schema2 != null) { ((IDataSourceViewSchemaAccessor)binding2).DataSourceViewSchema = schema2; } this._propertyGrid.SelectedObject = binding2; this._propertyGrid.Refresh(); } }
public void Test_ToString() { var mib = new MenuItemBinding(); Assert.AreEqual("(Empty)", mib.ToString(), "#A1"); foreach (var entry in toStringValues) { ToStringTestProperty(entry.Key, entry.Value); } }
private void UpdateSelectedBinding() { MenuItemBinding binding = null; if (this._bindingsListView.SelectedItems.Count > 0) { binding = (MenuItemBinding)this._bindingsListView.SelectedItems[0]; } this._propertyGrid.SelectedObject = binding; this._propertyGrid.Refresh(); this.UpdateEnabledStates(); }
public MenuBindingsEditorForm(IServiceProvider serviceProvider, System.Web.UI.WebControls.Menu menu, MenuDesigner menuDesigner) : base(serviceProvider) { this._menu = menu; this.InitializeComponent(); this.InitializeUI(); foreach (MenuItemBinding binding in this._menu.DataBindings) { MenuItemBinding clone = (MenuItemBinding)((ICloneable)binding).Clone(); menuDesigner.RegisterClone(binding, clone); this._bindingsListView.Items.Add(clone); } }
private void OnMoveBindingUpButtonClick(object sender, EventArgs e) { if (this._bindingsListView.SelectedIndices.Count > 0) { this._applyButton.Enabled = true; int index = this._bindingsListView.SelectedIndices[0]; if (index > 0) { MenuItemBinding item = (MenuItemBinding)this._bindingsListView.Items[index]; this._bindingsListView.Items.RemoveAt(index); this._bindingsListView.Items.Insert(index - 1, item); this._bindingsListView.SetSelected(index - 1, true); } } }
private void AddBinding() { System.Windows.Forms.TreeNode selectedNode = this._schemaTreeView.SelectedNode; if (selectedNode != null) { MenuItemBinding binding = new MenuItemBinding(); if (selectedNode.Text != this._schemaTreeView.Nodes[0].Text) { binding.DataMember = selectedNode.Text; if (((SchemaTreeNode)selectedNode).Duplicate) { binding.Depth = selectedNode.FullPath.Split(new char[] { this._schemaTreeView.PathSeparator[0] }).Length - 1; } ((IDataSourceViewSchemaAccessor)binding).DataSourceViewSchema = ((SchemaTreeNode)selectedNode).Schema; int index = this._bindingsListView.Items.IndexOf(binding); if (index == -1) { this._bindingsListView.Items.Add(binding); this._bindingsListView.SetSelected(this._bindingsListView.Items.Count - 1, true); } else { binding = (MenuItemBinding)this._bindingsListView.Items[index]; this._bindingsListView.SetSelected(index, true); } } else { this._bindingsListView.Items.Add(binding); this._bindingsListView.SetSelected(this._bindingsListView.Items.Count - 1, true); } this._propertyGrid.SelectedObject = binding; this._propertyGrid.Refresh(); this.UpdateEnabledStates(); } this._bindingsListView.Focus(); }
public void Remove(MenuItemBinding binding) {}
public void Insert(int index, MenuItemBinding binding) { }
public int IndexOf(MenuItemBinding value) {}
public void CopyTo(MenuItemBinding[] array, int index) {}
public bool Contains(MenuItemBinding binding) {}
// Methods public int Add(MenuItemBinding binding) {}
public bool Contains(MenuItemBinding binding) { }
// Methods public int Add(MenuItemBinding binding) { }
public void Remove(MenuItemBinding binding) { }
public void Insert(int index, MenuItemBinding binding) {}
void ToStringTestProperty(string propertyName, string expectedValue) { PropertyInfo pi = typeof(MenuItemBinding).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (pi == null) { Assert.Fail("Property '{0}' not found.", propertyName); } object defaultValue = null; object[] attrs = pi.GetCustomAttributes(typeof(DefaultValueAttribute), false); Type t = pi.PropertyType; if (attrs != null && attrs.Length > 0) { var dva = attrs [0] as DefaultValueAttribute; defaultValue = dva.Value; } else { if (t == typeof(string)) { defaultValue = String.Empty; } else if (t == typeof(bool)) { defaultValue = false; } else if (t == typeof(int)) { defaultValue = Int32.MaxValue; } else { Assert.Fail("Unsupported return type '{0}' for property '{1}'", t.FullName, propertyName); } } object setToValue = null; if (t == typeof(string)) { string v = defaultValue as String; if (v == String.Empty || v != "value") { setToValue = "value"; } else { setToValue = "value123"; } } else if (t == typeof(bool)) { bool v = (bool)defaultValue; if (v) { setToValue = false; } else { setToValue = true; } } else if (t == typeof(int)) { int v = (int)defaultValue; if (v == Int32.MaxValue) { v = Int32.MinValue; } else { v = Int32.MaxValue; } } else { Assert.Fail("Unsupported return type '{0}' for property '{1}'", t.FullName, propertyName); } var mib = new MenuItemBinding(); pi.SetValue(mib, setToValue, null); Assert.AreEqual(expectedValue, mib.ToString(), propertyName); }
public int IndexOf(MenuItemBinding value) { }