示例#1
0
        public static void NewScript()
        {
            if (-1 != _defaultTemplateIndex)
            {
                LoadItem(_defaultTemplateIndex);
            }
            else
            {
                _defaultScript[1] = _defaultScript[1].Replace("vX.XX", "v" + Application.ProductVersion);

                _ScripterForm.CreateNewDocument(Scripter.DEF_FILE_NAME);

                _ScripterForm.CurrentEditor.Loading = true;

                foreach (string s in _defaultScript)
                {
                    _ScripterForm.CurrentEditor.AddLine(s);
                }
                _ScripterForm.CurrentEditor.Dirty = false;
                _ScripterForm.CurrentEditor.InitUndoStack();
                Scripter.DoEvents();
                _ScripterForm.OnReParse();
                Scripter.DoEvents();
                _ScripterForm.CurrentEditor.Focus();
            }

            _ScripterForm.CurrentEditor.Loading = false;
        }
示例#2
0
        public static void LoadItem(int index)
        {
            _ScripterForm.CreateNewDocument(Scripter.DEF_FILE_NAME);

            string filename = "Template" + index + ".tem";
            string path     = Path.Combine(Path.Combine(Path.Combine(Scripter.AppPath, "data"), "templates"), filename);

            if (!File.Exists(path))
            {
                UtilSys.MessageBox("File '" + path + "' does not exist.");
                return;
            }

            string[] buffer = UtilIO.ReadFile2Array(path);

            _ScripterForm.CurrentEditor.Loading = true;

            foreach (string line in buffer)
            {
                _ScripterForm.CurrentEditor.AddLine(line);
            }
            _ScripterForm.CurrentEditor.Loading = false;
            _ScripterForm.CurrentEditor.Dirty   = false;
            _ScripterForm.CurrentEditor.InitUndoStack();
            Scripter.DoEvents();
            _ScripterForm.OnReParse();
            Scripter.DoEvents();
            _ScripterForm.CurrentEditor.Focus();
        }
示例#3
0
        public static void ShowTokensInCurrentLine(List <string> tokens, string line, int currentLine)
        {
            Scripter.ClearDebugOutput();

            foreach (string item in tokens)
            {
                Scripter.DebugOutput(item);
            }
        }
示例#4
0
        private void FormServerConfigure_Load(object sender, EventArgs e)
        {
            cboServer.Items.Clear();

            m_lst = Scripter.LoadServerIPHistory();

            for (int i = m_lst.Count - 1; i > -1; --i)
            {
                cboServer.Items.Add(m_lst[i]);
            }

            cboServer.Text = Settings.Get("ServerIP");
        }
示例#5
0
        private void cmdDownload_Click(object sender, EventArgs e)
        {
            string downloadTo = Settings.Get("DownloadTo");

            if (string.IsNullOrEmpty(downloadTo))
            {
                UtilSys.MessageBox("Set download to location first");
                return;
            }

            m_downloadList.Clear();
            GetList(tvw.Nodes[0]);

            FrmProgress frmP = new FrmProgress();

            frmP.Text = "Downloading...";
            frmP.SetProgressMax(m_downloadList.Count);

            frmP.Show();
            frmP.Top  = Top + Height / 2;
            frmP.Left = (Left + Width / 2) - frmP.Width / 2;

            frmP.Update();

            Scripter.DoEvents();

            foreach (string item in m_downloadList)
            {
                string temp = Settings.Get("ServerIP");

                string[] arr = temp.Split(':');

                if (2 == arr.Length)
                {
                    frmP.Text = item;
                    frmP.UpdateProgress();

                    string ip   = arr[0];
                    int    port = Convert.ToInt32(arr[1]);

                    NetworkClient nc = new NetworkClient(ip, port);

                    string savePath = Path.Combine(downloadTo, item);
                    nc.DownloadFile(item, savePath);
                }
            }
            frmP.Close();
        }
示例#6
0
        private void AddTextToSearchHistory(string text)
        {
            int index = 0;

            foreach (string item in m_lstSearchHistory)
            {
                if (item == text)
                {
                    m_lstSearchHistory.RemoveAt(index);
                    break;
                }
                ++index;
            }

            m_lstSearchHistory.Add(text);
            Scripter.SaveSearchHistory(m_lstSearchHistory);
        }
示例#7
0
        private void FrmFindAndReplace_Load(object sender, EventArgs e)
        {
            chkMatchCase.Checked = _bMatchCase;
            chkWholeWord.Checked = _bWholeWord;

            m_lstSearchHistory = Scripter.LoadSearchHistory();

            for (int i = m_lstSearchHistory.Count - 1; i > -1; --i)
            {
                cboTextToFind.Items.Add(m_lstSearchHistory[i]);
            }

            m_lstReplaceHistory = Scripter.LoadReplaceHistory();

            for (int i = m_lstReplaceHistory.Count - 1; i > -1; --i)
            {
                cboReplaceWith.Items.Add(m_lstReplaceHistory[i]);
            }

            cboTextToFind.Text = (string)Tag;
        }
示例#8
0
        private void AddToHistory(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            int index = 0;

            foreach (string item in m_lst)
            {
                if (item == text)
                {
                    m_lst.RemoveAt(index);
                    break;
                }
                ++index;
            }

            m_lst.Add(text);
            Scripter.SaveServerIPHistory(m_lst);
        }
示例#9
0
文件: Opener.cs 项目: rgunczer/QAB
        public static void Open(string path, string filter)
        {
            if (string.IsNullOrEmpty(filter))
            {
                filter = "QABOT Script Files (*.scp)|*.scp|QABOT Script Import Modules (*.sci)|*.sci|QABOT Data Files (*.dat)|*.dat|QABOT Project Files (*.qpf)|*.qpf|QABOT Template Files (*.tem)|*.tem|All Files (*.*)|*.*";
            }

            if (string.IsNullOrEmpty(path))
            {
                path = UtilSys.OpenFileDialog("Open QABOT Script, Data or Template File", filter, LastOpenedFolder);
            }

            if (string.Empty == path)
            {
                return;
            }

            bool bOpened = false;

            // if the script is already opened in one of tabs
            // check if it is modified if yes, ask to save it?
            int    i      = 0;
            Editor editor = null;

            foreach (TabPage page in frm.tabFiles.TabPages)
            {
                editor = (Editor)page.Controls[0].Controls[0];

                Debug.Assert(null != editor);

                if (editor.Path2File == path)
                {
                    bOpened = true;
                    frm.tabFiles.SelectedIndex = i;
                    editor.Clear();
                    Application.DoEvents();
                    break;
                }
                ++i;
            }

            Stopwatch sw = new Stopwatch();

            sw.Start();

            string[] buffer = ScriptLoader.Load(frm, mru, path);

            if (null == buffer)
            {
                frm.UpdateMRUMenu();
                return;
            }

            LastOpenedFolder = Path.GetDirectoryName(path);

            FrmProgress frmP = new FrmProgress();

            frmP.Show();
            frmP.Top  = frm.Top + frm.Height / 2;
            frmP.Left = (frm.Left + frm.Width / 2) - frmP.Width / 2;

            frmP.SetProgressMax(buffer.Length);

            if (!bOpened)
            {
                frm.CreateNewDocument(path);
                editor = frm.CurrentEditor;
            }

            editor.Dirty   = false;
            editor.Loading = true;
            editor.SuspendLayout();

            bool IsCompatibilityChangeMade = false;

            string line = string.Empty;

            for (int j = 0; j < buffer.Length; ++j)
            {
                line = buffer[j];

                if (_bCompatibilty)
                {
                    line = CreateCompatibileLine(line);

                    if (line != buffer[j])
                    {
                        IsCompatibilityChangeMade = true;
                        Scripter.Output("Line(" + j.ToString() + ") changed from -> to: '" + buffer[j] + "' -> '" + line + "'");
                    }
                }
                editor.AddLine(line);
                frmP.UpdateProgress();
                frmP.Text = "Progress... (" + j + "/" + buffer.Length + ")";
            }

            editor.ResumeLayout();
            editor.Loading = false;
            editor.HandleBlockComments();
            editor.InitUndoStack();
            frmP.Close();

            if (!bOpened)
            {
                frm.tabFiles.SelectedIndex = frm.tabFiles.TabPages.Count - 1;
                frm.tabFiles.TabPages[frm.tabFiles.SelectedIndex].Focus();
                frm.UpdateDebugButtons();
            }

            editor.Dirty = IsCompatibilityChangeMade;

            frm.UpdateMRUMenu();
            frm.OnReParse();
            editor.Focus();

            sw.Stop();

            TimeSpan span = sw.Elapsed;

            Scripter.Output("Load Time: " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + ":" + span.Milliseconds);
        }
示例#10
0
 public void DoEvents()
 {
     Scripter.DoEvents();
 }