How to close the active sdlxliff file opened in the Editor

Hello.

I'm trying to learn the features available in the Integration API.
The first thing that I'm trying is to close the active sdlxliff file opened in the Editor.

I've created a C# project with a form containing one button.

I've added the following references:

Sdl.Desktop.IntegrationApi
Sdl.Desktop.IntegrationApi.Extensions
Sdl.TranslationStudioAutomation.IntegrationApi

Below is the code written in Form1.cs.

When I run this code, nothing happens (the active file does not close).
What am I missing here?

Thank you in advance.

Tak Osato


====================================================
using System;
using System.IO;
using System.Xml;
using System.Text.RegularExpressions;
using System.Net.NetworkInformation;
using System.Globalization;
using System.Threading;
using System.ComponentModel;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sdl.Desktop.IntegrationApi;
using Sdl.Desktop.IntegrationApi.Extensions;
using Sdl.TranslationStudioAutomation.IntegrationApi;


namespace Trados_SDK_test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {

            EditorController myEditor = new EditorController();
                       

            Document myDoc;

            
            myDoc = myEditor.ActiveDocument;

            myEditor.Close(myDoc);



        }
    }
}

===========================================

Parents Reply Children
  • Hi Sorin

    Thanks for your reply; I realized that this DLL is only available for SDK 2014, but in our agency the main translation tool is still Studio 2011, so I need to find a solution using SDK 2011.

    I created a verification plug-in which performs several verifications, however, there are 2 ways to launch a verification task, the first one is through the batch task (which verifies all files in the same project) and the second one is with a file open in editor, press F8 (or Tools -> Verify), depending on which one was used, I want to do different treatment, like save the file already open in my editor, for example.

    I thought, the way to tell whether I am using a batch task or I am verifying an individual file in editor is to see whether the file is open in my editor, but if I don’t have access to an instance of my editor, then I won’t be able to check that.

    Or is there any other way to detect if a batch verification is launched? Or F8 is pressed (like an event handler?).

    Hope I was clear with my explanation.

    Thanks

    Marcelo

  • Hi,

    As Sorin wrote about all the functionality which gives you access to the application actions is only provided with IntegrationAPI which is only available in Studio 2014 - there are no plans for backporting the API into previous versions of Studio.

    I'm not sure why you would need that information - if you run a batch task user is automatically prompted to close (and save) the file. In the interactive process (F8) I'm not sure why it would matter - I might be missing something here but I'm afraid there no way to get this information anyway.

    Regards

    Patrik

  • Hi Patrick

    Thanks for your reply, the reason why I need to distinguish whether the verification was launched using a batch or in the editor is because in French language, there are some F & R that need to be made, for example, replacing straight apostrophes by curly ones, replace a normal space by a non-breaking space before currency, etc.

    If the verification is launched using a batch action, Studio would save the changes and reopen files in the editor, but if launched by pressing F8, then I need to add one step of saving the file currently open in editor.

    If the feature of taking control of the editor is not available, then I will look for an alternative.

    Thanks