Пример #1
0
        static bool ShowProgramOptions(string filename, Lcd lcd, Buttons btns)
        {
            string runString        = "Run Program";
            string runInDebugString = "Debug Program";
            string deleteString     = "Delete Program";
            var    dialog           = new SelectDialog <string> (Font.MediumFont, lcd, btns, new string[] {
                runString,
                runInDebugString,
                deleteString
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                string selection = dialog.GetSelection();
                if (selection == runString)
                {
                    lcd.Clear();
                    lcd.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    lcd.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    lcd.Update();
                    MenuAction = () => RunAndWaitForProgram(filename, false);
                }
                if (selection == runInDebugString)
                {
                    MenuAction = () => RunAndWaitForProgram(filename, true);
                }
                if (selection == deleteString)
                {
                    var infoDialog = new InfoDialog(font, lcd, btns, "Deleting File. Please wait", false, "Deleting File");
                    infoDialog.Show();
                    if (ProcessHelper.RunAndWaitForProcess("rm", filename) == 0)
                    {
                        infoDialog = new InfoDialog(font, lcd, btns, "Program deleted", true, "Deleting File");
                    }
                    else
                    {
                        infoDialog = new InfoDialog(font, lcd, btns, "Error deleting program", true, "Deleting File");
                    }
                    infoDialog.Show();
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Пример #2
0
        private void btnViewDataTable_Click(object sender, EventArgs e)
        {
            var navigateTo = new SelectDialog <IMapsDirectlyToDatabaseTable>(Activator, GetCatalogueItems().Where(ci => string.IsNullOrWhiteSpace(ci.Description)), false, false);

            navigateTo.Show();

            navigateTo.Closed += (o, args) =>
            {
                if (navigateTo.DialogResult == DialogResult.OK)
                {
                    var cmd = new ExecuteCommandShow(Activator, navigateTo.Selected, 1);
                    cmd.Execute();
                }
            };
        }
Пример #3
0
        public Open(IButton button, IControlUtil control, IPrimFactory factory)
            : base(button)
        {
            IPrim prim = button.Prims.Count() > 0 ? button.Prims.First() : factory.Host;

            _dialog = new Dialog(prim, factory, SEQUENCE, TOPOLOGY, Dialog.CANCEL);
            SelectDialog openSequenceDialog = new SelectDialog(prim, factory, name => control.Record.GetUserFolder(name), control.Record.SharedFolder);
            SelectDialog openTopologyDialog = new SelectDialog(prim, factory, name => control.Topology.GetUserFolder(name), control.Topology.SharedFolder);

            _dialog.ResponseReceived += (name, id, text, chat) => {
                if (text.Equals(Dialog.CANCEL))
                {
                    return;
                }
                switch (text)
                {
                case SEQUENCE: openSequenceDialog.Show(name, id); break;

                case TOPOLOGY: openTopologyDialog.Show(name, id); break;
                }
            };
            openSequenceDialog.OnSelect += (name, id, file) => control.Record.PlayRecording(name, id, file);
            openTopologyDialog.OnSelect += (name, id, file) => control.Topology.LoadTopology(name, id, file);
        }
Пример #4
0
        static bool ShowProgramOptions(string programFolder)
        {
            string fileName = "";

            try {
                fileName = Directory.EnumerateFiles(programFolder, "*.exe").First();
            } catch {
                var info = new InfoDialog(programFolder + "is not executable", true, "Program");
                info.Show();
                Directory.Delete(programFolder, true);
                updateProgramList = true;
                return(true);
            }

            var dialog = new SelectDialog <string> (new string[] {
                "Run Program",
                "Debug Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                Action programAction = null;
                switch (dialog.GetSelectionIndex())
                {
                case 0:
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.Normal);
                    break;

                case 1:
                    programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.Debug);
                    break;

                case 2:
                    if (!AOTHelper.IsFileCompiled(fileName))
                    {
                        if (AOTCompileAndShowDialog(programFolder))
                        {
                            programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.AOT);
                        }
                    }
                    else
                    {
                        programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.AOT);
                    }
                    break;

                case 3:

                    if (AOTHelper.IsFileCompiled(fileName))
                    {
                        var questionDialog = new QuestionDialog("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show())
                        {
                            AOTCompileAndShowDialog(programFolder);
                        }
                    }
                    else
                    {
                        AOTCompileAndShowDialog(programFolder);
                    }
                    break;

                case 4:
                    var question = new QuestionDialog("Are you sure?", "Delete");
                    if (question.Show())
                    {
                        var step = new StepContainer(() => {
                            Directory.Delete(programFolder, true);
                            return(true);
                        }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog("Program", step);
                        progressDialog.Show();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine("Done running application");
                }
                return(updateProgramList);
            }
            return(false);
        }
Пример #5
0
        static bool ShowProgramOptions(string programFolder)
        {
            string fileName = "";
            try {
                fileName = Directory.EnumerateFiles (programFolder, "*.exe").First ();
            } catch {
                var info = new InfoDialog (programFolder + "is not executable", true, "Program");
                info.Show ();
                Directory.Delete (programFolder, true);
                updateProgramList = true;
                return true;
            }

            var dialog = new SelectDialog<string> (new string[] {
                "Run Program",
                "Debug Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);
            dialog.Show ();
            if (!dialog.EscPressed) {
                Action programAction = null;
                switch (dialog.GetSelectionIndex ()) {
                case 0:
                    Lcd.Instance.Clear ();
                    Lcd.Instance.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle (new Point (0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point (Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update ();
                    programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.Normal);
                    break;
                case 1:
                    programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.Debug);
                    break;
                case 2:
                    if (!AOTHelper.IsFileCompiled (fileName)) {
                        if (AOTCompileAndShowDialog (programFolder)) {
                            programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.AOT);
                        }
                    } else {
                        programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.AOT);
                    }
                    break;
                case 3:

                    if (AOTHelper.IsFileCompiled (fileName)) {
                        var questionDialog = new QuestionDialog ("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show ()) {
                            AOTCompileAndShowDialog (programFolder);
                        }
                    } else {
                        AOTCompileAndShowDialog (programFolder);
                    }
                    break;
                case 4:
                    var question = new QuestionDialog ("Are you sure?", "Delete");
                    if (question.Show ()) {
                        var step = new StepContainer (() => {
                            Directory.Delete (programFolder, true);
                            return true;
                        }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog ("Program", step);
                        progressDialog.Show ();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine ("Done running application");
                }
                return updateProgramList;
            }
            return false;
        }
Пример #6
0
        static bool ShowProgramOptions(ProgramInformation program)
        {
            var dialog = new SelectDialog <string> (new string[] {
                "Run Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                Action programAction = null;
                switch (dialog.GetSelectionIndex())
                {
                case 0:
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    programAction = () => ProgramManager.Instance.StartProgram(program, false);
                    break;

                case 1:
                    if (!program.IsAOTCompiled)
                    {
                        if (AOTCompileAndShowDialog(program))
                        {
                            programAction = () => ProgramManager.Instance.StartProgram(program, true);
                        }
                    }
                    else
                    {
                        programAction = () => ProgramManager.Instance.StartProgram(program, true);
                    }
                    break;

                case 3:

                    if (program.IsAOTCompiled)
                    {
                        var questionDialog = new QuestionDialog("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show())
                        {
                            AOTCompileAndShowDialog(program);
                        }
                    }
                    else
                    {
                        AOTCompileAndShowDialog(program);
                    }
                    break;

                case 4:
                    var question = new QuestionDialog("Are you sure?", "Delete");
                    if (question.Show())
                    {
                        var step           = new StepContainer(() => { ProgramManager.Instance.DeleteProgram(program); return(true); }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog("Program", step);
                        progressDialog.Show();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine("Done running application");
                }
                return(updateProgramList);
            }
            return(false);
        }
Пример #7
0
		static bool ShowProgramOptions (ProgramInformation program)
		{
			var dialog = new SelectDialog<string> (new string[] {
				"Run Program",
				"Run In AOT",
				"AOT Compile",
				"Delete Program",
			}, "Options", true);
			dialog.Show ();
			if (!dialog.EscPressed) {
				Action programAction = null;
				switch (dialog.GetSelectionIndex ()) {
				case 0:
					Lcd.Instance.Clear ();
					Lcd.Instance.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 5));					
					Rectangle textRect = new Rectangle (new Point (0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point (Lcd.Width, Lcd.Height - 2));
					Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
					Lcd.Instance.Update ();						
					programAction = () => ProgramManager.Instance.StartProgram(program,false);	
					break;
				case 1:
					if (!program.IsAOTCompiled) 
					{
						if (AOTCompileAndShowDialog (program)) 
						{
							programAction = () => ProgramManager.Instance.StartProgram(program,true);	
						}
					} 
					else 
					{
						programAction = () => ProgramManager.Instance.StartProgram(program, true);
					}
					break;
				case 3:
						
					if (program.IsAOTCompiled) {
						var questionDialog = new QuestionDialog ("Progran already compiled. Recompile?", "AOT recompile");
						if (questionDialog.Show ()) {
							AOTCompileAndShowDialog (program);
						}
					} 
					else 
					{
						AOTCompileAndShowDialog (program);
					}
					break;
				case 4:
					var question = new QuestionDialog ("Are you sure?", "Delete");
					if (question.Show ()) 
					{
						var step = new StepContainer (() => {ProgramManager.Instance.DeleteProgram(program); return true;}, "Deleting ", "Error deleting program"); 
						var progressDialog = new ProgressDialog ("Program", step);
						progressDialog.Show ();
						updateProgramList = true;
					}
					break;
				}
				if (programAction != null) 
				{
					Console.WriteLine("Starting application");
					programAction();					
					Console.WriteLine ("Done running application");
				}
				return updateProgramList;
			}
			return false;
			
		}