예제 #1
0
        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();
        }
예제 #2
0
        void InitChartData()
        {
            Dictionary <string, long> dict = new Dictionary <string, long>();
            var cvt = new GrowthStage2StringConverter();

            this.Service.GetPeriodsSheepGrowthStageCount(DateTime.Today, null).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;
        }