Example #1
0
        private ToolStripMenuItem MapToToolStripMenuItem(QuickLaunchItem item)
        {
            var handlerInfo = _quickLaunchApi.GetHandlerInfo(item.Handler);
            var image       = _images[handlerInfo.HandlerKey];

            return(new ToolStripMenuItem(item.DisplayName, image, (s, e) => _quickLaunchApi.Handle(item)));
        }
Example #2
0
 public bool Handle(QuickLaunchItem item)
 {
     if (_handlers.TryGetValue(item.Handler, out var handler))
     {
         return(handler.Handle(item));
     }
     throw new Exception($"Could not find handler for type '{item.Handler}'");
 }
Example #3
0
 public void AddItem(QuickLaunchItem item)
 {
     item.Id = item.Id ?? Guid.NewGuid();
     if (_storage.items.Any(i => i.Id == item.Id))
     {
         throw new Exception("Duplicate id");
     }
     _storage.items.Add(item);
 }
Example #4
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     Item              = new QuickLaunchItem();
     Item.DisplayName  = textBoxDisplayName.Text;
     Item.Group        = textBoxGroup.Text;
     Item.Handler      = ((ComboBoxItem)comboBoxType.SelectedItem).Value.HandlerKey;
     Item.URI          = textBoxResource.Text;
     this.DialogResult = DialogResult.OK;
 }
        public override bool Handle(QuickLaunchItem item)
        {
            var startInfo = new ProcessStartInfo
            {
                FileName         = cmdPath,
                WorkingDirectory = item.URI
            };

            Process.Start(startInfo);
            return(true);
        }
Example #6
0
        public void UpdateItem(QuickLaunchItem item)
        {
            var _item = _storage.items.FirstOrDefault(i => i.Id == item.Id);

            if (item == null)
            {
                throw new Exception("Id doesn't exist");
            }
            _storage.items.Remove(_item);
            _storage.items.Add(item);
        }
Example #7
0
 public abstract bool Handle(QuickLaunchItem item);
Example #8
0
 public override bool Handle(QuickLaunchItem item)
 {
     Process.Start(item.URI);
     return(true);
 }
Example #9
0
 public bool Validate(QuickLaunchItem item)
 {
     return(!string.IsNullOrWhiteSpace(item.DisplayName) &&
            !string.IsNullOrWhiteSpace(item.URI) &&
            !string.IsNullOrWhiteSpace(item.Handler));
 }
Example #10
0
 public void AddItem(QuickLaunchItem item)
 {
     _repo.AddItem(item);
 }