Exemplo n.º 1
0
 /// <summary>
 /// This opens a valid spread sheet in a new window.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (NewForm != null)
     {
         NewForm.Invoke(new Action(() => NewForm.Close()));
         NewForm = null;
     }
     SpreadsheetApplicationContext.getAppContext().RunForm(OpenForm = new OpenSpreadsheetForm());
     OpenForm.open_setup += open_setup_received;
 }
Exemplo n.º 2
0
        private int wait_time = 0; // This is how many times second_process will run;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new spread sheet the user can interact with.
        /// </summary>
        public Form1()
        {
            InitializeComponent();
            //sets the title of the spread sheet to 1 more than the one that opened it.
            this.Text = "DangerZone";//"Spreadsheet " + (SpreadsheetApplicationContext.getAppContext().get_form_count() + 1);
            my_spread_sheet = new Spreadsheet(IsValid, Normalize, "ps6");
            //sets the initial user edit location to the contents box.
            contents_box.Select();
            spreadsheetPanel1.SelectionChanged += update_display;
            spreadsheetPanel1.SetSelection(0, 0);
            unprocessed_commands = new Queue<string>();
            old_contents = new Queue<string>();
            changes_queue = new Queue<string>();
            cells_to_recalulate = new HashSet<string>();
            change_lock = new object();// This is the lock for when a current change is being done
            queue_lock = new object();
            command_queue_lock = new object();
            cell_name = string.Empty;
            spreadsheet_name = string.Empty;
            server_ready = true;
            waiting = false;
            undo_pending = false;
            send_ok = false;
            ignore_timer = false;
            ignore_timer1 = false;
            NewForm = null;
            OpenForm = null;
        }
Exemplo n.º 3
0
 /*
  * This will send the create command with the filename and the password to the server
  *
  * */
 private void new_setup_received(object s)
 {
     if (s.ToString().Length != 0)
     {
         stringsocket.BeginSend("CREATE\n" + s.ToString() + "\n", (e, p) => { }, null);
     }
     NewForm = null;
 }
Exemplo n.º 4
0
        /*
         * This disconnects the client connection
         *
         * */
        private void disconnect()
        {
            try
            {
                connected_label1.Invoke(new Action(() => connected_label1.Text = "Connected: Offline"));
                connected_label1.Invoke(new Action(() => connected_label1.ForeColor = System.Drawing.Color.Red));
                connect_button.Invoke(new Action(() => connect_button.Enabled = true));
                contents_box.Invoke(new Action(() => contents_box.Enabled = false));
                contents_box.Invoke(new Action(() => contents_box.Clear()));
                value_box.Invoke(new Action(() => value_box.Clear()));
                Invoke(new Action(() => newToolStripMenuItem.Enabled = false));
                Invoke(new Action(() => openToolStripMenuItem.Enabled = false));
                Invoke(new Action(() => saveToolStripMenuItem1.Enabled = false));
                Invoke(new Action(() => undoToolStripMenuItem.Enabled = false));
                Invoke(new Action(() => leaveSessionToolStripMenuItem.Enabled = false));
                ip_address_box.Invoke(new Action(()=>ip_address_box.Enabled = true));
                port_text_box.Invoke(new Action(() => port_text_box.Enabled = true));

                // clear the spreadsheet logic and gui
                my_spread_sheet = new Spreadsheet(IsValid, Normalize, "ps6");
                spreadsheetPanel1.Invoke(new Action(() => spreadsheetPanel1.Clear()));

                this.Invoke(new Action(() => this.Text = "DangerZone"));

                MessageConsoletextBox.Invoke(new Action(() => MessageConsoletextBox.Clear()));// clears the message console text box.
                lock (queue_lock)
                {
                    changes_queue.Clear();// empty out out changes queue
                }
                lock (command_queue_lock)
                {
                    unprocessed_commands.Clear();// empty out the unprocessed commands queue
                }
            }
            catch
            {
            }
            if(NewForm != null)
            {
                NewForm.Invoke(new Action(() => NewForm.Close()));
                NewForm = null;
            }

            if (OpenForm != null)
            {
                OpenForm.Invoke(new Action(() => OpenForm.Close()));
                OpenForm = null;
            }

            try
            {
                client.Client.Shutdown(SocketShutdown.Both);
                client.Client.Close();
                stringsocket = null;
            }
            catch (Exception)
            {
            }
        }