Пример #1
0
        private void CloseTab()
        {
            bool success         = true;
            int  currentTabIndex = tabControl.SelectedIndex;

            currentFileEditor = (FileEditor)fileEditors[currentTabIndex];
            if (currentFileEditor.IsDirty())
            {
                if (currentFileEditor.IsNew())
                {
                    DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        success = SaveAs();
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        success = false;
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        Save(currentFileEditor.Path());
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        success = false;
                    }
                }
            }
            if (success)
            {
                if (tabControl.TabCount == 1)
                {
                    System.Environment.Exit(0);
                }
                else
                {
                    fileEditors.RemoveAt(currentTabIndex);
                    tabControl.SelectedTab.Dispose();
                    if (currentTabIndex == tabControl.TabCount)
                    {
                        tabControl.SelectTab(currentTabIndex - 1);
                    }
                    else
                    {
                        tabControl.SelectTab(currentTabIndex);
                    }
                }
            }
        }
Пример #2
0
        private void Save(String path)
        {
            System.IO.StreamWriter saveFile = new System.IO.StreamWriter(path);
            String lines = currentFileEditor.GetText();

            saveFile.Write(lines);
            saveFile.Close();
            currentFileEditor.SetDirty(false);
            currentFileEditor.SetNew(false);
            tabControl.SelectedTab.Text = currentFileEditor.ShortName();
        }
Пример #3
0
        private void OnNewWindow()
        {
            currentFileEditor    = null;
            fileEditors          = new ArrayList();
            tabControl           = new TabControl();
            tabControl.Name      = "tabControl";
            tabControl.Selected += TabControl_Selected;
            tabControl.MouseUp  += TabControl_MouseUp;
            menuStrip1.Dock      = DockStyle.Top;
            tabControl.Dock      = DockStyle.Fill;
            splitContainer1.Panel1.Controls.Add(tabControl);
            splitContainer1.Panel1.Controls.Add(menuStrip1);       //Fixed the problem <- Can this line be avoided
            splitContainer2.Panel1.Controls.Add(tabControl);
            splitContainer2.Panel1.Controls.Add(menuStrip1);

            mnu             = new ContextMenu();
            mnuClose        = new MenuItem("Close");
            mnuClose.Click += new EventHandler(MnuClose_Click);
            mnu.MenuItems.AddRange(new MenuItem[] { mnuClose });

            uploadButton.Enabled = false;
            stepButton.Enabled   = false;
            breakPoints          = new ArrayList();

            if (!File.Exists(lastSessionName))
            {
                OnNewFile();
            }
            else
            {
                using (StreamReader reader = new StreamReader(lastSessionName)) {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Equals("new tab"))
                        {
                            currentFileEditor = new FileEditor(tabControl);
                            fileEditors.Add(currentFileEditor);
                            TabPage newTab = new TabPage(currentFileEditor.ShortName());
                            tabControl.Controls.Add(newTab);
                            newTab.Controls.Add(currentFileEditor.GetScintilla());
                        }
                        else
                        {
                            if (File.Exists(line))
                            {
                                currentFileEditor = new FileEditor(tabControl, line, line.Substring(line.LastIndexOf("\\") + 1), File.ReadAllText(line));
                                fileEditors.Add(currentFileEditor);
                                TabPage newTab = new TabPage(currentFileEditor.ShortName());
                                tabControl.Controls.Add(newTab);
                                newTab.Controls.Add(currentFileEditor.GetScintilla());
                            }
                        }
                    }
                }
            }
            port = 3002;
            Client client = new Client(address, port, this);
        }
Пример #4
0
        private void OnNewFile()
        {
            currentFileEditor = new FileEditor(tabControl);
            fileEditors.Add(currentFileEditor);
            TabPage newTab = new TabPage(currentFileEditor.ShortName());

            tabControl.TabPages.Add(newTab);
            newTab.Controls.Add(currentFileEditor.GetScintilla());
            tabControl.SelectTab(fileEditors.Count - 1);
        }
Пример #5
0
        private bool CloseFile()
        {
            int i = 0;

            while (i < tabControl.TabCount)
            {
                currentFileEditor = (FileEditor)fileEditors[i];
                tabControl.SelectTab(i);
                if (currentFileEditor.IsDirty())
                {
                    if (currentFileEditor.IsNew())
                    {
                        DialogResult result = MessageBox.Show("Do you want to save this file?", "Saving new file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            if (SaveAs() == false)
                            {
                                return(false);
                            }
                        }
                        else if (result == DialogResult.Cancel)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            Save(currentFileEditor.Path());
                        }
                        else if (result == DialogResult.Cancel)
                        {
                            return(false);
                        }
                    }
                }
                i++;
            }
            saveSession();
            return(true);
        }
Пример #6
0
 private bool CloseFile()
 {
     int i = 0;
     while (i < tabControl.TabCount)
     {
         currentFileEditor = (FileEditor)fileEditors[i];
         tabControl.SelectTab(i);
         if (currentFileEditor.IsDirty())
         {
             if (currentFileEditor.IsNew())
             {
                 DialogResult result = MessageBox.Show("Do you want to save this file?", "Saving new file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                 if (result == DialogResult.Yes)
                 {
                     if (SaveAs() == false)
                         return false;
                 }
                 else if (result == DialogResult.Cancel)
                     return false;
             }
             else
             {
                 DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                 if (result == DialogResult.Yes)
                     Save(currentFileEditor.Path());
                 else if (result == DialogResult.Cancel)
                     return false;
             }
         }
         i++;
     }
     saveSession ();
     return true;
 }
Пример #7
0
        private void OnNewWindow()
        {
            currentFileEditor = null;
            fileEditors = new ArrayList();
            tabControl = new TabControl();
            tabControl.Name = "tabControl";
            tabControl.Selected += TabControl_Selected;
            tabControl.MouseUp += TabControl_MouseUp;
            menuStrip1.Dock = DockStyle.Top;
            tabControl.Dock = DockStyle.Fill;
            splitContainer1.Panel1.Controls.Add(tabControl);
            splitContainer1.Panel1.Controls.Add(menuStrip1);       //Fixed the problem <- Can this line be avoided
            splitContainer2.Panel1.Controls.Add(tabControl);
            splitContainer2.Panel1.Controls.Add(menuStrip1);

            mnu = new ContextMenu();
            mnuClose = new MenuItem("Close");
            mnuClose.Click += new EventHandler(MnuClose_Click);
            mnu.MenuItems.AddRange(new MenuItem[] { mnuClose });

            uploadButton.Enabled = false;
            stepButton.Enabled = false;
            breakPoints = new ArrayList();

            if (!File.Exists (lastSessionName))
                OnNewFile ();
            else {
                using (StreamReader reader = new StreamReader (lastSessionName)) {
                    string line;
                    while ((line = reader.ReadLine ()) != null) {
                        if (line.Equals ("new tab")) {
                            currentFileEditor = new FileEditor (tabControl);
                            fileEditors.Add (currentFileEditor);
                            TabPage newTab = new TabPage (currentFileEditor.ShortName ());
                            tabControl.Controls.Add (newTab);
                            newTab.Controls.Add (currentFileEditor.GetScintilla ());
                        } else {
                            if (File.Exists (line)) {
                                currentFileEditor = new FileEditor (tabControl, line, line.Substring (line.LastIndexOf ("\\") + 1), File.ReadAllText (line));
                                fileEditors.Add (currentFileEditor);
                                TabPage newTab = new TabPage (currentFileEditor.ShortName ());
                                tabControl.Controls.Add (newTab);
                                newTab.Controls.Add (currentFileEditor.GetScintilla ());
                            }
                        }
                    }
                }
            }
            port = 3002;
            Client client = new Client(address, port, this);
        }
Пример #8
0
 private void OnNewFile()
 {
     currentFileEditor = new FileEditor (tabControl);
     fileEditors.Add (currentFileEditor);
     TabPage newTab = new TabPage (currentFileEditor.ShortName ());
     tabControl.TabPages.Add (newTab);
     newTab.Controls.Add (currentFileEditor.GetScintilla ());
     tabControl.SelectTab (fileEditors.Count - 1);
 }
Пример #9
0
 private void CloseTab()
 {
     bool success = true;
     int currentTabIndex = tabControl.SelectedIndex;
     currentFileEditor = (FileEditor)fileEditors[currentTabIndex];
     if (currentFileEditor.IsDirty())
     {
         if (currentFileEditor.IsNew())
         {
             DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
                 success = SaveAs();
             else if (result == DialogResult.Cancel)
                 success = false;
         }
         else
         {
             DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
                 Save(currentFileEditor.Path());
             else if (result == DialogResult.Cancel)
                 success = false;
         }
     }
     if (success)
     {
         if (tabControl.TabCount == 1)
             System.Environment.Exit(0);
         else
         {
             fileEditors.RemoveAt(currentTabIndex);
             tabControl.SelectedTab.Dispose();
             if (currentTabIndex == tabControl.TabCount)
             {
                 tabControl.SelectTab(currentTabIndex - 1);
             }
             else
                 tabControl.SelectTab(currentTabIndex);
         }
     }
 }