void BringRowIntoView(FixtureProfileRow row) { if (!IsAtLeastPartiallyInView(row)) { BringRowIntoViewLow(row); } }
public void Delete(FixtureProfileRow row) { if (RowSelected == null) { return; } Analysis.FixtureProfiles.Remove(row.FixtureProfile); int index = StackPanelRows.Children.IndexOf(row); StackPanelRows.Children.Remove(row); if (index == 0) { if (StackPanelRows.Children.Count > 0) { index = 0; } else { return; } } else { index = index - 1; } SelectRow((FixtureProfileRow)(StackPanelRows.Children[index])); }
bool IsAtLeastPartiallyInView(FixtureProfileRow row) { double percentElapsed = ((double)StackPanelRows.Children.IndexOf(row) + 1) / (double)StackPanelRows.Children.Count; double percentOneRow = (double)1.0 / (double)StackPanelRows.Children.Count; return(((percentElapsed + percentOneRow) * StackPanelRows.ActualHeight) > ScrollViewer.VerticalOffset && (percentElapsed * StackPanelRows.ActualHeight) < ScrollViewer.VerticalOffset + ScrollViewer.ViewportHeight); }
public void UnselectAll() { foreach (FixtureProfileRow row in StackPanelRows.Children) { row.ClearSelection(); } RowSelected = null; }
public void AddRow(FixtureProfile fixtureProfile) { var row = new FixtureProfileRow(); row.FixtureProfile = fixtureProfile; row.FixtureProfilesEditor = this; row.Initialize(); StackPanelRows.Children.Add(row); }
public void BringRowIntoViewLow(FixtureProfileRow row) { double percentElapsed = ((double)StackPanelRows.Children.IndexOf(row) + 1) / (double)StackPanelRows.Children.Count; if (((percentElapsed * StackPanelRows.ActualHeight) - ScrollViewer.ActualHeight / 2) >= (StackPanelRows.ActualHeight - ScrollViewer.ActualHeight)) { ScrollViewer.ScrollToEnd(); } else { ScrollViewer.ScrollToVerticalOffset(EventsViewer.Between(0, StackPanelRows.ActualHeight - ScrollViewer.ActualHeight, ((percentElapsed * StackPanelRows.ActualHeight) - ScrollViewer.ActualHeight / 2))); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.FixtureProfileHeader = ((TraceWizard.TwApp.FixtureProfileRow)(target)); return; case 2: this.ScrollViewer = ((System.Windows.Controls.ScrollViewer)(target)); return; case 3: this.StackPanelRows = ((System.Windows.Controls.StackPanel)(target)); return; } this._contentLoaded = true; }
public void MoveDown(FixtureProfileRow row) { if (RowSelected == null) { return; } var fixtureProfile = row.FixtureProfile; int index = Analysis.FixtureProfiles.IndexOf(fixtureProfile); if (index == Analysis.FixtureProfiles.Count - 1) { return; } Analysis.FixtureProfiles.Remove(fixtureProfile); Analysis.FixtureProfiles.Insert(index + 1, fixtureProfile); StackPanelRows.Children.Remove(row); StackPanelRows.Children.Insert(index + 1, row); }
public void SelectRow(FixtureProfileRow rowToSelect) { bool clearSelection = true; foreach (FixtureProfileRow row in StackPanelRows.Children) { if (row == rowToSelect) { if (row == RowSelected) { row.ClearSelection(); } else { row.Select(); RowSelected = row; if (row.Button.IsChecked != true) { row.Button.IsChecked = true; } row.Button.Focus(); clearSelection = false; BringRowIntoView(row); } } else { row.ClearSelection(); } } if (clearSelection) { RowSelected = null; } }