Esempio n. 1
0
        public WaitingDialog()
        {
            InitializeComponent();

            bgw = new BackgroundWorker();
            bgw.RunWorkerCompleted += (s, e) =>
            {
                WorkingResult = e;
                if (WorkComplete != null)
                {
                    WorkComplete(this, e);
                }
                if (AutoClose)
                {
                    Close();
                }
            };
            bgw.DoWork += (s, e) =>
            {
                Progress.WorkingData = e;
                if (ThreadWorker != null)
                {
                    ThreadWorker(Progress);
                }
                if (CloseDelay > 0)
                {
                    System.Threading.Thread.Sleep(CloseDelay);
                }
            };

            Progress = new ProgressIdentifier()
            {
                WorkerManager = bgw
            };

            Progress.CurrentValueChanged += (s, e) => { pgUpdate.Value = Progress.CurrentValue; };
            Progress.MaxValueChanged     += (s, e) =>
            {
                pgUpdate.Style   = Progress.MaxValue == 0 ? ProgressBarStyle.Marquee : ProgressBarStyle.Continuous;
                pgUpdate.Maximum = Progress.MaxValue;
            };
            Progress.StateMessageChanged += (s, e) =>
            {
                if (!string.IsNullOrEmpty(Progress.StateMessage))
                {
                    lblMessage.Text = Progress.StateMessage;
                    if (ShowLog)
                    {
                        var lvi = new ListViewItem(DateTime.Now.ToShortTimeString());
                        lvi.SubItems.Add(Progress.StateMessage);
                        logList.Items.Add(lvi);
                        lvi.EnsureVisible();
                    }
                }
            };
            Progress.StateObjChanged += (s, e) =>
            {
                if (!ShowLog || Progress.StateObject == null)
                {
                    return;
                }

                if (Progress.StateObject is ProgressIdentifier.ProgressIdentifierEventEntry)
                {
                    ProgressIdentifier.ProgressIdentifierEventEntry piee = Progress.StateObject as ProgressIdentifier.ProgressIdentifierEventEntry;
                    if (!piee.IsValid)
                    {
                        return;
                    }

                    var lvi = new ListViewItem(DateTime.Now.ToShortTimeString());
                    lvi.SubItems.Add(Progress.StateMessage);
                    logList.Items.Add(lvi);
                    lvi.EnsureVisible();
                }
            };



            AutoClose  = true;
            CloseDelay = 1000;

            var fader = new FadeEffectComponent()
            {
                ParentForm = this
            };

            fader.FadeFinished += (s, e) =>
            {
                if (e.Direct != FadeEffectComponent.FadeDirection.FadeIn)
                {
                    return;
                }
                RunWorker();
            };

            this.StartPosition = FormStartPosition.CenterScreen;
        }
Esempio n. 2
0
		void RescanServices(ProgressIdentifier act)
		{
			act.StateMessage = "正在从程序集中扫描插件........";

			string[] installedService = Array.ConvertAll<ServiceInfo, string>(Env.ClientConfig.IPMClientConfig.Services.ToArray(), s => s.TypeName.ToLower());
			ServiceList newservice = ServiceManager.GetServices(Program.GetAddinPath());


			int count = 0;
			int failed = 0;
			int succeed = 0;

			act.MaxValue = newservice.Count;
			act.CurrentValue = 0;

			foreach (var ns in newservice)
			{
				act.CurrentValue++;

				if (installedService.Contains(ns.TypeName.ToLower())) continue;

				//因为我们需要显示插件信息,所以需要预先加载啦。。。
				if (!ns.EnsureLoadAssembly()) continue;

				if (!ns.Enabled)
				{
					act.NotifyStateObjChanged("插件 " + ns.ServiceDescription.Name + " 默认为禁用状态");
				}

				count++;

				act.StateMessage = "正在尝试加载 " + ns.ServiceDescription.Name + " ....";


				Env.ClientConfig.IPMClientConfig.Services.Add(ns);


				if (ns.EnsureLoadAssembly() && ns.CreateProviderInstance() && ns.InitialzingServiceProvider(Env.IPMClient))
				{
					if (!ns.LoadService())
					{
						failed++;
						act.NotifyStateObjChanged("插件 " + ns.ServiceDescription.Name + " 未能成功加载,可能需要重新启动飞鸽传书");
					}
					else
					{
						succeed++;
						act.NotifyStateObjChanged("插件 " + ns.ServiceDescription.Name + " 已经成功加载");
					}
				}
				else
				{
					act.NotifyStateObjChanged("插件 " + ns.ServiceDescription.Name + " 未能成功加载,请联系插件作者");
					failed++;
				}
				LoadPluginItem(ns);
			}

			btnRescan.Enabled = true;
			MessageBox.Show(string.Format("已经重新扫描插件,已找到 {0} 个新插件,已成功加载 {1} 个,{2}。", count, succeed, failed == 0 ? "没有插件加载失败" : "有 " + failed.ToString() + " 个插件没有能成功加载,请重新启动飞鸽传书来加载它们。"), "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
		}
Esempio n. 3
0
		public WaitingDialog()
		{
			InitializeComponent();

			bgw = new BackgroundWorker();
			bgw.RunWorkerCompleted += (s, e) =>
			{
				WorkingResult = e;
				if (WorkComplete != null) WorkComplete(this, e);
				if (AutoClose) Close();
			};
			bgw.DoWork += (s, e) =>
			{
				Progress.WorkingData = e;
				if (ThreadWorker != null) ThreadWorker(Progress);
				if (CloseDelay > 0) System.Threading.Thread.Sleep(CloseDelay);
			};

			Progress = new ProgressIdentifier()
			{
				WorkerManager = bgw
			};

			Progress.CurrentValueChanged += (s, e) => { pgUpdate.Value = Progress.CurrentValue; };
			Progress.MaxValueChanged += (s, e) =>
			{
				pgUpdate.Style = Progress.MaxValue == 0 ? ProgressBarStyle.Marquee : ProgressBarStyle.Continuous;
				pgUpdate.Maximum = Progress.MaxValue;
			};
			Progress.StateMessageChanged += (s, e) =>
			{
				if (!string.IsNullOrEmpty(Progress.StateMessage))
				{
					lblMessage.Text = Progress.StateMessage;
					if (ShowLog)
					{
						var lvi = new ListViewItem(DateTime.Now.ToShortTimeString());
						lvi.SubItems.Add(Progress.StateMessage);
						logList.Items.Add(lvi);
						lvi.EnsureVisible();
					}
				}
			};
			Progress.StateObjChanged += (s, e) =>
			{
				if (!ShowLog || Progress.StateObject == null) return;

				if (Progress.StateObject is ProgressIdentifier.ProgressIdentifierEventEntry)
				{
					ProgressIdentifier.ProgressIdentifierEventEntry piee = Progress.StateObject as ProgressIdentifier.ProgressIdentifierEventEntry;
					if (!piee.IsValid) return;

					var lvi = new ListViewItem(DateTime.Now.ToShortTimeString());
					lvi.SubItems.Add(Progress.StateMessage);
					logList.Items.Add(lvi);
					lvi.EnsureVisible();
				}
			};



			AutoClose = true;
			CloseDelay = 1000;

			var fader = new FadeEffectComponent()
			{
				ParentForm = this
			};
			fader.FadeFinished += (s, e) =>
			{
				if (e.Direct != FadeEffectComponent.FadeDirection.FadeIn) return;
				RunWorker();
			};

			this.StartPosition = FormStartPosition.CenterScreen;
		}