Beispiel #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);
        }