Code:
void Remove()
{
Word word = new Word();
try { word = FindWord(listView1.SelectedItems[0].Text); }
catch { return; }
if (listView1.SelectedItems.Count > 0)
{
try
{
foreach (ListViewItem eachItem in listView1.SelectedItems)
{
words.RemoveAll(x => x.WordOrPhrase == eachItem.Text);
listView1.Items[listView1.Items.Count - 1].Selected = true;
listView1.Items.Remove(eachItem);
}
}
catch { }
ClearAll();
ReadOnlyON();
}
else
{
MessageBox.Show("You have not selected any words!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
ReadOnlyOFF();
WordCount();
Sync();
}
private Word FindWord(string word)
{
return words.Find(x => x.WordOrPhrase == word);
}
void Remove()
{
Word word = new Word();
try { word = FindWord(listView1.SelectedItems[0].Text); }
catch { return; }
if (listView1.SelectedItems.Count > 0)
{
try
{
foreach (ListViewItem eachItem in listView1.SelectedItems)
{
words.RemoveAll(x => x.WordOrPhrase == eachItem.Text);
listView1.Items[listView1.Items.Count - 1].Selected = true;
listView1.Items.Remove(eachItem);
}
}
catch { }
ClearAll();
ReadOnlyON();
}
else
{
MessageBox.Show("You have not selected any words!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
ReadOnlyOFF();
WordCount();
Sync();
}
private Word FindWord(string word)
{
return words.Find(x => x.WordOrPhrase == word);
}
Evo sta sam uradio dosad:
Code:
def FindWord(word):
for x in words:
if x.WordOrPhrase == word:
return x
def FindWord(word):
for x in words:
if x.WordOrPhrase == word:
return x
Code:
def FindWord(word):
return next((x for x in words if x.WordOrPhrase == word), None)
def FindWord(word):
return next((x for x in words if x.WordOrPhrase == word), None)
Code:
def FindWord(word):
return next(filter(lambda x: x.WordOrPhrase == word, words), None)
def FindWord(word):
return next(filter(lambda x: x.WordOrPhrase == word, words), None)
Mucim se sa Remove() metodom:
Code:
def remove_item(self):
word = Word()
try:
word = find_word(self.listBox.get(ACTIVE))
except:
return
if self.listBox.get(ACTIVE) > 0:
try:
for item in self.listBox.get(ACTIVE):
self.words.remove(lambda x: x.wordorphrase == item.text)
self.listBox # listView1.Items[listView1.Items.Count - 1].Selected = true;
self.listBox.remove(item)
except:
pass
self.clear_all()
else:
pass
# show messagebox
def remove_item(self):
word = Word()
try:
word = find_word(self.listBox.get(ACTIVE))
except:
return
if self.listBox.get(ACTIVE) > 0:
try:
for item in self.listBox.get(ACTIVE):
self.words.remove(lambda x: x.wordorphrase == item.text)
self.listBox # listView1.Items[listView1.Items.Count - 1].Selected = true;
self.listBox.remove(item)
except:
pass
self.clear_all()
else:
pass
# show messagebox
[Ovu poruku je menjao wraith46 dana 13.04.2017. u 19:36 GMT+1]