コード例 #1
0
 /// <summary>
 /// Create new project
 /// </summary>
 /// <param name="name">Name of project</param>
 /// <param name="folder">folder, where project will be saved</param>
 /// <returns></returns>
 public static ByterProject CreateProject(string name, string folder)
 {
     ByterProject res = new ByterProject();
     res.ProjectPath = folder + name;
     res.MainMethod = "Main";
     res.AddMethod(res.MainMethod, folder + res.MainMethod + ".byt");
     return res;
 }
コード例 #2
0
        /// <summary>
        /// Create new project
        /// </summary>
        /// <param name="name">Name of project</param>
        /// <param name="folder">folder, where project will be saved</param>
        /// <returns></returns>
        public static ByterProject CreateProject(string name, string folder)
        {
            ByterProject res = new ByterProject();

            res.ProjectPath = folder + name;
            res.MainMethod  = "Main";
            res.AddMethod(res.MainMethod, folder + res.MainMethod + ".byt");
            return(res);
        }
コード例 #3
0
 static void Main(params string[] args)
 {
     if (args.Length != 1 ||  !File.Exists(args[0]))
         return;
     ByterProject project = new ByterProject();
     project.LoadFiles(args[0]);
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     OutputForm outf = new OutputForm();
     DebugForm debug = new DebugForm(project, project.MainMethod, outf);
     debug.IsMain = true;
     Application.Run(debug);
 }
コード例 #4
0
 public DebugForm(ByterProject project, string methodName, OutputForm output)
 {
     if (project == null || methodName == null || output == null)
         throw new ArgumentNullException("Cannot create debug form for empty procedure.");
     InitializeComponent();
     Project = project;
     CodeTable = new char[16, 16];
     Array.Copy(Project.Sources[methodName], CodeTable, 256);
     Output = output;
     CurrentPosition = new Point(0, 0);
     IsMain = false;
     CurrentDirection = Direction.Right;
     Child = Parent = null;
     dataGridView1.RowCount = 16;
     dataGridView1.ColumnCount = 16;
     RefreshTable();
     for (int i = 0; i < 16; i++)
         dataGridView1.Columns[i].Width = dataGridView1.Rows[i].Height;
     Text += " — " + methodName;
 }
コード例 #5
0
        private void openProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog(this) == DialogResult.OK && Path.GetExtension(openFileDialog1.FileName) == ".bytpr")
                {
                    Directory.SetCurrentDirectory(Path.GetDirectoryName(openFileDialog1.FileName));
                    ByterProject newProject = new ByterProject();
                    newProject.LoadFiles(openFileDialog1.FileName);
                    OpenedProject = newProject;
                    projectExplorerBox.Items.Clear();
                    codeTabControl.TabPages.Clear();
                    foreach (var k in OpenedProject.FileNames)
                        projectExplorerBox.Items.Add("Module " + k.Key);

                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #6
0
 private void newProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string newProjectName = "";
         bool CreateNewFolder = true;
         if (InputBox.ShowDialog("Введите название проекта", "Название проекта", "Создать новую папку", ref newProjectName, ref CreateNewFolder) == DialogResult.OK &&
             folderBrowserDialog1.ShowDialog() == DialogResult.OK)
         {
             if (!System.Text.RegularExpressions.Regex.IsMatch(newProjectName, @"\w+"))
             {
                 MessageBox.Show("Incorrect project name!");
                 return;
             }
             string s = folderBrowserDialog1.SelectedPath;
             s += @"\";
             if (CreateNewFolder)
                 s += newProjectName + @"\";
             if (OpenedProject != null)
                 this.closeProjectToolStripMenuItem_Click(sender, e);
             OpenedProject = ByterProject.CreateProject(newProjectName + ".bytpr", s);
             projectExplorerBox.Items.Clear();
             codeTabControl.TabPages.Clear();
             foreach (var k in OpenedProject.FileNames)
                 projectExplorerBox.Items.Add("Module " + k.Key);
             this.AddTab(OpenedProject.MainMethod);
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
コード例 #7
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         if(DbgProcess!= null)
             switch (MessageBox.Show(this, "Stop debugging?", "Confirm", MessageBoxButtons.OKCancel))
             {
                 case DialogResult.OK: DbgProcess.Kill(); break;
                 case DialogResult.Cancel: e.Cancel = true; return;
             }
         if (OpenedProject != null && OpenedProject.ProjectChanged)
             switch (MessageBox.Show(this, "Save changes in project?", "Confirm", MessageBoxButtons.YesNoCancel))
             {
                 case DialogResult.Yes: OpenedProject.SaveAll(); break;
                 case DialogResult.Cancel: e.Cancel = true; return;
             }
         OpenedProject = null;
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
コード例 #8
0
 private void closeProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (OpenedProject.ProjectChanged || OpenedProject.FilesChanged.ContainsValue(true))
             switch (MessageBox.Show(this, "Save changes in project?", "Confirm", MessageBoxButtons.YesNoCancel))
             {
                 case DialogResult.Yes: OpenedProject.SaveAll(); break;
                 case DialogResult.Cancel: return;
             }
         codeTabControl.TabPages.Clear();
         OpenedProject = null;
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }