private void CreateListCommands(IEnumerable <ToolbarCommand> toolbars) { this.CreateListCurrentCommands(toolbars); this.listAvailableActions.Items.Clear(); KryptonListItem item = new KryptonListItem(separator); item.Image = new Bitmap(16, 16); this.listAvailableActions.Items.Add(item); foreach (Command cmd in this.commands.Keys) { if (!this.IsCurrentCommand(cmd)) { item = new KryptonListItem(this.commands[cmd].Text); item.Tag = cmd; if (string.IsNullOrEmpty(cmd.ImageKey)) { item.Image = new Bitmap(16, 16); } else { item.Image = CommandImageCollection.GetImage(cmd.DefaultImageKey); } this.listAvailableActions.Items.Add(item); } } }
private void MoveToCurrentActions() { KryptonListItem item = (KryptonListItem)this.listAvailableActions.SelectedItem; int index = this.listAvailableActions.SelectedIndex; Command cmd = (Command)item.Tag; if (cmd != null) { this.listAvailableActions.Items.Remove(item); if (cmd.ImageKey != cmd.DefaultImageKey) { if (this.changedImages.ContainsKey(cmd)) { this.changedImages[cmd] = cmd.DefaultImageKey; } else { this.changedImages.Add(cmd, cmd.DefaultImageKey); } } } this.listCurrentActions.Items.Add(item); if (index >= this.listAvailableActions.Items.Count) { index--; } this.listAvailableActions.SelectedIndex = index; this.Changed = true; }
//增加一条提醒。flag=true系统提醒;flag=false自定义提醒 private void AddOneAlarmMsg(提醒 tx, bool flag) { KryptonListItem item = new KryptonListItem(); if (flag)//系统提醒 { item.Image = Resources.idea_16; item.ShortText = tx.事项; item.LongText = "【系统提醒】"; } else//自定义提醒 { var yf = context.源房.FirstOrDefault(m => m.ID == tx.源房ID); var kf = context.客房.FirstOrDefault(m => m.ID == tx.客房ID); item.ShortText = tx.ToString(); item.Tag = tx;//自定义提醒的tag保留对象引用,双击会发生响应。 if (kf == null) { item.LongText = string.Format("{0}【源房提醒】", yf.房名); item.Image = Resources.源房16; } else { item.LongText = string.Format("{0} - {1}【客房提醒】", yf.房名, kf.命名); item.Image = Resources.客房16; } } DoThreadSafe(delegate { kryptonListBox1.Items.Add(item); }); }
private void DeleteCurrentAction() { KryptonListItem item = (KryptonListItem)this.listCurrentActions.SelectedItem; int index = this.listCurrentActions.SelectedIndex; Command cmd = (Command)item.Tag; this.listCurrentActions.Items.Remove(item); if (cmd != null) { if (this.changedImages.ContainsKey(cmd)) { this.changedImages.Remove(cmd); } item.Image = CommandImageCollection.GetImage(cmd.DefaultImageKey); this.listAvailableActions.Items.Add(item); } if (index >= this.listCurrentActions.Items.Count) { index--; } this.listCurrentActions.SelectedIndex = index; this.Changed = true; }
private void InitCheckListBox() { { var item = new KryptonListItem(); item.ShortText = "重要度高"; item.Tag = MemoImportanceKind.High; item.Image = Resources.sticky_note_important; _importanceCheckedListBox.Items.Add(item); } { var item = new KryptonListItem(); item.ShortText = "重要度普通"; item.Tag = MemoImportanceKind.Normal; item.Image = Resources.sticky_note; _importanceCheckedListBox.Items.Add(item); } { var item = new KryptonListItem(); item.ShortText = "重要度低"; item.Tag = MemoImportanceKind.Low; item.Image = Resources.sticky_note_unimportant; _importanceCheckedListBox.Items.Add(item); } }
private object CreateNewItem() { KryptonListItem item = new KryptonListItem(); item.ShortText = "Item " + (_next++).ToString(); item.LongText = "(" + _rand.Next(Int32.MaxValue).ToString() + ")"; item.Image = imageList.Images[_rand.Next(imageList.Images.Count - 1)]; return(item); }
private object CreateNewItem(string itemname) { KryptonListItem item = new KryptonListItem(); item.ShortText = Path.GetFileNameWithoutExtension(itemname); item.LongText = "(" + "Hotkey Profile" + ")"; item.Image = imageList1.Images[0]; return(item); }
private object CreateNewItem() { KryptonListItem item = new KryptonListItem { ShortText = $"Item {(_next++)}", LongText = $"({_rand.Next(Int32.MaxValue)})", Image = imageList.Images[_rand.Next(imageList.Images.Count - 1)] }; return(item); }
void TextNameTextChanged(object sender, EventArgs e) { if (listLang.SelectedIndex != -1 && !updating) { KryptonListItem item = (KryptonListItem)listLang.Items[listLang.SelectedIndex]; Language language = (Language)item.Tag; language.AlternateName = textName.Text.NullIfEmpty(); RefreshLanguageProperty(language); } }
private void MoveItemDown() { KryptonListBox list = this.CurrentListBox; KryptonListItem item = (KryptonListItem)list.SelectedItem; int index = list.SelectedIndex; list.Items.RemoveAt(index); list.Items.Insert(index + 1, item); list.SelectedItem = item; this.Changed = true; }
void ButtonDeleteTenseClick(object sender, EventArgs e) { if (listLang.SelectedIndex != -1 && listTenses.SelectedIndex != -1) { Tense selected_tense = (Tense)listTenses.SelectedItem; KryptonListItem item = (KryptonListItem)listLang.Items[listLang.SelectedIndex]; Language language = (Language)item.Tag; language.RemoveTense(selected_tense); listTenses.Items.Remove(selected_tense); } }
void ButtonAddTenseClick(object sender, EventArgs e) { if (listLang.SelectedIndex != -1) { string tenseName; if (EditValueDialog.ShowDialog(this, Strings.TenseNameHeader, Strings.TenseNameEnter, string.Empty, out tenseName)) { KryptonListItem item = (KryptonListItem)this.listLang.Items[this.listLang.SelectedIndex]; Language language = (Language)item.Tag; listTenses.Items.Add(language.AddTense(tenseName)); } } }
private void InitMarkDefCheckListBox() { var defs = MemoMarkUtil.GetMemoMarkDefinitions(); foreach (var def in defs) { var item = new KryptonListItem(); item.ShortText = def.Name; item.Image = def.Image; item.Tag = def; _markDefinitionCheckedListBox.Items.Add(item); } }
void ComboFlagSelectedIndexChanged(object sender, EventArgs e) { if (comboFlag.SelectedIndex != -1 && listLang.SelectedIndex != -1 && !updating) { KryptonListItem item = (KryptonListItem)listLang.Items[listLang.SelectedIndex]; Language language = (Language)item.Tag; language.ImageKey = comboFlag.Text + ".ico"; AddItem(item, language); RefreshLanguageProperty(language); } }
KryptonListItem AddItem(Language language) { adding = true; try { KryptonListItem item = CreateItem(language); listLang.Items.Add(item); return(item); } finally { adding = false; } }
private void button1_Click(object sender, EventArgs e) { //authorList1.Items.RemoveAt(authorList1.Items.Count - 1); try { KryptonListItem it = (KryptonListItem)authorList1.SelectedItem; authorList1.Items.Remove(it); auths.Remove(auths.Find(x => x.first + " " + x.middle + " " + x.last == it.ShortText)); } catch (NullReferenceException ex) { //do nothing } }
void ComboLangSelectedIndexChanged(object sender, EventArgs e) { if (comboLang.SelectedIndex != -1 && listLang.SelectedIndex != -1 && !updating) { Culture culture = (Culture)comboLang.Items[comboLang.SelectedIndex]; KryptonListItem item = (KryptonListItem)listLang.Items[this.listLang.SelectedIndex]; Language language = languages.SingleOrDefault <Language>(x => x.CultureIdentifier == culture.Id) ?? new Language(culture); theme.ReplaceLanguage((Language)item.Tag, language); AddItem(item, language); RefreshLanguageProperty(language); } }
public void kryptonListBox1_MouseDoubleClick(object sender, MouseEventArgs e) { //编辑提醒 if (e.Button == System.Windows.Forms.MouseButtons.Left && kryptonListBox1.SelectedItem != null) { KryptonListItem item = kryptonListBox1.SelectedItem as KryptonListItem; if (item.Tag != null) { 提醒 obj = item.Tag as 提醒; using (提醒Form form = new 提醒Form(obj)) { form.ShowDialog(this); } } } }
void ButtonChangeTenseClick(object sender, EventArgs e) { if (listLang.SelectedIndex != -1 && listTenses.SelectedIndex != -1) { string tenseName; Tense selected_tense = (Tense)listTenses.SelectedItem; if (EditValueDialog.ShowDialog(this, Strings.TenseNameHeader, Strings.TenseNameEnter, selected_tense.Name, out tenseName)) { KryptonListItem item = (KryptonListItem)listLang.Items[this.listLang.SelectedIndex]; Language language = (Language)item.Tag; selected_tense.Name = tenseName; listTenses.Refresh(); } } }
// ------------------------------ // private // ------------------------------ private void UpdateRecentlyClosedListBox() { _recentlyClosedListBox.SuspendLayout(); _recentlyClosedListBox.Items.Clear(); foreach (var info in _facade.RecentlyClosedMemoInfos.Reverse()) { var item = new KryptonListItem(); item.ShortText = info.Title; item.Image = Resources.sticky_note; item.Tag = info; _recentlyClosedListBox.Items.Add(item); } _recentlyClosedListBox.ResumeLayout(); }
private object CreateNewItem(string fln) { KryptonListItem item = new KryptonListItem(); //item.ShortText = "Item " + (_next++).ToString(); item.ShortText = fln; //if (item.ShortText.ToString().Contains(".mgz")) //{ // item.LongText = "(" + "mgz" + ")"; //} //else if (item.ShortText.ToString().Contains(".mgx")) //{ // item.LongText = "(" + "mgx" + ")"; //} item.Image = imageList.Images[0]; return(item); }
void ComboDictsSelectedIndexChanged(object sender, EventArgs e) { if (this.listLang.SelectedIndex != -1) { KryptonListItem item = (KryptonListItem)listLang.Items[listLang.SelectedIndex]; Language language = (Language)item.Tag; if (comboDicts.SelectedIndex != -1) { ISpellDictionary d = (ISpellDictionary)comboDicts.Items[comboDicts.SelectedIndex]; language.DictionaryLocale = d.Locale; } else { language.DictionaryLocale = null; } } }
KryptonListItem AddItem(KryptonListItem replaced, Language language) { adding = true; try { KryptonListItem item = CreateItem(language); int selected = listLang.SelectedIndex; int index = listLang.Items.IndexOf(replaced); listLang.Items.Remove(replaced); listLang.Items.Insert(index, item); listLang.SelectedIndex = selected; return(item); } finally { adding = false; } }
protected override void RunOnce() { host.MainMenu["View"].Items.AddCommand("ViewGrades", "ColumnsSeparator", Strings.Grades, new ViewWindowCommand(this)); for (int grade = 7; grade > 0; grade--) { KryptonListItem item = new KryptonListItem() { ShortText = $"{Strings.LevelNumber} {grade}", LongText = 0.ToString(CultureInfo.InvariantCulture), Image = host.Settings.View.UseGradeColors.Enabled ? GetBitmap(grade) : null, Tag = grade }; listGrades.Items.Add(item); } vocabularyWindow.GradeContentModified += (sender, e) => Update(e.Entities); vocabularyWindow.WordsSelected += (sender, e) => Update(e.Words); }
private void UpdateSmartFilterListBox() { _smartFilterListBox.BeginUpdate(); _smartFilterListBox.Sorted = false; _smartFilterListBox.SelectedIndices.Clear(); _smartFilterListBox.Items.Clear(); var app = MemopadApplication.Instance; var filters = app.Container.FindAll <MemoSmartFilter>(); foreach (var filter in filters) { var item = new KryptonListItem(filter.Name); item.Tag = filter; _smartFilterListBox.Items.Add(item); } _smartFilterListBox.Sorted = true; _smartFilterListBox.EndUpdate(); }
private void CreateListCurrentCommands(IEnumerable <ToolbarCommand> toolbars) { this.listCurrentActions.Items.Clear(); this.styles.Clear(); KryptonListItem item; foreach (ToolbarCommand cmd in toolbars) { if (cmd.Command.IsSeparator) { item = new KryptonListItem(separator); } else { item = new KryptonListItem(this.commands[cmd.Command].Text); item.Tag = cmd.Command; } if (string.IsNullOrEmpty(cmd.Command.ImageKey)) { item.Image = new Bitmap(16, 16); } else { if (this.changedImages.ContainsKey(cmd.Command)) { item.Image = CommandImageCollection.GetImage(this.changedImages[cmd.Command]); } else { item.Image = CommandImageCollection.GetImage(cmd.Command.ImageKey); } } this.listCurrentActions.Items.Add(item); this.styles.Add(cmd.Command, cmd.DisplayStyle); } }
private void ButtonChangeIconClick(object sender, EventArgs e) { KryptonListItem item = (KryptonListItem)this.listCurrentActions.SelectedItem; if (item.Tag != null) { Command cmd = (Command)item.Tag; string newImage = ImagesDialog.Show(); if (!string.IsNullOrEmpty(newImage)) { item.Image = CommandImageCollection.GetImage(newImage); if (this.changedImages.ContainsKey(cmd)) { this.changedImages[cmd] = newImage; } else { this.changedImages.Add(cmd, newImage); } } this.Changed = true; } }
public void PopulateDatabaseFilter() { if (InvokeRequired) { this.BeginInvoke(new Action(PopulateDatabaseFilter)); return; } comboBoxSearchKeyword.Text = ""; comboBoxSearchKeyword.Items.Clear(); comboBoxSearchKeyword.Items.Add("Example1;Example2"); List <string> albums = databaseAndCacheMetadataExiftool.ListAllPersonalAlbumsCache(MetadataBrokerType.ExifTool); albums.Sort(); FilterReplaceNullWithIsNotDefineText(albums); comboBoxSearchAlbum.SuspendLayout(); comboBoxSearchAlbum.Text = null; comboBoxSearchAlbum.Items.Clear(); comboBoxSearchAlbum.Items.AddRange(albums.ToArray()); comboBoxSearchAlbum.ResumeLayout(); //List<string> authors = databaseAndCacheMetadataExiftool.ListAllPersonalAuthors(MetadataBrokerType.ExifTool); //authors.Sort(); //ListViewRemoveNull(authors); //comboBoxSearchAuthor.Items.Clear(); //comboBoxSearchAuthor.Items.AddRange(authors.ToArray()); List <string> comments = databaseAndCacheMetadataExiftool.ListAllPersonalCommentsCache(MetadataBrokerType.ExifTool); comments.Sort(); FilterReplaceNullWithIsNotDefineText(comments); comboBoxSearchComments.SuspendLayout(); comboBoxSearchComments.Text = ""; comboBoxSearchComments.Items.Clear(); comboBoxSearchComments.Items.AddRange(comments.ToArray()); comboBoxSearchComments.ResumeLayout(); List <string> descriptions = databaseAndCacheMetadataExiftool.ListAllPersonalDescriptionsCache(MetadataBrokerType.ExifTool); descriptions.Sort(); FilterReplaceNullWithIsNotDefineText(descriptions); comboBoxSearchDescription.SuspendLayout(); comboBoxSearchDescription.Text = ""; comboBoxSearchDescription.Items.Clear(); comboBoxSearchDescription.Items.AddRange(descriptions.ToArray()); comboBoxSearchDescription.ResumeLayout(); List <string> titles = databaseAndCacheMetadataExiftool.ListAllPersonalTitlesCache(MetadataBrokerType.ExifTool); titles.Sort(); FilterReplaceNullWithIsNotDefineText(titles); comboBoxSearchTitle.SuspendLayout(); comboBoxSearchTitle.Text = ""; comboBoxSearchTitle.Items.Clear(); comboBoxSearchTitle.Items.AddRange(titles.ToArray()); comboBoxSearchTitle.ResumeLayout(); List <string> locations = databaseAndCacheMetadataExiftool.ListAllLocationNamesCache(MetadataBrokerType.ExifTool); locations.Sort(); FilterReplaceNullWithIsNotDefineText(locations); comboBoxSearchLocationName.SuspendLayout(); comboBoxSearchLocationName.Text = ""; comboBoxSearchLocationName.Items.Clear(); comboBoxSearchLocationName.Items.AddRange(locations.ToArray()); comboBoxSearchLocationName.ResumeLayout(); List <string> cities = databaseAndCacheMetadataExiftool.ListAllLocationCitiesCache(MetadataBrokerType.ExifTool); cities.Sort(); FilterReplaceNullWithIsNotDefineText(cities); comboBoxSearchLocationCity.SuspendLayout(); comboBoxSearchLocationCity.Text = ""; comboBoxSearchLocationCity.Items.Clear(); comboBoxSearchLocationCity.Items.AddRange(cities.ToArray()); comboBoxSearchLocationCity.ResumeLayout(); List <string> states = databaseAndCacheMetadataExiftool.ListAllLocationStatesCache(MetadataBrokerType.ExifTool); states.Sort(); FilterReplaceNullWithIsNotDefineText(states); comboBoxSearchLocationState.SuspendLayout(); comboBoxSearchLocationState.Text = ""; comboBoxSearchLocationState.Items.Clear(); comboBoxSearchLocationState.Items.AddRange(states.ToArray()); comboBoxSearchLocationState.ResumeLayout(); List <string> countries = databaseAndCacheMetadataExiftool.ListAllLocationCountriesCache(MetadataBrokerType.ExifTool); countries.Sort(); FilterReplaceNullWithIsNotDefineText(countries); comboBoxSearchLocationCountry.SuspendLayout(); comboBoxSearchLocationCountry.Text = ""; comboBoxSearchLocationCountry.Items.Clear(); comboBoxSearchLocationCountry.Items.AddRange(countries.ToArray()); comboBoxSearchLocationCountry.ResumeLayout(); List <string> peoples = databaseAndCacheMetadataExiftool.ListAllPersonalRegionNameCache(MetadataBrokerType.ExifTool); peoples.Sort(); FilterReplaceNullWithIsNotDefineText(peoples); checkedListBoxSearchPeople.SuspendLayout(); checkedListBoxSearchPeople.Items.Clear(); foreach (string people in peoples) { KryptonListItem item = new KryptonListItem(); item.ShortText = people; item.LongText = ""; Image image = databaseAndCacheMetadataExiftool.ReadRandomThumbnailFromCacheOrDatabase(people); if (image != null) { item.Image = image; } checkedListBoxSearchPeople.Items.Add(item); } if (checkedListBoxSearchPeople.Items.Count == 0) { checkedListBoxSearchPeople.Items.Insert(0, "No people added yet"); checkedListBoxSearchPeople.SelectedItem = checkedListBoxSearchPeople.Items[0]; } checkedListBoxSearchPeople.ResumeLayout(); }