public override void ReadAttributes(XmlTextReader reader) { m_Direction = eExpandDirection.Default; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "direction") { string s = reader.Value.ToLower(); if (s == "left") m_Direction = eExpandDirection.Left; else if (s == "right") m_Direction = eExpandDirection.Right; else if (s == "top") m_Direction = eExpandDirection.Top; else if (s == "bottom") m_Direction = eExpandDirection.Bottom; else if (s == "popup") m_Direction = eExpandDirection.PopupDropDown; break; } } }
/// <summary> /// Called when ExpandDirection property has changed. /// </summary> /// <param name="oldValue">Old property value</param> /// <param name="newValue">New property value</param> protected virtual void OnExpandDirectionChanged(eExpandDirection oldValue, eExpandDirection newValue) { //OnPropertyChanged(new PropertyChangedEventArgs("ExpandDirection")); }
private Point[] GetExpandPolygon(Rectangle r, eExpandDirection direction) { Point[] p = new Point[3]; switch (direction) { case eExpandDirection.Right: { p[0].X = r.Left + 1; p[0].Y = r.Top + (r.Height - m_DefaultSize.Height) / 2 - 1; p[1].X = p[0].X; p[1].Y = p[0].Y + 6; p[2].X = p[0].X + 3; p[2].Y = p[0].Y + 3; break; } case eExpandDirection.Left: { p[0].X = r.Left + 3; p[0].Y = r.Top + (r.Height - m_DefaultSize.Height) / 2 - 1; p[1].X = p[0].X; p[1].Y = p[0].Y + 6; p[2].X = p[0].X - 3; p[2].Y = p[0].Y + 3; break; } case eExpandDirection.Top: { p[0].X = r.Left - 1; p[0].Y = r.Top + (r.Height - m_DefaultSize.Height) / 2 + m_DefaultSize.Height; p[1].X = p[0].X + 6; p[1].Y = p[0].Y; p[2].X = p[0].X + 3; p[2].Y = p[0].Y - 4; break; } case eExpandDirection.Bottom: case eExpandDirection.PopupDropDown: { p[0].X = r.Left; p[0].Y = r.Top + (r.Height - m_DefaultSize.Height) / 2 + 1; p[1].X = p[0].X + 5; p[1].Y = p[0].Y; p[2].X = p[0].X + 2; p[2].Y = p[0].Y + 3; break; } } return p; }
private void OnExpandedChanged() { _ChangingExpanded = true; try { Rectangle startRect = this.Bounds; Rectangle endRect; ElementStyle style = GetBackgroundStyle(); int styleWhiteSpace = 0; if (style != null) styleWhiteSpace = ElementStyleLayout.VerticalStyleWhiteSpace(style); if (_Expanded) { eExpandDirection direction = GetExpandDirection(); if (direction == eExpandDirection.Bottom) endRect = new Rectangle(this.Left, this.Top, this.Width, _ItemContainer.HeightInternal + styleWhiteSpace); else endRect = new Rectangle(this.Left, this.Top - (_ItemContainer.HeightInternal - _ItemContainer.MainItemsContainer.HeightInternal), this.Width, _ItemContainer.HeightInternal + styleWhiteSpace); _LastExpandDirection = direction; } else { if (_LastExpandDirection == eExpandDirection.Bottom) endRect = new Rectangle(this.Left, this.Top, this.Width, _ItemContainer.MainItemsContainer.HeightInternal + styleWhiteSpace); else endRect = new Rectangle(this.Left, this.Top + (_ItemContainer.HeightInternal - _ItemContainer.MainItemsContainer.HeightInternal), this.Width, _ItemContainer.MainItemsContainer.HeightInternal + styleWhiteSpace); } if (_AnimationSpeed <= 0 || this.DesignMode) { if (this.DesignMode) TypeDescriptor.GetProperties(this)["Bounds"].SetValue(this, endRect); else this.Bounds = endRect; } else BarFunctions.AnimateControl(this, true, _AnimationSpeed, startRect, endRect); OnExpandedChanged(EventArgs.Empty); if (_Expanded) { if (_AutoCollapse && !this.DesignMode) TrackAutoCollapse(); } else { if (_AutoCollapse) StopAutoCollapseTracking(); } } finally { _ChangingExpanded = false; } }