Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            RunnerManager = new RunManager(ReadStringRequest);

            //this.Width = 800;
            //this.Height = 600;
            UserOptions = new UserOptions();

            visualStates = new VisualStates();

            

            string hdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\Highlighting\\";
            if (Directory.Exists(hdir))
            {
                FileSyntaxProvider = new ICSharpCode.TextEditor.Document.FileSyntaxModeProvider(hdir);
                ICSharpCode.TextEditor.Document.HighlightingManager.Manager.AddSyntaxModeFileProvider(FileSyntaxProvider);
                string Filter = "", AllFilter = "";
                foreach (ICSharpCode.TextEditor.Document.SyntaxMode sm in FileSyntaxProvider.SyntaxModes)
                {
                    Filter = Tools.MakeFilter(Filter, sm.Name, sm.Extensions);
                    AllFilter = Tools.MakeAllFilter(AllFilter, sm.Name, sm.Extensions);
                }
                saveFileDialog1.Filter = openFileDialog1.Filter = Tools.FinishMakeFilter(Filter, AllFilter);
            }
            RunnerManager.Exited += new RunManager.RunnerManagerActionDelegate(RunnerManager_Exited);
            RunnerManager.Started += new RunManager.RunnerManagerActionDelegate(RunnerManager_Started);
            RunnerManager.OutputStringReceived += new RunManager.TextRecivedDelegate(RunnerManager_OutputStringReceived);
            RunnerManager.RunnerManagerUnhanledRuntimeException += new RunManager.RunnerManagerUnhanledRuntimeExceptionDelegate(RunnerManager_RunnerManagerUnhanledRuntimeException);

            FormLeft = this.Left; FormTop = this.Top; FormWidth = this.Width; FormHeight = this.Height;

            LoadOptions(OptionsFileName);


            tsOutputWindow.Checked = BottomTabsVisible;

            StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            StandartDirectories.Add(Constants.SystemDirectoryIdent, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName));
            if (WorkingDirectory == null)
                WorkingDirectory = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DefaultWorkingDirectory, StandartDirectories);
            StandartDirectories.Add(Constants.WorkingDirectoryIdent, WorkingDirectory);

            AddNewProgramToTab(tabControl1, InstNameNewProgramm(tabControl1));
            foreach (string FileName in VisualPascalABC.CommandLineArgs)
                OpenFile(FileName);
            dataGridView1.Rows.Add();
            ErrorListAddRowsFill();

            SetStopEnabled(false);
            CompilingButtonsEnabled = CloseButtonsEnabled = SaveAllButtonsEnabled = SaveButtonsEnabled = false;

            NavigBackButtonsEnabled = NavigForwButtonsEnabled = false;

            try
            {
                if (!Directory.Exists(WorkingDirectory))
                    Directory.CreateDirectory(WorkingDirectory);
            }
            catch (Exception exc)
            {
                AddTextToCompilerMessages(Form1StringResources.Get("MSGTYPE")+String.Format(Form1StringResources.Get("ERROR_CREATING_WORKDIR_{0}_{1}"), WorkingDirectory,exc.Message)+Environment.NewLine);
            }

        }
Пример #2
0
        public Form1()
        {
            if (Tools.IsUnix())
            {
                ProjectsUseable = false;
                DesignerUseable = false;
                //DebuggerVisible = false;
            }
        	PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig();
            //if (PascalABCCompiler.StringResourcesLanguage.AccessibleLanguages.Count > 0)
            //    PascalABCCompiler.StringResourcesLanguage.CurrentLanguageName = PascalABCCompiler.StringResourcesLanguage.AccessibleLanguages[0];
           
            InitializeComponent();
           
            VisualPABCSingleton.MainForm = this;
            WorkbenchStorage.MainProgramThread = System.Threading.Thread.CurrentThread;
            //images init
            this.miNewProject.Image = new System.Drawing.Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualPascalABC.Resources.Icons.16x16.NewProjectIcon.png"));
            this.mADDFILEToolStripMenuItem.Image = miNew.Image;
            this.mADDEXISTFILEToolStripMenuItem.Image = miOpen.Image;
            this.mADDFORMToolStripMenuItem.Image = new System.Drawing.Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualPascalABC.Resources.Icons.16x16.Form.png"));
            toolStripPanel.Size = new Size(toolStripPanel.Size.Width, toolStrip1.Height);
            var gr = Graphics.FromHwnd(Handle);
            if (gr.DpiX >= 96*2)
            {
                toolStrip1.ImageScalingSize = new Size(32, 32);
                menuStrip1.ImageScalingSize = new Size(32, 32);
                toolStripPanel.Size = new Size(toolStripPanel.Size.Width, 38);
            }
            serviceContainer = new WorkbenchServiceContainer();

            if (DebuggerVisible)
            {
            	InitForm();
                this.StepOutButton.Visible = false;
                PlayPauseButtonsVisibleInPanel = PlayPauseButtonsVisibleInPanel;
                SetDebugButtonsEnabled(false);
            }
            
            AddOwnedForm(CompilerForm1 = new CompilerForm());
            AddOwnedForm(AboutBox1 = new AboutBox());
            AddOwnedForm(FindForm = new FindReplaceForm(FindReplaceForm.FormType.Find));
            AddOwnedForm(ReplaceForm = new FindReplaceForm(FindReplaceForm.FormType.Replace));
            AddOwnedForm(GotoLineForm = new GotoLineForm());
           
            LastOpenFiles = new List<string>();
            LastOpenProjects = new List<string>();

            WorkbenchServiceFactory.BuildService.CompilerOptions.Debug = true;
            WorkbenchServiceFactory.BuildService.CompilerOptions.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;

            LocalizeControls();

            tsatConsoleApplication.Tag = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
            tsatWindowsApplication.Tag = PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication;
            tsatDll.Tag = PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary;

            SelectAppType(WorkbenchServiceFactory.BuildService.CompilerOptions.OutputFileType);

            //this.Width = 800;
            //this.Height = 600;
            UserOptions = new UserOptions();

            visualStates = new VisualStates();

            SetFiltersAndHighlighting();
            
            FormLeft = this.Left; FormTop = this.Top; FormWidth = this.Width; FormHeight = this.Height;
			MainDockPanel.DockRightPortion = 0.22;
            MainDockPanel.DockLeftPortion = 0.22;
                
            //UserOptions.OutputDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName)+"\\Output";
            UserOptions.OutputDirectory = Constants.DefaultOutputDirectory;

            PlayPauseButtonsVisibleInPanel = false;

            WorkbenchStorage.StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            WorkbenchStorage.StandartDirectories.Add(Constants.SystemDirectoryIdent, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName));

            RestoreDesktop();

            LoadOptions();

            HelpExamplesDirectory = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.HelpExamplesDirectory, WorkbenchStorage.StandartDirectories);
            HelpTutorialExamplesDirectory = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.HelpTutorialExamplesDirectory, WorkbenchStorage.StandartDirectories);

            UpdateUserOptions();
            ErrorsListWindow.Resized();
            FindSymbolsResultWindow.Resized();

            UpdateOutputWindowVisibleButtons();

            if (WorkbenchStorage.WorkingDirectory == null || true)
            {
                WorkbenchStorage.WorkingDirectoryInOptionsFile = Constants.DefaultWorkingDirectory;
                WorkbenchStorage.WorkingDirectory = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DefaultWorkingDirectory, WorkbenchStorage.StandartDirectories);
            }
            if (Path.GetDirectoryName(Application.ExecutablePath).ToLower() != Environment.CurrentDirectory.ToLower())
                WorkbenchStorage.WorkingDirectory = Environment.CurrentDirectory;
            WorkbenchStorage.StandartDirectories.Add(Constants.WorkingDirectoryIdent, WorkbenchStorage.WorkingDirectory);
            openFileDialog1.InitialDirectory = WorkbenchStorage.WorkingDirectory;

            if (WorkbenchStorage.LibSourceDirectory == null)
                WorkbenchStorage.LibSourceDirectory = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DefaultLibSourceDirectory, WorkbenchStorage.StandartDirectories);
            WorkbenchStorage.StandartDirectories.Add(Constants.LibSourceDirectoryIdent, WorkbenchStorage.LibSourceDirectory);
            AddSearchDebugPath(WorkbenchStorage.LibSourceDirectory);

            if (UserOptions.UseOutputDirectory)
                WorkbenchStorage.StandartDirectories.Add(Constants.OutputDirectoryIdent, UserOptions.OutputDirectory);
            else
                WorkbenchStorage.StandartDirectories.Add(Constants.OutputDirectoryIdent, null);

            RunManager RunnerManager = (WorkbenchServiceFactory.RunService as WorkbenchRunService).RunnerManager;
            VisualEnvironmentCompiler = new VisualEnvironmentCompiler(
                this.BeginInvoke, SetCompilingButtonsEnabled, SetDedugButtonsEnabled, SetStateText,
                AddTextToCompilerMessagesSync, miPlugins, toolStrip1,
                ExecuteSourceLocationAction, ExecuteVisualEnvironmentCompilerAction, ErrorsManager, RunnerManager,
                WorkbenchServiceFactory.DebuggerManager, UserOptions, WorkbenchStorage.StandartDirectories, OpenDocuments, this);
            if (OnEnvorimentEvent != null)
                OnEnvorimentEvent(EnvorimentEvent.VisualEnvironmentCompilerCreated);

            NavigationManager = new NavigationManager(ExecuteSourceLocationAction);
            NavigationManager.StateChanged += new NavigationManager.NavigationManagerStateChanged(NavigationManager_StateChanged);

            AddNewProgramToTab(MainDockPanel, InstNameNewProgramm(MainDockPanel));

            AddOptionsContent();
            Application.AddMessageFilter(this);

            if (DesignerUseable)
            {
                //miProperties.Visible = true;
                //miToolBox.Visible = true;
                //miNewAdv.Visible = true;
                miUndo.Visible = true;
            }
			this.mRPROJECTToolStripMenuItem.Visible = false;
            if (ProjectsUseable)
            {
            	miNewProject.Visible = true;
            	miRecentProjects.Visible = true;
            	//miCloseProject.Visible = true;
            	miOpenProject.Visible = true;
            }
            if (!UseImmediate)
            {
            	tsImmediateWindow.Visible = false;
            }
            this.mNEWASPToolStripMenuItem.Visible = DebugModus;
            if (!Tools.IsUnix())
                AddDesignerSidebars();

        }