/** -------------------------------------------------------------------- **/

        private void CallbackSaveKeywordAnalysisExcelReport(object sender, EventArgs e)
        {
            SaveFileDialog Dialog = new SaveFileDialog();

            Dialog.Filter           = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
            Dialog.FilterIndex      = 2;
            Dialog.RestoreDirectory = true;
            Dialog.DefaultExt       = "xlsx";
            Dialog.AddExtension     = true;
            Dialog.FileName         = "Macroscope-Keyword-Analysis.xlsx";

            this.Enabled = false;

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Path = Dialog.FileName;
                MacroscopeDoublePercentageProgressForm ProgressForm;
                MacroscopeExcelKeywordAnalysisReport   msExcelReport;

                ProgressForm  = new MacroscopeDoublePercentageProgressForm(MainForm: this);
                msExcelReport = new MacroscopeExcelKeywordAnalysisReport(ProgressFormDialogue: ProgressForm);

                Cursor.Current = Cursors.WaitCursor;

                try
                {
                    msExcelReport.WriteXslx(this.JobMaster, Path);
                }
                catch (MacroscopeSaveExcelFileException ex)
                {
                    this.DialogueBoxError("Error saving Keyword Analysis Excel Report", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Keyword Analysis Excel Report", ex.Message);
                }
                finally
                {
                    ProgressForm.DoClose();
                    Cursor.Current = Cursors.Default;
                }
            }

            if (Dialog != null)
            {
                Dialog.Dispose();
            }

            this.Enabled = true;
        }
Пример #2
0
        /**************************************************************************/

        private void RenderKeywordAnalysisListView(
            List <ListViewItem> ListViewItems,
            ListView TargetListView,
            Dictionary <string, int> DicTerms,
            MacroscopeDoublePercentageProgressForm ProgressForm
            )
        {
            if (TargetListView.IsDisposed)
            {
                return;
            }

            decimal Count           = 0;
            decimal TotalTerms      = ( decimal )DicTerms.Count;
            decimal MinorPercentage = 0;

            if (TotalTerms <= 0)
            {
                return;
            }

            try
            {
                foreach (string KeywordTerm in DicTerms.Keys)
                {
                    string       PairKey = KeywordTerm;
                    ListViewItem lvItem  = null;

                    if (TargetListView.Items.ContainsKey(PairKey))
                    {
                        try
                        {
                            lvItem = TargetListView.Items[PairKey];
                            lvItem.SubItems[0].Text = DicTerms[KeywordTerm].ToString();
                            lvItem.SubItems[1].Text = KeywordTerm;
                        }
                        catch (Exception ex)
                        {
                            DebugMsg(string.Format("MacroscopeDisplayStructureKeywordAnalysis 1: {0}", ex.Message));
                        }
                    }
                    else
                    {
                        try
                        {
                            lvItem = new ListViewItem(PairKey);
                            lvItem.UseItemStyleForSubItems = false;
                            lvItem.Name = PairKey;

                            lvItem.SubItems[0].Text = DicTerms[KeywordTerm].ToString();
                            lvItem.SubItems.Add(KeywordTerm);

                            ListViewItems.Add(lvItem);
                        }
                        catch (Exception ex)
                        {
                            DebugMsg(string.Format("MacroscopeDisplayStructureKeywordAnalysis 2: {0}", ex.Message));
                        }
                    }

                    if (lvItem != null)
                    {
                        lvItem.ForeColor = Color.Blue;
                    }

                    Count++;
                    MinorPercentage = (( decimal )100 / TotalTerms) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: -1,
                        ProgressLabelMajor: null,
                        MinorPercentage: MinorPercentage,
                        ProgressLabelMinor: string.Format("Keyword: {0}", Count)
                        );

                    Application.DoEvents();

                    if (ProgressForm.Cancelled())
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                DebugMsg(string.Format("MacroscopeDisplayStructureKeywordAnalysis 3: {0}", ex.Message));
            }
        }
Пример #3
0
        /**************************************************************************/

        public void RefreshKeywordAnalysisDataProgress(MacroscopeDocumentCollection DocCollection)
        {
            MacroscopeDoublePercentageProgressForm ProgressForm = new MacroscopeDoublePercentageProgressForm(this.MainForm);

            decimal MajorPercentage = 0;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing keyword terms collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: "",
                    MinorPercentage: 0,
                    ProgressLabelMinor: ""
                    );
            }

            try
            {
                ProgressForm.TopMost = true;
            }
            catch (Exception ex)
            {
                DebugMsg(string.Format("ProgressForm.Show(): {0}", ex.Message));
            }

            for (int i = 0; i <= 3; i++)
            {
                List <ListViewItem> ListViewItems = new List <ListViewItem> (DocCollection.CountDocuments());

                Application.DoEvents();

                if (!ProgressForm.Cancelled())
                {
                    Dictionary <string, int> DicTerms = DocCollection.GetDeepKeywordAnalysisAsDictonary(Words: i + 1);


                    if (MacroscopePreferencesManager.GetShowProgressDialogues())
                    {
                        MajorPercentage = (( decimal )100 / ( decimal )4) * ( decimal )(i + 1);

                        ProgressForm.UpdatePercentages(
                            Title: null,
                            Message: null,
                            MajorPercentage: MajorPercentage,
                            ProgressLabelMajor: string.Format("{0} Word Keywords", i + 1),
                            MinorPercentage: 0,
                            ProgressLabelMinor: ""
                            );
                    }

                    this.TargetListViews[i].BeginUpdate();

                    this.RenderKeywordAnalysisListView(
                        ListViewItems: ListViewItems,
                        TargetListView: this.TargetListViews[i],
                        DicTerms: DicTerms,
                        ProgressForm: ProgressForm
                        );

                    this.TargetListViews[i].Items.AddRange(ListViewItems.ToArray());

                    this.TargetListViews[i].EndUpdate();
                }
            }

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }