예제 #1
0
        /// <summary>
        /// Called by Paratext when the menu item created for this plugin was clicked.
        /// </summary>
        private void Run(IPluginHost host, IParatextChildState windowState)
        {
            AddLogEntryDialog dialog = new AddLogEntryDialog();

            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                List <string> stringParams = new List <string>();
                if (string.IsNullOrEmpty(dialog.Param1) == false)
                {
                    stringParams.Add(dialog.Param1);
                }
                if (string.IsNullOrEmpty(dialog.Param2) == false)
                {
                    stringParams.Add(dialog.Param2);
                }
                if (string.IsNullOrEmpty(dialog.Param3) == false)
                {
                    stringParams.Add(dialog.Param3);
                }
                host.Log(this, dialog.LogString, stringParams.ToArray());

                if (dialog.FlushToDisk)
                {
                    host.FlushLog();
                }
            }
            dialog.Dispose();
        }
예제 #2
0
        /// <summary>
        /// Called by Paratext when the menu item created for this plugin was clicked.
        /// </summary>
        private static void Run(IPluginHost host, IParatextChildState state)
        {
            var    activeProjectName = host.ActiveWindowState?.Project?.ShortName;
            string message           = string.IsNullOrEmpty(activeProjectName) ?
                                       "You clicked the menu item when there was no active project." :
                                       $"You clicked the menu item while the {activeProjectName} project was active.";

            MessageBox.Show(message, "Paratext Menu Plugin Demo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #3
0
        private void ActiveWindowSelectionChanged(IPluginHost host, IParatextChildState activeWindowState, IReadOnlyList <ISelection> currentSelections)
        {
            if (activeWindowState.Project == null)
            {
                textBox.Text = "Active window does not have a project associated with it.";
                return;
            }

            if (false == activeWindowState.Project.Equals(m_project))
            {
                textBox.Text = "Active window is for a different project.";
                return;
            }

            if (currentSelections == null)
            {
                textBox.Text = "Nothing selected.";
                return;
            }

            var           texts = currentSelections.OfType <IScriptureTextSelection>();
            List <string> lines = new List <string>();

            lines.Add($"There are {currentSelections.Count} current selections");
            lines.Add($"There are {texts.Count()} text selections");
            foreach (var text in texts)
            {
                lines.Add($"Selection starts at {text.VerseRefStart.BookCode} {text.VerseRefStart.ChapterNum}:{text.VerseRefStart.VerseNum}");
                lines.Add($"Selection ends at {text.VerseRefEnd.BookCode} {text.VerseRefEnd.ChapterNum}:{text.VerseRefEnd.VerseNum}");
                lines.Add(text.SelectedText);
            }

            if (lines.Count == 0)
            {
                textBox.Text = "Selection has no text selected";
                return;
            }

            if ((lines.Count == 1) && (lines[0].Length == 0))
            {
                textBox.Text = "Selection is empty";
                return;
            }

            textBox.Lines = lines.ToArray();
        }
예제 #4
0
        private void SetSelectedText(IParatextChildState activeWindowState, IReadOnlyList <ISelection> selections = null)
        {
            if (activeWindowState.Project != null && !activeWindowState.Project.Equals(m_project))
            {
                m_selectedText = "Active window is for a different project";
            }
            else
            {
                if (selections == null)
                {
                    selections = m_host.ActiveWindowState.Selections;
                }

                if (selections == null)
                {
                    m_selectedText = "Nothing selected";
                }
                else if (selections.Any(s => s is IReferenceListItem) && !m_host.ReferenceList.Project.Equals(m_project))
                {
                    // Note that while a reference list has its project set based on the one that originally "created"
                    // it, more items can be added to later it based on a differnet project. While this is unusual, it
                    // means that m_host.ReferenceList.Project is only kind of informative and it not 100% reliable. The
                    // items themselves do not remember which project they were created for.
                    m_selectedText = "Reference list is for a different project";
                }
                else
                {
                    // TODO: Only include whole words.
                    m_selectedText = string.Join(" ", selections.OfType <IScriptureTextSelection>().Select(s => s.SelectedText));
                    if (string.IsNullOrWhiteSpace(m_selectedText))
                    {
                        m_selectedText = "No Scripture text selected";
                    }
                }
            }

            UpdateWordleWithProgress();
        }
예제 #5
0
        /// <summary>
        /// Called by Paratext when the menu item created for this plugin was clicked.
        /// </summary>
        private void Run(IWindowPluginHost host, IParatextChildState windowState)
        {
            IProject          project = windowState.Project;
            OpenProjectDialog dialog  = new OpenProjectDialog();

            dialog.LoadControl(host, project);
            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                if (dialog.SelectedResourceCategory == OpenProjectDialog.ResourceCategory.Standard)
                {
                    host.OpenTextWindowFor(dialog.SelectedProject, dialog.SelectedOpenWindowBehavior, dialog.SelectedVerseRef);
                }
                else if (dialog.SelectedResourceCategory == OpenProjectDialog.ResourceCategory.Dictionary)
                {
                    host.OpenDictionaryWindowFor(dialog.SelectedProject, dialog.SelectedOpenWindowBehavior, dialog.SelectedDictionaryEntry);
                }
                else if (dialog.SelectedResourceCategory == OpenProjectDialog.ResourceCategory.SLT)
                {
                    host.OpenSLTWindowFor(dialog.SelectedSLTProject, dialog.SelectedOpenWindowBehavior, dialog.SelectedVerseRef, dialog.SelectedWordToSelect);
                }
            }
        }
예제 #6
0
 /// <summary>
 /// Called by Paratext when the menu item created for this plugin was clicked.
 /// </summary>
 private void Run(IWindowPluginHost host, IParatextChildState windowState)
 {
     host.ShowEmbeddedUi(new ControlJ(), windowState.Project);
 }
예제 #7
0
 private static void RunG(IPluginHost host, IParatextChildState windowState)
 {
     MessageBox.Show("Menu Entry G clicked", pluginName,
                     MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
예제 #8
0
 /// <summary>
 /// Called by Paratext when the menu item created for this plugin was clicked.
 /// </summary>
 private static void Run(IWindowPluginHost ptHost, IParatextChildState activeProjectState)
 {
     EditTextControl control = new EditTextControl();
     ptHost.ShowEmbeddedUi(control, activeProjectState.Project);
 }
예제 #9
0
        public void Run(IWindowPluginHost host, IParatextChildState windowState)
        {
            ControlF theControl = new ControlF();

            host.ShowEmbeddedUi(theControl, windowState.Project);
        }
예제 #10
0
 private void MenuClicked(IWindowPluginHost host, IParatextChildState windowState)
 {
     theControl.MenuClicked();
 }
예제 #11
0
 /// <summary>
 /// Called by Paratext when the menu item created for this plugin was clicked.
 /// </summary>
 private void Run(IWindowPluginHost host, IParatextChildState windowState)
 {
     theControl = new ControlH(host);
     host.ShowEmbeddedUi(theControl, windowState.Project);
 }
예제 #12
0
 /// <summary>
 /// Called by Paratext when the menu item created for this plugin was clicked.
 /// </summary>
 private static void Run(IWindowPluginHost host, IParatextChildState windowState)
 {
     host.ShowEmbeddedUi(new WordCloudControl(), windowState.Project);
 }
예제 #13
0
 private void ActiveWindowSelectionChanged(IPluginHost sender, IParatextChildState activeWindowState, IReadOnlyList <ISelection> currentSelections)
 {
     SetSelectedText(activeWindowState, currentSelections);
 }