This class is used for the communication between VwBaseVc.DoHotLinkAction and LinkListener.OnHandleLocalHotlink.
Ejemplo n.º 1
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Perform whatever action is appropriate when the user clicks on a hot link
        /// See the class comment on FwLinkArgs for details on how all the parts of (internal)
        /// hyperlinking work.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public virtual void DoHotLinkAction(string strData, ISilDataAccess sda)
        {
            if (strData.Length > 0 && (int)strData[0] == (int)FwObjDataTypes.kodtExternalPathName)
            {
                string url = strData.Substring(1).Trim();                 // may also be just a file name, launches default app.

                // If the file path is saved as a non rooted path, then it is relative to the project's
                // LinkedFilesRootDir.  In this case get the full path.
                // We also need to deal with url's like the following ( http:// silfw:// http:\ silfw:\ which are considered Not rooted).
                // thus the check for FileUtils.IsFilePathValid(url)
                // Added check IsFileUriOrPath since paths starting with silfw: are valid paths on Linux.
                if (FileUtils.IsFileUriOrPath(url) && FileUtils.IsFilePathValid(url) && !Path.IsPathRooted(url))
                {
                    string linkedFilesFolder = GetLinkedFilesRootDir(sda);
                    url = Path.Combine(linkedFilesFolder, url);
                }

                // See if we can handle it (via our own LinkListener) without starting a process.
                var args = new LocalLinkArgs()
                {
                    Link = url
                };
                if (Mediator != null)
                {
                    Mediator.SendMessage("HandleLocalHotlink", args);
                    if (args.LinkHandledLocally)
                    {
                        return;
                    }
                }

                // Review JohnT: do we need to do some validation here?
                // C++ version uses URLIs, and takes another approach to launching files if not.
                // But no such function in .NET that I can find.

                try
                {
                    using (Process.Start(url))
                    {
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(null,
                                    String.Format(Properties.Resources.ksMissingLinkTarget, url, e.Message),
                                    Properties.Resources.ksCannotFollowLink);
                }
            }
        }
Ejemplo n.º 2
0
		private void JumpToFlexObject(object sender, FLExJumpEventArgs e)
		{
			// TODO: Test to see if one conflict tool can do both FLEx and LIFT conflicts.
			if (!string.IsNullOrEmpty(e.JumpUrl))
			{
				var args = new LocalLinkArgs { Link = e.JumpUrl };
				if (_mediator != null)
					_mediator.SendMessage("HandleLocalHotlink", args);
			}
		}
Ejemplo n.º 3
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Perform whatever action is appropriate when the user clicks on a hot link
		/// See the class comment on FwLinkArgs for details on how all the parts of (internal)
		/// hyperlinking work.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public virtual void DoHotLinkAction(string strData, ISilDataAccess sda)
		{
			if (strData.Length > 0 && (int)strData[0] == (int)FwObjDataTypes.kodtExternalPathName)
			{
				string url = strData.Substring(1).Trim(); // may also be just a file name, launches default app.

				// If the file path is saved as a non rooted path, then it is relative to the project's
				// LinkedFilesRootDir.  In this case get the full path.
				// We also need to deal with url's like the following ( http:// silfw:// http:\ silfw:\ which are considered Not rooted).
				// thus the check for FileUtils.IsFilePathValid(url)
				// Added check IsFileUriOrPath since paths starting with silfw: are valid paths on Linux.
				if (FileUtils.IsFileUriOrPath(url) && FileUtils.IsFilePathValid(url) && !Path.IsPathRooted(url))
				{
					string linkedFilesFolder = GetLinkedFilesRootDir(sda);
					url = Path.Combine(linkedFilesFolder, url);
				}

				// See if we can handle it (via our own LinkListener) without starting a process.
				var args = new LocalLinkArgs() {Link = url};
				if (Mediator != null)
				{
					Mediator.SendMessage("HandleLocalHotlink", args);
					if (args.LinkHandledLocally)
						return;
				}

				// Review JohnT: do we need to do some validation here?
				// C++ version uses URLIs, and takes another approach to launching files if not.
				// But no such function in .NET that I can find.

				try
				{
					using (Process.Start(url))
					{
					}
				}
				catch (Exception e)
				{
					MessageBox.Show(null,
						String.Format(Properties.Resources.ksMissingLinkTarget, url, e.Message),
						Properties.Resources.ksCannotFollowLink);
				}
			}
		}