コード例 #1
0
ファイル: MainForm.cs プロジェクト: alon/bhuman2009fork
        private void ShowTab(int index)
        {
            if (index < _tabs.Count && index >= 0)
              {

            if (_curTab != null && _curTab.doc != null
              && _curTab.doc.CompilationIsRunning)
            {
              _curTab.doc.CancelCompilation();
            }

            _curTab = _tabs[index];

            tabControlEditor.SelectedIndex = index;

            if (_curTab.doc == null)
            {
              // is empty
              tabControlEditor.TabPages[index].Text = "empty";
              _curTab.view.EmptyUndoBuffer();
              _curTab.view.SetSavePoint();
              dropDownButtonOption.Text = "(choose an option)";
              toolStripStatusLabel.Text = "";
              enableGraphicalEnviroment(false);
              enableTextEnviroment(false, _curTab);
            }
            else
            {
              ShowDocument(_curTab, true);
            }
              }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: alon/bhuman2009fork
        private void ShowDocument(Tab theTab, bool updateSvg)
        {
            enableTextEnviroment(true, theTab);

              // adjust buttons
              buttonSave.Enabled = saveCurrentFileToolStripMenuItem.Enabled = !_curTab.wasSaved;
              buttonBack.Enabled = oneOptionBackToolStripMenuItem.Enabled =
            (theTab.backOptions == null || theTab.backOptions.Count == 0) ? false : true;
              buttonForward.Enabled = oneOptionForwardToolStripMenuItem.Enabled =
            (theTab.forwardOptions == null || theTab.forwardOptions.Count == 0) ? false : true;

              XabslDocument theDoc = theTab.doc;

              toolStripStatusLabel.Text = theDoc.File.FullName;

              /*
              timerCheckForChangedFile.Enabled = false;
              checkFileChanged(theDoc);
              timerCheckForChangedFile.Enabled = true;
              */

              if (!theDoc.IsOption)
              {
            // set title
            this.Text = "XabslEditor - " + theDoc.File.FullName;
            dropDownButtonOption.Text = "(choose an option)";
            enableGraphicalEnviroment(false);
              }
              else
              {
            enableGraphicalEnviroment(true);
            // set title
            this.Text = "XabslEditor - " + _curBehavior.BehaviorName + ": " + theDoc.RelativeOptionPath;

            dropDownButtonOption.Text = theDoc.RelativeOptionPath;
            if (updateSvg)
            {
              // get the needed files for graphical output
              theDoc.RequestSvgFiles(false);
            }
              }

              // set tab title
              tabControlEditor.SelectedTab.Text = theTab.wasSaved ? theDoc.File.Name : theDoc.File.Name + " *";

              // mark errors

              // clear old errors first
              theTab.view.StartStyling(0, Helpers.SCI_INDICS_MASK);
              theTab.view.SetStyling(theTab.view.Text.Length, 0);
              theTab.view.Colourise(0, theTab.view.Length - 1);

              if (_errorList != null && _errorList.Errors != null)
              {
            string[] seps = new string[] { "\r\n", "\n", "\r" };
            string[] lines = theTab.view.Text.Split(seps, StringSplitOptions.None);

            foreach (ErrorEntry entry in _errorList.Errors)
            {
              // the same document?
              if (entry.file.Equals(theDoc.File.FullName, StringComparison.InvariantCultureIgnoreCase))
              {
            int posFromLine = theTab.view.PositionFromLine(entry.line-1);

            try
            {
              if (entry.line > -1 && entry.line < lines.Length)
              {
                string theLine = lines[entry.line - 1];

                int startMark = 0;
                if (entry.errorSample != null)
                {
                  startMark = theLine.IndexOf(entry.errorSample);
                }
                theTab.view.StartStyling(posFromLine + startMark, Helpers.SCI_INDICS_MASK);

                int length = 0;
                if (entry.errorSample == null)
                {
                  length = theLine.Length;
                }
                else
                {
                  length = entry.errorSample.Length;
                }
                theTab.view.SetStyling(length, Helpers.SCI_INDIC0_MASK);

                theTab.view.SetIndicStyle(0, (int)Scintilla.Enums.IndicatorStyle.squiggle);
                theTab.view.SetIndicFore(0, 0x0000ff);
              }
            }
            catch (Exception ex)
            {
              ExceptionDialog.ShowWarning(ex);
            }
              }
            }
              }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: alon/bhuman2009fork
 /// <summary>
 /// Will enable or disable all elements of the ui, which are related to text editing.
 /// </summary>
 /// <param name="enable">wether to enable (true) or disable (false)</param>
 /// <param name="tab">the tab which is effected</param>
 private void enableTextEnviroment(bool enable, Tab tab)
 {
     tab.view.Enabled = enable;
       insertStateBodyToolStripMenuItem.Enabled = enable;
       commentCodeOutToolStripMenuItem.Enabled = enable;
       uncommentCodeToolStripMenuItem.Enabled = enable;
       autocompletitionToolStripMenuItem.Enabled = enable;
       findToolStripMenuItem.Enabled = enable;
       undoToolStripMenuItem.Enabled = buttonUndo.Enabled = enable;
       redoToolStripMenuItem.Enabled = buttonRedo.Enabled = enable;
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: alon/bhuman2009fork
        private void CreateNewTab()
        {
            tabControlEditor.TabPages.Add("empty");
              Tab t = new Tab(null, tabControlEditor.TabPages[tabControlEditor.TabCount-1],
            _appPath + "\\" + Properties.Settings.Default.ScintillaXabslFile);
              t.view.SavePointLeft += new Scintilla.SavePointLeftHandler(scintillaControlInput_SavePointLeft);
              t.view.SavePointReached += new Scintilla.SavePointReachedHandler(scintillaControlInput_SavePointReached);

              _tabs.Add(t);
              tabControlEditor.SelectTab(tabControlEditor.TabPages.Count - 1);
              ShowTab(_tabs.Count - 1);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: alon/bhuman2009fork
        /** returns true, if cancelation was requested */
        private bool checkSaved(Tab tab)
        {
            if(tab == null) return false;

              XabslDocument doc = tab.doc;

              bool curDocChanged = false;
              if (doc != null && _curTab.doc == doc && !tab.wasSaved)
            curDocChanged = true;

              if ((doc != null && !doc.ChangesSaved) || curDocChanged)
              {
            DialogResult result = MessageBox.Show(doc.File.FullName + "\n\nFile not saved yet, do you want to save it now?", "file not saved", MessageBoxButtons.YesNoCancel);
            if (result == DialogResult.Yes)
            {
              // save the file
              if (curDocChanged)
              {
            doc.Content = _curTab.view.Text;
              }
              doc.SaveChanges();
            }
            else if (result == DialogResult.Cancel)
            {
              return true;
            }
              }
              return false;
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: alon/bhuman2009fork
        /** checks wether a file has been changed by another program */
        private void checkFileChanged(Tab t)
        {
            if(t == null) return;

              XabslDocument doc = t.doc;

              if (doc != null && doc.FileChangedOutside)
              {
            // file has been changed
            DialogResult result = MessageBox.Show(doc.File.FullName
              + "\n\n The file has been changed by another program. Shall the file be reloaded?",
              "file changed outside of program",
              MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
              doc.ReloadFileContent();
              t.view.Text = doc.Content;
            }
              }
        }