本文整理汇总了C#中System.Windows.Documents.List.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# List.Distinct方法的具体用法?C# List.Distinct怎么用?C# List.Distinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Distinct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Report_UnLike
public void Report_UnLike()
{
try
{
List<string> Follower = new List<string>();
DataSet ds = DataBaseHandler.SelectQuery("select * from tbl_AccountReport where ModuleName ='" + "PhotoUnlikeModule" + "' and Status='" + "Unliked" + "'", "tbl_AccountReport");
foreach (DataRow ds_item in ds.Tables[0].Rows)
{
string Photo_Id = ds_item.ItemArray[3].ToString();
Follower.Add(Photo_Id);
Follower = Follower.Distinct().ToList();
}
int sum = ds.Tables[0].Rows.Count;
DataTable dt = ds.Tables[0];
Dispatcher.Invoke(new Action(delegate
{
if (Follower.Count != 0)
{
Success_UnLike_Done.Foreground = Brushes.Green;
}
Success_UnLike_Done.Content = Follower.Count;
}));
}
catch (Exception ex)
{
GlobusLogHelper.log.Error("Error:" + ex.StackTrace);
}
}
示例2: MainWindow
public MainWindow()
{
InitializeComponent();
// lisataan comboBoxiin kaikki maat
List<string> KaikkiMaat = new List<string>();
List<string> Maat = new List<string>();
KaikkiMaat.Add("Kaikki");
XmlDocument doc = new XmlDocument();
doc.Load(Properties.Settings.Default.ViiniXML);
XmlNodeList nodes = doc.SelectNodes("viinikellari/wine/maa/text()");
foreach (XmlNode node in nodes)
{
KaikkiMaat.Add(node.Value);
}
Maat = KaikkiMaat.Distinct().ToList();
comboBox.ItemsSource = Maat;
}
示例3: FnvLoadpopup
public void FnvLoadpopup(string host, string modulname, List<string> Participants)
{
try
{
tblHost.Text = "";
tblModule.Text = "";
tblParticipants.Text = "";
tblHost.Text = "You are invited by " + host;
tblModule.Text = modulname;
var distpart = Participants.Distinct();
string[] part = distpart.ToArray<string>();
tblParticipants.Text = part[0];
for (int i = 1; i<part.Count(); i++)
{
tblParticipants.Text = tblParticipants.Text + "," + part[i];
}
this.Left = Convert.ToInt64(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Right) - 300;
this.Top = Convert.ToInt64(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom) - 180;
// ShowWindow();
objsb.Begin(this);
}
catch (Exception ex)
{
VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "FnvLoadpopup1()", "wndVMuktiPopup.xaml.cs");
}
}
示例4: BranchDetails
public BranchDetails()
{
DataTable dt = new DataTable();
using (var connection = DatabaseService.GetAccessConnection())
{
connection.Open();
dt = DatabaseService.GetDataTable("CityList");
connection.Close();
}
InitializeComponent();
List<string> cities = new List<string>();
foreach (DataRow row in dt.Rows)
{
cities.Add(row["City"].ToString());
}
cities.Distinct().ToList().ForEach(x => cbCity.Items.Add(x));
}
示例5: ChangeAttributeColor
public void ChangeAttributeColor(Models.Users users, string AttributeName, string value, double baseRate)
{
List<int> list = new List<int>();
foreach (var item in comunities.Where(n => n.UserIds != null))
{
list.AddRange(item.UserIds);
}
var rate = users.GetRate(AttributeName, value, list.Distinct());
if (rate != double.NaN)
{
var r = rate / baseRate;
if (r > 1.2)
{
NewBrush(Color.FromArgb(255, 231, 159, 190), 0.5);
}
else if (r < 0.8)
{
NewBrush(Color.FromArgb(255, 175,238, 238), 0.5);
}
else
{
NewBrush(Colors.White, 0.5);
}
}
else
{
NewBrush(Colors.White, 0.5);
}
}
示例6: btnCompare_Click
private void btnCompare_Click(object sender, RoutedEventArgs e)
{
Diffs = new List<XmlDifferences>();
var pathOld = string.Empty;
var pathNew = string.Empty;
if (SelectedFolders.IsFile)
{
pathOld = SelectedFolders.FolderOld;
pathNew = SelectedFolders.FolderNew;
CompareFiles(pathOld, pathNew);
}
else if (SelectedFolders.IsFolder)
{
if (SelectedFolders.IncludeSubFolders)
{
pathOld = SelectedFolders.FolderOld;
pathNew = SelectedFolders.FolderNew;
CompareFolderStructure(pathOld, pathNew, CompareAction.remove);
CompareFolderStructure(pathNew, pathOld, CompareAction.add);
}
else
{
pathOld = SelectedFolders.FolderOld;
pathNew = SelectedFolders.FolderNew;
AddOrRemoveFile(pathOld, pathNew, CompareAction.remove);
AddOrRemoveFile(pathNew, pathOld, CompareAction.add);
CompareFolderFiles(pathOld, pathNew);
}
}
grid.ItemsSource = null;
Diffs = Diffs.Distinct().OrderBy(i => i.Component).ToList();
grid.ItemsSource = Diffs;
}
示例7: tryTakeProducts
private List<Product> tryTakeProducts(string url, int Zaderzhka)
{
string page = "";
using (System.Net.WebClient web = new System.Net.WebClient())
{
web.Encoding = UTF8Encoding.Default;
string str1 = web.DownloadString(url);
str1 = System.Web.HttpUtility.HtmlDecode(str1);
var numArr = Regex.Matches(str1, @"itemsCount"":([0-9]{1,5}),")
.Cast<Match>()
.Select(m => m.Groups[1].Value)
.Distinct()
.ToArray();
int num = Int32.Parse(numArr[0]);
while (num >= 0)
{
num = num - 10;
string zagotovka = "http://vk.com/al_market.php?al=1&id=-$2&load=1&offset=" + num +
"&price_from=&price_to=&q=&sort=0";
_url = Regex.Replace(url, @"(http://vk.com/market-)(.+)", zagotovka);
string str = web.DownloadString(_url);
str = System.Web.HttpUtility.HtmlDecode(str);
page = page + str; //doc.DocumentNode.InnerHtml
Thread.Sleep(Zaderzhka);
}
//<div id="market_item24046" class="market_row">
//File.WriteAllText("C:\\Users\\Maxs\\Desktop\\www1.txt", page);
//div[@class='market_row_inner_cont']
List<Product> listProducts = new List<Product>();
var tempUrlToItems = Regex.Matches(page, @"name""><a href=""(/market-[0-9]{2,20}\?w=product-[0-9_]{2,35})")
.Cast<Match>()
.Select(m => m.Groups[1].Value)
.ToArray();
var tempIdToItems = Regex.Matches(page, @"<div id=""market_item([0-9]{1,9})"" class=""market_row"">")
.Cast<Match>()
.Select(m => m.Groups[1].Value)
.ToArray();
var tempNameToItems = Regex.Matches(page, @"<div class=""market_row_name""><a.*?>(.*?)</a")
.Cast<Match>()
.Select(m => m.Groups[1].Value)
.ToArray();
var tempPriceToItems = Regex.Matches(page, @"<div class=""market_row_price"">(.*?)</div>")
.Cast<Match>()
.Select(m => m.Groups[1].Value)
.ToArray();
Product product;
for (int i = 0; i < tempUrlToItems.Length; i++)
{
product = new Product();
product.Url = Regex.Replace(tempUrlToItems[i], @"/(market-[0-9]{2,20})\?w=(product-[0-9_]{2,35})",
"http://vk.com/wkview.php?act=show&al=1&loc=$1&w=$2");
product.Name = tempNameToItems[i];
product.Id = tempIdToItems[i];
//<div class="market_row_price">2<span class="num_delim"> </span>230 руб.</div>
product.Price = Regex.Replace(tempPriceToItems[i], @"(<div class=""market_row_price"".*?)([7-9]{1,7} руб.)(</div>)",
"$2");
listProducts.Add(product);
}
listProducts = listProducts.Distinct(new ProductComparer()).ToList();
str1 = System.Web.HttpUtility.HtmlDecode(str1);
//3<span class="num_delim"> </span>990 руб.
//</div> <div class="market_item_controls unshown">
foreach (var prod in listProducts)
{
prod.Price = Regex.Replace(prod.Price, @"<span class=""num_delim"">\s*?</span>",
" ");
string desc = web.DownloadString(prod.Url);
desc = System.Web.HttpUtility.HtmlDecode(desc);
prod.Desc = Regex.Replace(desc, @".*?<div class=""market_item_description"">[\n]*?\s+(.*?)</div>(.*?)<div class=""market_item_controls unshown"">.*",
"$1", RegexOptions.Singleline);
prod.Desc = Regex.Replace(prod.Desc, @"<.*?>", " ", RegexOptions.Singleline);
prod.Desc = Regex.Replace(prod.Desc, @"Показать полностью\.\.", "", RegexOptions.Singleline);
prod.Desc = Regex.Replace(prod.Desc, @"\s+", " ", RegexOptions.Singleline);
Thread.Sleep(Zaderzhka);
}
return listProducts;
}
}
示例8: FindImages
private static List<string> FindImages(string pageContent)
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(pageContent);
var listOfImageSources = new List<string>();
foreach (var node in doc.DocumentNode.SelectNodes("//img"))
{
var src = node.Attributes.FirstOrDefault(a => a.Name.ToLower() == "src");
if (src != null && !string.IsNullOrEmpty(src.Value))
{
listOfImageSources.Add(src.Value.ToLower());
}
}
return listOfImageSources.Distinct().ToList();
}
示例9: report_status
public void report_status()
{
try
{
List<string> lst_Unfollow = new List<string>();
DataSet ds = DataBaseHandler.SelectQuery("select * from tbl_AccountReport where ModuleName ='" + "UnfollowModule" + "' and Status='" + "Success" + "'", "tbl_AccountReport");
foreach (DataRow ds_item in ds.Tables[0].Rows)
{
string Photo_Id = ds_item.ItemArray[5].ToString();
lst_Unfollow.Add(Photo_Id);
lst_Unfollow = lst_Unfollow.Distinct().ToList();
}
int sum = ds.Tables[0].Rows.Count;
DataTable dt = ds.Tables[0];
Dispatcher.Invoke(new Action(delegate
{
if (lst_Unfollow.Count != 0)
{
User_Unfollow_success.Foreground = Brushes.Green;
}
User_Unfollow_success.Content = lst_Unfollow.Count;
}));
}
catch (Exception ex)
{
GlobusLogHelper.log.Error("Error:" + ex.StackTrace);
}
}
示例10: Rawler2XAML
public string Rawler2XAML(RawlerBase rawler)
{
StringBuilder xaml = new StringBuilder(System.Xaml.XamlServices.Save(rawler));
xaml = xaml.Replace("\"{x:Null}\"", "Null").Replace(" Enable=\"True\"","").Replace(" Comment=\"\"","");
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\w*=Null");
List<string> list = new List<string>();
foreach (System.Text.RegularExpressions.Match item in regex.Matches(xaml.ToString()))
{
list.Add(item.Value);
}
foreach (var item in list.Distinct())
{
xaml = xaml.Replace(" " + item, string.Empty);
}
return xaml.ToString();
}
示例11: load
private void load()
{
cmbStoreId.Items.Clear();
foreach (var r in Factory.Instance.i.Project.StoreInfo)
cmbStoreId.Items.Add(r.Id);
cmbExistAction.Items.Clear();
foreach (string s in Enum.GetNames(typeof(IntelliScraper.Db.saveIfExist)))
cmbExistAction.Items.Add(s);
if (rule != null)
{
txtTableName.Text = rule.tableName;
chkCheckExist.IsChecked = rule.checkExistBeforeSave;
txtCheckExistAttrs.Text = rule.checkExistAttributes;
txtCheckExistSeparator.Text = rule.checkExistAttributesSeparator;
cmbExistAction.SelectedValue = rule.ifExist.ToString();
cmbStoreId.SelectedValue = rule.storeId;
cmbStoreId_SelectionChanged(this, null);
if (rule.map != null)
{
dataGrid1.Items.Clear();
foreach(var m in rule.map)
dataGrid1.Items.Add(m);
}
cmbMapColName.Items.Clear();
var store = (from x in Factory.Instance.i.Project.StoreInfo where x.Id == rule.storeId select x).FirstOrDefault();
if (store != null)
{
if ((store.type == IntelliScraper.Db.intelliScraperProjectStoreInfoType.csv || store.type == IntelliScraper.Db.intelliScraperProjectStoreInfoType.excel) && store.CsvExcelSetting != null)
{
foreach (string s in store.CsvExcelSetting.csvHeader.Split(store.CsvExcelSetting.csvSeparator.ToCharArray()))
cmbMapColName.Items.Add(s);
}
}
cmbAttributes.Items.Clear();
List<string> attrs = new List<string>();
if (Factory.Instance.i.rules.xpathSingle != null)
{
foreach (var o in Factory.Instance.i.rules.xpathSingle)
{
foreach (var attr in o.attributes)
attrs.Add(attr.id);
}
}
if (Factory.Instance.i.rules.xpathCollection != null)
{
foreach (var c in Factory.Instance.i.rules.xpathCollection)
{
if(c.xpathSingle != null)
{
foreach (var attr in c.xpathSingle.attributes)
attrs.Add(attr.id);
}
}
}
attrs.Remove(string.Empty);
attrs = attrs.Distinct().ToList();
foreach(string attr in attrs)
cmbAttributes.Items.Add(attr);
}
}
示例12: chkTicket_Click
//自动提交订单--单击车次
void chkTicket_Click(object sender, RoutedEventArgs e)
{
List<string> lstTickets = new List<string>();
string strSeatTypes = "";
foreach (var chkItem in gridTickets.Children)
{
if (chkItem is CheckBox)
{
CheckBox chkTicket = chkItem as CheckBox;
if ((bool)chkTicket.IsChecked)
{
lstTickets.Add(chkTicket.Content.ToString());
if (lstTickets.Count() < 5)
{
strSeatTypes += chkTicket.Tag.ToString() + ",";
}
}
}
}
if (lstTickets.Count() > 5)
{
MessageBox.Show("选择车次数不能超过5个", "消息");
CheckBox chkObj = e.Source as CheckBox;
chkObj.IsChecked = false;
return;
}
var arrSeatType = strSeatTypes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
Dictionary<string, string> dicSeatTypes = new Dictionary<string, string>();
List<string> lstSeat = new List<string>();
for (int i = 0; i < arrSeatType.Count(); i++)
{
lstSeat.Add(arrSeatType[i]);
}
lstSeat = lstSeat.Distinct().ToList();
dicSeatTypes.Clear();
for (int s = 0; s < lstSeat.Count(); s++)
{
string seatValue = lstSeat[s] == "商务座" ? "9" : lstSeat[s] == "特等座" ? "P" : lstSeat[s] == "一等座" ? "M" : lstSeat[s] == "二等座" ? "O" : lstSeat[s] == "高级软卧" ? "6" : lstSeat[s] == "软卧" ? "4" : lstSeat[s] == "硬卧" ? "3" : lstSeat[s] == "软座" ? "2" : lstSeat[s] == "硬座" ? "1" : lstSeat[s] == "无座" ? "1" : "1";
dicSeatTypes.Add(lstSeat[s], seatValue);
}
int sRow = (int)Math.Ceiling((double)lstSeat.Count() / 6), sCell = 6;
while (sRow-- > 0)
{
gridSeatTypes.RowDefinitions.Add(new RowDefinition()
{
Height = new GridLength(15)
});
}
while (sCell-- > 0)
{
gridSeatTypes.ColumnDefinitions.Add(new ColumnDefinition()
{
Width = new GridLength()
});
}
gridSeatTypes.Children.Clear();
int sR = 0, sC = 0, sT = 0;
foreach (var d in dicSeatTypes)
{
CheckBox chkSeatType = new CheckBox()
{
Name = "chk" + d.Value,
Content = d.Key,
Tag = d.Value
};
chkSeatType.Click += chkSeatType_Click;
gridSeatTypes.Children.Add(chkSeatType);
if (sT > 0)
{
if (sT % 6 == 0)
{
sR += 1;
sC = 0;
}
else
{
sC++;
}
}
chkSeatType.SetValue(Grid.RowProperty, sR);
chkSeatType.SetValue(Grid.ColumnProperty, sC);
sT++;
}
}
示例13: MainWindow_OnActivated
private void MainWindow_OnActivated(object sender, EventArgs e)
{
if (FirstTimeActivated)
{
FirstTimeActivated = false;
//Try to login with the saved credentials.
if (!Auth.Login(Config.Instance.Username, Config.Instance.Password).Item1)
{
ShowLoginDialog();
}
else
{
OnLogin(Config.Instance.Username);
}
var allAssemblies = new List<LeagueSharpAssembly>();
foreach (var profile in Config.Instance.Profiles)
{
allAssemblies.AddRange(profile.InstalledAssemblies);
}
allAssemblies = allAssemblies.Distinct().ToList();
GitUpdater.ClearUnusedRepos(allAssemblies);
PrepareAssemblies(allAssemblies, Config.Instance.FirstRun || Config.Instance.UpdateOnLoad, true, true);
Remoting.Init();
}
var text = Clipboard.GetText();
if (text.StartsWith(LSUriScheme.FullName))
{
Clipboard.SetText("");
LSUriScheme.HandleUrl(text, this);
}
}
示例14: GetUniqueLines
private static Tuple<Point3D, Point3D>[] GetUniqueLines(IEnumerable<Tuple<Point3D, Point3D>> allLines)
{
List<Tuple<Point3D, Point3D>> intermediate = new List<Tuple<Point3D, Point3D>>();
// Put the "smaller" point as item1
foreach (var line in allLines)
{
if (line.Item1.X < line.Item2.X)
{
intermediate.Add(line);
}
else if (line.Item1.X == line.Item2.X)
{
if (line.Item1.Y < line.Item2.Y)
{
intermediate.Add(line);
}
else
{
intermediate.Add(Tuple.Create(line.Item2, line.Item1));
}
}
else
{
intermediate.Add(Tuple.Create(line.Item2, line.Item1));
}
}
return intermediate.Distinct().ToArray();
}
示例15: ShowReconstructTriangles
private void ShowReconstructTriangles(Point3D[] points)
{
//NOTE: This thinking is flawed (trying to reconstruct the triangle definitions based on the centers of the triangles) - I need this when instantiating a
//camera from dna, the original control points are lost (vertices of the triangles)
//
//Instead, I'll go with Voronoi around the original even dist points, which is a much cleaner design all around
Point3D[] points3D = points;//.Select(o => o.ToPoint()).ToArray();
Point[] points2D = points3D.Select(o => new Point(o.X, o.Y)).ToArray();
TriangleIndexed[] triangles = Math2D.GetDelaunayTriangulation(points2D, points3D);
var quickHull = Math2D.GetConvexHull(points);
bool[] isPerimiter = Enumerable.Range(0, points.Length).Select(o => quickHull.PerimiterLines.Contains(o)).ToArray();
var remaining = TriangleIndexed.GetUniqueLines(triangles).ToList();
#region First Pass
List<Tuple<int, int>> first = new List<Tuple<int, int>>();
for (int cntr = 0; cntr < points.Length; cntr++)
{
// Get the lines connected to this point
var connected = remaining.Where(o => o.Item1 == cntr || o.Item2 == cntr).
OrderBy(o => (points[o.Item2] - points[o.Item1]).LengthSquared).
ToArray();
if (connected.Length == 0)
{
continue;
}
// Of these, choose the shortest
first.Add(connected[0]);
}
first = first.Distinct().ToList();
foreach (var shrt in first)
{
remaining.Remove(shrt);
}
#endregion
#region Second Pass
List<Tuple<int, int>> second = new List<Tuple<int, int>>();
for (int cntr = 0; cntr < points.Length; cntr++)
{
int numConnected = first.Count(o => o.Item1 == cntr || o.Item2 == cntr);
if (numConnected > 3)
{
int seven = 8;
}
if (numConnected == 3)
{
continue;
}
if (isPerimiter[cntr] && numConnected == 2)
{
continue;
}
// This still needs connections
var connected = remaining.Where(o => o.Item1 == cntr || o.Item2 == cntr).
OrderBy(o => (points[o.Item2] - points[o.Item1]).LengthSquared).
ToArray();
if (connected.Length == 0)
{
continue;
}
// Of these, choose the shortest
second.Add(connected[0]);
}
second = second.Distinct().ToList();
foreach (var shrt in second)
{
remaining.Remove(shrt);
}
#endregion
#region Third Pass
List<Tuple<int, int>> third = new List<Tuple<int, int>>();
for (int cntr = 0; cntr < points.Length; cntr++)
{
int numConnected = first.Count(o => o.Item1 == cntr || o.Item2 == cntr);
numConnected += second.Count(o => o.Item1 == cntr || o.Item2 == cntr);
if (numConnected > 3)
//.........这里部分代码省略.........