Ejemplo n.º 1
0
 public void BeginTask(string name, int totalWork)
 {
     FlushLog();
     tracker.BeginTask(name, totalWork);
     status.SetMessage(tracker.CurrentTask);
     status.SetProgress(tracker.GlobalWork);
 }
Ejemplo n.º 2
0
 public void SetProgress(double progress)
 {
     local.SetProgress(progress);
 }
Ejemplo n.º 3
0
        internal bool LoadAddin(IProgressStatus statusMonitor, string id, bool throwExceptions)
        {
            try {
                lock (LocalLock) {
                    if (IsAddinLoaded(id))
                    {
                        return(true);
                    }

                    if (!Registry.IsAddinEnabled(id))
                    {
                        string msg = GettextCatalog.GetString("Disabled add-ins can't be loaded.");
                        ReportError(msg, id, null, false);
                        if (throwExceptions)
                        {
                            throw new InvalidOperationException(msg);
                        }
                        return(false);
                    }

                    ArrayList addins   = new ArrayList();
                    Stack     depCheck = new Stack();
                    ResolveLoadDependencies(addins, depCheck, id, false);
                    addins.Reverse();

                    if (statusMonitor != null)
                    {
                        statusMonitor.SetMessage("Loading Addins");
                    }

                    for (int n = 0; n < addins.Count; n++)
                    {
                        if (statusMonitor != null)
                        {
                            statusMonitor.SetProgress((double)n / (double)addins.Count);
                        }

                        Addin iad = (Addin)addins [n];
                        if (IsAddinLoaded(iad.Id))
                        {
                            continue;
                        }

                        if (statusMonitor != null)
                        {
                            statusMonitor.SetMessage(string.Format(GettextCatalog.GetString("Loading {0} add-in"), iad.Id));
                        }

                        if (!InsertAddin(statusMonitor, iad))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex) {
                ReportError("Add-in could not be loaded: " + ex.Message, id, ex, false);
                if (statusMonitor != null)
                {
                    statusMonitor.ReportError("Add-in '" + id + "' could not be loaded.", ex);
                }
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }
        }
Ejemplo n.º 4
0
        internal bool LoadAddin(IProgressStatus statusMonitor, string id, bool throwExceptions)
        {
            try {
                if (IsAddinLoaded (id))
                    return true;

                if (!Registry.IsAddinEnabled (id)) {
                    string msg = GettextCatalog.GetString ("Disabled add-ins can't be loaded.");
                    ReportError (msg, id, null, false);
                    if (throwExceptions)
                        throw new InvalidOperationException (msg);
                    return false;
                }

                ArrayList addins = new ArrayList ();
                Stack depCheck = new Stack ();
                ResolveLoadDependencies (addins, depCheck, id, false);
                addins.Reverse ();

                if (statusMonitor != null)
                    statusMonitor.SetMessage ("Loading Addins");

                for (int n=0; n<addins.Count; n++) {

                    if (statusMonitor != null)
                        statusMonitor.SetProgress ((double) n / (double)addins.Count);

                    Addin iad = (Addin) addins [n];
                    if (IsAddinLoaded (iad.Id))
                        continue;

                    if (statusMonitor != null)
                        statusMonitor.SetMessage (string.Format(GettextCatalog.GetString("Loading {0} add-in"), iad.Id));

                    if (!InsertAddin (statusMonitor, iad))
                        return false;
                }
                return true;
            }
            catch (Exception ex) {
                ReportError ("Add-in could not be loaded: " + ex.Message, id, ex, false);
                if (statusMonitor != null)
                    statusMonitor.ReportError ("Add-in '" + id + "' could not be loaded.", ex);
                if (throwExceptions)
                    throw;
                return false;
            }
        }
Ejemplo n.º 5
0
		public static void MonitorProcessStatus (IProgressStatus monitor, TextReader reader, StringCollection progessLog)
		{
			string line;
			string exceptionText = null;
			while ((line = reader.ReadLine ()) != null) {
				int i = line.IndexOf (':');
				if (i != -1) {
					string tag = line.Substring (0, i);
					string txt = line.Substring (i+1);
					bool wasTag = true;
					
					switch (tag) {
						case "process-ps-msg":
							monitor.SetMessage (Decode (txt));
							break;
						case "process-ps-progress":
							monitor.SetProgress (double.Parse (txt));
							break;
						case "process-ps-log":
							monitor.Log (Decode (txt));
							break;
						case "process-ps-warning":
							monitor.ReportWarning (Decode (txt));
							break;
						case "process-ps-exception":
							exceptionText = Decode (txt);
							if (exceptionText == string.Empty)
								exceptionText = null;
							break;
						case "process-ps-error":
							string err = Decode (txt);
							if (err == string.Empty) err = null;
							monitor.ReportError (err, exceptionText != null ? new Exception (exceptionText) : null);
							break;
						case "process-ps-cancel":
							monitor.Cancel ();
							break;
						case "process-ps-plog":
							progessLog.Add (Decode (txt));
							break;
						default:
							wasTag = false;
							break;
					}
					if (wasTag)
						continue;
				}
				Console.WriteLine (line);
			}
		}
Ejemplo n.º 6
0
        public static void MonitorProcessStatus(IProgressStatus monitor, TextReader reader, StringCollection progessLog)
        {
            string line;
            string exceptionText = null;

            while ((line = reader.ReadLine()) != null)
            {
                int i = line.IndexOf(':');
                if (i != -1)
                {
                    string tag    = line.Substring(0, i);
                    string txt    = line.Substring(i + 1);
                    bool   wasTag = true;

                    switch (tag)
                    {
                    case "process-ps-msg":
                        monitor.SetMessage(Decode(txt));
                        break;

                    case "process-ps-progress":
                        monitor.SetProgress(double.Parse(txt));
                        break;

                    case "process-ps-log":
                        monitor.Log(Decode(txt));
                        break;

                    case "process-ps-warning":
                        monitor.ReportWarning(Decode(txt));
                        break;

                    case "process-ps-exception":
                        exceptionText = Decode(txt);
                        if (exceptionText == string.Empty)
                        {
                            exceptionText = null;
                        }
                        break;

                    case "process-ps-error":
                        string err = Decode(txt);
                        if (err == string.Empty)
                        {
                            err = null;
                        }
                        monitor.ReportError(err, exceptionText != null ? new Exception(exceptionText) : null);
                        break;

                    case "process-ps-cancel":
                        monitor.Cancel();
                        break;

                    case "process-ps-plog":
                        progessLog.Add(Decode(txt));
                        break;

                    default:
                        wasTag = false;
                        break;
                    }
                    if (wasTag)
                    {
                        continue;
                    }
                }
                Console.WriteLine(line);
            }
        }