public int SaveChanges() { int result = AddList.Count + RemoveList.Count; foreach (var addItem in AddList) { if (FinalList.Any(x => x.Equals(addItem))) { throw new Exception("Cannot add twice the same item"); } FinalList.Add(addItem); } foreach (var removeItem in RemoveList) { if (!FinalList.Any(x => x.Equals(removeItem))) { throw new Exception("Cannot remove items that are not in the list"); } FinalList.Remove(removeItem); } AddList.Clear(); RemoveList.Clear(); return(result); }
private void MoveUpBt_Click(object sender, EventArgs e) { if (FinalList.SelectedItems.Count > 0) { int selectedId = FinalList.SelectedIndex; string insertContent = FinalList.SelectedItem.ToString(); if (selectedId > 0) { FinalList.Items.Insert(selectedId - 1, insertContent); FinalList.Items.RemoveAt(selectedId + 1); FinalList.SetSelected(selectedId - 1, true); } } }
public static char Join(char Initial, char Medial, char Final) { const string InitialList = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ"; const string MedialList = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ"; const string FinalList = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ"; const int UnicodeHangulBase = 0xAC00; int PosInitial = InitialList.IndexOf(Initial); int PosMedial = MedialList.IndexOf(Medial); int PosFinal = FinalList.IndexOf(Final); int Value = UnicodeHangulBase + (PosInitial * 21 + PosMedial) * 28 + PosFinal; return((char)Value); }
private void FinaList_MouseUp(object sender, MouseEventArgs e) { if (FinalListIndex == -1) { return; } FinaListCombined = FinalList.Text + "|" + FinalListBeforeCombine; int indexNow = FinalList.SelectedIndex; //标记复制到的项 if (indexNow == FinalListIndex || indexNow == -1) { return; //不能自己复制自己 } FinalList.Items.RemoveAt(indexNow); FinalList.Items.Insert(indexNow, FinaListCombined); FinalList.Items.RemoveAt(FinalListIndex); FinalList.ClearSelected(); }
private void LinkPipeline() { var linkOptions = new DataflowLinkOptions() { PropagateCompletion = true }; buffer.LinkTo(step1, linkOptions); step1.LinkTo(step2, linkOptions); finalStep = step2.AsObservable(); finalStepSubscription = finalStep.Subscribe( x => { Task.Delay(rnd.Next(100, 500)).Wait(); Console.WriteLine($"Final,{x.Id}"); FinalList.Enqueue(x); }, () => { tcs.SetResult(true); }); }
public IQueryable <T> GetAll() { return(FinalList.AsQueryable()); }
private void TrySaveExcel(string name) { var users = __uid__ucl__.ToList(); int usercnt = users.Count; ExcelOperator excel = new ExcelOperator(); excel.ExcelWorkbook = excel.ExcelApplication.Workbooks.Add(true); excel.CreateExcel(); // ExcelWorksheet Other: Sort by User int idxRow = 1; bool first = true; foreach (var user in users) { int uid = user.Key; string ucl = user.Value; if (first) { first = false; } else { excel.ExcelWorksheet = excel.ExcelWorkbook.Worksheets.Add(); } excel.ExcelWorksheet.Name = ucl; idxRow = 1; for (int idxColumn = 1; idxColumn <= 6; idxColumn++) { excel[idxRow, idxColumn].Value2 = __excel__header__[idxColumn - 1]; } excel[idxRow, 7].Value2 = __excel__header__[7]; idxRow = 2; var data = from item in FinalList where item.MainValue.UserID == uid select item; foreach (var item in data) { excel[idxRow, 1].Value2 = item.MainInfo.BookID.ToString(); excel[idxRow, 2].Value2 = item.MainInfo.BookInfo.Name; excel[idxRow, 3].Value2 = __Rank_Word_1__[(int)item.MainValue.Value.Level]; excel[idxRow, 4].Value2 = __Rank_Word_2__[(int)item.MainValue.Value.Application]; excel[idxRow, 5].Value2 = __Rank_Word_3__[(int)item.MainValue.Value.Influence]; excel[idxRow, 6].Value2 = __Rank_Word_4__[(int)item.MainValue.Value.ServiceQuality]; excel[idxRow++, 7].Value2 = item.FinalValue.ToString("F2"); } Range cell = excel.ExcelWorksheet.get_Range("G2", "G" + (data.Count() + 1).ToString()); cell.NumberFormatLocal = "$#,##0.000"; } // ExcelWorksheet 2: All Data excel.ExcelWorksheet = excel.ExcelWorkbook.Worksheets.Add(); excel.ExcelWorksheet.Name = "评价列表"; idxRow = 1; for (int idxColumn = 1; idxColumn <= 8; idxColumn++) { excel[idxRow, idxColumn].Value2 = __excel__header__[idxColumn - 1]; } idxRow++; foreach (var item in FinalList) { excel[idxRow, 1].Value2 = item.MainInfo.BookID.ToString(); excel[idxRow, 2].Value2 = item.MainInfo.BookInfo.Name; excel[idxRow, 3].Value2 = __Rank_Word_1__[(int)item.MainValue.Value.Level]; excel[idxRow, 4].Value2 = __Rank_Word_2__[(int)item.MainValue.Value.Application]; excel[idxRow, 5].Value2 = __Rank_Word_3__[(int)item.MainValue.Value.Influence]; excel[idxRow, 6].Value2 = __Rank_Word_4__[(int)item.MainValue.Value.ServiceQuality]; excel[idxRow, 7].Value2 = __uid__ucl__[item.MainValue.UserID]; excel[idxRow++, 8].Value2 = item.FinalValue.ToString("F2"); } Range cells = excel.ExcelWorksheet.get_Range("H2", "H" + (FinalList.Count() + 1).ToString()); cells.NumberFormatLocal = "$#,##0.000"; // ExcelWorksheet 1: Main Result excel.ExcelWorksheet = excel.ExcelWorkbook.Worksheets.Add(); excel.ExcelWorksheet.Name = "评价结果"; idxRow = 1; excel[idxRow, 1].Value2 = __excel__header__[0]; excel[idxRow, 2].Value2 = __excel__header__[1]; excel[idxRow, 3].Value2 = "平均资助金额"; for (int offset = 1; offset <= usercnt; offset++) { excel[idxRow, 3 + offset].Value2 = users[offset - 1].Value; } idxRow = 2; string flag = ExcelOperator.GetExcelColumnName(3 + usercnt); foreach (var book in BookList.Data) { string rowname = idxRow.ToString(); excel[idxRow, 1].Value2 = book.BookID.ToString(); excel[idxRow, 2].Value2 = book.BookInfo.Name; excel[idxRow, 3].Formula = "=AVERAGE(D" + rowname + ":" + flag + rowname + ")"; for (int offset = 1; offset <= usercnt; offset++) { var result = from item in FinalList where item.MainValue.BookID == book.BookID where item.MainValue.UserID == users[offset - 1].Key select item.FinalValue; if (result.Count() != 0) { excel[idxRow, 3 + offset].Value2 = result.First().ToString("F2"); } } idxRow++; } idxRow--; Range range = excel.ExcelWorksheet.get_Range("C2", flag + idxRow.ToString()); range.NumberFormatLocal = "$#,##0.000"; excel.SaveExcel(name); excel.QuitExcel(); }
//SPACE DOWN private void PressSpaceKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) { //TODO: var finalcount = FinalList.Items.Count; var selectedindex = FinalList.SelectedIndex; if (selectedindex < finalcount) { String selectedMaterial = FinalList.SelectedItem.ToString(); string[] s = selectedMaterial.Split(new char[] { '|' }); var ExecuteNum = s.Length; for (int i = 0; i < ExecuteNum; i++) { if (s[i][0] == '#') { string[] AnimateS = s[i].Split(new char[] { ',' }); string[] stemp = AnimateS[0].Split(new char[] { '#' }); AnimateExecute(stemp[1], AnimateS[1]); } else { string[] PropertiseS = s[i].Split(new char[] { ',' }); var Proinstance = nodeGraph.Nodes[PropertiseS[0]]; var ZDProType = nodeGraph.Nodes[PropertiseS[0]].Properties[PropertiseS[1]].DependencyObjectType.Name; switch (ZDProType) { case "ZDProperty_String": if (PropertiseS[1].Equals("NodeName")) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("不可修改NodeName,若要修改请联系管理员", "退出", messButton); if (dr == DialogResult.OK) //如果点击“确定”按钮 { this.Close(); } else //如果点击“取消”按钮 { this.Close(); } } else { (Proinstance.Properties[PropertiseS[1]] as ZDProperty_String).Value = PropertiseS[2]; } break; case "ZDProperty_Float": (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Float).Value = Convert.ToSingle(PropertiseS[2]); break; case "ZDProperty_Boolean": var tbool = false; if (PropertiseS[2].Equals("true")) { tbool = true; } (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Boolean).Value = tbool; break; case "ZDProperty_Integer": (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Integer).Value = Convert.ToInt32(PropertiseS[2]); break; case "ZDProperty_Transform": (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Location.X = Convert.ToSingle(PropertiseS[2]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Location.Y = Convert.ToSingle(PropertiseS[3]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Location.Z = Convert.ToSingle(PropertiseS[4]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Rotation.Roll = Convert.ToSingle(PropertiseS[5]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Rotation.Yaw = Convert.ToSingle(PropertiseS[6]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Rotation.Pitch = Convert.ToSingle(PropertiseS[7]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Scale.X = Convert.ToSingle(PropertiseS[8]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Scale.Y = Convert.ToSingle(PropertiseS[9]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Transform).Value.Scale.Z = Convert.ToSingle(PropertiseS[10]); break; case "ZDProperty_Color": (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Color).Value.R = Convert.ToSingle(PropertiseS[2]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Color).Value.G = Convert.ToSingle(PropertiseS[3]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Color).Value.B = Convert.ToSingle(PropertiseS[4]); (Proinstance.Properties[PropertiseS[1]] as ZDProperty_Color).Value.A = Convert.ToSingle(PropertiseS[5]); break; default: break; } } } if (selectedindex + 1 == finalcount) { } else { FinalList.SetSelected(selectedindex + 1, true); } } } else { } }