예제 #1
0
        public override void RunActionKeyEvent(MultiboxFunctionParam args)
        {
            if (args.MultiboxText.IndexOf(">>>") > 1)
            {
                throw new InvalidOperationException();
            }
            int ind2 = args.MultiboxText.IndexOf("<<");

            if (ind2 <= 1)
            {
                ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
                if (tmp2 != null)
                {
                    Process.Start(AddHDIfNeeded(args, tmp2.FullText));
                }
                return;
            }
            string pth  = args.MultiboxText.Substring(1, ind2 - 1);
            string name = "";

            try
            {
                name = args.MultiboxText.Substring(ind2 + 2);
            }
            catch { }
            if (name.Length > 0)
            {
                BookmarkList.Add(new BookmarkItem(name, pth));
            }
        }
예제 #2
0
        public override void RunActionKeyEvent(MultiboxFunctionParam args)
        {
            int    ind = args.MultiboxText.IndexOf(" ");
            string k;
            string t;

            if (ind > 1)
            {
                k = args.MultiboxText.Substring(1, ind - 1);
                try
                {
                    t = args.MultiboxText.Substring(ind + 1);
                }
                catch
                {
                    t = "";
                }
            }
            else
            {
                k = args.MultiboxText.Substring(1);
                t = "";
            }
            t = HttpUtility.UrlEncode(t);
            foreach (SearchItem i in SearchList.Items)
            {
                if (!i.Keyword.Equals(k))
                {
                    continue;
                }
                Process.Start(i.SearchPath.Replace("%s", t));
                break;
            }
        }
예제 #3
0
        public override string RunSingle(MultiboxFunctionParam args)
        {
            string rval = "Search engine not found";
            int    ind  = args.MultiboxText.IndexOf(" ");
            string k;
            string t;

            if (ind > 1)
            {
                k = args.MultiboxText.Substring(1, ind - 1);
                try
                {
                    t = args.MultiboxText.Substring(ind + 1);
                }
                catch
                {
                    t = "";
                }
            }
            else
            {
                k = args.MultiboxText.Substring(1);
                t = "";
            }
            foreach (SearchItem i in SearchList.Items)
            {
                if (!i.Keyword.Equals(k))
                {
                    continue;
                }
                rval = "Search " + i.Name + " for \"" + t + "\"";
                break;
            }
            return(rval);
        }
예제 #4
0
 public override List <ResultItem> RunMulti(MultiboxFunctionParam args)
 {
     if (args.MultiboxText.Trim().Length == 1 && !(args.Key == Keys.Up || args.Key == Keys.Down || args.Key == Keys.Tab || args.Key == Keys.Enter || args.Key == Keys.Back))
     {
         return(args.MC.HelpDialog.GetAutocompleteOptions(""));
     }
     if (args.Key == Keys.Tab)
     {
         ResultItem tmp = args.MC.LabelManager.CurrentSelection;
         if (tmp != null)
         {
             args.MC.InputFieldText = "?" + tmp.FullText;
             return(args.MC.HelpDialog.GetAutocompleteOptions(tmp.FullText));
         }
     }
     else if (args.Key == Keys.Back)
     {
         if (args.MultiboxText.Length <= 1)
         {
             args.MC.InputFieldText = "";
             return(null);
         }
         int ind = args.MultiboxText.LastIndexOf(">", args.MultiboxText.Length - 2);
         if (ind > 1)
         {
             args.MC.InputFieldText = args.MultiboxText.Remove(ind + 1);
             return(args.MC.HelpDialog.GetAutocompleteOptions(args.MultiboxText.Substring(1)));
         }
         args.MC.InputFieldText = "?";
         return(args.MC.HelpDialog.GetAutocompleteOptions(""));
     }
     return(null);
 }
예제 #5
0
        private static List <ResultItem> GetSearchResultItems(MultiboxFunctionParam args, bool ht, List <string> rlts)
        {
            List <ResultItem> tmp = new List <ResultItem>(0);

            tmp.AddRange(rlts.Select(tpth => new ResultItem(tpth.Substring(tpth.LastIndexOf("\\") + 1), tpth, ht ? tpth.Replace(Filesystem.UserProfile, "~") : tpth)));
            return(tmp);
        }
예제 #6
0
        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 {}
        }
예제 #7
0
        public override string GetDetails(MultiboxFunctionParam args)
        {
            string pth     = AddHDIfNeeded(args, args.MC.LabelManager.CurrentSelection.FullText);
            long   sz      = GetFileSize(pth);
            string sizestr = FormatSizestr(sz);
            string typ     = GetTypeString(pth, sz);

            if (sz <= 0 && IsDrive(pth))
            {
                try
                {
                    foreach (Drive di in Filesystem.GetDrives())
                    {
                        if (!di.Name.Equals(pth))
                        {
                            continue;
                        }
                        sizestr = FormatSizestr(di.TotalSize - di.TotalFreeSpace) + " / " + FormatSizestr(di.TotalSize);
                        break;
                    }
                }
                catch { }
            }
            string lmd = "";

            try
            {
                DateTime lmddt = Filesystem.GetFileLastWriteTime(pth);
                lmd = lmddt.ToShortDateString() + " " + lmddt.ToLongTimeString();
            }
            catch { }
            return("Name: " + args.MC.LabelManager.CurrentSelection.DisplayText + "\nType: " + typ + "\nSize: " + sizestr + "\nLast Modified: " + lmd);
        }
예제 #8
0
 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 {}
 }
예제 #9
0
 public override string RunSingle(MultiboxFunctionParam args)
 {
     if (args.MultiboxText.IndexOf(">>>") <= 1 && args.MultiboxText.IndexOf("<<") > 1)
     {
         return(GetBookmarkString(args, args.MultiboxText.IndexOf("<<")));
     }
     throw new InvalidOperationException();
 }
예제 #10
0
 public override string RunSingle(MultiboxFunctionParam args)
 {
     if (args.Key == Keys.Tab)
     {
         args.MC.VChk.CheckForUpdateForce();
         return("No update found");
     }
     return("Check for updates");
 }
예제 #11
0
 private static string GetEnding(MultiboxFunctionParam args, int ind)
 {
     try
     {
         return(args.MultiboxText.Substring(ind + 3).ToLower());
     }
     catch {}
     return(sizeEndings[sizeEndings.Length - 1].ToLower());
 }
예제 #12
0
        public override void RunActionKeyEvent(MultiboxFunctionParam args)
        {
            ResultItem tmp = args.MC.LabelManager.CurrentSelection;

            if (tmp != null)
            {
                args.MC.HelpDialog.LaunchPage(tmp.EvalText);
            }
        }
예제 #13
0
 private static string BackspaceIfNeeded(MultiboxFunctionParam args, string pth)
 {
     if (args.Key == Keys.Back && args.Control)
     {
         pth = pth.EndsWith("\\") ? pth.Remove(pth.LastIndexOf("\\", pth.Length - 2) + 1) : pth.Remove(pth.LastIndexOf("\\") + 1);
         args.MC.InputFieldText = ":" + pth;
     }
     return(pth);
 }
예제 #14
0
        private static string GetBookmarkString(MultiboxFunctionParam args, int ind2)
        {
            string pth2 = args.MultiboxText.Substring(1, ind2 - 1).Substring(0, args.MultiboxText.Substring(1, ind2 - 1).LastIndexOf("\\") + 1);
            string name = "";

            try
            {
                name = args.MultiboxText.Substring(ind2 + 2);
            }
            catch {}
            return("Bookmark " + pth2 + " as \"" + name + "\"");
        }
 public override string GetDetails(MultiboxFunctionParam args)
 {
     try
     {
         ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
         if (tmp2 != null)
         {
             return("Name: " + tmp2.DisplayText + "\nPath: " + tmp2.FullText);
         }
     }
     catch { }
     return("");
 }
예제 #16
0
 public override string GetDetails(MultiboxFunctionParam args)
 {
     try
     {
         ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
         if (tmp2 != null)
         {
             return("Path: " + (!string.IsNullOrEmpty(tmp2.FullText) ? tmp2.FullText : "--") + "\nSection #: " + (!string.IsNullOrEmpty(tmp2.EvalText) ? tmp2.EvalText : "--"));
         }
     }
     catch { }
     return("");
 }
예제 #17
0
        public override List <ResultItem> RunMulti(MultiboxFunctionParam args)
        {
            if ((args.MultiboxText.IndexOf(">>>") > 1) || (args.MultiboxText.IndexOf("<<") > 1))
            {
                throw new InvalidOperationException();
            }
            AutocompleteIfNeeded(args);
            int ind = args.MultiboxText.IndexOf(">> ");

            if (args.Key != Keys.Up && args.Key != Keys.Down)
            {
                if (ind <= 1)
                {
                    string pth = args.MultiboxText.Substring(1);
                    if (!pth.Contains("\\"))
                    {
                        return(BackspaceIfNeededAndGetFileResultItems(args, pth));
                    }
                    pth = BackspaceIfNeeded(args, pth);
                    string   pth2 = pth.Substring(0, pth.LastIndexOf("\\") + 1);
                    string   pth3 = AddHDIfNeeded(args, pth2);
                    string   pth4 = AddHDIfNeeded(args, pth);
                    string[] pths = DirList(pth3, pth4);
                    if (pths != null)
                    {
                        List <ResultItem> tmp = new List <ResultItem>(0);
                        tmp.AddRange(pths.Select(tpth => new ResultItem(tpth, pth3 + tpth, pth2 + tpth)));
                        return(tmp);
                    }
                }
                else
                {
                    string pth  = args.MultiboxText.Substring(1, ind - 1);
                    string pth2 = pth.Substring(0, pth.LastIndexOf("\\") + 1);
                    string pth3 = AddHDIfNeeded(args, pth2);
                    string fnd  = args.MultiboxText.Substring(ind + 3);
                    if (fnd.Length > 0 && fnd[0] == '/')
                    {
                        fnd = @"^" + fnd.Substring(1) + @"$";
                    }
                    List <string> rlts = new List <string>(0);
                    DirSearch(pth3, fnd, rlts);
                    if (rlts.Count > 0)
                    {
                        return(GetSearchResultItems(args, pth2.Length > 0 && pth2[0] == '~', rlts));
                    }
                }
            }
            return(null);
        }
예제 #18
0
 public override void RunActionKeyEvent(MultiboxFunctionParam args)
 {
     try
     {
         ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
         if (tmp2 == null)
         {
             return;
         }
         string tmpt = tmp2.FullText;
         Process.Start(tmpt);
     }
     catch { }
 }
예제 #19
0
 private static List <ResultItem> BackspaceIfNeededAndGetFileResultItems(MultiboxFunctionParam args, string pth)
 {
     if (args.Key == Keys.Back && args.Control)
     {
         if (string.IsNullOrEmpty(pth))
         {
             args.MC.InputFieldText = "";
             return(null);
         }
         args.MC.InputFieldText = ":";
         pth = "";
     }
     return(GetFileResultItems(pth));
 }
예제 #20
0
        private static void AutocompleteIfNeeded(MultiboxFunctionParam args)
        {
            if (args.Key != Keys.Tab)
            {
                return;
            }
            ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;

            if (tmp2 == null)
            {
                return;
            }
            args.MC.InputFieldText = ":" + tmp2.EvalText;
        }
예제 #21
0
 private IMultiboxFunction GetActivatedFunction(MultiboxFunctionParam args)
 {
     try
     {
         foreach (IMultiboxFunction f in functions)
         {
             if (f.Triggers(args))
             {
                 return(f);
             }
         }
     }
     catch {}
     return(null);
 }
        public override string RunSpecialDisplayCopyHandling(MultiboxFunctionParam args)
        {
            ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;

            if (tmp2 != null)
            {
                string tmpt = tmp2.FullText;
                if (tmpt.Length > 0 && tmpt[0] == '~')
                {
                    tmpt = Filesystem.UserProfile + tmpt.Substring(1);
                }
                return(tmpt);
            }
            return(null);
        }
예제 #23
0
        public override void RunSingleBackgroundStream(MultiboxFunctionParam args)
        {
            int ind = args.MultiboxText.IndexOf(">>>");

            if (ind <= 1)
            {
                return;
            }
            string pth = AddHDIfNeeded(args, args.MultiboxText.Substring(1, ind - 1));

            currentEnding = GetEnding(args, ind);
            if (args.Key != Keys.Tab && lastSizePath != null && lastSizePath.Equals(pth) && isCalculating)
            {
                return;
            }
            cancelCalc = true;
            Thread.Sleep(10);
            cancelCalc = false;
            if (args.Key == Keys.Tab || lastSizeValue <= 0 || lastSizePath == null || !lastSizePath.Equals(pth) || (DateTime.Now - lastSizeTime).TotalMinutes >= 5)
            {
                lastSizePath            = pth;
                args.MC.OutputLabelText = "Calculating size, please wait...";
                args.MC.UpdateSize();
                DateTime ld = DateTime.Now;
                SetLastSizeValues(0);
                isCalculating = true;
                if (!GetFolderSize(pth, args.MC, ref lastSizeValue, ref lastSizeFiles, ref lastSizeFolders, ref ld, 500))
                {
                    SetLastSizeValues(-1);
                }
                isCalculating = false;
                if (cancelCalc)
                {
                    return;
                }
                lastSizeTime = DateTime.Now;
            }
            if (lastSizeValue <= 0)
            {
                args.MC.OutputLabelText = "Invalid selection";
                return;
            }
            SetMCOutputLabelText(args.MC, lastSizeValue, lastSizeFiles, lastSizeFolders, currentEnding);
            args.MC.UpdateSize();
        }
예제 #24
0
 public override void RunMultiBackgroundStream(MultiboxFunctionParam args)
 {
     if (args.Key == Keys.Tab)
     {
         ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
         if (tmp2 != null)
         {
             args.MC.InputFieldText = ">" + tmp2.EvalText;
         }
     }
     try
     {
         args.MC.LabelManager.ResultItems = DirList(args.MultiboxText.Substring(1));
         args.MC.UpdateSize();
         return;
     }
     catch { }
     args.MC.LabelManager.ResultItems = null;
     args.MC.UpdateSize();
 }
예제 #25
0
 public override string RunSingle(MultiboxFunctionParam args)
 {
     try
     {
         string     rval;
         Expression tmp = new Expression(intToDec.Replace(prefixDec.Replace(args.MultiboxText, PrefixDecHelper), IntToDecHelper), EvaluateOptions.IgnoreCase);
         if (tmp.HasErrors())
         {
             rval = tmp.Error;
         }
         else
         {
             try
             {
                 rval = ((int)tmp.Evaluate()).ToString("#,##0.#########");
             }
             catch
             {
                 try
                 {
                     rval = ((float)tmp.Evaluate()).ToString("#,##0.#########");
                 }
                 catch
                 {
                     try
                     {
                         rval = ((double)tmp.Evaluate()).ToString("#,##0.#########");
                     }
                     catch
                     {
                         rval = double.Parse("" + tmp.Evaluate()).ToString("#,##0.#########");
                     }
                 }
             }
         }
         return(rval);
         //return intToDec.Replace(prefixDec.Replace(args.MultiboxText, PrefixDecHelper), IntToDecHelper);
     }
     catch { }
     return("");
 }
        public override List <ResultItem> RunMulti(MultiboxFunctionParam args)
        {
            if (args.Key == Keys.Tab)
            {
                ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
                if (tmp2 != null)
                {
                    try
                    {
                        args.MC.InputFieldText = ":" + tmp2.FullText;
                        return(new FilesystemFunction().RunMulti(args));
                    }
                    catch { }
                    return(null);
                }
            }
            if (args.Key == Keys.Delete && args.Shift)
            {
                ResultItem tmp2 = args.MC.LabelManager.CurrentSelection;
                if (tmp2 != null)
                {
                    BookmarkList.Delete(tmp2.DisplayText);
                }
            }
            BookmarkItem[] itms = BookmarkList.Find(args.MultiboxText.Substring(2));
            if (itms == null || itms.Length <= 0)
            {
                return(null);
            }
            List <ResultItem> ritms = new List <ResultItem>(0);

            foreach (BookmarkItem itm in itms)
            {
                try
                {
                    ritms.Add(new ResultItem(itm.Name, itm.Path, itm.Path));
                }
                catch { }
            }
            return(ritms.Count <= 0 ? null : ritms);
        }
예제 #27
0
 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);
 }
예제 #28
0
 public override bool HasActionKeyEvent(MultiboxFunctionParam args)
 {
     return(true);
 }
예제 #29
0
 public override bool SupressKeyPress(MultiboxFunctionParam args)
 {
     return(true);
 }
예제 #30
0
 public override bool HasDetails(MultiboxFunctionParam args)
 {
     return(true);
 }