/// <summary> /// Sets visiblity of tab item /// </summary> /// <param name="sheet">Sheet to change property to</param> /// <param name="p">Is sheet visible</param> protected virtual void SetVisibility(ref SheetControl sheet, bool isVisible) { if (sheet == null) throw new ArgumentNullException("sheet", "Can't change visiblity of sheet that is null!"); // Sets control visibility sheet.Visibility = isVisible ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; if (!isVisible) { // TODO: Add tabItem to list of hidden sheets } }
/// <summary> /// Converts ExcelWorksheet to TabItem sheet equivalent /// </summary> /// <param name="worksheet">Worksheet to convert, null will create new empty sheet.</param> /// <returns>TabItem of given ExcelWorksheet</returns> protected TabItem FromExcelWorksheetToTabItem(ExcelWorksheet worksheet = null) { // Create new TabItem TabItem sheet = new TabItem() { //Style = (Style)FindResource("SimpleTabItem") }; // Create new SheetControl and fill the information SheetControl control = new SheetControl(worksheet); // If worksheet isn't null, start importing data if (worksheet != null) { sheet.Header = worksheet.Name; // TODO Import rest SetVisibility(ref control, worksheet.Visibility == SheetVisibility.Visible); } // Sets events control.SelectionEnded += (s, se) => { UpdateMenuFontSize(se.FontSize); ComboBoxFontFamily.SelectedIndex = SystemFontFamilies.IndexOf(se.FontFamily); if (se.Formula != null) { } }; // Set content to just created control and return tab item sheet.Content = control; return sheet; }