Esempio n. 1
0
        /// <summary>
        /// Runs a form in this application context
        /// </summary>
        public void RunNew(string pathName)
        {
            Spreadsheet spreadsheet = null;
            string      name        = "Spreadsheet" + (windowCount + 1);

            if (pathName == null)
            {
                spreadsheet = new Spreadsheet(new Regex(@"^[A-Z][1-9]\d?$"));
            }
            else
            {
                name = Path.GetFileName(pathName);

                using (StreamReader reader = new StreamReader(pathName))
                    spreadsheet = new Spreadsheet(reader, new Regex(@"^[A-Z][1-9]\d?$"));
            }

            SpreadsheetWindow window = new SpreadsheetWindow();

            new Controller(window, spreadsheet, name);

            window.FormClosed += (obj, eve) => { if (--windowCount <= 0)
                                                 {
                                                     ExitThread();
                                                 }
            };

            window.Show();

            windowCount++;
        }
Esempio n. 2
0
        /// <summary>
        /// Runs a new form in this context
        /// </summary>
        public void RunNewWithSpreadsheet(Spreadsheet spreadsheet)
        {
            SpreadsheetWindow window = new SpreadsheetWindow();

            new Controller(window, spreadsheet);
            windowCount++;

            window.FormClosed += (o, e) => { if (--windowCount <= 0)
                                             {
                                                 ExitThread();
                                             }
            };
            window.Show();
        }
Esempio n. 3
0
        public void RunNew(TextReader file)
        {
            SpreadsheetWindow window = new SpreadsheetWindow();

            new Controller(window, file);

            windows++;

            window.FormClosed += (a, b) => { if (--windows <= 0)
                                             {
                                                 ExitThread();
                                             }
            };

            window.Show();
        }
        public void RunNew(string filename)
        {
            // Create the window and the controller
            SpreadsheetWindow window = new SpreadsheetWindow();

            new SpreadsheetController(window, filename);

            // One more form is running
            windowCount++;

            // When this form closes, we want to find out
            window.FormClosed += (o, e) => { if (--windowCount <= 0)
                                             {
                                                 ExitThread();
                                             }
            };

            // Run the form
            window.Show();
        }
Esempio n. 5
0
        /// <summary>
        /// Runs a form in this application context
        /// </summary>
        /// <param name="textReader"></param>
        public void RunNew(string ipaddress, string spreadsheetName)
        {
            var server = new ServerConnection();

            // Create the window and the controller
            SpreadsheetWindow spreadsheetWindow = new SpreadsheetWindow();
            var controller = new Controller(spreadsheetWindow, server, spreadsheetName);

            server.MessageReceived += s => spreadsheetWindow.Invoke(new Test(() => { controller.MessageReceived(s); }));

            server.ClientDisconnected += () =>
            {
                ServerOnClientDisconnected(spreadsheetWindow);
            };

            // One more form is running
            spreadsheetWindowCount++;

            // When this form closes, we want to find out
            spreadsheetWindow.FormClosed += (o, e) =>
            {
                spreadsheetWindow.Dispose();
                Task.Run(() => { server.Disconnect(); });
                if (--spreadsheetWindowCount <= 0)
                {
                    RunLauncher();
                }
            };
            if (!IsUnitTest)
            {
                // Run the form
                spreadsheetWindow.Show();
            }

            server.Connect(ipaddress, spreadsheetName);
        }