Example #1
0
        /// <summary>
        /// Set the value of the main window to null so that only
        /// one can be created
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">Any Event arguments</param>
        private static void AutoSheetMainWindowOnClosed(object sender, EventArgs e)
        {
            _autoSheetMainWindow = null;

            if (DataSheet == null)
            {
                return;
            }
            DataSheet.Dispose();
            DataSheet = null;
        }
Example #2
0
        /// <summary>
        /// Opens a design Sheet given a path
        /// </summary>
        /// <param name="filePath">The path to the design sheet</param>
        public static void OpenDesignSheet(string filePath)
        {
            if (DataSheet != null && DataSheet.IsReady())
            {
                throw new DataSheetAlreadyExists();
            }

            if (DataSheet != null && !DataSheet.IsReady())
            {
                DataSheet.Dispose();
                DataSheet = null;
            }
            try
            {
                DataSheet
                    = new PipeDataSheet(filePath, PipeDataSheet.PipeDataSheetName);

                // Test to see if it succeeded
                if (!DataSheet.IsReady())
                {
                    DataSheet = null;
                }
            }
            catch (FilenameNullException)
            {
                MessageBox.Show("No Filename was provided", "AutoSheet Error", MessageBoxButtons.OK);
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("Filename provided could not be found", "AutoSheet Error", MessageBoxButtons.OK);
            }
            catch (COMException e)
            {
                MessageBox.Show($"There was an error opening the file: {e}", "AutoSheet Error", MessageBoxButtons.OK);
                DataSheet?.Dispose();
            }
        }