コード例 #1
0
        static void DoTheRestore(string path)
        {
            LbxApplication libronixApp = null;

            try
            {
                // If Libronix isn't running, we'll get an exception here
                object libApp = Marshal.GetActiveObject("LibronixDLS.LbxApplication");
                return;                 // It IS running; don't disturb it.
            }
            catch (COMException e)
            {
                if ((uint)e.ErrorCode == 0x800401E3)                 // MK_E_UNAVAILABLE
                {
                    // try to start
                    libronixApp = new LbxApplicationClass();
                }
            }
            if (libronixApp == null)             // can't start, or not installed.
            {
                return;
            }
            try
            {
                // Try to load workspace.
                if (!File.Exists(path))
                {
                    libronixApp.Visible = true;                     //let them see it, anyway.
                    return;
                }
                object             document = libronixApp.MSXML.CreateDocument(0);
                MSXML2.DOMDocument doc      = document as MSXML2.DOMDocument;
                doc.load(path);

                //Type docType = document.GetType();
                //MethodInfo info = docType.GetMethod("Save");
                //if (info == null)
                //{
                //    ReportLoadProblem();
                //    return;
                //}
                //info.Invoke(document, new object[] { path });
                libronixApp.LoadWorkspace(document, "", DlsSaveChanges.dlsPromptToSaveChanges);
                libronixApp.Visible = true;                 //only after we reload the workspace, to save flashing.
            }
            catch (Exception)
            {
                libronixApp.Visible = true;                 //let them see it, anyway.
                ReportLoadProblem();
            }
        }
コード例 #2
0
		static void DoTheRestore(string path)
		{
			LbxApplication libronixApp = null;
			try
			{
				// If Libronix isn't running, we'll get an exception here
				object libApp = Marshal.GetActiveObject("LibronixDLS.LbxApplication");
				return; // It IS running; don't disturb it.
			}
			catch (COMException e)
			{
				if ((uint)e.ErrorCode == 0x800401E3) // MK_E_UNAVAILABLE
				{
					// try to start
					libronixApp = new LbxApplicationClass();
				}
			}
			if (libronixApp == null) // can't start, or not installed.
				return;
			try
			{
				// Try to load workspace.
				if (!File.Exists(path))
				{
					libronixApp.Visible = true; //let them see it, anyway.
					return;
				}
				object document = libronixApp.MSXML.CreateDocument(0);
				MSXML2.DOMDocument doc = document as MSXML2.DOMDocument;
				doc.load(path);

				//Type docType = document.GetType();
				//MethodInfo info = docType.GetMethod("Save");
				//if (info == null)
				//{
				//    ReportLoadProblem();
				//    return;
				//}
				//info.Invoke(document, new object[] { path });
				libronixApp.LoadWorkspace(document, "", DlsSaveChanges.dlsPromptToSaveChanges);
				libronixApp.Visible = true; //only after we reload the workspace, to save flashing.
			}
			catch (Exception)
			{
				libronixApp.Visible = true; //let them see it, anyway.
				ReportLoadProblem();
			}
		}