Exemplo n.º 1
0
        public override void Run()
        {
            string             fileName           = Application.StartupPath + Path.DirectorySeparatorChar + System.Configuration.ConfigurationSettings.AppSettings["HelpFileDirectory"].ToString();
            FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));

            if (fileUtilityService.TestFileExists(fileName))
            {
                Help.ShowHelp((Form)WorkbenchSingleton.Workbench, fileName);
            }
        }
        void startEvent(object sender, System.EventArgs e)
        {
            resultListView.BeginUpdate();
            resultListView.Items.Clear();
            switch (locationComboBox.SelectedIndex)
            {
            case 0: {                    // current file
                IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent;
                if (content != null)
                {
                    if (content.ContentName == null)
                    {
                        MessageBox.Show(ResourceService.GetString("Dialog.WordCountDialog.SaveTheFileWarning"), ResourceService.GetString("Global.WarningText"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
                        if (fileUtilityService.TestFileExists(content.ContentName))
                        {
                            resultListView.Items.Add(GetReport(content.ContentName).ToListItem());
                        }
                    }
                }
                break;
            }

            case 1: {                    // all open files
                if (WorkbenchSingleton.Workbench.ViewContentCollection.Count > 0)
                {
                    string tmp = "";

                    Report all = new Report(ResourceService.GetString("Dialog.WordCountDialog.TotalText"), 0, 0, 0);
                    foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection)
                    {
                        if (content.ContentName == null)
                        {
                            MessageBox.Show(ResourceService.GetString("Dialog.WordCountDialog.SaveAllFileWarning"), ResourceService.GetString("Global.WarningText"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            continue;
                        }
                        else
                        {
                            FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
                            if (fileUtilityService.TestFileExists(content.ContentName))
                            {
                                Report r = GetReport(content.ContentName);
                                tmp += r.ToString();
                                all += r;
                                resultListView.Items.Add(r.ToListItem());
                            }
                        }
                    }
                    resultListView.Items.Add(new ListViewItem(""));
                    resultListView.Items.Add(all.ToListItem());
                }
                break;
            }
            }
            resultListView.EndUpdate();
        }