예제 #1
0
        /// <summary>
        /// Analyzes selected item and create folders scores for it.
        /// </summary>
        /// <param name="item">Selected item</param>
        public static async void SelectionChanged(IOutlookItem item)
        {
            try
            {
                SelectedItem = item;
                var r = item.GetText();
                var s = item.GetSubject();
                SelectedMailScores = await Task.Run(() => GetScoresForMail(item));

                var myRibbon = Globals.Ribbons.MainRibbon;
                myRibbon.menuChoose.Enabled   = SelectedMailScores.Count > 0;
                myRibbon.btnFileEmail.Enabled = SelectedMailScores.Count > 0;
                myRibbon.btnChoose1.Visible   = SelectedMailScores.Count > 0;
                myRibbon.btnNdOpt.Enabled     = SelectedMailScores.Count > 1;
                myRibbon.btnChoose2.Visible   = SelectedMailScores.Count > 1;
                myRibbon.btnRdOpt.Enabled     = SelectedMailScores.Count > 2;
                myRibbon.btnChoose3.Visible   = SelectedMailScores.Count > 2;
                myRibbon.btnChoose4.Visible   = SelectedMailScores.Count > 3;
                myRibbon.btnChoose5.Visible   = SelectedMailScores.Count > 4;

                myRibbon.btnFileEmail.Label = SelectedMailScores.Count > 0 ? SelectedMailScores.First().Key : "";
                myRibbon.btnNdOpt.Label     = SelectedMailScores.Count > 1 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(1).Key) : "";
                myRibbon.btnRdOpt.Label     = SelectedMailScores.Count > 2 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(2).Key) : "";
                myRibbon.btnChoose1.Label   = SelectedMailScores.Count > 0 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.First().Key) : "";
                myRibbon.btnChoose2.Label   = SelectedMailScores.Count > 1 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(1).Key) : "";
                myRibbon.btnChoose3.Label   = SelectedMailScores.Count > 2 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(2).Key) : "";
                myRibbon.btnChoose4.Label   = SelectedMailScores.Count > 3 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(3).Key) : "";
                myRibbon.btnChoose5.Label   = SelectedMailScores.Count > 4 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(4).Key) : "";
            }
            catch (System.Exception ex)
            {
                MyMessageBox.Show("Error occured when selection changed. Error: " + ex);
            }
        }
예제 #2
0
파일: StoreModel.cs 프로젝트: kremda/Fodler
        /// <summary>
        /// Return scores for item.
        /// </summary>
        /// <param name="item">Item to be analyzed</param>
        public Dictionary <string, double> GetScoresForMail(IOutlookItem item)
        {
            if (item != null && Accord.IsReady())
            {
                var input   = item.GetInput();
                var subject = item.GetSubject();
                var text    = item.GetText();
                var results = Accord.DecideFolder(input, subject, text);
                return(results);
            }

            return(new Dictionary <string, double>());
        }