public void SelectionChanged(IMainClass mc) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(Keys.None, false, false, false, mc); IMultiboxFunction function = GetActivatedFunction(p); if (function == null || !function.IsMulti(p) || !function.HasDetails(p)) { p.MC.DetailsLabelText = ""; p.MC.UpdateSize(); return; } bool ibs = function.IsBackgroundDetailsStream(p); if (ibs) { new RunBgS(function.GetBackgroundDetailsStream).BeginInvoke(p, null, null); } else { p.MC.DetailsLabelText = function.GetDetails(p); p.MC.UpdateSize(); } } catch {} }
public void KeyDown(IMainClass mc, Keys key, bool control, bool alt, bool shift) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(key, control, alt, shift, mc); IMultiboxFunction function = GetActivatedFunction(p); if (function == null) { return; } if (function.IsMulti(p) && (p.Key == Keys.Up || p.Key == Keys.Down)) { switch (p.Key) { case Keys.Up: p.MC.LabelManager.SelectPrev(); break; case Keys.Down: p.MC.LabelManager.SelectNext(); break; } } if (function.HasKeyDownAction(p)) { function.RunKeyDownAction(p); } if (function.SupressKeyPress(p)) { SuppressKeyPress = true; } } catch {} }
public static void KeyDown(IMainClass mc, KeyEventArgs e) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(e.KeyCode, e.Control, e.Alt, e.Shift, mc); IMultiboxFunction af = GetActivatedFunction(p); if (af == null) { return; } if (af.IsMulti(p) && (p.Key == Keys.Up || p.Key == Keys.Down)) { switch (p.Key) { case Keys.Up: p.MC.LabelManager.SelectPrev(); break; case Keys.Down: p.MC.LabelManager.SelectNext(); break; } } if (af.HasKeyDownAction(p)) { af.RunKeyDownAction(p); } if (af.SupressKeyPress(p)) { e.SuppressKeyPress = true; } } catch {} }
public InteractionManager( IMainClass mainClass, ISubClass subClass) { this.mainClass = mainClass; this.subClass = subClass; }
public static void KeyDown(IMainClass mc, KeyEventArgs e) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(e.KeyCode, e.Control, e.Alt, e.Shift, mc); IMultiboxFunction af = GetActivatedFunction(p); if (af == null) return; if (af.IsMulti(p) && (p.Key == Keys.Up || p.Key == Keys.Down)) { switch (p.Key) { case Keys.Up: p.MC.LabelManager.SelectPrev(); break; case Keys.Down: p.MC.LabelManager.SelectNext(); break; } } if (af.HasKeyDownAction(p)) af.RunKeyDownAction(p); if (af.SupressKeyPress(p)) e.SuppressKeyPress = true; } catch {} }
public MultiboxFunctionParam(Keys key, bool control, bool alt, bool shift, IMainClass mc) { this.key = key; this.control = control; this.alt = alt; this.shift = shift; this.mc = mc; }
public Tester(IMultiboxFunction[] functions, int maxResults, bool mockFilesystem = true, bool resetFilesystem = false) { functionManager = new MockFunctionManager(functions); mainClass = new MockMainClass(maxResults); mainClass.LabelManager.Sc = SelectionChanged; Filesystem.DebugMode = mockFilesystem; if(resetFilesystem) Filesystem.Reset(); history = new List<string[]>(0); }
public Tester(IMultiboxFunction[] functions, int maxResults, bool mockFilesystem = true, bool resetFilesystem = false) { functionManager = new MockFunctionManager(functions); mainClass = new MockMainClass(maxResults); mainClass.LabelManager.Sc = SelectionChanged; Filesystem.DebugMode = mockFilesystem; if (resetFilesystem) { Filesystem.Reset(); } history = new List <string[]>(0); }
private static bool GetFolderSize(string path, IMainClass mc, ref long cs, ref long files, ref long folders, ref DateTime ld, long delay) { try { if (cancelCalc) { return(false); } if (Filesystem.FileExists(path)) { cs += GetFileSize(path); files++; DateTime nw = DateTime.Now; if ((nw - ld).TotalMilliseconds > delay) { ld = nw; if (cancelCalc) { return(false); } new SetMCOutputLabelTextDel(SetMCOutputLabelText).BeginInvoke(mc, cs, files, folders, currentEnding, null, null); } return(true); } folders++; string[] itms = DirList2(path); if (itms == null || itms.Length <= 0 || cancelCalc) { return(false); } foreach (string itm in itms) { if (cancelCalc) { return(false); } GetFolderSize(itm, mc, ref cs, ref files, ref folders, ref ld, delay); } return(true); } catch { } return(false); }
public static void SelectionChanged(IMainClass mc) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(Keys.None, false, false, false, mc); IMultiboxFunction af = GetActivatedFunction(p); if (!af.IsMulti(p) || !af.HasDetails(p)) { p.MC.DetailsLabelText = ""; p.MC.UpdateSize(); return; } bool ibs = af.IsBackgroundDetailsStream(p); if (ibs) new RunBgS(af.GetBackgroundDetailsStream).BeginInvoke(p, null, null); else { p.MC.DetailsLabelText = af.GetDetails(p); p.MC.UpdateSize(); } } catch {} }
private static void SetMCOutputLabelText(IMainClass mc, long cs, long files, long folders, string ending) { mc.OutputLabelText = files.ToString("#,##0") + " file(s); " + folders.ToString("#,##0") + " folder(s); " + FormatSizestr(cs); }
private static bool GetFolderSize(string path, IMainClass mc, ref long cs, ref long files, ref long folders, ref DateTime ld, long delay) { try { if (cancelCalc) return false; if (Filesystem.FileExists(path)) { cs += GetFileSize(path); files++; DateTime nw = DateTime.Now; if ((nw - ld).TotalMilliseconds > delay) { ld = nw; if (cancelCalc) return false; new SetMCOutputLabelTextDel(SetMCOutputLabelText).BeginInvoke(mc, cs, files, folders, currentEnding, null, null); } return true; } folders++; string[] itms = DirList2(path); if (itms == null || itms.Length <= 0 || cancelCalc) return false; foreach (string itm in itms) { if (cancelCalc) return false; GetFolderSize(itm, mc, ref cs, ref files, ref folders, ref ld, delay); } return true; } catch { } return false; }
public bool KeyUp(IMainClass mc, Keys key, bool control, bool alt, bool shift) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(key, control, alt, shift, mc); IMultiboxFunction function = GetActivatedFunction(p); if (function == null) { mc.OutputLabelText = ""; mc.LabelManager.ResultItems = null; return(false); } if (p.Key == Keys.Enter && !p.Control && !p.Shift && !p.Alt && p.MultiboxText.Trim().Length > 0) { if (function.HasActionKeyEvent(p)) { function.RunActionKeyEvent(p); } } else if (p.Key == Keys.Enter && p.Control && !p.Shift && !p.Alt) { string tc = p.DisplayText; if (function.IsMulti(p)) { tc = p.MC.LabelManager.CurrentSelection != null ? p.MC.LabelManager.CurrentSelection.FullText : null; } if (function.HasSpecialDisplayCopyHandling(p)) { tc = function.RunSpecialDisplayCopyHandling(p); } if (!string.IsNullOrEmpty(tc)) { Clipboard = tc; } } else if (p.Key == Keys.Enter && p.Shift && !p.Control && !p.Alt && p.MultiboxText.Trim().Length > 0) { string tc = p.MultiboxText; if (function.HasSpecialInputCopyHandling(p)) { tc = function.RunSpecialInputCopyHandling(p); } if (!string.IsNullOrEmpty(tc)) { Clipboard = tc; } } else { bool sr = function.ShouldRun(p); bool ibs = function.IsBackgroundStream(p); if (function.IsMulti(p)) { if (sr && !(p.Key == Keys.Up || p.Key == Keys.Down || p.Key == Keys.ControlKey || p.Key == Keys.ShiftKey)) { if (ibs) { new RunBgS(function.RunMultiBackgroundStream).BeginInvoke(p, null, null); } else { p.MC.LabelManager.ResultItems = function.RunMulti(p); } } if (function.SupressKeyPress(p) || p.Key == Keys.Up || p.Key == Keys.Down) { SuppressKeyPress = true; } return(true); } if (sr) { if (ibs) { new RunBgS(function.RunSingleBackgroundStream).BeginInvoke(p, null, null); } else { p.MC.OutputLabelText = function.RunSingle(p); } } } if (function.SupressKeyPress(p)) { SuppressKeyPress = true; } } catch {} return(false); }
public static bool KeyUp(IMainClass mc, KeyEventArgs e) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(e.KeyCode, e.Control, e.Alt, e.Shift, mc); IMultiboxFunction af = GetActivatedFunction(p); if (af == null) { mc.OutputLabelText = ""; mc.LabelManager.ResultItems = null; return false; } if (p.Key == Keys.Enter && !p.Control && !p.Shift && !p.Alt && p.MultiboxText.Trim().Length > 0) { if (af.HasActionKeyEvent(p)) af.RunActionKeyEvent(p); } else if (p.Key == Keys.Enter && p.Control && !p.Shift && !p.Alt) { string tc = p.DisplayText; if(af.IsMulti(p)) tc = p.MC.LabelManager.CurrentSelection != null ? p.MC.LabelManager.CurrentSelection.FullText : null; if (af.HasSpecialDisplayCopyHandling(p)) tc = af.RunSpecialDisplayCopyHandling(p); if (!string.IsNullOrEmpty(tc)) Clipboard.SetText(tc); } else if (p.Key == Keys.Enter && p.Shift && !p.Control && !p.Alt && p.MultiboxText.Trim().Length > 0) { string tc = p.MultiboxText; if (af.HasSpecialInputCopyHandling(p)) tc = af.RunSpecialInputCopyHandling(p); if (!string.IsNullOrEmpty(tc)) Clipboard.SetText(tc); } else { bool sr = af.ShouldRun(p); bool ibs = af.IsBackgroundStream(p); if (af.IsMulti(p)) { if (sr && !(p.Key == Keys.Up || p.Key == Keys.Down || p.Key == Keys.ControlKey || p.Key == Keys.ShiftKey)) { if (ibs) new RunBgS(af.RunMultiBackgroundStream).BeginInvoke(p, null, null); else p.MC.LabelManager.ResultItems = af.RunMulti(p); } if (af.SupressKeyPress(p) || p.Key == Keys.Up || p.Key == Keys.Down) e.SuppressKeyPress = true; return true; } if (sr) { if (ibs) new RunBgS(af.RunSingleBackgroundStream).BeginInvoke(p, null, null); else p.MC.OutputLabelText = af.RunSingle(p); } } if (af.SupressKeyPress(p)) e.SuppressKeyPress = true; } catch {} return false; }
public void KeyDown(IMainClass mc, Keys key, bool control, bool alt, bool shift) { try { MultiboxFunctionParam p = new MultiboxFunctionParam(key, control, alt, shift, mc); IMultiboxFunction function = GetActivatedFunction(p); if (function == null) return; if (function.IsMulti(p) && (p.Key == Keys.Up || p.Key == Keys.Down)) { switch (p.Key) { case Keys.Up: p.MC.LabelManager.SelectPrev(); break; case Keys.Down: p.MC.LabelManager.SelectNext(); break; } } if (function.HasKeyDownAction(p)) function.RunKeyDownAction(p); if (function.SupressKeyPress(p)) SuppressKeyPress = true; } catch {} }