コード例 #1
0
            public TagLabel(TagsListControl container, ContactTagViewModel tagViewModel)
            {
                _container    = container;
                _tagViewModel = tagViewModel;

                Text      = string.Format("#{0}", _tagViewModel.Name);
                ForeColor = _tagViewModel.Color;
                AutoSize  = true;
            }
コード例 #2
0
        private void OnMouseRightClick(object sender, MouseEventArgs e)
        {
            if (ContactsManager == null)
            {
                return;
            }

            var contextMenu = new ContextMenuStrip();

            foreach (var tag in ContactsManager.Tags)
            {
                var tagCopy = tag;
                var item    = new ToolStripMenuItem(string.Format("#{0}", tag.Name), null, (o, args) =>
                {
                    _contactViewModel.AddTag(tagCopy);
                    RefreshData();
                })
                {
                    ForeColor = ContactTagViewModel.ParseColor(tag.Color)
                };

                contextMenu.Items.Add(item);
            }

            contextMenu.Items.Add(new ToolStripSeparator());

            var label = sender as TagLabel;

            if (label != null && !label.TagViewModel.ReadOnly)
            {
                contextMenu.Items.Add(string.Format("Remove #{0}", label.TagViewModel.Name), null, (o, args) =>
                {
                    if (MessageBox.Show(string.Format("Remove tag '{0}' for '{1}'?", label.TagViewModel.Name, _contactViewModel.ShowedName), "Confirm tag delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        _contactViewModel.RemoveTag(label.TagViewModel);
                        RefreshData();
                    }
                });
            }

            var createItem = new ToolStripMenuItem("Create new tag");

            foreach (var item in ContactsManager.AddressBooks.Where(x => !x.ReadOnly))
            {
                createItem.DropDownItems.Add(new ToolStripMenuItem(string.Format("Create tag for {0}...", item.Name), null, CreateNewTag)
                {
                    Tag = item
                });
            }

            contextMenu.Items.Add(createItem);
            contextMenu.Show(Cursor.Position);
        }
コード例 #3
0
ファイル: TagForm.cs プロジェクト: modernstar/core
        public TagForm(ContactTagViewModel contactTagViewModel)
        {
            _contactTagViewModel = contactTagViewModel;

            InitializeComponent();

            ToolStripManager.Renderer = new ToolStripSystemRenderer();

            colorPicker.SelectedColor = _contactTagViewModel.Color;
            textboxName.Text          = _contactTagViewModel.Name;

            if (string.IsNullOrWhiteSpace(_contactTagViewModel.Name))
            {
                Text = "New tag";
            }
            else
            {
                Text = String.Format("Editing tag: {0}", _contactTagViewModel.Name);
            }
        }