Exemple #1
0
 /// <summary>
 /// Jumps to the target.
 /// </summary>
 /// <returns>True on success, false on failure</returns>
 public bool Jump()
 {
     if (CanJump)
     {
         bool success = false;
         if (IsReference)
         {
             Logger.Info("Jump: Reference: {0}", Reference.ReferenceString);
             Reference.Activate();
             success = true;
         }
         else if (IsFile)
         {
             string path = Uri.LocalPath;
             Logger.Info("Jump: Path: {0}", path);
             Workbook workbook = null;
             if (_workbookPattern.Value.IsMatch(path))
             {
                 Logger.Info("Jump: Attempting to open workbook");
                 workbook = Instance.Default.LocateWorkbook(path);
                 success  = workbook != null;
                 if (success)
                 {
                     ((_Workbook)workbook).Activate();
                     Logger.Info("Jump: Workbook opened");
                 }
             }
             if (!success)
             {
                 if (System.IO.File.Exists(path) || System.IO.Directory.Exists(path))
                 {
                     Logger.Info("Jump: Starting process from path");
                     System.Diagnostics.Process.Start(path);
                     success = true;
                 }
                 else
                 {
                     Logger.Warn("Jump: Unable to locate target \"{0}\"", path);
                 }
             }
             Bovender.ComHelpers.ReleaseComObject(workbook);
         }
         else if (IsWebUrl)
         {
             string url = Uri.AbsoluteUri;
             Logger.Info("Jump: URL: {0}", url);
             System.Diagnostics.Process.Start(url);
             success = true;
         }
         return(success);
     }
     else
     {
         Logger.Warn("Jump: Cannot jump to this target: \"{0}\"", Target);
         return(false);
     }
 }