Ejemplo n.º 1
0
 public OptionsForm( Engine engine, Options options, Categories categories )
 {
   _engine = engine;
   _categories = categories;
   _options = options;
   InitializeComponent();
 }
Ejemplo n.º 2
0
    public CustomUI(Engine engine, Categories categories, Options options )
    {
      // the engine.
      _engine = engine;

      // the categories.
      _categories = categories;

      // the options
      _options = options;
    }
Ejemplo n.º 3
0
    public MagnetMailItemForm( Engine engine, Outlook._MailItem mailItem, Categories categories )
    {
      // 
      InitializeComponent();

      // the engine to create new categories.
      _engine = engine;

      // the categories
      _categories = categories;

      // the mail item
      _mailItem = mailItem;
    }
Ejemplo n.º 4
0
    public MagnetForm( Engine engine, Categories categories, Magnet magnet  )
    {
      // 
      InitializeComponent();

      // the engine to create new categories.
      _engine = engine;

      // the category we working with.
      GivenMagnet = magnet;

      // the categories
      _Categories = categories;
    }
Ejemplo n.º 5
0
 public CategoriesForm( Categories categories, Engine engine)
 {
   _engine = engine;
   _categories = categories;
   InitializeComponent();
 }
Ejemplo n.º 6
0
    /// <summary>
    /// Guess the posible new category id 
    /// </summary>
    /// <param name="mailItem">the mail item itself.</param>
    /// <param name="categories">the categories tool we will use to re-categorise</param>
    /// <param name="currentCategoryId">The current value of the category</param>
    /// <returns>Categories.CategorizeResponse the new id or -1 if we don't know.</returns>
    protected async Task<Categories.CategorizeResponse> GuessPosibleCategory( _MailItem mailItem, int currentCategoryId, Categories categories )
    {
      var guessCategoryResponse = new Categories.CategorizeResponse
      {
        CategoryId = 0,
        WasMagnetUsed = false
      };

      if ( !_options.ReCheckIfCtrlKeyIsDown || (Control.ModifierKeys & Keys.Control) != Keys.Control)
      {
        // if we do not want to check options, then we don't want to do that.
        if ( !_options.ReCheckCategories )
        {
          return guessCategoryResponse;
        }

        // if we currently have a category and we only want to check the
        // unknown categories, then we musn't check.
        if (currentCategoryId != -1 && _options.CheckIfUnownCategory)
        {
          return guessCategoryResponse;
        }
      }

      var currentCursor = Cursor.Current;
      Cursor.Current = Cursors.WaitCursor;

      try
      {
        // guess where it could be going to now.
        if (mailItem != null)
        {
          guessCategoryResponse = await categories.CategorizeAsync(mailItem).ConfigureAwait(false);
        }
      }
      catch (Exception)
      {
        // @todo we need to log that there was an issue.
        guessCategoryResponse = new Categories.CategorizeResponse
        {
          CategoryId = 0,
          WasMagnetUsed = false
        };
      }

      // reset the cursor.
      Cursor.Current = currentCursor;
      
      // add a debug message.
      Debug.WriteLine(guessCategoryResponse.CategoryId != currentCategoryId
        ? $"My new classifying guess for this message is : {guessCategoryResponse.CategoryId}"
        : $"My classifying guess for this message is category remains the same : {guessCategoryResponse.CategoryId}");

      // return what we found
      return guessCategoryResponse;
    }