public override void Do(ActionPerformerArgs actionPerformerArgs) { PanelSet panelSet = (PanelSet)actionPerformerArgs.Sender; FileSystemInfo senderInfo = panelSet.FocusedListView.SelectedItem.Item; var source = senderInfo.FullName; PopupInput popupInput = new PopupInput(panelSet, "Enter new name:"); popupInput.Render(); string newName = popupInput.UserInputResult; var destination = Path.GetDirectoryName(source) + "\\" + newName; if (senderInfo is FileInfo) { File.Move(source, destination); } else if (senderInfo is DirectoryInfo) { Directory.Move(source, destination); } panelSet.RefreshScreen(); }
public override void Do(ActionPerformerArgs actionPerformerArgs) { PanelSet panelSet = (PanelSet)actionPerformerArgs.Sender; PopupList popupList = new PopupList("Search result:"); PopupInput popupInput = new PopupInput(panelSet, "Enter the name of a file or directory:", "Search"); popupInput.Render(); var userInput = popupInput.UserInputResult; popupList.ListView = new ListView <FileSystemInfo>(popupList.OffsetX, popupList.OffsetY, popupList.Height, 0, popupList.BackgroundColor, popupList.ForegroundColor); popupList.ListView.Focused = true; popupList.ListView.ColumnWidths = new List <int>() { 30, 10, 10 }; popupList.ListView.Current = panelSet.FocusedPanel.Current; panelSet.Modal = popupList; popupList.ListView.Items = GetAllFilesAndFolders((DirectoryInfo)popupList.ListView.Current).Where(i => i.Item.Name.Contains(userInput)).ToList(); if (popupList.ListView.Items.Count > 0) { popupList.ListView.Current = panelSet.Modal.ListView.Items[0].Item; } else { return; } popupList.Render(); }
/// <summary> /// Execution function for Day 2 /// </summary> public void Execute2() { UserActionAsync(() => { WriteToConsole("Start execution of Day2"); var parser = GetInputParser("Day2Input.txt"); var originalCode = parser.GetIntCode(); var code = originalCode.ToList(); code[1] = 12; code[2] = 2; var input = new PopupInput("No input needed"); var intComputer = new IntCodeComputerInstance(code, input, _consoleOutput); intComputer.Compute(); WriteToConsole($"After execution the value at position 0 is {intComputer.Code[0].ToString("N")}"); AddEmptyLine(); WriteToConsole("For part 2 we need to find the inputs that produce the output 19690720"); int finalNoun = -1; int finalVerb = -1; for (int noun = 0; noun <= 99; noun++) { for (int verb = 0; verb <= 99; verb++) { var testCode = originalCode.ToList(); testCode[1] = noun; testCode[2] = verb; intComputer = new IntCodeComputerInstance(testCode, input, _consoleOutput); intComputer.Compute(); if (intComputer.Code[0] == 19690720) { finalNoun = noun; finalVerb = verb; //Breaks the outer loop noun = 100; break; } } } WriteToConsole($"Found the correct inputs: Noun = {finalNoun}, Verb = {finalVerb}. 100 * Noun + verb = {100 * finalNoun + finalVerb}"); AddEmptyLine(); }); }
public override void Do(ActionPerformerArgs actionPerformerArgs) { PanelSet panelSet = (PanelSet)actionPerformerArgs.Sender; PopupInput popupInput = new PopupInput(panelSet, "Enter new folder name:"); popupInput.Render(); string newName = popupInput.UserInputResult; var currentPath = panelSet.FocusedListView.Current.FullName + "\\" + newName; Directory.CreateDirectory(currentPath); panelSet.RefreshFocusedPanel(); }
/// <summary> /// Execution function for Day 9 /// </summary> public void Execute9() { UserActionAsync(() => { WriteToConsole("Start execution of Day9"); var parser = GetInputParser("Day9Input.txt"); var originalCode = parser.GetIntCode(); var code = originalCode.ToList(); var input = new PopupInput("Start BOOST. Inputs:\n1 - Test Mode\n2 - Sensor Boost Mode"); var intComputer = new IntCodeComputerInstance(code, input, _consoleOutput); intComputer.Compute(); WriteToConsole($"Finished BOOST"); AddEmptyLine(); }); }
/// <summary> /// Execution function for Day 5 /// </summary> public void Execute5() { UserActionAsync(() => { WriteToConsole("Start execution of Day5"); var parser = GetInputParser("Day5Input.txt"); var originalCode = parser.GetIntCode(); var code = originalCode.ToList(); var input = new PopupInput("Started Diagnostics. Inputs:\n1 - air conditioner unit\n5 - thermal radiator controller"); var intComputer = new IntCodeComputerInstance(code, input, _consoleOutput); intComputer.ContinueAfterOutput = true; intComputer.Compute(); WriteToConsole($"Diagnostics finished"); AddEmptyLine(); }); }