private void btnOK_Click(object sender, EventArgs e) { edName.BackColor = SystemColors.Window; if (string.IsNullOrWhiteSpace(edName.Text)) { edName.BackColor = Color.LightPink; return; } edPath.BackColor = SystemColors.Window; if (string.IsNullOrWhiteSpace(edPath.Text)) { edPath.BackColor = Color.LightPink; return; } ToolParameters = new ToolParameters { Name = edName.Text, Path = edPath.Text, CustomImagePath = edIcon.Text, CommandLine = edCommandLine.Text, ToolCategory = rbDiff.Checked ? ToolCategory.Diff : ToolCategory.Merge, }; DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
public ToolOptionsForm(ToolParameters toolParameters) { InitializeComponent(); if (toolParameters != null) { ToolParameters = toolParameters.Clone(); } else { ToolParameters = new ToolParameters(); } edName.Text = ToolParameters.Name; edPath.Text = ToolParameters.Path; edCommandLine.Text = ToolParameters.CommandLine; edIcon.Text = ToolParameters.CustomImagePath; switch (ToolParameters.ToolCategory) { case ToolCategory.Diff: rbDiff.Checked = true; break; case ToolCategory.Merge: rbMerge.Checked = true; break; } imgIcon.Image = ToolParameters.GetAssociatedIcon(); }
public async Task <IActionResult> GetTools([FromQuery] ToolParameters toolParameters) { var tools = await _repository.GetAllToolsAsync(toolParameters, false); Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(tools.MetaData)); var toolsDto = _mapper.Map <IEnumerable <ToolDto> >(tools); return(Ok(toolsDto)); }
private void FillListItem(ListViewItem item, ToolParameters tp) { item.Tag = tp; item.Group = listView1.Groups[(int)tp.ToolCategory]; item.Text = " " + tp.Name; item.Name = tp.Name; item.SubItems.Clear(); item.SubItems.Add(tp.Path); item.SubItems.Add(tp.CommandLine); }
public void ExecuteTool(ToolParameters tp, string[] parameters, Action <ToolExecutionResult> callback) { _parameters = parameters; var commandLine = tp.CommandLine; if (string.IsNullOrWhiteSpace(commandLine)) { commandLine = "%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20"; } commandLine = commandLine .Replace("%20", GetParam(19)) .Replace("%19", GetParam(18)) .Replace("%18", GetParam(17)) .Replace("%17", GetParam(16)) .Replace("%16", GetParam(15)) .Replace("%15", GetParam(14)) .Replace("%14", GetParam(13)) .Replace("%13", GetParam(12)) .Replace("%12", GetParam(11)) .Replace("%11", GetParam(10)) .Replace("%10", GetParam(9)) .Replace("%1", GetParam(0)) .Replace("%2", GetParam(1)) .Replace("%3", GetParam(2)) .Replace("%4", GetParam(3)) .Replace("%5", GetParam(4)) .Replace("%6", GetParam(5)) .Replace("%7", GetParam(6)) .Replace("%8", GetParam(7)) .Replace("%9", GetParam(8)) ; new Thread(() => { try { var process = System.Diagnostics.Process.Start(tp.Path, commandLine); callback(new ToolExecutionResult(this, tp, ToolExecutionStatus.Started)); process.WaitForExit(); callback(new ToolExecutionResult(this, tp, ToolExecutionStatus.FinishedSuccess)); } catch (Exception ex) { callback(new ToolExecutionResult(this, tp, ToolExecutionStatus.Error) { Exception = ex, }); } }).Start(); }
public void GetToolsTest() { var toolParameters = new ToolParameters(); var repository = new Mock <IToolRepository>(); var tools = GetFakeData(); var pagedTools = PagedList <Tool> .ToPagedList(tools, toolParameters.PageNumber, toolParameters.PageSize); repository.Setup(x => x.GetAllToolsAsync(toolParameters, false)) .ReturnsAsync(pagedTools); Assert.Equal(10, pagedTools.Count()); }
public static void ExecuteTool(ToolParameters tp, string[] parameters) { var toolEx = new ToolExecution(); _executionTools.Add(toolEx); toolEx.ExecuteTool(tp, parameters, (result) => { lock (_tasksResultsQueue) { _tasksResultsQueue.Enqueue(result); } }); }
private void Execute(ToolParameters tp) { if (chRememberChoice.Checked) { var config = Config.Instance; config.LastChoiceToolIndex = lvTools.SelectedIndices[0]; config.LastChoiceDuration = 100; config.LastChoiceValid = DateTime.Now.AddMinutes(config.LastChoiceDuration); config.Save(); } ToolExecutionManager.ExecuteTool(tp, _parameters); Close(); }
public ToolNotificationForm(ToolParameters toolParameters, int seconds) { InitializeComponent(); lbText.Text = lbText.Text.Replace("%ToolName%", toolParameters.Name); picIcon.Image = toolParameters.GetAssociatedIcon(); //TODO: somehow identify screen on which diff merge tool opens var screen = Screen.PrimaryScreen; Top = screen.WorkingArea.Bottom - Height; Left = screen.WorkingArea.Right - Width; timer1.Enabled = true; timer1.Interval = 100; timer1.Tag = "wait for close"; _timeWhenStartClose = DateTime.Now.AddSeconds(seconds); TopMost = true; }
public async Task <PagedList <Tool> > GetAllToolsAsync(ToolParameters toolParameters, bool trackChanges) { List <Tool> tools; if (toolParameters.Tag != null) { tools = await(!trackChanges ? _context.Tools.Where(tool => tool.Tags.Contains(toolParameters.Tag)).AsNoTracking() .OrderBy(tool => tool.Title) .ToListAsync() : _context.Tools.Where(tool => tool.Tags.Contains(toolParameters.Tag)).OrderBy(tool => tool.Title) .ToListAsync()); } else { tools = await(!trackChanges ? _context.Tools.OrderBy(tool => tool.Title).ToListAsync() : _context.Tools.OrderBy(tool => tool.Title).ToListAsync()); } return(PagedList <Tool> .ToPagedList(tools, toolParameters.PageNumber, toolParameters.PageSize)); }
public ToolExecutionResult(ToolExecution te, ToolParameters tp, ToolExecutionStatus status) { ToolExecution = te; ToolParameters = tp; Status = status; }