/// <summary> Executes the "active" view sheet demo operation. </summary> /// /// <param name="sheetName"> Name of the ViewSheet to set as the active sheet. </param> /// /// <returns> true if it succeeds, false if it fails. </returns> private bool RunActiveViewSheetDemo(string sheetName) { // We use 'sheetIndex" later on to set the *active* sheet. var sheetIndex = ViewSheets.GetViewSheet(sheetName); if (sheetIndex == -1 && !this.ShowMessage($"Could not find sheet {sheetName}.", LocalizationStrings.Title, true)) { return(false); } // If ViewSheets are enabled, this should not fail! // Get the current active sheet var currentSheetIndex = ViewSheets.GetActiveViewSheet(); // Get the name of the *active* sheet var currentSheetName = ViewSheets.GetViewSheetName(currentSheetIndex); this.ShowMessage($"{currentSheetName} at sheet index {currentSheetIndex} is the current active sheet.", LocalizationStrings.Title); // Now set the requested sheet to be the *active* sheet. if (ViewSheets.SetActiveViewSheet(sheetIndex)) { this.ShowMessage($"{sheetName} at sheet index {sheetIndex} is the new active sheet.", LocalizationStrings.Title); } return(true); }
/// <summary> Shows the VisibleLevel data in the active ViewSheet. </summary> private void ShowLevels() { var sheetIndex = ViewSheets.GetActiveViewSheet(); var name = ViewSheets.GetViewSheetName(sheetIndex); var data = new ViewSheets.ViewSheetData(); if (ViewSheets.GetViewSheetData(sheetIndex, ref data)) { var sb = new StringBuilder(name); foreach (var level in data.VisibleLevels) { sb.AppendFormat("\nLevel {0}", level); } MessageBox.Show(sb.ToString(), LocalizationStrings.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(LocalizationStrings.FailedToGetSheetData, LocalizationStrings.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> Executes the "main" view sheet demo operation. </summary> /// /// <returns> true if it succeeds, false if it fails. </returns> private bool RunMainViewSheetDemo() { var sheetIndex = ViewSheets.GetActiveViewSheet(); if (sheetIndex == -1 && !this.ShowMessage(LocalizationStrings.CouldNotFindSheet, LocalizationStrings.Title, true)) { return(false); } var sheetName = ViewSheets.GetViewSheetName(sheetIndex); if (string.IsNullOrWhiteSpace(sheetName) && !this.ShowMessage(LocalizationStrings.CouldNotFindSheet, LocalizationStrings.Title, true)) { return(false); } this.ShowMessage($"{sheetName} at sheet index {sheetIndex} is the main sheet.", LocalizationStrings.Title); return(true); }