public void SetElementsSelection(CustomEditorElementControl elementCtrl, ModifierKey modKey) { if (modKey == ModifierKey.Ctrl) { elementCtrl.IsSelected = !elementCtrl.IsSelected; this.baseIndex = this.GetIndexOfElement(elementCtrl); } else if (modKey == ModifierKey.Shift) { int currentIdx = this.GetIndexOfElement(elementCtrl); if (currentIdx >= 0 && this.baseIndex >= 0) { this.UnselectElements(); int minIdx = System.Math.Min(currentIdx, this.baseIndex); int maxIdx = System.Math.Max(currentIdx, this.baseIndex); this.SetElementsSelection(minIdx, maxIdx); } } else { this.UnselectElements(); elementCtrl.IsSelected = true; this.baseIndex = this.GetIndexOfElement(elementCtrl); } }
private void AddUIElement(ProcessVar var) { CustomEditorElementControl element = new CustomEditorElementControl(this, this.editor.flowsheet, var); this.panel.Controls.Add(element); elements.Add(element); }
private void DisplayElements() { this.panel.Visible = false; // calculate the number of elements that fit in a column // (we substract the header's height) double e1 = System.Convert.ToDouble(this.panel.Height - ELEMENT_HEIGHT) / System.Convert.ToDouble(ELEMENT_HEIGHT); double e2 = System.Math.Floor(e1); int countColumnElements = System.Convert.ToInt32(e2); // calculate the number of columns double d1 = System.Convert.ToDouble(this.elements.Count) / System.Convert.ToDouble(countColumnElements); double d2 = System.Math.Ceiling(d1); int countColumns = System.Convert.ToInt32(d2); // calculate the reminder of elements in the last column int reminderElements = 0; System.Math.DivRem(this.elements.Count, countColumnElements, out reminderElements); if (reminderElements == 0) { // treat all the columns the same for (int column = 0; column < countColumns; column++) { for (int row = 0; row < countColumnElements; row++) { int idx = column * countColumnElements + row; CustomEditorElementControl element = (CustomEditorElementControl)elements[idx]; element.Location = new Point(ELEMENT_WIDTH * column, 20 * (row + 1)); } } } else { // treat the all the columns, except the last one, in the same way for (int column = 0; column < countColumns - 1; column++) { for (int row = 0; row < countColumnElements; row++) { int idx = column * countColumnElements + row; CustomEditorElementControl element = (CustomEditorElementControl)elements[idx]; element.Location = new Point(ELEMENT_WIDTH * column, 20 * (row + 1)); } } // treat the last column in a special way for (int row = 0; row < reminderElements; row++) { int idx = (countColumns - 1) * countColumnElements + row; CustomEditorElementControl element = (CustomEditorElementControl)elements[idx]; element.Location = new Point(ELEMENT_WIDTH * (countColumns - 1), 20 * (row + 1)); } } // adjust the width of the header this.panelHeader.Width = ELEMENT_WIDTH * countColumns; this.panel.Visible = true; }
private void SetElementsSelection(int minIdx, int maxIdx) { CustomEditorElementControl element = null; for (int i = 0; i < this.elements.Count; i++) { if (i >= minIdx && i <= maxIdx) { element = this.elements[i] as CustomEditorElementControl; element.IsSelected = true; } } }
private int GetIndexOfElement(CustomEditorElementControl elementCtrl) { int index = -1; for (int i = 0; i < this.elements.Count; i++) { if ((this.elements[i] as CustomEditorElementControl).Equals(elementCtrl)) { index = i; break; } } return(index); }
private void editor_ProcessVarDeleted(ArrayList vars, ArrayList idxs) { IEnumerator e = idxs.GetEnumerator(); while (e.MoveNext()) { int idx = (int)e.Current; CustomEditorElementControl element = (CustomEditorElementControl)this.elements[idx]; this.elements.RemoveAt(idx); this.panel.Controls.Remove(element); } this.DisplayElements(); this.Editor.flowsheet.IsDirty = true; }