Ejemplo n.º 1
0
        private void B_Click()
        {
            switch (GlobalTool.ButtonNameParent)
            {
            case "ButtonSearch":
            {
                ObservableCollection <ParentCard> reCard = new ObservableCollection <ParentCard>();

                if (GlobalTool.BoolColor == true)
                {        //按颜色查父本
                    if (GlobalTool.IndexColor == 0)
                    {
                        GlobalTool.OpenDialogButton(_syncContextTaskScheduler, "没有选择颜色");
                        return;
                    }
                    if (SelectedColorDic == null || SelectedColorDic.Count == 0)
                    {
                        return;
                    }

                    foreach (var everyflower in SelectedColorDic)
                    {
                        var parent = FlowerHelper.GetMyParent(everyflower);
                        foreach (var a in parent)
                        {
                            var  aa       = new ParentCard(a);
                            bool inResult = false;
                            foreach (var b in reCard)
                            {
                                if (b.TextGeneLeft == aa.TextGeneLeft && b.TextGeneRight == aa.TextGeneRight)
                                {
                                    inResult = true;
                                }
                            }
                            if (!inResult)
                            {
                                reCard.Add(aa);
                            }
                        }
                    }
                }
                if (GlobalTool.BoolGene == true)
                {        //按基因型查父本
                    Gene     a1 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA1);
                    Gene     a2 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA2);
                    Gene     a3 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA3);
                    Gene     a4 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA4);
                    MyFlower f  = new MyFlower(SelectedFlower, a1, a2, a3, a4);
                    var      re = FlowerHelper.GetMyParent(f);

                    foreach (var a in re)
                    {
                        reCard.Add(new ParentCard(a));
                    }
                }

                Task.Factory.StartNew(() => ShowData(reCard),
                                      new CancellationTokenSource().Token, TaskCreationOptions.None, _syncContextTaskScheduler).Wait();
            }
            break;
            }
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (GlobalTool.NaviViewMain.SelectedItem != GlobalTool.NaviItemParent)
            {
                return;
            }

            ObservableCollection <ParentCard> reCard = new ObservableCollection <ParentCard>();

            GlobalTool.ShowProgress();
            Task.Factory.StartNew(() =>
            {
                if (GlobalTool.BoolColor == true)
                {//按颜色查父本
                    if (GlobalTool.IndexColor == 0)
                    {
                        GlobalTool.TipSearch.IsOpen = true;
                        return;
                    }
                    if (SelectedColorDic == null || SelectedColorDic.Count == 0)
                    {
                        return;
                    }

                    foreach (var everyflower in SelectedColorDic)
                    {
                        var parent = FlowerHelper.GetMyParent(everyflower);
                        foreach (var a in parent)
                        {
                            var aa        = new ParentCard(a);
                            bool inResult = false;
                            foreach (var b in reCard)
                            {
                                if (b.TextGeneLeft == aa.TextGeneLeft && b.TextGeneRight == aa.TextGeneRight)
                                {
                                    inResult = true;
                                }
                            }
                            if (!inResult)
                            {
                                reCard.Add(aa);
                            }
                        }
                    }
                }
                if (GlobalTool.BoolGene == true)
                {//按基因型查父本
                    Gene a1    = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA1);
                    Gene a2    = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA2);
                    Gene a3    = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA3);
                    Gene a4    = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA4);
                    MyFlower f = new MyFlower(GlobalTool.SelectedFlower, a1, a2, a3, a4);
                    var re     = FlowerHelper.GetMyParent(f);

                    foreach (var a in re)
                    {
                        reCard.Add(new ParentCard(a));
                    }
                }

                Sync.Post((o) =>
                {
                    GlobalTool.CloseProgress();
                    var r = o as ObservableCollection <ParentCard>;
                    ListViewParent.ItemsSource = r;
                }, reCard);
            });
        }