Example #1
0
        public EmbeddedBrowserControl(string initialUrl, WebEntryInfo webEntryInfo, bool multiThreadedMessageLoopEnabled)
        {
            InitializeComponent();
            this.initialUrl   = initialUrl;
            this.webEntryInfo = webEntryInfo;
            var bitness = Environment.Is64BitProcess ? "x64" : "x86";

            Text = "CefSharp.WinForms - " + bitness;
            //WindowState = FormWindowState.Maximized;

            Load += BrowserFormLoad;

            //Only perform layout when control has completly finished resizing
            //todo
            //ResizeBegin += (s, e) => SuspendLayout();
            //ResizeEnd += (s, e) => ResumeLayout(true);

            this.multiThreadedMessageLoopEnabled = multiThreadedMessageLoopEnabled;

            //close button support
            closeImage = new Bitmap(Resources.closeTab);
            addImage   = new Bitmap(Resources.addTab);
            browserTabControl.DrawMode       = TabDrawMode.OwnerDrawFixed;
            browserTabControl.DrawItem      += BrowserTabControl_DrawItem;
            browserTabControl.HandleCreated += BrowserTabControl_HandleCreated;
            //browserTabControl.SelectedIndexChanged += BrowserTabControl_SelectedIndexChanged;
            browserTabControl.MouseClick += BrowserTabControl_MouseClick;
            browserTabControl.Padding     = new Point(10, 3);
        }
Example #2
0
        /// <summary>
        /// http://www.9bis.net/kitty/?page=Command-line%20options
        /// </summary>
        /// <param name="w"></param>
        /// <returns></returns>
        public static string MakePuttyPathForCmd(WebEntryInfo w)
        {
            if (w.Url == null)
            {
                return(null);
            }
            StringBuilder str = new StringBuilder();

            if (w.Login != null)
            {
                str.Append(w.Login);
                str.Append("@");
            }
            if (w.IsInInternalNetwork)
            {
                if (string.IsNullOrEmpty(w.InternalAddress))
                {
                    return(null);
                }
                str.Append(w.InternalAddress);
            }
            else
            {
                if (string.IsNullOrEmpty(w.ExternalAddress))
                {
                    return(null);
                }
                str.Append(w.ExternalAddress);
            }

            /* not supported
             * todo script https://superuser.com/questions/1010031/auto-start-putty-from-command-line-with-a-specific-startup-path
             * if (w.Path != null)
             * {
             *  if (w.Path.StartsWith("/") == false) str.Append("/");
             *  str.Append(w.Path);
             *  if (w.Path.EndsWith("/") == false) str.Append("/");
             * }
             */
            if (w.Password != null)
            {
                str.Append(" -pw ");
                str.Append(w.Password);
            }

            if (w.IsInInternalNetwork == true && string.IsNullOrEmpty(w.PortSSH) == false)
            {
                str.Append(" -P ");
                str.Append(w.PortSSH);
            }
            else if (w.IsInInternalNetwork == false && string.IsNullOrEmpty(w.ExtPortSSH) == false)
            {
                str.Append(" -P ");
                str.Append(w.ExtPortSSH);
            }
            return(str.ToString());
        }
Example #3
0
        public EmbeddedBrowserControl(string initialUrl, WebEntryInfo webEntryInfo, bool multiThreadedMessageLoopEnabled)
        {
            InitializeComponent();
            this.initialUrl   = initialUrl;
            this.webEntryInfo = webEntryInfo;
            var bitness = Environment.Is64BitProcess ? "x64" : "x86";

            Text = "CefSharp.WinForms - " + bitness;
            //WindowState = FormWindowState.Maximized;

            Load += BrowserFormLoad;

            //Only perform layout when control has completly finished resizing
            //todo
            //ResizeBegin += (s, e) => SuspendLayout();
            //ResizeEnd += (s, e) => ResumeLayout(true);

            this.multiThreadedMessageLoopEnabled = multiThreadedMessageLoopEnabled;
        }
Example #4
0
        private void OpenInInternalBrowser(
            WebEntryInfo webEntryInfo,
            IContentContainer contentContainer,
            object selectedObject,
            string webEntityInfoPropertyName = null)
        {
            string             url = webEntryInfo != null ? webEntryInfo.Url : null;
            BrowserPrivateType browserPrivateType = webEntryInfo.BrowserPrivateType;
            ViewType           viewType           = webEntryInfo.RecоmmendedViewType;

            bool isFile = false;
            bool isUrl  = false;

            FileUtils.IsFilePath(url, out isFile, out isUrl);
            if (isFile)
            {
                if (viewType == ViewType.NONE)
                {
                    viewType = GetViewTypeByFilePath(url);
                }
            }
            else
            {
                viewType = ViewType.CefBrowser;
            }

            BaseViewWindow itemViewWindow = AppManager.Instance.CreateContent(contentContainer, AppManager.Instance.DefaultViewWindowType,
                                                                              new Dictionary <string, object>()
            {
                { "Item", selectedObject },
                { "WebEntityInfoPropertyName", webEntityInfoPropertyName },
                { "BrowserPrivateType", browserPrivateType }
            }) as BaseViewWindow;

            itemViewWindow.ViewType     = viewType;
            itemViewWindow.FileFullPath = url;
            itemViewWindow.ProcessView();
        }
Example #5
0
 virtual public bool CheckLevel(WebEntryInfo webEntryInfo)
 {
     /*
      * string mes = null;
      * if (JDm.MyCurrentCompDeviceNetwork == null)
      * {
      *  mes = "Не установлена текущая сеть.";
      * }
      * else
      * {
      *  bool found = false;
      *  if (webEntryInfo.AllowedNetworks != null && webEntryInfo.AllowedNetworks.Count > 0)
      *  {
      *      foreach (var n in webEntryInfo.AllowedNetworks)
      *      {
      *          if (n.Equals(JDm.MyCurrentCompDeviceNetwork))
      *          {
      *              found = true;
      *              break;
      *          }
      *      }
      *  }
      *
      *  if (found == false)
      *  {
      *      if (webEntryInfo.AllowedNetworks != null && webEntryInfo.AllowedNetworks.Count > 0)
      *      {
      *          mes = "Текущая сеть не найдена в списке разрешенных для данного устройства";
      *      }
      *      else
      *      {
      *          if (JDm.MyCurrentCompDeviceNetwork.IsPersonal == true)
      *          {
      *              mes = "Текущая сеть является персональной. Она должна быть явно прописана для открытия данного ресурса.";
      *          }
      *      }
      *  }
      *  if (mes == null)
      *  {
      *      SecLevelEnum networkSecLevel = SecLevelEnum.Low;
      *      if (JDm.MyCurrentCompDeviceNetwork.Router != null && JDm.MyCurrentCompDeviceNetwork.Router.JPhoneNumber != null
      *          && JDm.MyCurrentCompDeviceNetwork.Router.JPhoneNumber.JActor != null)
      *      {
      *          networkSecLevel = (SecLevelEnum)JDm.MyCurrentCompDeviceNetwork.Router.JPhoneNumber.JActor.SecLevel;
      *      }
      *      SecLevelEnum proxySecLevel = SecLevelEnum.Low;
      *      if (DotRasUtils.CurrentProxyServer != null)
      *      {
      *          proxySecLevel = (SecLevelEnum)DotRasUtils.CurrentProxyServer.JProxyProvider.SecLevel;
      *          if (webEntryInfo.SecLevel >= (int)SecLevelEnum.High)
      *          {
      *              if ((int)proxySecLevel < webEntryInfo.SecLevel)
      *              {
      *                  mes = "Уровень безопасности текущего прокси (" + proxySecLevel + ") меньше, чем требуемый уровень для данного ресурса (" + ((SecLevelEnum)webEntryInfo.SecLevel) + ")"; ;
      *              }
      *          }
      *
      *      }
      *      else
      *      {
      *
      *          if (webEntryInfo.SecLevel >= (int)SecLevelEnum.High)
      *          {
      *              if ((int)networkSecLevel < webEntryInfo.SecLevel)
      *              {
      *                  mes = "Уровень безопасности текущей сети (" + networkSecLevel + ") меньше, чем требуемый уровень для данного ресурса (" + ((SecLevelEnum)webEntryInfo.SecLevel) + ")"; ;
      *              }
      *          }
      *      }
      *  }
      * }
      * if (mes != null)
      * {
      *  DialogResult res = MessageBox.Show(mes + " Нажмите ОК, чтобы игонорировать предупреждение и продолжить. Нажмите Cancel для отмены",
      *      FrwConstants.WARNING, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
      *  if (res != DialogResult.OK)
      *  {
      *      //todo подключение к прокси
      *      return false;
      *  }
      * }
      */
     return(true);
 }
Example #6
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);
        }
Example #7
0
 virtual protected void OpenInOtherBrowsers(WebEntryInfo webEntryInfo, string url, List <ToolStripItem> subs1)
 {
 }
Example #8
0
 virtual protected void OpenOtherTools(WebEntryInfo webEntryInfo, List <ToolStripItem> subs)
 {
 }
Example #9
0
        private void CreateOpenInInternalBrowserContextMenu(List <ToolStripItem> subs2,
                                                            ViewType viewType,
                                                            ViewType recоmmendedViewType,
                                                            BrowserPrivateType browserPrivateType,
                                                            string url,
                                                            WebEntryInfo webEntryInfo,
                                                            IContentContainer contentContainer,
                                                            object selectedObject,
                                                            string webEntityInfoPropertyName = null)
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem();

            StringBuilder text = new StringBuilder();

            text.Append(WebAccountLibRes.Open_in_ + " ");
            if (viewType == ViewType.Awesomium)
            {
                text.Append(WebAccountLibRes.Awesomium);
            }
            else if (viewType == ViewType.CefBrowser)
            {
                text.Append(WebAccountLibRes.Chromium_Embedded);
            }
            else if (viewType == ViewType.IE)
            {
                text.Append(WebAccountLibRes.IE);
            }
            else if (viewType == ViewType.Simple)
            {
                text.Append(WebAccountLibRes.Simple_editor);
            }
            else if (viewType == ViewType.WORD)
            {
                text.Append(WebAccountLibRes.MS_Word);
            }
            if (viewType == ViewType.CefBrowser)
            {
                if (browserPrivateType == BrowserPrivateType.COMMON_CACHE)
                {
                    text.Append("");
                }
                else if (browserPrivateType == BrowserPrivateType.PERSONAL_IN_MEMORY_CACHE)
                {
                    text.Append(WebAccountLibRes.__private_in_memory_cache_);
                }
                else if (browserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE)
                {
                    text.Append(WebAccountLibRes.__private_persistent_cache_);
                }
                else if (browserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE)
                {
                    text.Append(WebAccountLibRes.__private_persistent_cache__cleared__);
                }
            }
            menuItem.Text   = text.ToString();
            menuItem.Click += (s, em) =>
            {
                try
                {
                    if (CheckLevel(webEntryInfo) == false)
                    {
                        return;
                    }

                    BaseViewWindow itemViewWindow = AppManager.Instance.CreateContent(contentContainer, AppManager.Instance.DefaultViewWindowType,
                                                                                      new Dictionary <string, object>()
                    {
                        { "Item", selectedObject },
                        { "WebEntityInfoPropertyName", webEntityInfoPropertyName },
                        { "BrowserPrivateType", browserPrivateType }
                    }) as BaseViewWindow;
                    itemViewWindow.ViewType     = viewType;
                    itemViewWindow.FileFullPath = url;
                    itemViewWindow.ProcessView();
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            subs2.Add(menuItem);
        }
        public EmbeddedBrowserTabUserControl(Action <string, int?> openNewTab, string url, WebEntryInfo webEntryInfo, bool multiThreadedMessageLoopEnabled)
        {
            InitializeComponent();
            WebEntryInfo    = webEntryInfo;
            this.openNewTab = openNewTab;
            this.multiThreadedMessageLoopEnabled = multiThreadedMessageLoopEnabled;

            EmbeddedBrowserHelper.InitIfNeed();//we need this to correctly init first browser instance

            //https://stackoverflow.com/questions/34549565/separate-cache-per-browser
            ChromiumWebBrowser browser = null;

            if (WebEntryInfo.BrowserPrivateType == BrowserPrivateType.COMMON_CACHE ||
                WebEntryInfo.BrowserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE ||
                WebEntryInfo.BrowserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE)
            {
                if (WebEntryInfo.CachePath != null)
                {
                    if (WebEntryInfo.BrowserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE)
                    {
                        FileUtils.CreateOrClearDirectory(WebEntryInfo.CachePath);
                    }
                    else if (WebEntryInfo.BrowserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE ||
                             WebEntryInfo.BrowserPrivateType == BrowserPrivateType.COMMON_CACHE)
                    {
                        FileUtils.CreateDirectory(WebEntryInfo.CachePath);
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
                BrowserSettings        browserSettings        = new BrowserSettings();
                RequestContextSettings requestContextSettings = new RequestContextSettings {
                    CachePath = WebEntryInfo.CachePath
                };
                var requestContext = new RequestContext(requestContextSettings);
                browser = new ChromiumWebBrowser(url)
                {
                    BrowserSettings = browserSettings,
                    RequestContext  = requestContext,
                    Dock            = DockStyle.Fill
                };
            }
            else if (WebEntryInfo.BrowserPrivateType == BrowserPrivateType.PERSONAL_IN_MEMORY_CACHE)
            {
                var browserSettings        = new BrowserSettings();
                var requestContextSettings = new RequestContextSettings {
                    CachePath = null
                };
                var requestContext = new RequestContext(requestContextSettings);
                browser = new ChromiumWebBrowser(url)
                {
                    BrowserSettings = browserSettings,
                    RequestContext  = requestContext,
                    Dock            = DockStyle.Fill
                };
            }

            browserPanel.Controls.Add(browser);
            Browser = browser;

            MenuHandler handler = new MenuHandler();

            //handler.DownloadImage += Handler_DownloadImage;
            //handler.ViewPageSource += Handler_ViewPageSource;
            // handler.DownloadYouTubeVideo += Handler_DownloadYouTubeVideo;
            //handler.ViewImageExif += Handler_ViewImageExif;
            //handler.ViewFacebookIdNum += Handler_ViewFacebookIdNum;
            // handler.ViewTwitterIdNum += Handler_ViewTwitterIdNum;
            handler.CopyImageLocation       += Handler_CopyImageLocation;;
            handler.OpenInNewTabContextMenu += Handler_OpenInNewTabContextMenu;
            handler.ReverseImgSearch        += Handler_ReverseImgSearch;
            //handler.ExtractLinks += Handler_ExtractLinks;
            //handler.AddPageToBookmarks += Handler_AddPageToBookmarks;
            handler.SearchText       += Handler_SearchText;
            handler.SaveSelectedText += Handler_SaveSelectedText;

            Browser.MenuHandler = handler;


            //todo
            browser.RequestHandler              = new WinFormsRequestHandler(openNewTab, webEntryInfo);
            browser.LoadingStateChanged        += OnBrowserLoadingStateChanged;//todo some errors when press 'Go'
            browser.ConsoleMessage             += OnBrowserConsoleMessage;
            browser.TitleChanged               += OnBrowserTitleChanged;
            browser.AddressChanged             += OnBrowserAddressChanged;
            browser.StatusMessage              += OnBrowserStatusMessage;//to status label
            browser.LoadError                  += OnLoadError;
            browser.RenderProcessMessageHandler = new RenderProcessMessageHandler();
            browser.DisplayHandler              = new DisplayHandler();

            //var version = String.Format(EmbeddedBrowserControlRes.Chromium___0___CEF___1___CefSharp___2_, Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);
            var version = String.Format(EmbeddedBrowserControlRes.Chromium___0, Cef.ChromiumVersion);

            DisplayOutput(version);
        }
Example #11
0
 public WinFormsRequestHandler(Action <string, int?> openNewTab, WebEntryInfo webEntryInfo)
 {
     this.openNewTab   = openNewTab;
     this.WebEntryInfo = webEntryInfo;
 }
Example #12
0
        static public void CreateCefBrowser(BrowserPrivateType BrowserPrivateType, object LinkedObject, string WebEntityInfoPropertyName, string FileFullPath, ref UserControl viewControl)
        {
            WebEntryInfo webEntryInfo = null;

            if (LinkedObject != null)
            {
                IList <WebEntryInfoWrap> webEntryInfos = WebEntryInfo.GetWebEntryInfosFromObject(LinkedObject);
                if (webEntryInfos.Count > 1)
                {
                    if (WebEntityInfoPropertyName == null)
                    {
                        throw new Exception("WebEntityInfoPropertyName not set, but found more than one WebEntityInfo");
                    }
                    else
                    {
                        WebEntryInfoWrap webEntryInfoWrap = webEntryInfos.Where <WebEntryInfoWrap>(s => s.Property.Name == WebEntityInfoPropertyName).FirstOrDefault();
                        if (webEntryInfoWrap == null)
                        {
                            throw new Exception("Not found WebEntityInfo with specified name: " + WebEntityInfoPropertyName);
                        }
                        else
                        {
                            webEntryInfo = webEntryInfoWrap.WebEntryInfo;
                        }
                    }
                }
                else if (webEntryInfos.Count == 1)
                {
                    webEntryInfo = webEntryInfos[0].WebEntryInfo;
                }
            }
            else
            {
                webEntryInfo = new WebEntryInfo();
            }
            //if (viewControl == null || !(viewControl is EmbeddedBrowserControl))
            //{
            webEntryInfo.BrowserPrivateType = BrowserPrivateType;
            if (BrowserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE
                //|| BrowserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE
                )
            {
                string path = null;

                JActor actor = null;

                if (LinkedObject != null)
                {
                    var  pl = LinkedObject.GetType().GetProperties();
                    Type at = typeof(JActor);
                    foreach (var p in pl)
                    {
                        if (p.PropertyType == at)
                        {
                            actor = AttrHelper.GetPropertyValue(LinkedObject, p) as JActor;
                            break;
                        }
                    }
                }
                //PropertyInfo actorProperty = AttrHelper.GetProperty(typeof(JActor), LinkedObject.GetType());
                //if (actorProperty != null) actor = AttrHelper.GetPropertyValue(LinkedObject, actorProperty) as JActor;
                if (actor != null)
                {
                    path = Dm.Instance.GetCacheFullPathForObjectUniqueForCompAndUser(actor);
                }
                else
                {
                    path = Dm.Instance.GetCacheFullPathForObjectUniqueForCompAndUser(LinkedObject);
                }
                webEntryInfo.CachePath = path;
            }
            else if (BrowserPrivateType == BrowserPrivateType.COMMON_CACHE)
            {
                string path = Dm.Instance.GetBrowserCommonCachePathUniqueForCompAndUser();
                webEntryInfo.CachePath = path;
            }
            viewControl = new EmbeddedBrowserControl(FileFullPath, webEntryInfo, EmbeddedBrowserHelper.MultiThreadedMessageLoop);
        }
Example #13
0
        override public void ProcessView()
        {
            //if (viewControl != null) throw new InvalidOperationException();
            //if (viewProcessed) throw new InvalidOperationException();
            //else viewProcessed = true;

            WebEntryInfo webEntryInfo = null;

            //WebEntryInfo webEntryInfo = WebEntryInfo.GetWebEntryInfoFromObject(LinkedObject);
            if (LinkedObject != null)
            {
                IList <WebEntryInfoWrap> webEntryInfos = WebEntryInfo.GetWebEntryInfosFromObject(LinkedObject);
                if (webEntryInfos.Count > 1)
                {
                    if (WebEntityInfoPropertyName == null)
                    {
                        throw new Exception("WebEntityInfoPropertyName not set, but found more than one WebEntityInfo");
                    }
                    else
                    {
                        WebEntryInfoWrap webEntryInfoWrap = webEntryInfos.Where <WebEntryInfoWrap>(s => s.Property.Name == WebEntityInfoPropertyName).FirstOrDefault();
                        if (webEntryInfoWrap == null)
                        {
                            throw new Exception("Not found WebEntityInfo with specified name: " + WebEntityInfoPropertyName);
                        }
                        else
                        {
                            webEntryInfo = webEntryInfoWrap.WebEntryInfo;
                        }
                    }
                }
                else if (webEntryInfos.Count == 1)
                {
                    webEntryInfo = webEntryInfos[0].WebEntryInfo;
                }
            }
            if (viewType != ViewType.NONE)
            {
                bool newControlCreated = false;
                if (viewType == ViewType.CefBrowser)
                {
                    if (viewControl == null || !(viewControl is EmbeddedBrowserControl))
                    {
                        webEntryInfo.BrowserPrivateType = BrowserPrivateType;
                        if (BrowserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE ||
                            BrowserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE)
                        {
                            string path = Dm.Instance.GetCacheFullPathForObject(LinkedObject);
                            webEntryInfo.CachePath = path;
                        }
                        else if (BrowserPrivateType == BrowserPrivateType.COMMON_CACHE)
                        {
                            string path = Path.Combine(Dm.Instance.GetCommonCachePath(), EmbeddedBrowserHelper.BROWSER_CACHE_PATH);
                            webEntryInfo.CachePath = path;
                        }
                        viewControl       = new EmbeddedBrowserControl(FileFullPath, webEntryInfo, true);
                        newControlCreated = true;
                    }
                }
                else if (viewType == ViewType.Simple)
                {
                    if (viewControl == null || !(viewControl is SimpleViewControl))
                    {
                        viewControl       = new SimpleViewControl();
                        newControlCreated = true;
                    }
                }
                else
                {
                    throw new InvalidOperationException();
                }

                if (newControlCreated)
                {
                    AddSpecialTask();//todo Заваисмость от урл?
                    viewControl.Dock = DockStyle.Fill;
                    this.Controls.Add(viewControl);
                }

                if (FileFullPath != null)
                {
                    if (viewType == ViewType.Simple)
                    {
                        //todo (SimpleViewControl)viewControl;
                    }
                    else if (viewType == ViewType.CefBrowser)
                    {
                        //((CefBrowserControl)viewControl).Navigate(FileFullPath);
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
            string cap = null;

            if (LinkedObject != null)
            {
                cap = ModelHelper.GetNameForObject(LinkedObject);
            }
            else if (FileFullPath != null)
            {
                cap = FileFullPath;
            }
            if (cap != null && cap.Length > 200)
            {
                cap = cap.Substring(0, 200) + "...";
            }
            if (cap != null)
            {
                SetNewCaption(cap);
            }
        }
        public bool CheckIfWeNeedVPN(WebEntryInfo webEntryInfo)
        {
            string     mes = null;
            JVPNServer allowedVPNServer = null;

            if (webEntryInfo.AllowedVPNServerId != null)
            {
                allowedVPNServer = Dm.Instance.Find <JVPNServer>(webEntryInfo.AllowedVPNServerId);
            }
            //if (webEntryInfo.AllowedVPNServerId != null || webEntryInfo.AllowedVPNCountrу != null || webEntryInfo.AllowedVPNTown != null)
            if (webEntryInfo.AllowedVPNServerId != null)
            {
                string allowedMes = WebAccountLibRes.For_this_entity_you_need_access_to_the_Internet_through_a_specific_VPN;
                if (VpnConnUtils.CurrentVPNServer == null)
                {
                    mes = allowedMes + WebAccountLibRes.Current_VPN_connection_is_not_established;
                }
                else
                {
                    if (webEntryInfo.AllowedVPNServerId != null)
                    {
                        if (allowedVPNServer == null)
                        {
                            mes = allowedMes + WebAccountLibRes.This_VPN_connection_has_not_been_established;
                        }
                        else if (VpnConnUtils.CurrentVPNServer != allowedVPNServer)
                        {
                            mes = allowedMes + WebAccountLibRes.The_current_VPN_connection_does_not_match;
                        }
                    }
                }
            }

            if (mes != null)
            {
                if (allowedVPNServer != null)
                {
                    DialogResult res = MessageBox.Show(mes + " " + WebAccountLibRes.Click_Yes_to_connect_to_the_desired_VPN_server,
                                                       FrwConstants.WARNING, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (res == DialogResult.Yes)
                    {
                        try {
                            Cursor.Current = Cursors.WaitCursor;
                            bool conRes = VpnConnUtils.ConnectWithConfirmation(allowedVPNServer);
                            return(conRes);
                        }
                        finally
                        {
                            Cursor.Current = Cursors.Default;
                        }
                    }
                    else if (res == DialogResult.No)
                    {
                        //do nothing
                    }
                    else //Cancel or close
                    {
                        return(false);
                    }
                }
                else
                {
                    DialogResult res = MessageBox.Show(mes + " " + WebAccountLibRes.Click_OK_to_ignore_the_warning_and_continue_Click_Cancel_to_cancel,
                                                       FrwConstants.WARNING, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (res != DialogResult.OK) //Cancel or close
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        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);
        }