Exemplo n.º 1
0
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            int recv;
            byte[] rdata = new byte[1024*1024];

            List<UserData> Delete_list = LUserdata.FindAll(p => { if (p.user.Ischecked) { return true; } return false; });
            Delete_list.FindAll(p => { p.Count = Delete_list.Count; return true; });
            Delete_list.FindAll(p => { p.Ischeckedcount = LUserdata.Count(t => t.user.Ischecked == true); return true; });
            if (Delete_list.Count != 0)
            {
                string post_data = "&#D" + Delete_list.Count.ToString();
                foreach (UserData item in Delete_list)
                {
                    post_data = post_data + "&#" + item.user.Id + "::" +
                        item.user.Password + "::" +
                        ((int)item.user.Power).ToString() + "::" +
                        ((int)item.user.State).ToString();
                }
                byte[] tmp_data = Encoding.UTF8.GetBytes(post_data);
                client.Send(tmp_data);
                recv = client.Receive(rdata);
                if (Encoding.UTF8.GetString(rdata, 0, recv) == "1")
                {
                    LUserdata = LUserdata.FindAll(p => { if (p.user.Ischecked) { p.user.Ischecked = false; return p.user.Id != p.user.Id; } return true; });
                    LUserdata.FindAll(p => { p.Count = LUserdata.Count; return true; });
                    LUserdata.FindAll(p => { p.Ischeckedcount = LUserdata.Count(t => t.user.Ischecked == true); return true; });
                    if (LUserdata.Count == 0)
                        Tb_SelectCount.Text = "0";
                    UserInfo.DataContext = LUserdata;
                    Grid_Data.DataContext = LUserdata;
                }
                else
                {
                    MessageBox.Show("删除用户失败!", "警告");
                }
            }
        }
Exemplo n.º 2
0
        private void TwitterSampleStream()
        {
            ListWordsByFrequency frequencyList = new ListWordsByFrequency();
            var logFile = System.IO.File.ReadAllLines(@"C:\Users\Daniel\Source\Repos\TwitterCrawl\positive-words.txt");
            List <string> StringList = new List<string>(logFile);
            Globals.Stream = Stream.CreateSampleStream();
            int incomming = 0;
            int success = 0;

            Globals.Stream.TweetReceived += (sender, args) =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    incomming++;
                    label.Content = incomming;
                    label1.Content = success;

                    string tweet = args.Tweet.ToString();
                    bool test = StringList.Any(tweet.Contains);

                    if (test)
                    {
                        success++;
                        txtBxTwitterFeed.Clear();
                        txtBxTwitterFeed.Text = tweet;

                        var matchingvalues = StringList.FindAll(tweet.Contains);

                        StringBuilder builder = new StringBuilder();
                        foreach (string v in matchingvalues) // Loop through all strings
                        {
                            builder.Append(v).Append(" "); // Append string to StringBuilder
                        }

                        frequencyList.split(builder.ToString());
                        rTxtBxFrequency.Document.Blocks.Clear();
                        rTxtBxFrequency.Document.Blocks.Add(new Paragraph(new Run(frequencyList.output)));
                    }

                }));
            };
        }
Exemplo n.º 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            standList = standBLL.GetModelList("");
            List<Model.TB_StandardInfo> standListLevel1 = standList.FindAll(x => x.Stand_Level == 1);
            lbLevel1.ItemsSource = standListLevel1;

            //lbLevel1.SelectedIndex = 0;
            lbLevel1.SelectedIndex = -1;
            if (selectStandInfo1 != null) {
                for (int i = 0; i < standListLevel1.Count; i++)
                {
                    if (standListLevel1[i].ID == selectStandInfo1.ID)
                    {
                        lbLevel1.SelectedIndex = i;
                        break;
                    }
                }
            }

            //lbLevel1.SelectedValue = selectStandInfo1;
        }
        /* populates selected visit details */
        private void lbxVisits_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbxVisits.SelectedIndex != -1)
            {
                /* If User clicks on previous visits while creating a visit
                 * ui needs to be updated for updating */
                if (mode == Mode.create)
                {
                    CreateNewVisitComplete();
                }
                if(TempVisitMedia!=null)
                    CleanupMedia.AddRange(TempVisitMedia.FindAll(m => m.Id == 0).Select(m => m.Path));

                SelectedVisit = (Domain.Visit)lbxVisits.SelectedItem;

                acbReferredBy.Text = SelectedVisit.ReferredBy;
                acbDoctors_Email.Text = SelectedVisit.Doctors_Email;
                acbDoctor.Text = SelectedVisit.Doctor;
                dtDate_of_Examination.Text = SelectedVisit.Date_of_Examination.Date.ToString();

                acbDiagnosis.Text = SelectedVisit.Diagnosis;
                acbTreatment.Text = SelectedVisit.Treatment;

                TempVisitSymptoms = SelectedVisit.Symptoms.ToList();
                lbxSymptoms.ItemsSource = TempVisitSymptoms;
                TempVisitTags = SelectedVisit.Tags.ToList();
                lbxTags.ItemsSource = TempVisitTags;
                TempVisitMedia = SelectedVisit.Media.ToList();
                lbxVideos.ItemsSource = TempVisitMedia.FindAll(n => n.Type == Domain.MediumType.Video);
                lbxImages.ItemsSource = TempVisitMedia.FindAll(n => n.Type == Domain.MediumType.Image);

                acbSymptom.Text = "";
                acbTag.Text = "";

                UpdateVisit();

            }
        }
        private AvailableTime calcOverlappingDateTimeOfAllMusicians(AvailableTime timeToFit, List<AvailableTime> possibleTimes)
        {
            Boolean hadOneFit;

            foreach (Musician m in currentBand.Musicians)
            {
                hadOneFit = false;

                foreach (AvailableTime aT in possibleTimes.FindAll(time => time.Id == m.Id))
                {
                    if (timeToFit.StartTime >= aT.StartTime && timeToFit.EndTime <= aT.EndTime
                                   || (timeToFit.EndTime >= aT.StartTime && timeToFit.EndTime <= aT.EndTime)
                                   || (timeToFit.StartTime <= aT.StartTime && timeToFit.EndTime >= aT.StartTime)
                                   || (timeToFit.StartTime <= aT.StartTime && timeToFit.EndTime >= aT.EndTime))
                    {
                        timeToFit.StartTime = new DateTime(Math.Max(timeToFit.StartTime.Ticks, aT.StartTime.Ticks));
                        timeToFit.EndTime = new DateTime(Math.Min(timeToFit.EndTime.Ticks, aT.EndTime.Ticks));

                        hadOneFit = true;
                        break;
                    }
                }

                if (hadOneFit == false)
                {
                    timeToFit = null;
                    break;
                }
            }

            return timeToFit;
        }
Exemplo n.º 6
0
        //下盘个数
        List<string> GetXiaPanCounts(int Min, int Max, List<string> ListR)
        {
            List<string> ListStr = new List<string>();

            ListStr = ListR.FindAll(t =>
            {
                string[] arry = t.Split(new char[] { '0', '1', '2' }, StringSplitOptions.None);
                int count = arry.Length - 1;
                return (Min <= count && count <= Max);
            });
            return ListStr;
        }
Exemplo n.º 7
0
        private void FillGridWithInfo()//Fetching info for each cell of Info grid and placing it there
        {
            int rows = WeekGrid.Rows;//we will need row and column number to properly placing info into the grid;
            int columns = WeekGrid.Columns;
            List<Group> searchresult = new List<Group>();

            foreach (ListView listView in WeekGrid.Children)
            {

                int index = WeekGrid.Children.IndexOf(listView);
                int row = index / columns;
                int column = index % columns;

                searchresult = groups.FindAll(delegate(Group group)//Looking up if there are ny group for at this date;
                {
                    DateTime weekday = GetStartOfCurrentWeek().AddDays(column);
                    return group.Date == weekday;
                });

                if (!searchresult.Any())//If there are none - setting empty labels.
                {
                    for (int i = 0; i < listView.Items.Count; i++)
                    {
                        ((Label)listView.Items[i]).Content = " ";
                        ((Label)listView.Items[i]).Tag = null;
                        ((Label)listView.Items[i]).Background = Brushes.White;
                    }
                }
                else if (searchresult.Any())//If there are any - we narrow search further to timeperiod.
                {
                    searchresult = searchresult.FindAll(delegate(Group gp)
                    {
                        timeperiod time = (timeperiod)row;
                        return gp.Time == time;
                    });

                    if (!searchresult.Any())//If there are none, we again set all to empty;
                    {
                        for (int i = 0; i < listView.Items.Count; i++)
                        {
                            ((Label)listView.Items[i]).Content = " ";
                            ((Label)listView.Items[i]).Tag = null;
                            ((Label)listView.Items[i]).Background = Brushes.White;
                        }
                    }
                    else if (searchresult.Any())//And if there are any we set them to appropriate posistions in list;
                    {
                        for (int i = 0; i < listView.Items.Count; i++)//we go through all labels on Listview
                        {
                            Group target = searchresult.Find(delegate(Group gp)//And see if there is group for this label
                            {//to be displayed
                                return gp.Room.Id == i + 1;//We check it by room id, because each label corresponds to unique room;
                            });
                            if (target != null)//If we get some result 
                            {
                                ((Label)listView.Items[target.Room.Id - 1]).Tag = target;//We place this group there
                                ((Label)listView.Items[target.Room.Id - 1]).Content = target.Room.Type + ": " +target.Name;
                                ((Label)listView.Items[i]).Background = Brushes.LightSeaGreen;//And display with text and color;
                            }
                            else
                            {
                                ((Label)listView.Items[i]).Content = " ";//Again if there is nothing - setting all to empty;
                                ((Label)listView.Items[i]).Tag = null;
                                ((Label)listView.Items[i]).Background = Brushes.White;
                            }

                        }


                    }
                }
            }
        }
        public void GetTwitterNewsAPI11(string url)
        {
            TwitterStatuses.Clear();
            if (string.IsNullOrEmpty(url)) {
                TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
                    Title = LanguageManager.Model.NewsTwitterError + ": [ERRCODE 4 - No URL specified]",
                    Date = DateTime.Now
                });
                return;
            }
            Uri link = new Uri(url);
            string response;
            using (WebClient wc = new WebClientEx()) {
                try {
                    response = wc.DownloadString(link);
                } catch (Exception e) {
                    TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
                        Title = LanguageManager.Model.NewsTwitterError + ": " + e.Message + " [ERRCODE 3 - Remote Error]",
                        Date = DateTime.Now
                    });
                    return;
                }
            }

            JArray tList;
            try {
                tList = JArray.Parse(System.Web.HttpUtility.HtmlDecode(response));
            } catch {
                TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
                    Title = LanguageManager.Model.NewsTwitterError + " [ERRCODE 1 - Parse Error]",
                    Date = DateTime.Now
                });
                return;
            }

            List<UserStatus> statuses = new List<UserStatus>();
            List<ProfileImage> profileImages = new List<ProfileImage>();
            List<ProfileImage> currentImage;
            ProfileImage profileImage;
            for (int i = 0; i < tList.Count(); i++) {
                JObject tweet = JObject.Parse(tList[i].ToString());
                UserStatus status = new UserStatus();

                status.UserName = tweet["user"]["name"].ToString();
                status.UserScreenName = tweet["user"]["screen_name"].ToString();
                status.ProfileImageUrl = tweet["user"]["profile_image_url"].ToString();
                var retweet = tweet["retweeted_status"];
                if (retweet != null) {
                    status.UserScreenName = retweet["user"]["name"].ToString();
                    status.UserName = retweet["user"]["screen_name"].ToString();
                    status.RetweetImageUrl = retweet["user"]["profile_image_url"].ToString();
                }

                status.Status = tweet["text"].ToString();
                status.StatusId = tweet["id"].ToString();
                status.StatusDate = ParseDateTime(tweet["created_at"].ToString());

                string profile_image;
                if (status.RetweetImageUrl != null) {
                    profile_image = status.RetweetImageUrl;
                } else {
                    profile_image = status.ProfileImageUrl;
                }

                currentImage = profileImages.FindAll(im => (im.url == profile_image));
                if (currentImage.Count == 0) {
                    profileImage = new ProfileImage();
                    profileImage.url = profile_image;
                    profileImage.bitmap = GetImage(profile_image);
                    if (profileImage.bitmap != null) {
                        profileImages.Add(profileImage);
                    }
                } else {
                    profileImage = currentImage[0];
                }
                status.ProfileImageBitmap = profileImage.bitmap;
                statuses.Add(status);
            }
            foreach (UserStatus status in statuses) {
                TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
                    Title = status.Status,
                    Date = status.StatusDate,
                    Image = status.ProfileImageBitmap,
                    StatusLink = "https://twitter.com/statuses/" + status.StatusId,
                    UserLink = "https://twitter.com/" + status.UserScreenName,
                    UserName = status.UserName
                });
            }
        }
        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            List<card> MissingCards = new List<card>();

            foreach (card item in card.cardList)
            {
                int numberOfCard = getNumberOfCardInCollection(item.CardId);
                int numberToHave;
                if (item.Rarity == "Legendary")
                {
                    numberToHave = 1;
                }
                else
                {
                    numberToHave = 2;
                }

                for (int i = 0; i < numberToHave - numberOfCard; i++)
                {
                    MissingCards.Add(item);
                }

            }

            int missingDust = 0;

            int missingDustClassic = 0;
            int missingDustGvG = 0;
            int missingDustTgT = 0;

            unsafe
            {
                int* dust = null;

                foreach (card item in MissingCards.FindAll(c => c.CardSet == "Classic" || c.CardSet == "Goblins vs Gnomes" || c.CardSet == "The Grand Tournament"))
                {

                    switch (item.CardSet)
                    {
                        case "Classic":
                            dust = &missingDustClassic;
                            break;
                        case "Goblins vs Gnomes":
                            dust = &missingDustGvG;
                            break;
                        case "The Grand Tournament":
                            dust = &missingDustTgT;
                            break;
                        default:
                            break;
                    }

                    switch (item.Rarity)
                    {
                        case "Common":
                            *dust += 40;
                            break;
                        case "Rare":
                            *dust += 100;
                            break;
                        case "Epic":
                            *dust += 400;
                            break;
                        case "Legendary":
                            *dust += 1600;
                            break;
                        default:
                            break;
                    }
                }
            }
            missingDust = missingDustClassic + missingDustGvG + missingDustTgT;
            MessageBox.Show(missingDust.ToString());
        }
        private void lv_dropdetails_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {

                if (e.AddedItems.Count > 0)
                {
                    GetUndeclaredVaultDrops vd_select = e.AddedItems[0] as GetUndeclaredVaultDrops;
                    if (vd_select != null)
                    {

                        if (vd_select.Cassettes != null && vd_select.Cassettes.Count > 0)
                        {
                            lst_cassettes = vd_select.Cassettes;
                            if (Settings.AutoFillDeclaredAmount)
                            {
                                foreach (CassetteDropsResult casette in vd_select.Cassettes)
                                {
                                    casette.DeclaredBalance = casette.VaultBalance.Value;
                                    if (casette.EnableControls)
                                    {
                                        casette.Quantity = Convert.ToInt32(Math.Truncate(casette.DeclaredBalance / Convert.ToDecimal(casette.Denom.Value)));
                                    }

                                }
                            }

                            p_cassette = lst_cassettes.Find(obj => obj.CassetteType_ID == (int)CassetteTypes.Cassette && !obj.EnableControls);
                            p_hopper = lst_cassettes.Find(obj => obj.CassetteType_ID == (int)CassetteTypes.Hopper && !obj.EnableControls);

                            if (lst_cassettes.FindAll(obj => obj.CassetteType_ID == (int)CassetteTypes.Cassette).Count == 0)
                            {
                                btnStart.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                btnStart.Visibility = Visibility.Visible;

                            }

                            lv_CassetteDetails.ItemsSource = lst_cassettes;
                            if (!vd_select.IsEmptyCassette)
                            {
                                vd_select.IsEmptyCassette = false;
                            }
                            vd_select.Declared_Balance = (p_cassette != null ? p_cassette.DeclaredBalance : 0) + (p_hopper != null ? p_hopper.DeclaredBalance : 0);
                        }
                        else
                        {
                            LoadEmptyCassette(vd_select);
                            if (lst_cassettes.FindAll(obj => obj.CassetteType_ID == (int)CassetteTypes.Cassette).Count == 0)
                            {
                                btnStart.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                btnStart.Visibility = Visibility.Visible;

                            }
                            vd_select.Declared_Balance = 0;
                            vd_select.IsEmptyCassette = true;
                        }
                        if (!vd_select.ToDeclared)
                        {
                            lblcounterWarning.Text = Application.Current.FindResource("Vault_MessageID16") as string;
                        }
                        else
                        {
                            lblcounterWarning.Text = "";
                        }
                        if (e.RemovedItems.Count > 0)
                        {
                            GetUndeclaredVaultDrops vd_removeselect = e.RemovedItems[0] as GetUndeclaredVaultDrops;
                            if (vd_removeselect != null)
                            {
                                if (vd_removeselect.Declared_Balance > 0 && vd_removeselect.ToDeclared)
                                {
                                    if ((Settings.ShowVaultConfirmMessage) && MessageBox.ShowBox("Vault_MessageID15", BMC_Icon.Information, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        lv_dropdetails.SelectionChanged -= lv_dropdetails_SelectionChanged;
                                        lv_dropdetails.SelectedItem = vd_removeselect;
                                        bool IsValidAmount = false;
                                        SaveVaultDeclaration(ref IsValidAmount);
                                        lv_dropdetails.SelectionChanged += lv_dropdetails_SelectionChanged;

                                        return;
                                    }
                                    else
                                    {
                                        foreach (CassetteDropsResult casette in vd_removeselect.Cassettes)
                                        {
                                            casette.Quantity = 0;
                                            casette.DeclaredBalance = 0;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (CassetteDropsResult casette in vd_removeselect.Cassettes)
                                    {
                                        casette.Quantity = 0;
                                        casette.DeclaredBalance = 0;
                                    }

                                }

                            }

                            vd_removeselect.Declared_Balance = 0;

                        }

                        vd_select.BillsTotal = 0;
                        vd_select.TotalCoinsValueAsCurrency = 0;

                    }
                }
            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
            }

        }
Exemplo n.º 11
0
        /// <summary>
        /// DataGridの異なる行異なる列を選択したコピーの禁止処理
        /// </summary>
        /// <returns></returns>
        bool CheckCopyDataGridContents()
        {
            List<System.Windows.Point> rowAndColList = new List<System.Windows.Point>();
            List<int> copyRowList = new List<int>();
            List<int> copyColumnList = new List<int>();

            var cells = upperdatagrid.SelectedCells;
            foreach (DataGridCellInfo cell in cells)
            {
                rowAndColList.Add(
                    new System.Windows.Point(upperdatagrid.Items.IndexOf(cell.Item), cell.Column.DisplayIndex));
                int b = copyColumnList.Find(s => s == cell.Column.DisplayIndex);
                if (copyColumnList.Count == 0 || !copyColumnList.Contains(cell.Column.DisplayIndex))
                {
                    copyColumnList.Add(cell.Column.DisplayIndex);
                }
                if (copyRowList.Count == 0 || !copyRowList.Contains(upperdatagrid.Items.IndexOf(cell.Item)))
                {
                    copyRowList.Add(upperdatagrid.Items.IndexOf(cell.Item));
                }
            }
            int copyRangeColumn = copyColumnList.Count;
            int copyRangeRow = copyRowList.Count;
            bool validCopyFlag = true;

            //複数コピーの禁止
            //全てのXがコピーした列数分だけ存在するか、すべてのYがコピーした行数分だけ存在する
            foreach (var y in copyColumnList)
            {
                validCopyFlag = true;
                if (rowAndColList.FindAll(s => s.Y == y).Count != copyRangeRow)
                {
                    validCopyFlag = false;
                    break;
                }
            }
            foreach (var x in copyRowList)
            {
                validCopyFlag = true;
                if (rowAndColList.FindAll(s => s.X == x).Count != copyRangeColumn)
                {
                    validCopyFlag = false;
                    break;
                }
            }
            if (!validCopyFlag)
            {
                System.Windows.Forms.MessageBox.Show(AnimeCheckerByXaml.Properties.Settings.Default.E0004,
                                            "エラー", System.Windows.Forms.MessageBoxButtons.OK,
                                            System.Windows.Forms.MessageBoxIcon.Error);
                return false;
            }
            return true;
        }
Exemplo n.º 12
0
        private void btn_show_Click(object sender, RoutedEventArgs e)
        {
            int recv;
            byte[] rdata = new byte[1024 * 1024];
            LUserdata = new List<UserData>();
            LUser = new List<User>();

            Edit_list = new List<string>();

            byte[] tmp_data = Encoding.UTF8.GetBytes("&#GET");
            client.Send(tmp_data);
            recv = client.Receive(rdata);
            string[] get_info = (Encoding.UTF8.GetString(rdata, 0, recv)).Split(new string[] { "&#" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string item in get_info)
            {
                string[] user = item.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                Power p = (Power)Int32.Parse(user[2]);
                State s = (State)Int32.Parse(user[3]);

                string Online = "";
                switch (user[6])
                {
                    case "0":
                        Online = "离线";
                        break;
                    case "1":
                        Online = "在线";
                        break;
                    default:
                        break;
                }

                LUser.Add(new User
                {
                    Id = user[0],
                    Password = user[1],
                    Power = p,
                    State = s,
                    Lastlogin = user[4],
                    Tcount = Int32.Parse(user[5]),
                    Isonline = Online,
                    Ischecked = false
                });
            }
            foreach (var item in LUser)
            {
                UserData Udata = new UserData();
                Udata.user = item;
                Udata.Count = LUser.Count;
                Udata.Ischeckedcount = LUser.Count(p => p.Ischecked == true);
                LUserdata.Add(Udata);
            }

            //bind
            UserInfo.DataContext = LUserdata;

            LUserdata = LUserdata.FindAll(p => { if (p.user.Ischecked) { p.user.Ischecked = false; return p.user.Id != p.user.Id; } return true; });
            LUserdata.FindAll(p => { p.Count = LUserdata.Count; return true; });
            LUserdata.FindAll(p => { p.Ischeckedcount = LUserdata.Count(t => t.user.Ischecked == true); return true; });
            if (LUserdata.Count == 0)
                Tb_SelectCount.Text = "0";
            Grid_Data.DataContext = LUserdata;
        }
Exemplo n.º 13
0
        //分组和值
        List<string> GetGoupSum(string terms, List<string> ListR)
        {
            List<string> ListStr = new List<string>();
            string[] arrTerms = terms.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string term in arrTerms)
            {
                string nums = term.Split('|')[0];
                string nums2 = term.Split('|')[1];
                string[] strs = nums.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List<int> number = new List<int>();
                for (int i = 0; i < strs.Length; i++)
                {
                    if (strs[i] == "Y")
                    {
                        number.Add(i);
                    }
                }

                double Min = double.Parse(nums2.Split('-')[0]);
                double max = double.Parse(nums2.Split('-')[1]);

                ListR = ListR.FindAll(t =>
                {
                    bool isOK = false;
                    int sum = 0;
                    foreach (int i in number)
                    {
                        if (t[i].ToString() != "*")
                        {
                            sum += int.Parse(t[i].ToString());
                        }
                        else
                        {
                            isOK = true;
                        }
                    }

                    return isOK || (Min <= sum && sum <= max);
                });
            }

            ListStr = ListR;

            return ListStr;
        }
Exemplo n.º 14
0
 //号码和值
 List<string> GetSumCounts(int Min, int Max, List<string> ListR)
 {
     List<string> ListStr = new List<string>();
     ListStr = ListR.FindAll(t =>
     {
         t = t.Replace("*", "");
         int sum = 0;
         foreach (char c in t)
         {
             sum += int.Parse(c.ToString());
         }
         return (Min <= sum && sum <= Max);
     });
     return ListStr;
 }
Exemplo n.º 15
0
        //3的个数/1的个数/0的个数
        private List<string> GetThreeCounts(int Min, int Max, string Num, List<string> ListR)
        {
            List<string> ListStr = new List<string>();

            string Reg1 = "";//匹配最小值正则
            string Reg = "";//匹配最大值正则
            if (Min == 0)
            {
                Reg1 = @"(\d|\*)*";
            }
            else
            {
                for (int i = 0; i < Min; i++)
                {
                    Reg1 += @"(\d|\*)*" + Num + @"(\d|\*)*";
                }
            }

            if (Max == 0)
            {
                Reg = @"(\d|\*)*" + Num + @"(\d|\*)*";
            }
            else
            {
                for (int j = 0; j < Max; j++)
                {
                    Reg += @"(\d|\*)*" + Num + @"(\d|\*)*";
                }

                Reg += @"(\d|\*)*" + Num + @"(\d|\*)*";
            }

            ListStr = ListR.FindAll(t => Regex.Match(t, Reg1).Success);

            ListStr = ListStr.FindAll(t => !Regex.Match(t, Reg).Success);
            return ListStr;
        }
Exemplo n.º 16
0
        //分组
        List<string> GetGoupNumbers(string terms, string type, List<string> ListR)
        {
            List<string> ListStr = new List<string>();
            string[] arrTerms = terms.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string term in arrTerms)
            {
                string nums = term.Split('|')[0];
                string nums2 = term.Split('|')[1];
                string[] strs = nums.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List<int> number = new List<int>();
                for (int i = 0; i < strs.Length; i++)
                {
                    if (strs[i] == "Y")
                    {
                        number.Add(i);
                    }
                }
                double Min = 0;
                double Max = 0;
                if (type != "进球差值")
                {
                    Min = double.Parse(nums2.Split('-')[0]);
                    Max = double.Parse(nums2.Split('-')[1]);
                }
                else
                {
                    int start1 = nums2.IndexOf("(") + 1;
                    int len1 = nums2.IndexOf(")") - start1;
                    int start2 = nums2.LastIndexOf("(") + 1;
                    int len2 = nums2.LastIndexOf(")") - start2;
                    if (len1 < 0 || len2 < 0)
                    {
                        return ListR;
                    }
                    Min = double.Parse(nums2.Substring(start1, len1));
                    Max = double.Parse(nums2.Substring(start2, len2));
                }

                switch (type)
                {
                    case "分组和值":
                        #region
                        ListR = ListR.FindAll(t =>
                        {
                            bool isOK = false;
                            int sum = 0;
                            foreach (int i in number)
                            {
                                string c = t.Substring(i * 2, 2);
                                if (c == "**")
                                {
                                    isOK = true;
                                    break;
                                }

                                sum += int.Parse(c[0].ToString()) + int.Parse(c[1].ToString());
                            }

                            return isOK || (Min <= sum && sum <= Max);
                        });
                        #endregion
                        break;
                    case "分组断点":
                        #region
                        ListR = ListR.FindAll(t =>
                        {
                            bool isOK = false;
                            int count = 0;
                            string Temp = "xx";
                            for (int i0 = 0; i0 < number.Count; i0++)
                            {
                                int i = number[i0];
                                string c = t.Substring(i * 2, 2);
                                if (i0 > 0)
                                {
                                    Temp = t.Substring(number[i0 - 1] * 2, 2);
                                }

                                if (c == "**")
                                {
                                    isOK = true;
                                    break;
                                }

                                if (c[0] != c[1])
                                {
                                    count++;
                                }

                                if (c[0] != Temp[1] && Temp != "xx")
                                {
                                    count++;
                                }

                            }

                            return isOK || (Min <= count && count <= Max);
                        });
                        break;
                        #endregion

                    case "分组最长连号":
                        #region
                        ListR = ListR.FindAll(t =>
                        {

                            bool isOK = false;
                            int count = 0;
                            int maxCount = 0;
                            string Temp = "xx";
                            for (int i0 = 0; i0 < number.Count; i0++)
                            {
                                int i = number[i0];
                                string c = t.Substring(i * 2, 2);
                                if (i0 > 0)
                                {
                                    Temp = t.Substring(number[i0 - 1] * 2, 2);
                                }

                                if (c == "**")
                                {
                                    isOK = true;
                                    break;
                                }

                                if (c[0] == Temp[1])
                                {
                                    count++;
                                }
                                else
                                {
                                    maxCount = Math.Max(count, maxCount);
                                    count = 0;
                                }

                                if (c[0] == c[1])
                                {
                                    count++;
                                }
                                else
                                {
                                    maxCount = Math.Max(count, maxCount);
                                    count = 0;
                                }

                            }

                            maxCount = Math.Max(count, maxCount);

                            return isOK || (Min <= maxCount && maxCount <= Max);
                        });
                        #endregion
                        break;

                }


            }

            ListStr = ListR;

            return ListStr;
        }
Exemplo n.º 17
0
        internal void ExpandChildren(TaxonViewModel taxon, List<Taxon> remaining = null)
        {
            if (remaining == null) {
                remaining = Service.GetExpandFullTree(taxon.TaxaID.Value);
            }
            if (!taxon.IsExpanded) {
                // BringModelToView(tvwAllTaxa, taxon);
                taxon.BulkAddChildren(remaining.FindAll((elem) => { return elem.TaxaParentID == taxon.TaxaID; }), GenerateTaxonDisplayLabel);
                remaining.RemoveAll((elem) => { return elem.TaxaParentID == taxon.TaxaID; });
                taxon.IsExpanded = true;

            }

            foreach (HierarchicalViewModelBase child in taxon.Children) {
                ExpandChildren(child as TaxonViewModel, remaining);
            }
        }
        private void SetColorForDoubleEntry(System.Windows.Controls.Control control, List<String> inputValues)
        {
            List<String> controlValues = new List<String>();
            String controlText = GetControlText((System.Windows.Controls.Control)control);

            if (!IsBooleanInputControl(control))
                controlValues.AddRange(controlText.Split('-'));
            else
                controlValues.Add(controlText);

            bool doubleEntry = false;
            for (int i = 0; i < controlValues.Count; i++)
            {
                String textBoxText = controlValues[i].Trim();
                if (inputValues.FindAll(delegate(String value) { return value == textBoxText; }).Count > 1)
                {
                    doubleEntry = true;
                    break;
                }
            }

            if (doubleEntry)
                control.Foreground = new SolidColorBrush(Colors.Red);
            else
                control.Foreground = new SolidColorBrush(Colors.Black);
        }
        //ProgressBars werden befüllt
        private void FillProgressBars(List<Vokabel> vokabel)
        {
            if (vokabel.Count != 0)
            {
                progressFach1.Maximum = vokabel.Count;
                progressFach2.Maximum = vokabel.Count;
                progressFach3.Maximum = vokabel.Count;
                progressFach4.Maximum = vokabel.Count;

                progressFach1.Value = vokabel.FindAll(vok => vok.Fach == 1).Count;
                progressFach2.Value = vokabel.FindAll(vok => vok.Fach == 2).Count;
                progressFach3.Value = vokabel.FindAll(vok => vok.Fach == 3).Count;
                progressFach4.Value = vokabel.FindAll(vok => vok.Fach == 4).Count;
            }
        }
Exemplo n.º 20
0
        private void CheckDoubleInputEntry(TextBox textBox, List<String> inputValues)
        {
            String[] textBoxValues = textBox.Text.Split('-');

            bool doubleEntry = false;
            for (int i = 0; i < textBoxValues.Length; i++)
            {
                if (inputValues.FindAll(delegate(String value) { return value == textBoxValues[i]; }).Count > 1)
                {
                    doubleEntry = true;
                    break;
                }
            }

            if (doubleEntry)
            {
                textBox.Foreground = new SolidColorBrush(Colors.Red);
            }
            else
            {
                textBox.Foreground = new SolidColorBrush(Colors.Black);
            }
        }
        private List<AvailableTime> calcBestTimesForRehRequest(RehearsalRequest rehRequest)
        {
            List<AvailableTime> tempList = new List<AvailableTime>();
            List<AvailableTime> retList = new List<AvailableTime>();

            foreach (Musician m in currentBand.MusiciansWithLeader)
            {
                tempList.AddRange(from period in m.AvailableTimes
                                 where (period.StartTime >= rehRequest.StartTime && period.EndTime <= rehRequest.EndTime)
                                   || (period.EndTime >= rehRequest.StartTime && period.EndTime <= rehRequest.EndTime)
                                   || (period.StartTime <= rehRequest.StartTime && period.EndTime >= rehRequest.StartTime)
                                   || (period.StartTime <= rehRequest.StartTime && period.EndTime >= rehRequest.EndTime)
                                 select new AvailableTime
                                 {
                                     Id = m.Id,
                                     StartTime = new DateTime(Math.Max(period.StartTime.Ticks, rehRequest.StartTime.Ticks)),
                                     EndTime = new DateTime(Math.Min(period.EndTime.Ticks, rehRequest.EndTime.Ticks))
                                 });
            }

            //filter: min duration
            tempList = tempList.FindAll(at => (at.EndTime - at.StartTime).TotalHours >= rehRequest.Duration);

            //filter: only where all have time

            foreach (AvailableTime aT in tempList.FindAll(time => time.Id == currentBand.Leader.Id)) //loop through all fitting aTs of Leader
            {
                //calc if all other musicians have their time too, if yes: return dateTime
                AvailableTime calcedAvailableTime = calcOverlappingDateTimeOfAllMusicians(aT, tempList);

                if (calcedAvailableTime != null && ((calcedAvailableTime.EndTime - calcedAvailableTime.StartTime).TotalHours >= rehRequest.Duration))
                {
                    retList.Add(calcedAvailableTime);
                }
            }

            return retList;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Événement lancé lorsque l'utilisateur tape quelque chose dans le champ de recherche.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtRecherche_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            List<Plat> listePlatsTemp = new List<Plat>();

            switch (gbContenu.Header.ToString())
            {
                case "Tous les plats":
                    listePlatsTemp = new List<Plat>(PlatService.RetrieveAll().OrderBy(plat => plat.Nom));
                    break;
                case "Nouveautés":
                    listePlatsTemp = new List<Plat>(PlatService.RetrieveSome(new RetrievePlatArgs { NbResultats = NbResultatsAffiches, Depart = "Fin" }));
                    break;
                case "Les plus populaires":
                    listePlatsTemp = new List<Plat>(PlatService.RetrieveSome(new RetrievePlatArgs { NbResultats = NbResultatsAffiches, PlusPopulaires = true }));
                    break;
            }

            string recherche = ((TextBox)sender).Text;
            ListePlats = new ObservableCollection<Plat>(listePlatsTemp.FindAll(plat => plat.Nom.ToLower().Contains(recherche.ToLower())).ToList());
            DeterminerNoteConviviale();
            dgPlats.ItemsSource = ListePlats;
        }
 private AccessPermissionTree BuileAccessTree(List<AccessPermission> permissions)
 {
     AccessPermissionTree accessTree = new AccessPermissionTree();
     foreach (ModuleCategoryType catetype in Enum.GetValues(typeof(ModuleCategoryType)))
     {
         CategoryNode category = new CategoryNode();
         category.CategoryType = catetype;
         List<AccessPermission> moduleList = permissions.FindAll(delegate(AccessPermission access) { return access.CategotyType == catetype; });
         List<ModuleType> moduleInCategory = new List<ModuleType>();
         foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType)))
         {
             AccessPermission accesssss = moduleList.Find(delegate(AccessPermission per)
             {
                 return per.ModuleType == moduleType;
             });
             if (moduleList.Find(delegate(AccessPermission per) { return per.ModuleType == moduleType; }) != null)
             {
                 moduleInCategory.Add(moduleType);
             }
         }
         foreach (ModuleType moduleType in moduleInCategory)
         {
             ModuleNode module = new ModuleNode();
             module.Type = moduleType;
             foreach (AccessPermission access in moduleList)
             {
                 if (access.ModuleType == moduleType)
                 {
                     OperationNode node = new OperationNode();
                     node.Id = access.OperationId;
                     node.OperationDescription = access.OperationName;
                     module.OperationNodes.Add(node);
                 }
             }
             category.ModuleNodes.Add(module);
         }
         if (category.ModuleNodes.Count != 0)
         {
             accessTree.CategoryNodes.Add(category);
         }
     }
     return accessTree;
 }