public CForm(OrderEntity source) { orderEntity = source; Type type = typeof(OrderSource<>).MakeGenericType(new Type[] { source.OrderType }); OrderSource = Activator.CreateInstance(type) as IOrderSource; if (string.IsNullOrEmpty(source.OrderID)) { OperationType = OperationTypes.New; this.GridToolBar_Delete.Visibility = Visibility.Collapsed; } else { OperationType = OperationTypes.Edit; } InitializeComponent(); List<string[]> FInfo = new List<string[]>(); FInfo.Add(new string[]{"单据编号", "OrderCode", "OrderCode", "0", "0"}); FInfo.Add(new string[] { "状态", "OrderStates", "OrderStates", "0", "0" }); FInfo.Add(new string[] { "创建人", "CreateUser", "CreateUser", "0", "0" }); FInfo.Add(new string[] { "创建时间", "CreateDate", "CreateDate", "0", "0" }); this.GForm.LeftFForm.Items = GetFieldItems(FInfo); this.GForm.LeftFForm.InitForm(); FInfo.Clear(); FInfo.Add(new string[] { "单据类型", "OrderType", "OrderType", "0", "0" }); FInfo.Add(new string[] { "申请人", "Applicant", "Applicant", "3", "1" }); FInfo.Add(new string[] { "申请部门", "AppliedDepartMent", "AppliedDepartMentData", "2", "1" }); FInfo.Add(new string[] { "申请公司", "Company", "CompanyData", "2", "1" }); this.GForm.RightForm.Items = GetFieldItems(FInfo); this.GForm.RightForm.InitForm(); FInfo.Clear(); FInfo.Add(new string[] { "备注", "Remark", "Remark", "4", "0" }); this.GFormRemark.Items = GetFieldItems(FInfo); this.GFormRemark.InitForm(); FInfo.Clear(); FInfo.Add(new string[] { "编号", "SerialNumber", "75", "1" }); FInfo.Add(new string[] { "预算项目", "ObjectName", "200", "1" }); FInfo.Add(new string[] { "可用金额", "UsableMoney", "100", "1" }); FInfo.Add(new string[] { "已用金额", "UsedMoney", "100", "0" }); FInfo.Add(new string[] { "费用类型", "ChargeType", "100", "1" }); this.AGrid.Items= GetDataGridItem(FInfo); this.AGrid.InitGrid(); BindingData(); }
public static List<object> TokenizeMessage(string message) { var tokens = new List<object>(); try { //TODO - better Regex var r = new Regex("<(.|\n)*?>", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.ExplicitCapture); var split = r.Split(message); foreach (var t in split) { if (!string.IsNullOrWhiteSpace(t)) { Uri uri = null; if (Uri.TryCreate(t, UriKind.Absolute, out uri)) { tokens.Add(uri); } else { tokens.Add(t); } } } } catch (Exception ex) { tokens.Clear(); tokens.Add(message); } return tokens; }
private void txtAuto_TextChanged(object sender, TextChangedEventArgs e) { string typedString = txtAuto.Text; List<string> autoList = new List<string>(); autoList.Clear(); foreach (string item in nameList) { if (!string.IsNullOrEmpty(txtAuto.Text)) { if (item.StartsWith(typedString)) { autoList.Add(item); } } } if (autoList.Count > 0) { lbSuggestion.ItemsSource = autoList; lbSuggestion.Visibility = Visibility.Visible; } else if (txtAuto.Text.Equals("")) { lbSuggestion.Visibility = Visibility.Collapsed; lbSuggestion.ItemsSource = null; } else { lbSuggestion.Visibility = Visibility.Collapsed; lbSuggestion.ItemsSource = null; } }
void orgClient_GetCompanyActivedCompleted(object sender, SMT.Saas.Tools.OrganizationWS.GetCompanyActivedCompletedEventArgs e) { if (e.Error != null && e.Error.Message != "") { //loadbar.Stop();//有错误停止转圈 ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error); return; } else { if (e.Result == null) { return; } ObservableCollection<SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY> entTemps = e.Result; allCompanys = new List<SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY>(); allCompanys.Clear(); var ents = entTemps.OrderBy(c => c.FATHERID); ents.ForEach(item => { allCompanys.Add(item); }); UICache.CreateCache("SYS_CompanyInfo", allCompanys); orgClient.GetDepartmentActivedAsync(SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID); } }
private void buttonSave_Click(object sender, RoutedEventArgs e) { List<Figuur> GewijzigdeFiguren = new List<Figuur>(); foreach (Figuur f in figuren) { if (f.Changed == true) GewijzigdeFiguren.Add(f); f.Changed = false; } if(GewijzigdeFiguren.Count() != 0) { FiguurManager manager = new FiguurManager(); try { manager.SChrijfWijzigingen(GewijzigdeFiguren); } catch (Exception ex) { MessageBox.Show(ex.Message); } } GewijzigdeFiguren.Clear(); }
private void previewButton_Click(object sender, RoutedEventArgs e) { string context=""; double duration=0; double numberofchars = 0; int speedfromui = Convert.ToInt32(speedslider.Value); animation = new List<Paragraph>(); SubLine line = _lines.OrderByDescending(x => x.Context.Length).ToList()[0]; context = HtmlTools.RemoveHtmlTags(line.Context.Replace("</br>", Environment.NewLine)); numberofchars = Convert.ToDouble(context.Length); duration = line.Duration * 1000; double speed = speedfromui+50; double b = (speed) / 50d; keytime = (duration / numberofchars) /b; var color1 = Color1ColorPicker.SelectedColor.Value; var color2 = Color2ColorPicker.SelectedColor.Value; animation.Clear(); for (int i = 0; i <=context.Length; i++) { Run c1 = new Run(context.Substring(0,i)); c1.Foreground =new SolidColorBrush(color1); Run c2 = new Run(context.Substring(i, context.Length - i)); c2.Foreground = new SolidColorBrush(color2); Paragraph para = new Paragraph(); para.Inlines.Add(c1); para.Inlines.Add(c2); animation.Add(para); } RunPreveiw(); }
private static void CreateTextBox(List<DependencyObject> list, List<Inline> current, IHtmlTextBlock textBlock) { if (current.Count > 0) { var p = new Paragraph(); foreach (var r in current) p.Inlines.Add(r); #if !WINRT var tb = new RichTextBox(); tb.Background = textBlock.Background; tb.Margin = new Thickness(-12, textBlock.ParagraphMargin, -12, textBlock.ParagraphMargin); #else var tb = new RichTextBlock(); tb.IsTextSelectionEnabled = false; tb.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, textBlock.ParagraphMargin); #endif tb.Blocks.Add(p); tb.Foreground = textBlock.Foreground; tb.FontSize = textBlock.FontSize; tb.FontFamily = textBlock.FontFamily; list.Add(tb); current.Clear(); } }
// todo probably use LINQ here. public override List<Point> Filter(List<Point> points) { if (points.Count == 0) return points; List<Point> resultPoints = points; if (points.Count > 2 * screenRect.Width) { resultPoints = new List<Point>(); List<Point> currentChain = new List<Point>(); double currentX = Math.Floor(points[0].X); foreach (Point p in points) { if (Math.Floor(p.X) == currentX) { currentChain.Add(p); } else { // Analyse current chain if (currentChain.Count <= 2) { resultPoints.AddRange(currentChain); } else { Point first = MinByX(currentChain); Point last = MaxByX(currentChain); Point min = MinByY(currentChain); Point max = MaxByY(currentChain); resultPoints.Add(first); Point smaller = min.X < max.X ? min : max; Point greater = min.X > max.X ? min : max; if (smaller != resultPoints[resultPoints.Count-1]) { resultPoints.Add(smaller); } if (greater != resultPoints[resultPoints.Count-1]) { resultPoints.Add(greater); } if (last != resultPoints[resultPoints.Count-1]) { resultPoints.Add(last); } } currentChain.Clear(); currentChain.Add(p); currentX = Math.Floor(p.X); } } } return resultPoints; }
public bool Validate(object instance) { _validationResults = _validationResults ?? new List<ValidationResult>(); _validationResults.Clear(); var isValid = Validator.TryValidateObject(instance, new ValidationContext(instance, null, null), _validationResults, true); return isValid; }
public SendItemToWindow(int gameIndex, ushort id, uint maxCount) { InitializeComponent(); upDownItemCount.Minimum = 0; upDownItemCount.Value = 1; upDownItemCount.Maximum = (int)maxCount; itemID = id; pocketTypes = new List<ItemTypes>(); loaded = false; count = 1; for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (i == gameIndex) { comboBoxGame.SetGameSaveVisible(i, false); continue; } IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType != GameTypes.Any && !ItemDatabase.GetItemFromID(id).Exclusives.HasFlag((GameTypeFlags)(1 << ((int)game.GameType - 1)))) { comboBoxGame.SetGameSaveVisible(i, false); } } pocketTypes.Clear(); comboBoxPocket.Items.Clear(); /*if (this.gameIndex == -1) { pocketTypes.Add(ItemDatabase.GetItemFromID(itemID).PocketType); comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemDatabase.GetItemFromID(itemID).PocketType)); comboBoxPocket.SelectedIndex = 0; } else { pocketTypes.Add(ItemTypes.PC); pocketTypes.Add(ItemDatabase.GetItemFromID(itemID).PocketType); comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemTypes.PC)); comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemDatabase.GetItemFromID(itemID).PocketType)); comboBoxPocket.SelectedIndex = 1; }*/ this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { //comboBoxGame.SelectedIndex = 0; this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; GameChanged(null, null); }
private void Window_Loaded(object sender, RoutedEventArgs e) { List<int> colh = new List<int>(); Globals.LoadUsers(); colh.Add(2); colh.Add(3); colh.Add(8); colh.Add(9); admin.LoadUsers(Globals.users, colh); colh.Clear(); admin.UserSelected += new EventHandler(UserSelected); }
private void btnDraw_Click(object sender, RoutedEventArgs e) { int drawNum = 0; List<int> lottoRivi = new List<int>(); if (Int32.TryParse(txtDrawNum.Text, out drawNum)) { for (int i = 0; i < drawNum; i++) { lottoRivi = lottoKone.ArvoRivi(cmbType.Text); lottoRivi.Sort(); lottoRivi.ForEach(Tulosta); lottoRivi.Clear(); txtResult.Text += Environment.NewLine; } } }
public MainWindow() { InitializeComponent(); ODRList.ItemsSource = outputDataRates; ODRList.SelectedIndex = 3; mySocketServer = new SocketServer(); Point[] pts = {new Point(20.0f, 10.0f), new Point(10.0f, 20.0f), new Point(15.0f, 20.0f), new Point(15.0f, 50.0f), new Point(25.0f, 50.0f), new Point(25.0f, 20.0f), new Point(30.0f, 20.0f), new Point(20.0f, 10.0f)}; List<Point> curvePoints = new List<Point>(); curvePoints.AddRange(pts); dongleIncomingTrafficArrow = new Polygon(); dongleIncomingTrafficArrow.Points = new PointCollection(curvePoints); dongleIncomingTrafficArrow.StrokeThickness = 2; dongleIncomingTrafficArrow.HorizontalAlignment = HorizontalAlignment.Left; dongleIncomingTrafficArrow.VerticalAlignment = VerticalAlignment.Center; DongleTrafficCanvas.Children.Add(dongleIncomingTrafficArrow); curvePoints.Clear(); Point[] pts2 = {new Point(35.0f, 10.0f), new Point(35.0f, 40.0f), new Point(30.0f, 40.0f), new Point(40.0f, 50.0f), new Point(50.0f, 40.0f), new Point(45.0f, 40.0f), new Point(45.0f, 10.0f), new Point(35.0f, 10.0f)}; curvePoints.AddRange(pts2); dongleOutgoingTrafficArrow = new Polygon(); dongleOutgoingTrafficArrow.Points = new PointCollection(curvePoints); dongleOutgoingTrafficArrow.StrokeThickness = 2; dongleOutgoingTrafficArrow.HorizontalAlignment = HorizontalAlignment.Right; dongleOutgoingTrafficArrow.VerticalAlignment = VerticalAlignment.Center; DongleTrafficCanvas.Children.Add(dongleOutgoingTrafficArrow); CompositionTarget.Rendering += CompositionTarget_Rendering; }
private void PopulateComboBox(object sender, bool dev) { List<string> data = new List<string>(); if (dev == false) { data.Add("Florida"); data.Add("Southeast"); data.Add("Texas"); data.Add("Puerto Rico"); } else { data.Clear(); data.Add("FL Dev"); data.Add("SE Dev"); data.Add("TX Dev"); data.Add("PR Dev"); } var comboBox = sender as ComboBox; comboBox.ItemsSource = data; comboBox.SelectedIndex = 0; }
/// <summary> /// Constructor /// </summary> /// <param name="active">whether or not the effects are active</param> /// <param name="effects">effect list</param> public AttributeSet(string prefix, List<IEffect> effects) { // Get which effects to use aliases for List<String> keys = new List<String>(); List<String> ids = new List<String>(); foreach (IEffect effect in effects) { string id = effect.GetKey() + ";" + effect.GetTarget(); if (ids.Contains(id)) continue; else ids.Add(id); if (keys.Contains(effect.GetKey())) { aliasedKeys.Add(effect.GetKey()); } else keys.Add(effect.GetKey()); } // Get the list of attributes List<Attribute> unaliased = new List<Attribute>(); keys.Clear(); foreach (IEffect effect in effects) { effect.GetAttributes(unaliased); // Apply prefixes and aliases foreach (Attribute attribute in unaliased) { string key = attribute.Key; if (aliasedKeys.Contains(effect.GetKey())) { key = effect.GetTarget() + " " + key; } key = prefix + key; // Prevent duplicates if (keys.Contains(key)) continue; else keys.Add(key); attributes.Add(new Attribute(key, attribute.Initial, attribute.Scale)); } unaliased.Clear(); } }
public Node randomPuzzle(int distance) { List<Node> listOfNodes = new List<Node>(); listOfNodes.Add(giveMeAGoalNode()); for (int i = 0; i <= distance; i++) { List<List<Node>> children = new List<List<Node>>(); foreach (Node n in randomPermute(listOfNodes)) { children.Add(n.generateChildNodes()); } listOfNodes.Clear(); foreach (List<Node> list in children) { foreach (Node node in list) { if (!(isGoalState(node.state)) && !(isItInSet(node, exploredSet[node.hValue]))) { if (Heuristics.manhattanDistanceHeuristicPlusReversalPenalty(node) >= distance) { node.parent = null; node.gValue = 0; node.fValue = node.hValue; node.action = ""; return node; } exploredSet[node.hValue].Add(node); listOfNodes.Add(node); } } } } Random rand = new Random(); return listOfNodes[rand.Next(0, listOfNodes.Count - 1)]; }
public static int DeleteExistingFrames (List<PositioningEntry> AllLoadedFrames) { if (AllLoadedFrames == null) return -1; int SelectedIndex = 0; int LastSelectedIndex = -1; foreach (PositioningEntry PosWindow in AllLoadedFrames) { if (PosWindow.IsSelected == true) LastSelectedIndex = SelectedIndex; PosWindow.Close (); SelectedIndex++; } AllLoadedFrames.Clear (); return LastSelectedIndex; }
//Laddar kategori och fyller på listor private void loadCategoryList() { try { List<string> category = new List<string>(); categoryListBox.Items.Clear(); cbCategory.Items.Clear(); category = readxml.readXMLDoc(); foreach (string item in category) { categoryListBox.Items.Add(item); cbCategory.Items.Add(item); } category.Clear(); } catch (Exception er) { string error = er.Message; Console.WriteLine(error); } }
public void RefreshSystemCleaners() { List<TreeNode> nodes_to_remove = new List<TreeNode>(); foreach (TreeNode node in this._nodes) { if (node.Key == "system" || node.Key == "duplicate_checker") { nodes_to_remove.Add(node); } } nodes_to_remove.ForEach((x) => this._nodes.Remove(x)); nodes_to_remove.Clear(); nodes_to_remove = null; AddSystemCleaner(); SortCleanerCollection(); }
private void DeleteItem() { List<PID> PIDLIST = new List<PID>(); PIDLIST = XML_W_R.XMLRead(FileName); PIDLIST.RemoveAll(FindItem); XML_W_R.XMLWrite(PIDLIST, FileName); PIDLIST.Clear(); }
void HandleCustomContextMenuEntry(ContextMenuEntry currentEntry, Category aCategory, VideoInfo aVideo) { List<KeyValuePair<string, ContextMenuEntry>> dialogOptions = new List<KeyValuePair<string, ContextMenuEntry>>(); while (true) { bool execute = currentEntry.Action == ContextMenuEntry.UIAction.Execute; if (currentEntry.Action == ContextMenuEntry.UIAction.GetText) { SearchDialog dlg = new SearchDialog() { Owner = this }; dlg.tbxSearch.Text = currentEntry.UserInputText ?? ""; dlg.lblHeading.Text = currentEntry.DisplayText; if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.tbxSearch.Text)) { currentEntry.UserInputText = dlg.tbxSearch.Text; execute = true; } else break; } if (currentEntry.Action == ContextMenuEntry.UIAction.ShowList) { PlaybackChoices dlg = new PlaybackChoices() { Owner = this }; dlg.lblHeading.Content = currentEntry.DisplayText; dialogOptions.Clear(); foreach (var subEntry in currentEntry.SubEntries) { dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(subEntry.DisplayText, subEntry)); } dlg.lvChoices.ItemsSource = dialogOptions.Select(dO => dO.Key).ToList(); dlg.lvChoices.SelectedIndex = 0; if (dlg.ShowDialog() != true) break; else currentEntry = dialogOptions[dlg.lvChoices.SelectedIndex].Value; } if (execute) { waitCursor.Visibility = System.Windows.Visibility.Visible; Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( delegate() { return SelectedSite.ExecuteContextMenuEntry(aCategory, aVideo, currentEntry); }, delegate(Gui2UtilConnector.ResultInfo resultInfo) { waitCursor.Visibility = System.Windows.Visibility.Hidden; if (ReactToResult(resultInfo, currentEntry.DisplayText)) { if (resultInfo.ResultObject is ContextMenuExecutionResult) { var cmer = resultInfo.ResultObject as ContextMenuExecutionResult; if (!string.IsNullOrEmpty(cmer.ExecutionResultMessage)) { notification.Show(currentEntry.DisplayText, cmer.ExecutionResultMessage); } if (cmer.RefreshCurrentItems) { CategorySelected(SelectedCategory); } if (cmer.ResultItems != null && cmer.ResultItems.Count > 0) { DisplaySearchResultItems(currentEntry.DisplayText, cmer.ResultItems); } } } }); break; } } }
HexLine CreateHexLine(ulong offset, ulong end, List<HexLinePart> parts, TextRunProperties textRunProps, StringBuilder sb, StringBuilder sb2, short[] bytesAry) { parts.Clear(); int skipBytes = (int)GetLineByteIndex(offset); int bytes = (int)Math.Min(end - offset + 1, (ulong)(visibleBytesPerLine - skipBytes)); if (bytes == 0) bytes = visibleBytesPerLine - skipBytes; ulong visibleOffs = PhysicalToVisibleOffset(offset - (ulong)skipBytes); Add(parts, sb, string.Format(offsetFormatString, UseHexPrefix ? "0x" : string.Empty, visibleOffs & offsetMask), textRunProps, OffsetForeground); if (skipBytes > 0) Add(parts, sb, new string(' ', skipBytes * 3), textRunProps, Foreground); var doc = Document; for (int i = 0; i < bytes; i++) { int b = doc == null ? -1 : doc.ReadByte(offset + (ulong)i); bytesAry[i] = (short)b; // The space gets the same color for speed. Less color switching = faster rendering if (b < 0) Add(parts, sb, " ??", textRunProps, ByteErrorForeground); else Add(parts, sb, string.Format(LowerCaseHex ? " {0:x2}" : " {0:X2}", b), textRunProps, BytesGroupCount <= 0 || ((i / BytesGroupCount) & 1) == 0 ? Byte0Foreground : Byte1Foreground); } if (visibleBytesPerLine - skipBytes != bytes) Add(parts, sb, new string(' ', (visibleBytesPerLine - skipBytes - bytes) * 3), textRunProps, Foreground); if (ShowAscii) { if (skipBytes > 0) Add(parts, sb, new string(' ', skipBytes), textRunProps, AsciiForeground); Add(parts, sb, " ", textRunProps, AsciiForeground); for (int i = 0; i < bytes; i++) { int b = bytesAry[i]; if (b >= 0x20 && b <= 0x7E) sb2.Append((char)b); else sb2.Append(b < 0 ? "?" : "."); } Add(parts, sb, sb2.ToString(), textRunProps, AsciiForeground); sb2.Clear(); } short[] originalBytes; if (!CacheLineBytes) originalBytes = null; else { originalBytes = new short[bytes]; Array.Copy(bytesAry, originalBytes, originalBytes.Length); } return new HexLine(offset, offset + (ulong)(bytes == 0 ? 0 : bytes - 1), sb.ToString(), parts.ToArray(), originalBytes); }
private void DoImport() { if (String.IsNullOrEmpty(txtFilename.Text)) { ErrorMessage.Show("You must select a file before proceeding!"); return; } int rowCount = 0; var service = new SupportService(User); using (var parser = new GenericParserAdapter(txtFilename.Text)) { parser.ColumnDelimiter = ','; parser.FirstRowHasHeader = chkFirstRowHeaders.IsChecked.GetValueOrDefault(false); parser.TextQualifier = '\"'; parser.FirstRowSetsExpectedColumnCount = true; var columnNames = new List<String>(); var values = new List<string>(); while (parser.Read()) { if (rowCount == 0) { for (int i = 0; i < parser.ColumnCount; ++i) { if (parser.FirstRowHasHeader) { columnNames.Add(parser.GetColumnName(i)); } else { columnNames.Add("Column" + i); } } } values.Clear(); for (int i = 0; i < parser.ColumnCount; ++i) { values.Add(parser[i]); } String strFullPath = null; if (values.Count == 0) { strFullPath = values[0]; } else { strFullPath = values.Join("\\"); } if (!String.IsNullOrWhiteSpace(strFullPath)) { service.GetDistributionIdFromPath(strFullPath); lblProgress.InvokeIfRequired(() => { lblProgress.Content = strFullPath; lblProgress.UpdateLayout(); }); rowCount++; } } } lblProgress.InvokeIfRequired(() => { lblProgress.Content = String.Format("{0} rows processed.", rowCount); }); btnCancel.Content = "_Close"; }
private void getdata() { DataTable table = dbOperation.GetDbHelper().GetDataSet(string.Format("call p_report_day_country('{0}','{1}','{2}','{3}','{4}')", Sj, DeptId, ItemId, ResultId, DeptType)).Tables[0]; currenttable = table; List<DeptItemInfo> list = new List<DeptItemInfo>(); list.Clear(); for (int i = 0; i < table.Rows.Count; i++) { DeptItemInfo info = new DeptItemInfo(); //info.DeptId = table.Rows[i][0].ToString(); info.DeptName = table.Rows[i][1].ToString(); //info.ItemId = table.Rows[i][2].ToString(); info.ItemName = table.Rows[i][3].ToString(); info.Count = table.Rows[i][4].ToString(); info.Sum = table.Rows[i][5].ToString(); info.Yin = table.Rows[i][6].ToString(); info.Yang = table.Rows[i][7].ToString(); info.Yisi = table.Rows[i][8].ToString(); list.Add(info); } //得到行和列标题 及数量 string[] DeptNames = list.Select(t => t.DeptName).Distinct().ToArray(); string[] ItemNames = list.Select(t => t.ItemName).Distinct().ToArray(); //创建DataTable DataTable tabledisplay = new DataTable(); //表中第一行第一列交叉处一般显示为第1列标题 tabledisplay.Columns.Add(new DataColumn("序号")); tabledisplay.Columns.Add(new DataColumn("部门名称")); MyColumns.Add("序号", new MyColumn("序号", "序号") { BShow = true, Width = 5 }); MyColumns.Add("部门名称", new MyColumn("部门名称", "部门名称") { BShow = true, Width = 16 }); //表中后面每列的标题其实是列分组的关键字 for (int i = 0; i < ItemNames.Length; i++) { DataColumn column = new DataColumn(ItemNames[i]); tabledisplay.Columns.Add(column); MyColumns.Add(ItemNames[i].ToString(), new MyColumn(ItemNames[i].ToString(), ItemNames[i].ToString()) { BShow = true, Width = 10 }); } //表格后面为合计列 tabledisplay.Columns.Add(new DataColumn("合计")); MyColumns.Add("合计", new MyColumn("合计", "合计") { BShow = true, Width = 10 }); switch (ResultId) { case "": tabledisplay.Columns.Add(new DataColumn("阴性样本")); tabledisplay.Columns.Add(new DataColumn("疑似阳性样本")); tabledisplay.Columns.Add(new DataColumn("阳性样本")); MyColumns.Add("阴性样本", new MyColumn("阴性样本", "阴性样本") { BShow = true, Width = 10 }); MyColumns.Add("疑似阳性样本", new MyColumn("疑似阳性样本", "疑似阳性样本") { BShow = true, Width = 10 }); MyColumns.Add("阳性样本", new MyColumn("阳性样本", "阳性样本") { BShow = true, Width = 10 }); break; case "1": tabledisplay.Columns.Add(new DataColumn("阴性样本")); MyColumns.Add("阴性样本", new MyColumn("阴性样本", "阴性样本") { BShow = true, Width = 10 }); break; case "0": tabledisplay.Columns.Add(new DataColumn("疑似阳性样本")); MyColumns.Add("疑似阳性样本", new MyColumn("疑似阳性样本", "疑似阳性样本") { BShow = true, Width = 10 }); break; case "2": tabledisplay.Columns.Add(new DataColumn("阳性样本")); MyColumns.Add("阳性样本", new MyColumn("阳性样本", "阳性样本") { BShow = true, Width = 10 }); break; default: break; } //为表中各行生成数据 for (int i = 0; i < DeptNames.Length; i++) { var row = tabledisplay.NewRow(); //每行第0列为行分组关键字 row[0] = i + 1 ; row[1] = DeptNames[i]; //每行的其余列为行列交叉对应的汇总数据 for (int j = 0; j < ItemNames.Length; j++) { string num = list.Where(t => t.DeptName == DeptNames[i] && t.ItemName == ItemNames[j]).Select(t => t.Count).FirstOrDefault(); if (num == null || num == "") { num = '0'.ToString(); } row[ItemNames[j]] = num; } row[ItemNames.Length + 2] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Sum).FirstOrDefault(); switch (ResultId) { case "": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yin).FirstOrDefault(); row[ItemNames.Length + 4] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yisi).FirstOrDefault(); row[ItemNames.Length + 5] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yang).FirstOrDefault(); break; case "1": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yin).FirstOrDefault(); break; case "0": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yisi).FirstOrDefault(); break; case "2": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yang).FirstOrDefault(); break; default: break; } tabledisplay.Rows.Add(row); } //计算报表总条数 int row_count = 0 ; if (table.Rows.Count != 0) { //表格最后添加合计行 tabledisplay.Rows.Add(tabledisplay.NewRow()[1] = "合计"); for (int j = 2; j < tabledisplay.Columns.Count; j++) { int sum = 0; for (int i = 0; i < tabledisplay.Rows.Count - 1 ; i++) { sum += Convert.ToInt32(tabledisplay.Rows[i][j].ToString()); } //sum_column += sum; tabledisplay.Rows[tabledisplay.Rows.Count - 1][j] = sum; } row_count = tabledisplay.Rows.Count - 1; } else { row_count = 0 ; } _tableview.MyColumns = MyColumns; _tableview.BShowDetails = true; _tableview.Table = tabledisplay; }
/// <summary> /// Remove a playlist from the search box's context menu /// </summary> /// <param name="playlist">The playlist to be removed</param> public void RemovePlaylist(PlaylistData playlist) { // remove from "add to playlist" menu in list List<MenuItem> menu_items_to_remove = new List<MenuItem>(); foreach (MenuItem item in Menu_Add.Items) { if (item.Header.ToString() == playlist.Name) menu_items_to_remove.Add(item); } foreach (MenuItem item in menu_items_to_remove) Menu_Add.Items.Remove(item); // remove from "remove from playlist" menu in list menu_items_to_remove.Clear(); foreach (MenuItem item in Menu_Remove.Items) { if (item.Header.ToString() == playlist.Name) menu_items_to_remove.Add(item); } foreach (MenuItem item in menu_items_to_remove) Menu_Remove.Items.Remove(item); if (SettingsManager.Playlists.Count <= 0) Menu_Remove.IsEnabled = false; }
protected double ArrangeRow(List<UIElement> rowElements, double left, bool arrange) { double max = 0; double rowHeight = smallHeight + (rowElements.Count == 2 ? (smallHeight / 3) : 0); double topOffset = rowElements.Count == 2 ? smallHeight / 3 : 0; foreach (UIElement e in rowElements) { max = Math.Max(e.DesiredSize.Width, max); } foreach (UIElement e in rowElements) { if (arrange) { double h = Math.Max(smallHeight, e.DesiredSize.Height); double w = e is IRibbonStretch ? max : e.DesiredSize.Width; FrameworkElement fe = e as FrameworkElement; if (fe != null && fe.HorizontalAlignment != HorizontalAlignment.Left) { switch (fe.HorizontalAlignment) { case HorizontalAlignment.Right: e.Arrange(new Rect(max - w + left, topOffset, w, h)); break; case HorizontalAlignment.Center: e.Arrange(new Rect((max - w) / 2 + left, topOffset, w, h)); break; case HorizontalAlignment.Left: case HorizontalAlignment.Stretch: e.Arrange(new Rect(left, topOffset, w, h)); break; } } else e.Arrange(new Rect(left, topOffset, w, h)); } topOffset += rowHeight; } rowElements.Clear(); return max; }
/// <summary> /// Carga la lista de empleados de forma dinámica y predictiva /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void filtroEmpleado_TextChanged(object sender, TextChangedEventArgs e) { string nombreBuscar = filtroEmpleado.Text; List<string> autolist = new List<string>(); autolist.Clear(); foreach (Empleada item in empleados) { if (!string.IsNullOrEmpty(filtroEmpleado.Text)) { if (item.nombre.ToLower().StartsWith(nombreBuscar.ToLower())) autolist.Add(item.nombre); } } if (autolist.Count > 0) { listaEmpleados.ItemsSource = autolist; listaEmpleados.Visibility = Visibility.Visible; } else if (filtroEmpleado.Text.Equals("")) { listaEmpleados.Visibility = Visibility.Collapsed; listaEmpleados.ItemsSource = null; } else { listaEmpleados.Visibility = Visibility.Collapsed; listaEmpleados.ItemsSource = null; } }
private void Button_Click(object sender, RoutedEventArgs e) { //LUCAS try { Random rand = new Random(42); List<int> numbers = new List<int>(); ListDisjointSet<int> disjointSet; disjointSet = new ListDisjointSet<int>(); Stopwatch iterationTimer = new Stopwatch(); List<long> ticksList = new List<long>(); for (int i = 0; i < 10000; i++) { int n = rand.Next(); numbers.Add(n); iterationTimer.Start(); disjointSet.MakeSet(n); iterationTimer.Stop(); ticksList.Add(iterationTimer.ElapsedTicks); iterationTimer.Reset(); } mksetOne.Text = String.Format("Avg : {0}, Max: {1}, Min: {2}", ticksList.Average(), ticksList.Max(), ticksList.Min()); ticksList.Clear(); for (int i = 0; i < numbers.Count * 3; i++) { int lookup = numbers[rand.Next(numbers.Count)]; iterationTimer.Start(); disjointSet.Find(lookup); iterationTimer.Stop(); ticksList.Add(iterationTimer.ElapsedTicks); iterationTimer.Reset(); } findOne.Text = String.Format("Avg : {0}, Max: {1}, Min: {2}", ticksList.Average(), ticksList.Max(), ticksList.Min()); ticksList.Clear(); for (int i = 0; i < numbers.Count * 3; i++) { int lookupA = numbers[rand.Next(numbers.Count)]; int lookupB = numbers[rand.Next(numbers.Count)]; iterationTimer.Start(); disjointSet.Union(disjointSet.Find(lookupA), disjointSet.Find(lookupB)); iterationTimer.Stop(); ticksList.Add(iterationTimer.ElapsedTicks); iterationTimer.Reset(); } unionOne.Text = String.Format("Avg : {0}, Max: {1}, Min: {2}", ticksList.Average(), ticksList.Max(), ticksList.Min()); } catch (Exception err) { Console.WriteLine(err.StackTrace); } //PAUL try { Random rand = new Random(42); List<int> numbers = new List<int>(); DisjointDataSet<int> disjointSet; disjointSet = new DisjointDataSet<int>(); Stopwatch iterationTimer = new Stopwatch(); List<long> ticksList = new List<long>(); for (int i = 0; i < 10000; i++) { int n = rand.Next(); numbers.Add(n); iterationTimer.Start(); disjointSet.MakeSet(n); iterationTimer.Stop(); ticksList.Add(iterationTimer.ElapsedTicks); iterationTimer.Reset(); } mksetTwo.Text = String.Format("Avg : {0}, Max: {1}, Min: {2}", ticksList.Average(), ticksList.Max(), ticksList.Min()); ticksList.Clear(); for (int i = 0; i < numbers.Count * 3; i++) { int lookup = numbers[rand.Next(numbers.Count)]; iterationTimer.Start(); disjointSet.Find(lookup); iterationTimer.Stop(); ticksList.Add(iterationTimer.ElapsedTicks); iterationTimer.Reset(); } findTwo.Text = String.Format("Avg : {0}, Max: {1}, Min: {2}", ticksList.Average(), ticksList.Max(), ticksList.Min()); ticksList.Clear(); for (int i = 0; i < numbers.Count * 3; i++) { int lookupA = numbers[rand.Next(numbers.Count)]; int lookupB = numbers[rand.Next(numbers.Count)]; iterationTimer.Start(); disjointSet.Union(lookupA, lookupB); iterationTimer.Stop(); ticksList.Add(iterationTimer.ElapsedTicks); iterationTimer.Reset(); } unionTwo.Text = String.Format("Avg : {0}, Max: {1}, Min: {2}", ticksList.Average(), ticksList.Max(), ticksList.Min()); } catch (Exception err) { Console.WriteLine(err.StackTrace); } }
private bool TryParseViaSyndicationFeed(FeedSource downloadRssSource, string downloadResult) { bool parsedSuccessfully = true; List<FeedItem> FeedItemsToAdd = new List<FeedItem>(); try { XmlReader xmlReader = XmlReader.Create(new StringReader(downloadResult)); SyndicationFeed synFeed = SyndicationFeed.Load(xmlReader); foreach (var synFeedItem in synFeed.Items) { if (synFeedItem != null && synFeedItem.Title != null && synFeedItem.Links.Count > 0) { FeedItem FeedItem = new FeedItem(); FeedItem.Title = synFeedItem.Title.Text; if (synFeedItem.Summary != null) FeedItem.Summary = synFeedItem.Summary.Text; //links Uri postUri = null; foreach (var link in synFeedItem.Links) { string relType = link.RelationshipType.ToString(); if (relType == "self" || relType == "replies") continue; else postUri = link.GetAbsoluteUri(); } if (postUri == null) postUri = synFeedItem.Links[0].GetAbsoluteUri(); FeedItem.PostUri = postUri; //FeedItem.PostUri = synFeedItem.Links[0].GetAbsoluteUri(); FeedItem.Source = downloadRssSource; FeedItemsToAdd.Add(FeedItem);//add to method-scoped list first } } } catch (Exception e) { parsedSuccessfully = false; if (FeedItemsToAdd != null) FeedItemsToAdd.Clear(); Services.Log("SyndicationFeed did not work with url " + downloadRssSource.UriString + "\n" + "Exception.Message: " + e.Message, LogPriority.Low, LogCategory.Information); } if (parsedSuccessfully) { //copy method-scoped feeditems to higher level scope results object foreach (var item in FeedItemsToAdd) { _DownloadFeedResults.FeedItems.Add(item); } } return parsedSuccessfully; }
private bool TryParseViaXDocument(FeedSource feedSource, string downloadResult) { bool parsedSuccessfully = true; List<FeedItem> feedItemsToAdd = new List<FeedItem>(); try { XDocument document = XDocument.Parse(downloadResult); var results = from c in document.Root.Element("channel").Elements("item") select c; foreach (var xElement in results) { FeedItem newItem = new FeedItem(); newItem.Summary = xElement.Element("description").Value; newItem.Title = xElement.Element("title").Value; newItem.PostUri = new Uri(xElement.Element("link").Value); newItem.Source = feedSource; feedItemsToAdd.Add(newItem); } } catch (Exception e) { parsedSuccessfully = false; if (feedItemsToAdd != null) feedItemsToAdd.Clear(); Services.Log("SyndicationFeed did not work with url " + feedSource.UriString + "\n" + "Exception.Message: " + e.Message, LogPriority.Low, LogCategory.Information); } if (parsedSuccessfully) { //copy method-scoped feeditems to higher level scope results object foreach (var item in feedItemsToAdd) { _DownloadFeedResults.FeedItems.Add(item); } } return parsedSuccessfully; }