public RegisterViewModel() { LoaddingWindow win = new LoaddingWindow(); Action initilize = () => { this.SerialNumber = Settings.Default.SerialNumber; this.Registered = LicenseHelper.ValidateLicense(Resources.ProductId, this.SerialNumber, Resources.PubKey); this.UIDispatcher.Invoke(new Action(() => win.Close()), null); }; initilize.BeginInvoke(ar => initilize.EndInvoke(ar as IAsyncResult), initilize); win.ShowDialog(); }
protected override void InitializeBindData() { LoaddingWindow win = new LoaddingWindow { Owner = this.CurrentWindow }; Action load = () => { Action close = () => this.UIDispatcher.Invoke(new Action(() => win.Close()), DispatcherPriority.Send, null); Dictionary <string, long> dict = new Dictionary <string, long>(); var cvt = new GrowthStage2StringConverter(); this.Service.GetPeriodsSheepGrowthStageCount(this.Date, this.BreedId, this.Gender).ForEach(gc => dict[cvt.Convert(gc.GrowthStage, typeof(string), null, null).ToString()] = gc.Count); this.ChartData = dict; Dictionary <string, string> dicp = new Dictionary <string, string>(); long sum = dict.Values.Sum(); dict.Keys.ToList().ForEach(k => dicp[k] = dict[k] <= 0 ? "0%" : Math.Round((dict[k] * 1.0 / sum * 100), 2) + "%"); this.PiePercent = dicp; if (isReload) { close(); return; } var breeds = this.Service.GetBreedBind(); this.UIDispatcher.Invoke(new Action(() => { this.Breeds.Clear(); this.Breeds.Add(new BreedBind { Name = defaultSelection }); breeds.ForEach(b => this.Breeds.Add(b)); }), DispatcherPriority.Send, null); close(); }; load.BeginInvoke(ar => load.EndInvoke(ar as IAsyncResult), load); win.ShowDialog(); }
//查看帮助 public void ViewDocument() { LoaddingWindow loadding = new LoaddingWindow(); //关闭加载窗口 Action loaded = () => this.UIDispatcher.Invoke(new Action(() => loadding.Close()), null); Action load = () => { bool handed = false; if (this.NetworkAvailable) { string ip = ConfigurationManager.AppSettings["supportHost"]; try { PingReply reply = new Ping().Send(ip); if (reply.Status == IPStatus.Success) { loaded(); Process.Start(ConfigurationManager.AppSettings["instructionUrl"]); handed = true; } } catch { handed = false; } } if (!handed) { loaded(); Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data\Document.chm")); } }; load.BeginInvoke(ar => load.EndInvoke(ar as IAsyncResult), load); loadding.ShowDialog(); }
protected override void InitializeBindData() { LoaddingWindow win = new LoaddingWindow { Owner = this.CurrentWindow }; Action load = () => { Action close = () => this.UIDispatcher.Invoke(new Action(() => win.Close()), DispatcherPriority.Send, null); Dictionary <string, long> dict = new Dictionary <string, long>(); this.Service.GetPeriodsSellSheepCount(this.StartDate, this.EndDate).ForEach(gc => dict[(gc.Month).ToString()] = gc.Count); this.ChartData = dict; if (isReload) { close(); return; } close(); }; load.BeginInvoke(ar => load.EndInvoke(ar as IAsyncResult), load); win.ShowDialog(); }