Пример #1
0
 private void basicIdeCtl1_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
 {
     // BasicIdeCtl's id can be ignored
     log_.Append(" >> " + e.Param);
     string command = sync_id_ + " " + Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Param)) + "\r\n";
     lock (lock_)
         commands_.Append(command);
 }
Пример #2
0
 private void basicIdeCtl1_EnterDesignMode(object sender, WinWrap.Basic.Classic.DesignModeEventArgs e)
 {
     if (module_ != null)
     {
         module_.Dispose();
         module_ = null;
         basicIdeCtl1.UnloadModule(ScriptPath("Globals.bas"));
     }
 }
Пример #3
0
 public static string FormatTimeoutError(WinWrap.Basic.BasicNoUIObj basicNoUIObj, bool timedout)
 {
     // get the line that's executing right now
     var sb = new StringBuilder();
     sb.AppendLine((string)basicNoUIObj.Query("GetStack")["Caller[0]"]);
     sb.AppendLine(timedout ? "time exceeded" : "paused" + ", terminating script.");
     sb.AppendLine("");
     return sb.ToString();
 }
Пример #4
0
        private void basicIdeCtl1_GetMacroName(object sender, WinWrap.Basic.Classic.GetMacroNameEventArgs e)
        {
            FileDialogForm dialog = new FileDialogForm();
            foreach (string script in Scripts)
                dialog.listBox1.Items.Add(script);

            dialog.listBox1.SelectedIndex = 0;
            dialog.Text = e.OpenDialog ? "Open" : "Save";
            dialog.ShowDialog(this);
            if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
                e.FileName = Scripts[dialog.listBox1.SelectedIndex] + ".bas";

            e.Handled = true;
        }
Пример #5
0
        private void basicIdeCtl1_LeaveDesignMode(object sender, WinWrap.Basic.Classic.DesignModeEventArgs e)
        {
            if (basicIdeCtl1.LoadModule(ScriptPath("Globals.bas")))
            {
                // Load selected script (can access globals loaded above)
                module_ = basicIdeCtl1.ModuleInstance(ScriptPath(Script), false);
            }

            if (module_ == null)
            {
                // Can't leave design mode because LoadModule or ModuleInstance were unsuccessful
                e.Cancel = true;
                basicIdeCtl1.ExecuteMenuCommand(WinWrap.Basic.CommandConstants.ShowError);
                basicIdeCtl1.UnloadModule(ScriptPath("Globals.bas"));
            }
        }
Пример #6
0
 public static string FormatError(WinWrap.Basic.Error error)
 {
     var sb = new StringBuilder();
     if (error != null)
     {
         sb.AppendLine(error.File);
         if (File.Exists(error.File))
         {
             string[] lines = File.ReadAllLines(error.File);
             string line = lines[error.Line - 1];
             if (error.Offset >= 0)
                 line = line.Insert(error.Offset, "<here>");
             line = string.Format(@"{0:00}:{1}", error.Line, line);
             sb.AppendLine(line);
         }
         sb.AppendLine(error.Text);
         sb.AppendLine("");
     }
     return sb.ToString();
 }
Пример #7
0
 public static string FormatError(WinWrap.Basic.Error error, WinWrap.Basic.IVirtualFileSystem vfs)
 {
     var sb = new StringBuilder();
     if (error != null)
     {
         if (vfs.Exists(error.File))
         {
             string[] lines = vfs.Read(error.File).Split(new string[]{"\r\n"}, StringSplitOptions.None);
             string line = lines[error.Line - 1];
             if (error.Offset >= 0)
                 line = line.Insert(error.Offset, "!here!");
             line = string.Format(@"* {0:00}: {1}", error.Line, line.Trim());
             sb.AppendLine(line);
             sb.AppendLine(error.Text);
             sb.AppendLine("");
             for (int i=1; i <= lines.Length; i++)
             {
                 sb.AppendLine(string.Format(@"* {0:00}: {1}", i, lines[i-1]));
             }
         }
     }
     return sb.ToString();
 }
Пример #8
0
 void basicNoUIObj_DebugPrint(object sender, WinWrap.Basic.Classic.TextEventArgs e)
 {
     AppendToTextBox1(e.Text);
 }
Пример #9
0
 private void basicIdeCtl1_StatusBar(object sender, WinWrap.Basic.Classic.StatusBarEventArgs e)
 {
     e.Handled = true;
 }
Пример #10
0
 private void basicIdeObj1_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
 {
     m_conn.Send(e.Param);
 }
Пример #11
0
 private void LogError(WinWrap.Basic.Error error)
 {
     LogError(Examples.SharedSource.WinWrapBasic.FormatError(error));
 }
Пример #12
0
        void basicNoUIObj_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
        {
            string data = Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Param)) + "\r\n";
            if (e.Id >= 0)
            {
                // response for a specific remote
                ApplicationQueue response = null;
                if (!responses_.TryGetValue(e.Id, out response))
                {
                    response = ApplicationQueue.Create("responses", LabelTarget.Text, e.Id.ToString());
                    responses_.Add(e.Id, response);
                }

                response.Append(data);
            }
            else
            {
                // response for all remotes
                foreach (ApplicationQueue response in responses_.Values)
                    response.Append(data);
            }
        }
Пример #13
0
        private void basicIdeObj1_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
        {
            txtSynchronizing.Text = e.Param;
            // send to all connections
            for (int i = 0; i < m_conns.Count; ++i)
            {
                Connection conn = (Connection)m_conns[i];
                if (conn.Connected)
                {
                    if (e.Id == -1 || e.Id == conn.Id)
                        conn.Send(e.Param);
                }
                else
                {
                    m_conns.Remove(conn);
                    --i;
                }
            }

            if (m_conns.Count == 0)
            {
                basicIdeObj1.Synchronized = false;
                lblInfo.Text = "All connections closed.";
            }
        }
Пример #14
0
 private void basicIdeObj1_DebugPrint(object sender, WinWrap.Basic.Classic.TextEventArgs e)
 {
     lblInfo.Text = e.Text;
 }
Пример #15
0
 private void ProcessSynchronizingEvents(WinWrap.Basic.BasicNoUIObj basicNoUIObj)
 {
     string commands = commands_.ReadAll();
     if (!string.IsNullOrEmpty(commands))
     {
         timelimit_ = DateTime.Now + new TimeSpan(0, 0, 10); // timeout in ten seconds
         string[] commands2 = commands.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
         foreach (string command in commands2)
         {
             string[] parts = command.Split(new char[] { ' ' }, 2);
             int id = int.Parse(parts[0]);
             string param = Encoding.UTF8.GetString(Convert.FromBase64String(parts[1]));
             basicNoUIObj.Synchronize(param, id);
         }
     }
 }
Пример #16
0
 void basicNoUIObj_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
 {
     string response = Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Param)) + "\r\n";
     conns_.ForEachConnection(conn =>
     {
         if (e.Id < 0 || e.Id == conn.Id)
             conn.Send(response);
     });
 }
Пример #17
0
 private void basicIdeCtl1_DebugTrace(object sender, WinWrap.Basic.Classic.TextEventArgs e)
 {
     if (DebugTrace != null)
         DebugTrace(this, e);
 }
Пример #18
0
        private void basicNoUIObj_DebugTrace(object sender, WinWrap.Basic.Classic.TextEventArgs e)
        {
            // *** AddBasic: not recommended (users are not interested in seeing this)
            // append the trace line to the trace output shown on the form
            if (txtTrace.TextLength > 30000)
                txtTrace.Text = "";

            txtTrace.SelectionStart = txtTrace.TextLength+1;
            if (txtTrace.TextLength > 0)
                txtTrace.SelectedText = "\r\n";

            txtTrace.SelectedText = e.Text;
            // ***
        }
Пример #19
0
 private void basicIdeCtl1_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
 {
     log_.Append(" >> " + e.Param);
     string command = Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Param)) + "\r\n";
     conn_.Send(command);
 }