private void Timeline_OnMouseWheel(object sender, MouseWheelEventArgs e) { if (Keyboard.Modifiers == ModifierKeys.Alt) { e.Handled = true; var zoomIn = e.Delta > 0; var bands = zoomIn ? Children.OfType <TimelineBand>().Reverse().ToList() : Children.OfType <TimelineBand>().ToList(); var rows = zoomIn ? RowDefinitions.Reverse().ToList() : RowDefinitions.ToList(); var index = bands.IndexOf(bands.First(x => x.IsMainBand)); var amount = Math.Min(Math.Abs(e.Delta / 120), bands.Count - index - 1); if (amount > 0) { var main = bands.SkipWhile(x => !x.IsMainBand).First(); var next = bands.SkipWhile(x => !x.IsMainBand).Skip(amount).First(); main.IsMainBand = false; next.IsMainBand = true; main.MaxEventHeight = 130; foreach (var band in bands.TakeWhile(x => !x.IsMainBand)) { band.MaxEventHeight = 4; } var mainRow = rows.SkipWhile(x => x.Height != new GridLength(1, GridUnitType.Star)).First(); var nextRow = rows.SkipWhile(x => x.Height != new GridLength(1, GridUnitType.Star)) .Skip(amount) .First(); mainRow.Height = new GridLength(40); nextRow.Height = new GridLength(1, GridUnitType.Star); foreach (var hide in rows.TakeWhile(x => x.Height != new GridLength(1, GridUnitType.Star))) { hide.Height = new GridLength(40); } // reset the bands HookChildElements(Children); main.CreateTimelineCalculator( CalendarType, CurrentDateTime, MinDateTime, MaxDateTime ); bands.ForEach( b => b.CreateTimelineCalculator(CalendarType, CurrentDateTime, MinDateTime, MaxDateTime)); RefreshEvents(false); } } }
void EnsureRowsColumnsInitialized() { _columns = ColumnDefinitions == null ? new List <ColumnDefinition>() : ColumnDefinitions.ToList(); _rows = RowDefinitions == null ? new List <RowDefinition>() : RowDefinitions.ToList(); int lastRow = -1; for (var index = 0; index < InternalChildren.Count; index++) { Element w = InternalChildren[index]; lastRow = Math.Max(lastRow, GetRow(w) + GetRowSpan(w) - 1); } lastRow = Math.Max(lastRow, RowDefinitions.Count - 1); int lastCol = -1; for (var index = 0; index < InternalChildren.Count; index++) { Element w = InternalChildren[index]; lastCol = Math.Max(lastCol, GetColumn(w) + GetColumnSpan(w) - 1); } lastCol = Math.Max(lastCol, ColumnDefinitions.Count - 1); while (_columns.Count <= lastCol) { _columns.Add(new ColumnDefinition()); } while (_rows.Count <= lastRow) { _rows.Add(new RowDefinition()); } for (var index = 0; index < _columns.Count; index++) { ColumnDefinition col = _columns[index]; col.ActualWidth = -1; } for (var index = 0; index < _rows.Count; index++) { RowDefinition row = _rows[index]; row.ActualHeight = -1; } }