コード例 #1
0
ファイル: HelpProvider.cs プロジェクト: killbug2004/WSProf
		/// <summary>
		/// Show help, using the default help file for this Installation
		/// </summary>
		/// <param name="helpId"></param>
		public void ShowHelp(HelpId helpId)
		{
            var installation = new Installation();
			
            string helpFile = ProfessionalChm;
            if (installation.InstalledProduct == InstalledProduct.CompareStandalone)
            {
                helpFile = CompareChm;
            }

            ShowHelp(helpFile, (int)helpId);
		}
コード例 #2
0
ファイル: PdfCreator.cs プロジェクト: killbug2004/WSProf
        static void Main(string[] args)
        {
            try
            {
                if (args.Length < 1)
                {
                    Logger.LogError("PdfCreator requires a command line argument");
                    return;
                }

                var installation = new Installation();
                if (installation.InstalledProduct != InstalledProduct.Workshare)
                {
                    Logger.LogError("PdfCreator: Installed Product doesn't allow PDF Create = " + installation.InstalledProduct.ToString());
                    return;
                }

                var filename = string.Empty;
                var email = false;

                if (args.Length >= 1)
                {
                    filename = args[0];
                }
                if (args.Length >= 2 && args[1] == "pdfandemail")
                {
                    email = true;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

                try
                {
                    var context = new PdfCreatorApplicationContext(filename, email);
                    Application.Run(context);
                }
                catch (InvalidCredentialException)
                {
                    OfficeApplicationCache.Instance.ShutDown();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
				if (ex.HResult != unchecked((int)0x80070006))	// E_HANDLE => is already open
				{
					WsMessage.ShowMessage(new WindowWrapper().Handle, "Error creating PDF: \n\n" + ex.Message, MessageButtons.WsOK, MessageBranding.WsDefault, MessageType.WsErrorIcon, string.Empty, (int) Common.Help.HelpId.CreatingPdf);
				}
				else
				{
					// find other running instance - with this file - and bring to front
					// mm, will just find the first, so could be a different file -> fix when is an issue!
					string className = "WindowsForms10.Window.8.app.0.2edafd9_r13_ad1"; // REALLY?!

					IntPtr handle = FindWindow(className, "Workshare Protect - Convert to PDF");	// we cannot detect which file it is using from the window!

					if (handle != IntPtr.Zero) 
					{
						SetForegroundWindow(handle);
					}							
				}

            }            
        }