コード例 #1
0
        override public List <ToolStripItem> CreateOpenInBrowserContextMenu(WebEntryInfo webEntryInfo, IContentContainer contentContainer, object selectedObject, string webEntityInfoPropertyName = null)
        {
            string               url      = webEntryInfo != null ? webEntryInfo.Url : null;
            ToolStripMenuItem    menuItem = null;
            List <ToolStripItem> subs     = new List <ToolStripItem>();
            List <ToolStripItem> subs1    = new List <ToolStripItem>();
            List <ToolStripItem> subs2    = null;


            if (string.IsNullOrEmpty(url) == false)
            {
                ViewType recоmmendedViewType = webEntryInfo.RecоmmendedViewType;

                bool isFile = false;
                bool isUrl  = false;
                FileUtils.IsFilePath(url, out isFile, out isUrl);
                string oTitle = isFile ? WebAccountLibRes.Path : WebAccountLibRes.URL;

                if (isFile)
                {
                    if (recоmmendedViewType == ViewType.NONE)
                    {
                        recоmmendedViewType = GetViewTypeByFilePath(url);
                    }
                }
                else
                {
                    recоmmendedViewType = ViewType.CefBrowser;
                }

                //////////////////
                //open favorit
                /////////////////

                //default
                menuItem        = new ToolStripMenuItem();
                menuItem.Text   = WebAccountLibRes.Open_in + " " + WebAccountLibRes.In_default_external_application;
                menuItem.Font   = new Font(menuItem.Font, FontStyle.Bold);
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        if (CheckLevel(webEntryInfo) == false)
                        {
                            return;
                        }
                        AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                        ProcessUtils.OpenFile(url);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);

                //internal
                CreateOpenInInternalBrowserContextMenu(subs, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_OLD_DISK_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                //external
                if (AppLocator.ChromePath != null)
                {
                    /*
                     * menuItem = new ToolStripMenuItem();
                     * menuItem.Text = WebAccountLibRes.Open_in_external_Chrome;
                     * menuItem.Click += (s, em) =>
                     * {
                     *  try
                     *  {
                     *      if (CheckLevel(webEntryInfo) == false) return;
                     *      AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                     *      ProcessUtils.ExecuteProgram(AppLocator.ChromePath,  url);
                     *  }
                     *  catch (Exception ex)
                     *  {
                     *      Log.ShowError(ex);
                     *  }
                     * };
                     * subs.Add(menuItem);
                     *
                     * menuItem = new ToolStripMenuItem();
                     * menuItem.Text = WebAccountLibRes.Open_in_external_Chrome + " (" + WebAccountLibRes.private_mode + ")";
                     * menuItem.Click += (s, em) =>
                     * {
                     *  try
                     *  {
                     *      if (CheckLevel(webEntryInfo) == false) return;
                     *      AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                     *      ProcessUtils.ExecuteProgram(AppLocator.ChromePath, "-incognito " + url);
                     *  }
                     *  catch (Exception ex)
                     *  {
                     *      Log.ShowError(ex);
                     *  }
                     * };
                     * subs.Add(menuItem);
                     */
                }
                if (isFile)
                {
                    //open folder
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_folder;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.OpenFile(FileUtils.GetDirectorNameForPath(url));
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
                //////////////////////////////////
                OpenOtherTools(webEntryInfo, subs);


                //////////////////////////////
                ///internal browser

                subs2 = new List <ToolStripItem>();

                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_OLD_DISK_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_NEW_DISK_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_IN_MEMORY_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.IE, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.Awesomium, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                if (isFile)
                {
                    CreateOpenInInternalBrowserContextMenu(subs2, ViewType.Simple, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                           url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                    CreateOpenInInternalBrowserContextMenu(subs2, ViewType.WORD, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                           url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                }

                //level 1 menu - open
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Open_in_embedded_browser;
                menuItem.DropDownItems.AddRange(subs2.ToArray <ToolStripItem>());
                subs1.Add(menuItem);

                /////////////////////////////////
                /////Open in external browser
                //////////////////////////////

                //open external app level 2
                subs2 = new List <ToolStripItem>();
                if (AppLocator.EdgePath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Microsoft_Edge;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram("cmd.exe", "/c start microsoft-edge:" + url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.InternetExplorerPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_IE__deprecated_;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.InternetExplorerPath, url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);

                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_IE__deprecated_ + " (" + WebAccountLibRes.private_mode + ")";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            //InPrivate Browsing helps prevent your browsing history, temporary Internet files, form data, cookies, and user names and passwords from being retained by the browser. You can start InPrivate Browsing from the Safety menu, by pressing Ctrl+Shift+P, or from the New Tab page. Internet Explorer will launch a new browser session that won’t keep any information about webpages you visit or searches you perform. Closing the browser window will end your InPrivate Browsing session.
                            ProcessUtils.ExecuteProgram(AppLocator.InternetExplorerPath, "-private " + url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.ChromePath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Chrome;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.ChromePath, url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Chrome + " (" + WebAccountLibRes.private_mode + ")";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.ChromePath, "-incognito " + url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.FirefoxPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_FireFox;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.FirefoxPath, url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.FirefoxProtablePath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_FireFox + " " + WebAccountLibRes.Portable;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.FirefoxProtablePath, url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.OperaPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Opera;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.OperaPath, url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.SafariPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Safary;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.SafariPath, url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (webEntryInfo.Url != null && webEntryInfo.Login != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_IE__KeeForm__and_try_to_autocomplate_web_form__ + webEntryInfo.Login;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckLevel(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;

                            StringBuilder args = new StringBuilder();
                            args.Append(webEntryInfo.Url);
                            args.Append(" ");
                            args.Append(webEntryInfo.Login);
                            args.Append(" ");
                            args.Append(webEntryInfo.Password != null ? webEntryInfo.Password : "******");
                            if (webEntryInfo.Password != null)
                            {
                                args.Append(" ");
                                //args.Append("{TAB}{TAB}{ENTERFORM}");
                                args.Append("{ENTERFORM}");
                            }
                            Console.WriteLine("Args: " + args.ToString());
                            ProcessUtils.ExecuteProgram("KeeForm.exe", args.ToString());
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }

                //level 1 menu - open
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Open_in_external + "...";
                menuItem.DropDownItems.AddRange(subs2.ToArray <ToolStripItem>());
                subs1.Add(menuItem);

                OpenInOtherBrowsers(webEntryInfo, url, subs1);


                //level 0 menu - open
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Open_in + "...";
                menuItem.DropDownItems.AddRange(subs1.ToArray <ToolStripItem>());
                subs.Add(menuItem);

                //copy url
                menuItem        = new ToolStripMenuItem();
                menuItem.Text   = WebAccountLibRes.Copy + " " + oTitle + " " + WebAccountLibRes.to_clipboard + ": " + (url.Length <= 50 ? url : (url.Substring(0, 50) + "..."));
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(url, TextDataFormat.Text);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);
            }

            //////////////login password
            if (webEntryInfo != null && webEntryInfo.Login != null)
            {
                menuItem         = new ToolStripMenuItem();
                menuItem.Text    = WebAccountLibRes.Copy_login_to_clipboard + ": " + webEntryInfo.Login;
                menuItem.Enabled = !string.IsNullOrEmpty(webEntryInfo.Login);
                menuItem.Click  += (s, em) =>
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(webEntryInfo.Login, TextDataFormat.Text);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);
            }

            if (webEntryInfo != null && webEntryInfo.Password != null)
            {
                menuItem         = new ToolStripMenuItem();
                menuItem.Text    = WebAccountLibRes.Copy_password_to_clipboard;
                menuItem.Enabled = !string.IsNullOrEmpty(webEntryInfo.Password);
                menuItem.Click  += (s, em) =>
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(webEntryInfo.Password, TextDataFormat.Text);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);
            }

            return(subs);
        }
コード例 #2
0
        override public List <ToolStripItem> CreateOpenInBrowserContextMenu(WebEntryInfo webEntryInfo, IContentContainer contentContainer, object selectedObject, string webEntityInfoPropertyName = null)
        {
            string url = webEntryInfo != null ? webEntryInfo.Url : null;

            ToolStripMenuItem    menuItem = null;
            List <ToolStripItem> subs     = new List <ToolStripItem>();
            List <ToolStripItem> subs1    = new List <ToolStripItem>();
            List <ToolStripItem> subs2    = null;


            if (string.IsNullOrEmpty(url) == false)
            {
                ViewType recоmmendedViewType = webEntryInfo.RecоmmendedViewType;

                bool isFile = false;
                bool isUrl  = false;
                FileUtils.IsFilePath(url, out isFile, out isUrl);
                string oTitle = isFile ? WebAccountLibRes.Path : WebAccountLibRes.URL;

                string uri = isFile? FileUtils.FilePathWithBookmarkToFileUrl(url) : url;

                if (isFile)
                {
                    if (recоmmendedViewType == ViewType.NONE)
                    {
                        recоmmendedViewType = GetViewTypeByFilePath(url);
                    }
                }
                else
                {
                    recоmmendedViewType = ViewType.CefBrowser;
                }

                //////////////////
                //open favorit
                /////////////////

                //default
                if (FileUtils.IsHtmlFileWithBookmark(url) && AppLocator.ChromePath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Chrome;
                    menuItem.Font   = new Font(menuItem.Font, FontStyle.Bold);
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.ChromePath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
                else
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in + " " + WebAccountLibRes.In_default_external_application;
                    menuItem.Font   = new Font(menuItem.Font, FontStyle.Bold);
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.OpenFile(url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }



                //internal
                CreateOpenInInternalBrowserContextMenu(subs, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_OLD_DISK_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                //external
                if (isFile)
                {
                    //open folder
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_folder;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.OpenFile(FileUtils.GetDirectorNameForPath(url));
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
                //////////////////////////////////
                OpenOtherTools(webEntryInfo, subs);


                //////////////////////////////
                ///internal browser

                subs2 = new List <ToolStripItem>();

                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_OLD_DISK_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                CreateOpenInInternalBrowserContextMenu(subs2, ViewType.CefBrowser, recоmmendedViewType, BrowserPrivateType.PERSONAL_IN_MEMORY_CACHE,
                                                       url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);

                string commonCachePath = Dm.Instance.GetBrowserCommonCachePathUniqueForCompAndUser();
                string objectCachepath = Dm.Instance.GetCacheFullPathForObjectUniqueForCompAndUser(selectedObject);
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Clear_browser_cache_for_entity;
                if (Directory.Exists(objectCachepath) == false)
                {
                    menuItem.Enabled = false;
                }
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        if (Directory.Exists(objectCachepath))
                        {
                            FileUtils.DeleteDirectory(objectCachepath);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs2.Add(menuItem);

                JActor actor = null;
                var    pl    = selectedObject.GetType().GetProperties();
                Type   at    = typeof(JActor);
                foreach (var p in pl)
                {
                    if (p.PropertyType == at)
                    {
                        actor = AttrHelper.GetPropertyValue(selectedObject, p) as JActor;
                        break;
                    }
                }
                if (actor != null)
                {
                    string actorCachepath = Dm.Instance.GetCacheFullPathForObjectUniqueForCompAndUser(actor);
                    menuItem      = new ToolStripMenuItem();
                    menuItem.Text = WebAccountLibRes.Clear_browser_cache_for_entity_actor;
                    if (Directory.Exists(actorCachepath) == false)
                    {
                        menuItem.Enabled = false;
                    }
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (Directory.Exists(actorCachepath))
                            {
                                FileUtils.DeleteDirectory(actorCachepath);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }

                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Clear_common_browser_cache;
                if (Directory.Exists(commonCachePath) == false)
                {
                    menuItem.Enabled = false;
                }
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        if (Directory.Exists(commonCachePath))
                        {
                            FileUtils.DeleteDirectory(commonCachePath);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs2.Add(menuItem);
                //open folder
                if (isFile)
                {
                    CreateOpenInInternalBrowserContextMenu(subs2, ViewType.Simple, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                           url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                    CreateOpenInInternalBrowserContextMenu(subs2, ViewType.WORD, recоmmendedViewType, BrowserPrivateType.COMMON_CACHE,
                                                           url, webEntryInfo, contentContainer, selectedObject, webEntityInfoPropertyName);
                }

                //level 1 menu - open
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Open_in_embedded_browser;
                menuItem.DropDownItems.AddRange(subs2.ToArray <ToolStripItem>());
                subs1.Add(menuItem);

                /////////////////////////////////
                /////Open in external browser
                //////////////////////////////

                //open external app level 2
                subs2 = new List <ToolStripItem>();
                if (AppLocator.EdgePath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Microsoft_Edge;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            //open local files (or local uri to file) not supported
                            //https://stackoverflow.com/questions/34798285/how-can-i-open-a-local-html-file-in-microsoft-edge-browser
                            ProcessUtils.ExecuteProgram("cmd.exe", "/c start microsoft-edge:" + url);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.InternetExplorerPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_IE__deprecated_;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.InternetExplorerPath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);

                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_IE__deprecated_ + " (" + WebAccountLibRes.private_mode + ")";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            //InPrivate Browsing helps prevent your browsing history, temporary Internet files, form data, cookies, and user names and passwords from being retained by the browser. You can start InPrivate Browsing from the Safety menu, by pressing Ctrl+Shift+P, or from the New Tab page. Internet Explorer will launch a new browser session that won’t keep any information about webpages you visit or searches you perform. Closing the browser window will end your InPrivate Browsing session.
                            ProcessUtils.ExecuteProgram(AppLocator.InternetExplorerPath, "-private " + uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.ChromePath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Chrome;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.ChromePath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Chrome + " (" + WebAccountLibRes.private_mode + ")";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.ChromePath, "-incognito " + uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.FirefoxPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_FireFox;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.FirefoxPath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.FirefoxProtablePath != null && File.Exists(AppLocator.FirefoxProtablePath))
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_FireFox + " " + WebAccountLibRes.Portable;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.FirefoxProtablePath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.ChromeProtablePath != null && File.Exists(AppLocator.ChromeProtablePath))
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Chrome + " " + WebAccountLibRes.Portable;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.ChromeProtablePath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.OperaPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Opera;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.OperaPath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (AppLocator.SafariPath != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_Safary;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.SafariPath, uri);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }
                if (webEntryInfo.Url != null && webEntryInfo.Login != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Open_in_IE__KeeForm__and_try_to_autocomplate_web_form__ + webEntryInfo.Login;
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;

                            StringBuilder args = new StringBuilder();
                            args.Append(webEntryInfo.Url);
                            args.Append(" ");
                            args.Append(webEntryInfo.Login);
                            args.Append(" ");
                            args.Append(webEntryInfo.Password != null ? webEntryInfo.Password : "******");
                            if (webEntryInfo.Password != null)
                            {
                                args.Append(" ");
                                //args.Append("{TAB}{TAB}{ENTERFORM}");
                                args.Append("{ENTERFORM}");
                            }
                            Console.WriteLine("Args: " + args.ToString());
                            ProcessUtils.ExecuteProgram("KeeForm.exe", args.ToString());
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs2.Add(menuItem);
                }

                //level 1 menu - open
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Open_in_external + "...";
                menuItem.DropDownItems.AddRange(subs2.ToArray <ToolStripItem>());
                subs1.Add(menuItem);

                OpenInOtherBrowsers(webEntryInfo, uri, subs1);


                //level 0 menu - open
                menuItem      = new ToolStripMenuItem();
                menuItem.Text = WebAccountLibRes.Open_in + "...";
                menuItem.DropDownItems.AddRange(subs1.ToArray <ToolStripItem>());
                subs.Add(menuItem);

                //copy url
                menuItem        = new ToolStripMenuItem();
                menuItem.Text   = WebAccountLibRes.Copy + " " + oTitle + " " + WebAccountLibRes.to_clipboard + ": " + (url.Length <= 50 ? url : (url.Substring(0, 50) + "..."));
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(url, TextDataFormat.Text);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);
                if (url.Equals(uri) == false)
                {
                    //copy uri
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = WebAccountLibRes.Copy + " " + oTitle + " " + WebAccountLibRes.to_clipboard + ": " + (uri.Length <= 50 ? uri : (uri.Substring(0, 50) + "..."));
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            Clipboard.Clear();
                            Clipboard.SetText(uri, TextDataFormat.Text);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
            }

            //////////////login password
            if (webEntryInfo != null && webEntryInfo.Login != null)
            {
                menuItem         = new ToolStripMenuItem();
                menuItem.Text    = WebAccountLibRes.Copy_login_to_clipboard + ": " + webEntryInfo.Login;
                menuItem.Enabled = !string.IsNullOrEmpty(webEntryInfo.Login);
                menuItem.Click  += (s, em) =>
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(webEntryInfo.Login, TextDataFormat.Text);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);
            }

            if (webEntryInfo != null && webEntryInfo.Password != null)
            {
                menuItem         = new ToolStripMenuItem();
                menuItem.Text    = WebAccountLibRes.Copy_password_to_clipboard;
                menuItem.Enabled = !string.IsNullOrEmpty(webEntryInfo.Password);
                menuItem.Click  += (s, em) =>
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(webEntryInfo.Password, TextDataFormat.Text);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                subs.Add(menuItem);
            }

            return(subs);
        }