1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
|
//------------------------------------------------------------------------------
// <copyright file="EntityDataSourceDataSelectionPanel.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//
// @owner [....]
// @backupOwner [....]
//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Web.UI.Design.WebControls.Util;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace System.Web.UI.Design.WebControls
{
internal partial class EntityDataSourceDataSelectionPanel : WizardPanel
{
private EntityDataSourceDataSelection _dataSelection;
private bool _ignoreEvents; // used when a control is set by the wizard, tells the event handlers to do nothing
public EntityDataSourceDataSelectionPanel()
{
InitializeComponent();
InitializeUI();
InitializeTabIndexes();
}
#region General Initialization
public void Register(EntityDataSourceDataSelection dataSelection)
{
_dataSelection = dataSelection;
}
#endregion
#region Control Initialization
private void InitializeSizes()
{
int top = 0;
_entitySetLabel.Location = new Point(9, top + 8);
_entitySetLabel.Size = new Size(80, 13);
top = _entitySetLabel.Bottom;
_entitySetComboBox.Location = new Point(12, top + 3);
_entitySetComboBox.Size = new Size(502, 21);
top = _entitySetComboBox.Bottom;
_entityTypeFilterLabel.Location = new Point(9, top + 6);
_entityTypeFilterLabel.Size = new Size(118, 13);
top = _entityTypeFilterLabel.Bottom;
_entityTypeFilterComboBox.Location = new System.Drawing.Point(12, top + 3);
_entityTypeFilterComboBox.Size = new System.Drawing.Size(502, 21);
top = _entityTypeFilterComboBox.Bottom;
_selectLabel.Location = new Point(9, top + 6);
_selectLabel.Size = new Size(40, 13);
top = _selectLabel.Bottom;
_selectAdvancedTextBox.Location = new Point(12, top + 3);
_selectAdvancedTextBox.Multiline = true; // set this here so the size will be set properly
_selectAdvancedTextBox.Size = new Size(502, 137);
// don't need to set top here because the next control has the same location and size
_selectSimpleCheckedListBox.Location = _selectAdvancedTextBox.Location;
_selectSimpleCheckedListBox.Size = _selectAdvancedTextBox.Size;
_selectSimpleCheckedListBox.ColumnWidth = 225;
top = _selectSimpleCheckedListBox.Bottom;
_insertUpdateDeletePanel.Location = new Point(12, top + 3);
_insertUpdateDeletePanel.Size = new Size(502, 69);
top = 0; // position of rest of controls are relative to this panel
_enableInsertCheckBox.Location = new Point(3, top + 3);
_enableInsertCheckBox.Size = new Size(141, 17);
top = _enableInsertCheckBox.Bottom;
_enableUpdateCheckBox.Location = new Point(3, top + 6);
_enableUpdateCheckBox.Size = new Size(149, 17);
top = _enableUpdateCheckBox.Bottom;
_enableDeleteCheckBox.Location = new Point(3, top + 6);
_enableDeleteCheckBox.Size = new Size(145, 17);
// if any controls are added, top should be reset to _insertUpdateDeletePanel.Bottom before adding them here
}
private void InitializeTabIndexes()
{
_entitySetLabel.TabStop = false;
_entitySetComboBox.TabStop = true;
_entityTypeFilterLabel.TabStop = false;
_entityTypeFilterComboBox.TabStop = true;
_selectLabel.TabStop = false;
_selectSimpleCheckedListBox.TabStop = true;
_selectAdvancedTextBox.TabStop = true;
_insertUpdateDeletePanel.TabStop = false;
_enableInsertCheckBox.TabStop = true;
_enableDeleteCheckBox.TabStop = true;
_enableUpdateCheckBox.TabStop = true;
int tabIndex = 0;
_entitySetLabel.TabIndex = tabIndex += 10;
_entitySetComboBox.TabIndex = tabIndex += 10;
_entityTypeFilterLabel.TabIndex = tabIndex += 10;
_entityTypeFilterComboBox.TabIndex = tabIndex += 10;
_selectLabel.TabIndex = tabIndex += 10;
_selectSimpleCheckedListBox.TabIndex = tabIndex += 10;
_selectAdvancedTextBox.TabIndex = tabIndex += 10;
_insertUpdateDeletePanel.TabIndex = tabIndex += 10;
_enableInsertCheckBox.TabIndex = tabIndex += 10;
_enableUpdateCheckBox.TabIndex = tabIndex += 10;
_enableDeleteCheckBox.TabIndex = tabIndex += 10;
}
private void InitializeUI()
{
_entitySetLabel.Text = Strings.Wizard_DataSelectionPanel_EntitySetName;
_entitySetComboBox.AccessibleName = Strings.Wizard_DataSelectionPanel_EntitySetNameAccessibleName;
_entityTypeFilterLabel.Text = Strings.Wizard_DataSelectionPanel_EntityTypeFilter;
_entityTypeFilterComboBox.AccessibleName = Strings.Wizard_DataSelectionPanel_EntityTypeFilterAccessibleName;
_selectLabel.Text = Strings.Wizard_DataSelectionPanel_Select;
_selectSimpleCheckedListBox.AccessibleName = Strings.Wizard_DataSelectionPanel_SelectAccessibleName;
_selectAdvancedTextBox.AccessibleName = Strings.Wizard_DataSelectionPanel_SelectAccessibleName;
_enableInsertCheckBox.Text = Strings.Wizard_DataSelectionPanel_Insert;
_enableInsertCheckBox.AccessibleName = Strings.Wizard_DataSelectionPanel_InsertAccessibleName;
_enableDeleteCheckBox.Text = Strings.Wizard_DataSelectionPanel_Delete;
_enableDeleteCheckBox.AccessibleName = Strings.Wizard_DataSelectionPanel_DeleteAccessibleName;
_enableUpdateCheckBox.Text = Strings.Wizard_DataSelectionPanel_Update;
_enableUpdateCheckBox.AccessibleName = Strings.Wizard_DataSelectionPanel_UpdateAccessibleName;
this.Caption = Strings.Wizard_DataSelectionPanel_Caption;
this.AccessibleName = Strings.Wizard_DataSelectionPanel_Caption;
}
#endregion
#region Control Event Handlers
private void OnEnableDeleteCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!_ignoreEvents)
{
_dataSelection.SelectEnableDelete(_enableDeleteCheckBox.Checked);
// this property has no effect on the wizard, so don't need to update it
}
}
private void OnEnableInsertCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!_ignoreEvents)
{
_dataSelection.SelectEnableInsert(_enableInsertCheckBox.Checked);
// this property has no effect on the wizard, so don't need to update it
}
}
private void OnEnableUpdateCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!_ignoreEvents)
{
_dataSelection.SelectEnableUpdate(_enableUpdateCheckBox.Checked);
// this property has no effect on the wizard, so don't need to update it
}
}
private void OnEntitySetComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_ignoreEvents)
{
_dataSelection.SelectEntitySetName(_entitySetComboBox.SelectedItem as EntityDataSourceEntitySetNameItem);
_dataSelection.UpdateWizardState();
}
}
private void OnEntityTypeFilterComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_ignoreEvents)
{
_dataSelection.SelectEntityTypeFilter(_entityTypeFilterComboBox.SelectedItem as EntityDataSourceEntityTypeFilterItem);
_dataSelection.UpdateWizardState();
}
}
private void OnSelectAdvancedTextBox_TextChanged(object sender, EventArgs e)
{
if (!_ignoreEvents)
{
_dataSelection.SelectAdvancedSelect(_selectAdvancedTextBox.Text);
_dataSelection.UpdateWizardState();
}
}
private void OnSelectSimpleCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (!_ignoreEvents)
{
if (e.NewValue == CheckState.Checked)
{
// if any other box is checked except 'Select All (Entity Value)', clear 'Select All (Entity Value)'
if (e.Index != 0)
{
_selectSimpleCheckedListBox.SetItemChecked(0, false);
_dataSelection.SelectEnableInsert(false);
_dataSelection.SelectEnableUpdate(false);
_dataSelection.SelectEnableDelete(false);
}
// if 'Select All (Entity Value)' is checked, uncheck all others
else
{
// disable events while we bulk clear the selected items
_ignoreEvents = true;
// this event occurs before the check state is changed on the current selection, so it won't
// uncheck the box that triggered this event
foreach (int checkedIndex in _selectSimpleCheckedListBox.CheckedIndices)
{
_selectSimpleCheckedListBox.SetItemChecked(checkedIndex, false);
}
_ignoreEvents = false;
_dataSelection.ClearAllSelectedProperties();
}
// Add the current index to the list of selected properties in temporary state storage
_dataSelection.SelectEntityProperty(e.Index);
}
else
{
// Remove the current index from the list of selected properties in temporary state storage.
_dataSelection.DeselectEntityProperty(e.Index);
}
_dataSelection.UpdateInsertUpdateDeleteState();
// If there are no longer any properties checked at this point, the Finish button will be disabled
_dataSelection.UpdateWizardState();
}
}
#endregion
#region Wizard State Management
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
if (Visible)
{
_dataSelection.UpdateWizardState();
}
}
#endregion
#region Methods for setting control values
public void SetEnableInsertUpdateDelete(bool enableInsert, bool enableUpdate, bool enableDelete)
{
_ignoreEvents = true;
_enableInsertCheckBox.Checked = enableInsert;
_enableUpdateCheckBox.Checked = enableUpdate;
_enableDeleteCheckBox.Checked = enableDelete;
_ignoreEvents = false;
}
public void SetEnableInsertUpdateDeletePanel(bool enablePanel)
{
_ignoreEvents = true;
_insertUpdateDeletePanel.Enabled = enablePanel;
_ignoreEvents = false;
}
public void SetEntitySetNames(List<EntityDataSourceEntitySetNameItem> entitySetNames)
{
_ignoreEvents = true;
_entitySetComboBox.Items.Clear();
_entitySetComboBox.Items.AddRange(entitySetNames.ToArray());
_ignoreEvents = false;
}
// Populates the CheckedListBox with the specified entityTypeProperties and checks all of the indexes specified in selectedEntityTypeProperties
// Expects that 'Select All (Entity Value)' is in the list of properties already
public void SetEntityTypeProperties(List<string> entityTypeProperties, List<int> selectedEntityTypeProperties)
{
Debug.Assert(entityTypeProperties != null && entityTypeProperties.Count > 0, "unexpected null or empty entityTypeProperties");
Debug.Assert(selectedEntityTypeProperties != null && selectedEntityTypeProperties.Count > 0, "unexpected null or empty selectedEntityTypeProperties");
_ignoreEvents = true;
// remove any items currently in the list and replace them with the current list and selected properties
_selectSimpleCheckedListBox.Items.Clear();
_selectSimpleCheckedListBox.Items.AddRange(entityTypeProperties.ToArray());
foreach (int entityProperty in selectedEntityTypeProperties)
{
// check all of the items in the list of selected properties
_selectSimpleCheckedListBox.SetItemChecked(entityProperty, true);
}
// Update the controls
_selectAdvancedTextBox.Visible = false;
_selectSimpleCheckedListBox.Visible = true;
_ignoreEvents = false;
}
public void SetEntityTypeFilters(List<EntityDataSourceEntityTypeFilterItem> entityTypeFilters)
{
_ignoreEvents = true;
_entityTypeFilterComboBox.Items.Clear();
_entityTypeFilterComboBox.Items.AddRange(entityTypeFilters.ToArray());
_ignoreEvents = false;
}
public void SetSelectedEntityTypeFilter(EntityDataSourceEntityTypeFilterItem selectedEntityTypeFilter)
{
Debug.Assert(selectedEntityTypeFilter != null, "cannot select null from EntityTypeFilter combobox");
_ignoreEvents = true;
_entityTypeFilterComboBox.SelectedItem = selectedEntityTypeFilter;
_ignoreEvents = false;
}
public void SetSelect(string select)
{
_ignoreEvents = true;
_selectAdvancedTextBox.Text = select;
_selectAdvancedTextBox.Visible = true;
_selectSimpleCheckedListBox.Visible = false;
_ignoreEvents = false;
}
public void SetSelectedEntitySetName(EntityDataSourceEntitySetNameItem selectedEntitySet)
{
_ignoreEvents = true;
if (selectedEntitySet == null)
{
_entitySetComboBox.SelectedIndex = -1;
}
else
{
_entitySetComboBox.SelectedItem = selectedEntitySet;
}
_ignoreEvents = false;
}
#endregion
}
}
|