示例#1
0
        private void TorrentsView_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect != DragDropEffects.Copy)
            {
                return;
            }

            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            foreach (string s in files)
            {
                if (s.EndsWith(".torrent", StringComparison.InvariantCultureIgnoreCase))
                {
                    try
                    {
                        mainController.Add(s);
                    }
                    catch (TorrentException ex)
                    {
                        MessageBox.Show(this, ex.Message, "Invalid Torrent", MessageBoxButtons.OK);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "Please report this exception:" + Environment.NewLine + Environment.NewLine + ex.ToString(),
                                        "Unhandled Exception", MessageBoxButtons.OK);
                    }
                }
            }
        }
示例#2
0
        // FIXME: Adding torrents not on the main loop, will throw up!
        // Solutions: Pop every add onto main loop resulting in blocking
        // or add async Load(uri, location) to library, or let the GUI
        // program handle downloading the torrent file
        public void AddTorrent(RssItem item, RssFilter filter)
        {
            history.Add(item);

            if (filter == null)
            {
                Console.Out.WriteLine("About to add with default savepath, URL: " + item.Link);
                try {
                    controller.Add(item.Link);
                } catch {
                    //logger.Error("RSS Manager: Unable to add - " + item.Title);
                }
            }
            else
            {
                Console.Out.WriteLine("About to add with custom savepath, Path: " + filter.SavePath);
                try{
                    controller.Add(item.Link, new TorrentSettings(), filter.SavePath);
                } catch {
                    //logger.Error("RSS Manager: Unabled to add - " + item.Title);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Обработка события со страницы - создание объекта
 /// </summary>
 /// <param name="obj"></param>
 private void Page_ItemCreated(INoteDisplayedData obj)
 {
     //если элемент был успешно добавлен запускаем внутренний таск
     var res = ctrl.Add(obj).ContinueWith(t =>
     {
         Debug.WriteLine("в главном потоке меняет GUI");
         //в главном потоке меняет GUI
         var innerTask = new Task(() =>
         {
             mainWinData.Add(obj);
             HidePage();
         },
                                  TaskCreationOptions.AttachedToParent);
         innerTask.Start(uiContext);
     }, TaskContinuationOptions.NotOnFaulted);
 }
示例#4
0
        public void AddTest()
        {
            int res = mc.Add(5, 3);

            Assert.Equals(res, "2");
        }