Example #1
0
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (codeTabControl.TabCount == 0)
                {
                    return;
                }
                var currentTab = codeTabControl.SelectedTab;
                if (OpenedProject != null && OpenedProject.FilesChanged.ContainsKey(currentTab.Name) && OpenedProject.FilesChanged[currentTab.Name])
                {
                    switch (MessageBox.Show(this, "Save changes in module" + currentTab.Name + '?', "Confirm", MessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.Yes: OpenedProject.SaveFile(currentTab.Name); break;

                    case DialogResult.Cancel: return;
                    }
                }
                codeTabControl.TabPages.Remove(currentTab);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Example #2
0
 private void toolStripMenuItemDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (projectExplorerBox.SelectedItem == null || OpenedProject == null)
         {
             return;
         }
         string methodName = projectExplorerBox.SelectedItem.ToString().Remove(0, "Module ".Length);
         if (codeTabControl.TabPages.ContainsKey(methodName))
         {
             codeTabControl.TabPages.RemoveByKey(methodName);
         }
         if (methodName.Length > 1)
         {
             MessageBox.Show("You cannot delete main method");
             return;
         }
         OpenedProject.RemoveMethod(methodName);
         projectExplorerBox.Items.Clear();
         foreach (var k in OpenedProject.FileNames)
         {
             projectExplorerBox.Items.Add("Module " + k.Key);
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #3
0
 private void debugToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (OpenedProject == null)
         {
             return;
         }
         if (DbgProcess != null)
         {
             DbgProcess.Kill();
             debugToolStripMenuItem.Text = "Debug";
             return;
         }
         if (MessageBox.Show("Project will be saved to debug.\nDo you sure to start?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             OpenedProject.SaveAll();
             DbgProcess = new System.Diagnostics.Process();
             Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));
             DbgProcess.StartInfo           = new System.Diagnostics.ProcessStartInfo("Debugger.exe", OpenedProject.ProjectPath);
             DbgProcess.EnableRaisingEvents = true;
             DbgProcess.Exited += DbgProcess_Exited;
             DbgProcess.Start();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #4
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);
            }
        }
Example #5
0
        void CloseOpenedProject(bool save)
        {
            if (OpenedProject == null)
            {
                return;
            }

            Log.Debug("Closing project " + OpenedProject.ID);
            if (Capturer != null)
            {
                Capturer.Close();
            }
            if (Player != null)
            {
                Player.Dispose();
            }

            if (save)
            {
                SaveProject(OpenedProject, OpenedProjectType);
            }

            if (OpenedProject != null)
            {
                OpenedProject.Clear();
            }
            OpenedProject     = null;
            OpenedProjectType = ProjectType.None;
            guiToolkit.CloseProject();
            EmitProjectChanged();
        }
Example #6
0
 private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (!(sender is DataGridView) || OpenedProject == null)
         {
             return;
         }
         DataGridView dg = sender as DataGridView;
         char[,] source = new char[16, 16];
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 source[i, j] = (dg.Rows[i].Cells[j].Value != null)?dg.Rows[i].Cells[j].Value.ToString()[0]:'0';
             }
         }
         string methodName = dg.Name.Remove(0, "codeGridView".Length);
         OpenedProject.ChangeSource(methodName, source);
         this.LoadCodeToTab(codeTabControl.TabPages[codeTabControl.TabPages.IndexOfKey(methodName)]);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #7
0
        /// <summary>
        /// Close tab when user press on close button in tabs
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void codeTabControl_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                System.Drawing.Font font = codeTabControl.Font;
                int margin = 3;
                for (int i = 0; i < codeTabControl.TabCount; i++)
                {
                    Rectangle  tabRect = codeTabControl.GetTabRect(i);
                    RectangleF btnRect = new RectangleF(tabRect.Right - margin - tabCloseButtonSize.Width, tabRect.Top + margin, tabCloseButtonSize.Width, tabCloseButtonSize.Height);
                    if (btnRect.Contains(e.Location))
                    {
                        if (OpenedProject != null && OpenedProject.FilesChanged.ContainsKey(codeTabControl.TabPages[i].Name) && OpenedProject.FilesChanged[codeTabControl.TabPages[i].Name])
                        {
                            switch (MessageBox.Show(this, "Save changes in module " + codeTabControl.TabPages[i].Name + '?', "Confirm", MessageBoxButtons.YesNoCancel))
                            {
                            case DialogResult.Yes: OpenedProject.SaveFile(codeTabControl.TabPages[i].Name); break;

                            case DialogResult.Cancel: return;
                            }
                        }
                        codeTabControl.TabPages.RemoveAt(i);
                        return;
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Example #8
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (codeTabControl.TabCount == 0)
         {
             return;
         }
         TabPage      currentTab = codeTabControl.SelectedTab;
         string       methodName = currentTab.Name;
         DataGridView dg         = (DataGridView)(currentTab.Controls.Find("codeGridView" + methodName, true)[0]);
         char[,] table = new char[16, 16];
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 table[i, j] = dg.Rows[i].Cells[j].Value.ToString()[0];
             }
         }
         OpenedProject.ChangeSource(methodName, table);
         OpenedProject.SaveFile(methodName);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #9
0
 private void renameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (projectExplorerBox.SelectedItem == null || OpenedProject == null)
         {
             return;
         }
         string methodName = projectExplorerBox.SelectedItem.ToString().Remove(0, "Module ".Length);
         string newname    = methodName;
         if (codeTabControl.TabPages.ContainsKey(methodName))
         {
             TabPage pg = codeTabControl.TabPages[codeTabControl.TabPages.IndexOfKey(methodName)];
             foreach (Control a in pg.Controls)
             {
                 a.LostFocus -= codeTextBox_Leave;
             }
             pg.Focus();
         }
         if (InputBox.ShowDialog("Changing method name", "Input new name", ref newname) == DialogResult.OK)
         {
             if (methodName.ToUpper() == "MAIN")
             {
                 if (newname.ToUpper() != "MAIN")
                 {
                     MessageBox.Show("Main method must be called as 'Main'");
                     return;
                 }
                 else
                 {
                     OpenedProject.RenameMethod(methodName, newname);
                 }
             }
             else
             {
                 OpenedProject.RenameMethod(methodName, newname);
             }
             projectExplorerBox.Items.Clear();
             foreach (var k in OpenedProject.FileNames)
             {
                 projectExplorerBox.Items.Add("Module " + k.Key);
             }
             if (codeTabControl.TabPages.ContainsKey(methodName))
             {
                 codeTabControl.TabPages.RemoveByKey(methodName);
                 OpenTab(newname);
             }
             foreach (TabPage a in codeTabControl.TabPages)
             {
                 LoadCodeToTab(a);
             }
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message);
     }
 }
Example #10
0
 private void saveAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         OpenedProject.SaveAll();
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #11
0
        /// <summary>
        ///     Called when [opened project].
        /// </summary>
        /// <param name="projectName">Name of the project.</param>
        public void OnOpenedProject(string projectName)
        {
            var configurationLayer     = GetConfigurationLayer();
            var startupProjects        = GetStartupProjects();
            var currentStartupProjects = GetCurrentStartupProjects();
            var parsedConfiguration    = GetParsedConfiguration(configurationLayer.ComputedConfig.Startup.Profiles, startupProjects, currentStartupProjects);

            _currentProfile = parsedConfiguration.CurrentProfile;

            OpenedProject?.Invoke(this, new ProjectEventArgs(projectName, configurationLayer.ComputedConfig, parsedConfiguration.Profiles, parsedConfiguration.CurrentProfile));
        }
Example #12
0
        public void CreateNewSpell()
        {
            var dialog = new CreateNewSpellDialog();

            dialog.ShowDialog();
            if (dialog.Success)
            {
                OpenedProject.AddSpell(dialog.FilePath, dialog.SpellName);
                SaveProject();
            }
        }
Example #13
0
 private void codeTextBox_Leave(object sender, EventArgs e)
 {
     try
     {
         if (!(sender is TextBox) || OpenedProject == null)
         {
             return;
         }
         TextBox tb      = sender as TextBox;
         bool    IsValid = tb.Lines.Length == 16;
         if (IsValid)
         {
             for (int i = 0; i < 16; i++)
             {
                 if (tb.Lines[i].Length != 16)
                 {
                     IsValid = false;
                     break;
                 }
             }
         }
         if (!IsValid)
         {
             MessageBox.Show("Table of code must be 16x16");
             tb.Focus();
             return;
         }
         char[,] source = new char[16, 16];
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 source[i, j] = tb.Lines[i][j];
             }
         }
         string methodName = tb.Name.Remove(0, "codeTextBox".Length);
         OpenedProject.ChangeSource(methodName, source);
         this.LoadCodeToTab(codeTabControl.TabPages[codeTabControl.TabPages.IndexOfKey(methodName)]);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #14
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (codeTabControl.TabCount == 0)
                {
                    return;
                }
                string name = codeTabControl.SelectedTab.Name;
                if (name.Length != 1 || !OpenedProject.Sources.ContainsKey(name))
                {
                    return;
                }
                bool   success;
                string oldName = name;
                string path    = ChooseMethodNameAndPath(ref name, out success);
                if (success)
                {
                    OpenedProject.RenameMethod(oldName, name);
                    OpenedProject.FileNames[name] = path;

                    projectExplorerBox.Items.Clear();
                    foreach (var k in OpenedProject.FileNames)
                    {
                        projectExplorerBox.Items.Add("Module " + k.Key);
                    }
                    codeTabControl.TabPages.RemoveAt(codeTabControl.SelectedIndex);

                    foreach (TabPage a in codeTabControl.TabPages)
                    {
                        this.LoadCodeToTab(a);
                    }
                    this.OpenTab(name);
                    OpenedProject.SaveFile(name);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Example #15
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);
            }
        }
Example #16
0
        private void _OutputCtlFile()
        {
            if (OpenedProject == null)
            {
                return;
            }
            SaveFileDialog dialog = MakeSaveFileDialog(FileType.MeepScript);

            dialog.Title = CurrentLanguage.MainForm.Dialog_OutputCtlFile;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    OpenedProject.WriteCtlFile(dialog.FileName, (sender, e) => { WriteLog(Indent + e.Message); });
                }
                catch
                {
                    MessageBox.Show(CurrentLanguage.MainForm.Dialog_FileSaveError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #17
0
 private void addModuleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string name = "";
         bool   success;
         string path = ChooseMethodNameAndPath(ref name, out success);
         if (success)
         {
             OpenedProject.AddMethod(name, path);
             projectExplorerBox.Items.Clear();
             foreach (var k in OpenedProject.FileNames)
             {
                 projectExplorerBox.Items.Add("Module " + k.Key);
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #18
0
        private bool _SaveProject(string filename)
        {
            if (OpenedProject == null)
            {
                return(false);
            }

            string path = filename;

            if (!IsValidFilePath(path))
            {
                SaveFileDialog dialog = MakeSaveFileDialog(FileType.Project);
                if (dialog.ShowDialog(MainForm) == DialogResult.OK)
                {
                    path = dialog.FileName;
                }
                if (!IsValidFilePath(path))
                {
                    return(false);
                }
            }
            OpenedProject.WriteProjectFile(path);
            return(true);
        }
Example #19
0
        private void CloseOpenedProject(bool save)
        {
            if (save)
            {
                SaveProject(OpenedProject, OpenedProjectType);
            }

            if (OpenedProjectType != ProjectType.FileProject)
            {
                Capturer.Close();
            }
            else
            {
                Player.Close();
            }

            if (OpenedProject != null)
            {
                OpenedProject.Clear();
            }
            OpenedProject     = null;
            OpenedProjectType = ProjectType.None;
            EmitProjectChanged();
        }
Example #20
0
 /// <summary>
 ///     Handles the OpenedProject event of the Solution control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="ProjectEventArgs" /> instance containing the event data.</param>
 private void Solution_OpenedProject(object sender, ProjectEventArgs e)
 {
     OpenedProject?.Invoke(this, e);
 }