Ejemplo n.º 1
0
        private void OnOpenUrl(object sender, DynamicMenuEventArgs e)
        {
            if (e == null)
            {
                Debug.Assert(false); return;
            }

            OpenWithItem it = (e.Tag as OpenWithItem);

            if (it == null)
            {
                Debug.Assert(false); return;
            }

            string strApp = it.FilePath;

            PwEntry[] v = Program.MainForm.GetSelectedEntries();
            if (v == null)
            {
                Debug.Assert(false); return;
            }

            foreach (PwEntry pe in v)
            {
                // Get the entry's URL, avoid URL override
                string strUrl = pe.Strings.ReadSafe(PwDefs.UrlField);
                if (string.IsNullOrEmpty(strUrl))
                {
                    continue;
                }

                if (it.FilePathType == OwFilePathType.Executable)
                {
                    WinUtil.OpenUrlWithApp(strUrl, pe, strApp);
                }
                else if (it.FilePathType == OwFilePathType.ShellExpand)
                {
                    string str = strApp.Replace(PlhTargetUri,
                                                SprEncoding.EncodeForCommandLine(strUrl));
                    WinUtil.OpenUrl(str, pe, false);
                }
                else
                {
                    Debug.Assert(false);
                }
            }
        }
Ejemplo n.º 2
0
        private void OnOpenUrl(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(sURL))
            {
                return;
            }
            try
            {
                if ((sender as ToolStripMenuItem).Tag != null)
                {
                    var    it            = (sender as ToolStripMenuItem).Tag;
                    int    iFilePathType = (int)it.GetType().GetProperty("FilePathType").GetValue(it, null);
                    string strApp        = (string)it.GetType().GetProperty("FilePath").GetValue(it, null);

                    if (iFilePathType == 0)                     //OwFilePathType.Executable
                    {
                        WinUtil.OpenUrlWithApp(sURL, PasswordChangeAssistantExt.SelectedEntry, strApp);
                    }
                    else if (iFilePathType == 1)                     //OwFilePathType.ShellExpand
                    {
                        string str = string.Empty;
                        if (m_miEncodeForCommandLine != null)
                        {
                            str = strApp.Replace(PlhTargetUri, (string)m_miEncodeForCommandLine.Invoke(null, new object[] { sURL }));
                        }
                        else
                        {
                            str = strApp.Replace(PlhTargetUri, sURL);
                        }
                        WinUtil.OpenUrl(str, PasswordChangeAssistantExt.SelectedEntry, false);
                    }
                }
                else
                {
                    Tools.OpenUrl(sURL);
                }
            }
            catch { }
        }