private bool checkIfDirectoriesExist() { List<string> directories = new List<string>() { FolderLocator1.Text, FolderLocator2.Text, FolderLocator3.Text }; if (directories.All(s => string.IsNullOrEmpty(s))) { this.ErrorSection.Text = "You must choose at least one directory."; return false; } foreach (string directory in directories) { if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) { this.ErrorSection.Text = "The chosen file directory " + directory + " does not exist."; return false; } } return true; }
public void UpdateView(List<Table> tables) { Methods.UiInvoke(() => { // remove non-existing foreach (var tableInfo in _tablesInfo.Where(ti => tables.All(t => t != ti.Table)).ToArray()) { _tablesInfo.Remove(tableInfo); } // find of add new foreach (var table in tables) { TableInfo tableInfo = _tablesInfo.FirstOrDefault(ti => ti.Table == table); if (tableInfo == null) { tableInfo = new TableInfo(table); _tablesInfo.Add(tableInfo); } tableInfo.Update(); } // fit grid view GridView_TablesInfo.ResetColumnWidths(); }); }
private void SaveFile() { if (Files.SelectedItem != null) { List<Documents> D = new List<Documents>(); foreach (Documents d in Files.SelectedItems) { D.Add(d); } D.All(a => { Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog(); sfd.OverwritePrompt = true; sfd.FileName = a.Name; sfd.ValidateNames = true; sfd.AddExtension = true; sfd.Filter = "文档|*.doc;*docx;*.pdf|电子表格|*.xls;*.xlsx|图片|*.jpg;*.gif;*.png;*.jpge|所有支持的文件类型|*.doc;*docx;*.pdf;*.xls;*.xlsx;*.jpg;*.gif;*.png;*.jpge"; sfd.FilterIndex = 4; sfd.Title = String.Format("另存为——{0}", a.Name); if ((bool)sfd.ShowDialog(this)) { System.IO.Stream output = sfd.OpenFile(); output.BeginWrite(a.Data, 0, a.Data.Length, new AsyncCallback((b) => { output.Close(); }), null); return true; } return false; }); } statusText.Content = "请先选择一个要下载的文件。"; }
void OnTagCheckedOrUnchecked(object sender, System.ComponentModel.PropertyChangedEventArgs e) { List<int> selected_tags = new List<int>(); if (e.PropertyName != "IsChecked") return; foreach (Tag t in _tags.Where(obj => obj.IsChecked)) { selected_tags.Add(t.ID); } _filteredAudioFiles.Clear(); if (selected_tags.Count == 0) return; foreach (AudioFile f in _audioFiles) { if (selected_tags.All(id => f.Tags.Contains(id))) { _filteredAudioFiles.Add(f); } } }
private void dataGridInvoices_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { var selectedRow = dataGridInvoices.CurrentItem as InvoiceViewModel; if (selectedRow is InvoiceViewModel) { _total = 0; tractors.Clear(); tractors = data.GetDetails<TRACTOR_PURCHASE>(s => s.INVOICE_ID, selectedRow.InvoiceNumber, selectedRow.InvoiceDate, CommonLayer.TYPE.TRACTOR); gridTractors.ItemsSource = tractors; tractors.All(s => { _total += s.TRACTOR_PURCHASE_RATE; return true; }); ShowTotal(); } }
private static double GetApproximateCount(List<Dot> dots, double radius) { if (dots.All(o => !o.IsStatic)) { return dots.Count; } double[] rads = dots.Select(o => o.Position.ToVector().Length).ToArray(); double maxRadius = radius * .15d; double retVal = 0d; for (int cntr = 0; cntr < dots.Count; cntr++) { if (!dots[cntr].IsStatic) { // The movable dots are always counted retVal += 1d; } else if (rads[cntr] <= radius) { // Fully include everything that's <= radius retVal += 1d; } else { // Scale out the ones that are > radius double percent = (rads[cntr] - radius) / maxRadius; if (percent < 1d && percent > 0d) { retVal += percent; } } } // Exit Function return retVal; }