void IEnsoService.SetUnicodeSelection(string text, EnsoCommand fromCommand) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } if (text == null) { throw new ArgumentNullException("text"); } if (fromCommand == null) { throw new ArgumentNullException("fromCommand"); } try { ensoProxy.SetUnicodeSelection(text, fromCommand.ToString()); } catch (Exception e) { throw new EnsoException("SetUnicodeSelection failed", e); } }
public LingvoExtension() { translateCommand = new EnsoCommand(COMMAND_NAME, COMMAND_POSTFIX, COMMAND_DESC, COMMAND_HELP, EnsoPostfixType.Arbitrary); quitCommand = new EnsoCommand(QUIT_NAME, null, QUIT_DESC, QUIT_DESC, EnsoPostfixType.None); }
public void OnCommand(EnsoCommand command, string postfix) { Action action = commandActions[command.Name]; if (action != null) { new Thread(new ThreadStart(action)).Start(); } }
public void OnCommand(EnsoCommand command, String postfix) { Action <String, IEnsoService> action = commandActions[command.Name]; if (action != null) { new Thread(() => action(postfix, service)).Start(); } }
void IEnsoService.RegisterCommand(IEnsoExtension extension, string uri, EnsoCommand command) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } if (extension == null) { throw new ArgumentNullException("extension"); } if (command == null) { throw new ArgumentNullException("command"); } IDictionary <string, EnsoExtensionProxy> extensions = this.extensions; IDictionary <EnsoCommand, EnsoExtensionProxy> commands = this.commands; if (extensions == null || commands == null) { throw new ObjectDisposedException(GetType().Name); } lock (this) { EnsoExtensionProxy extensionProxy; if (!extensions.TryGetValue(uri, out extensionProxy)) { extensionProxy = new EnsoExtensionProxy(extension, uri); RemotingServices.Marshal(extensionProxy, uri, typeof(EnsoExtensionProxy)); extensions.Add(uri, extensionProxy); } else if (extensionProxy.Extension != extension) { throw new EnsoException("Invalid uri."); } try { ensoProxy.RegisterCommand(GetUrlForUri(uri), command.ToString(), command.Description, command.Help, postfixTypes[(int)command.PostfixType]); } catch (Exception e) { throw new EnsoException("RegisterCommand failed", e); } commands.Add(command, extensionProxy); extensionProxy.Commands.Add(command.ToString(), command); } }
void IEnsoService.UnregisterCommand(EnsoCommand command) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } if (command == null) { throw new ArgumentNullException("command"); } IDictionary <EnsoCommand, EnsoExtensionProxy> commands = this.commands; if (commands == null) { throw new ObjectDisposedException(GetType().Name); } lock (this) { EnsoExtensionProxy extensionProxy; if (!commands.TryGetValue(command, out extensionProxy)) { throw new EnsoException("Command not registered."); } try { ensoProxy.UnregisterCommand(GetUrlForUri(extensionProxy.Uri), command.ToString()); } catch (Exception e) { throw new EnsoException("UnregisterCommand failed", e); } commands.Remove(command); extensionProxy.Commands.Remove(command.ToString()); if (extensionProxy.Commands.Count == 0) { extensions.Remove(extensionProxy.Uri); } } }
public void OnCommand(EnsoCommand command, string postfix) { Guid guid = Guid.NewGuid(); String result; if (POSTFIX_NUMERIC.Equals(postfix)) { result = guid.ToString("N").ToUpper(); } else { result = POSTFIX_LOWER.Equals(postfix) ? guid.ToString() : guid.ToString().ToUpper(); } service.InsertUnicodeAtCursor(result, command); }
void IEnsoService.SetCommandValidPostfixes(EnsoCommand command, string[] postfixes) { if (disposed) { throw new ObjectDisposedException(GetType().Name); } if (command == null) { throw new ArgumentNullException("command"); } if (postfixes == null) { throw new ArgumentNullException("postfixes"); } IDictionary <EnsoCommand, EnsoExtensionProxy> commands = this.commands; if (commands == null) { throw new ObjectDisposedException(GetType().Name); } EnsoExtensionProxy extensionProxy; if (!commands.TryGetValue(command, out extensionProxy)) { throw new EnsoException("Command not registered."); } try { ensoProxy.SetCommandValidPostfixes(GetUrlForUri(extensionProxy.Uri), command.ToString(), postfixes); } catch (Exception e) { throw new EnsoException("SetCommandValidPostfixes failed", e); } }
public void OnCommand(EnsoCommand command, String postfix) { Match m = boundsParser.Match(postfix); int from = 0; String s_from = m.Groups[1].Value; try { if (!"".Equals(s_from.Trim())) { from = Convert.ToInt32(s_from); } } catch (Exception) { service.DisplayMessage(new EnsoMessage(INVALID_BOUNDS_ERROR)); } int to = int.MaxValue; String s_to = m.Groups[2].Value; try { if (!"".Equals(s_to.Trim())) { to = Convert.ToInt32(s_to); } } catch (Exception) { service.DisplayMessage(new EnsoMessage(INVALID_BOUNDS_ERROR)); } int result = random.Next(from, to); service.InsertUnicodeAtCursor(result.ToString(), command); }
public GUIDExtension() { command = new EnsoCommand(COMMAND_NAME, COMMAND_POSTFIX, COMMAND_DESC, COMMAND_DESC, EnsoPostfixType.Bounded); }
public RandomExtension() { command = new EnsoCommand(COMMAND_NAME, COMMAND_POSTFIX, COMMAND_DESC, COMMAND_DESC, EnsoPostfixType.Arbitrary); }
public void OnCommand(EnsoCommand command, string postfix) { CommandDesc desc = commandActions[command.Name]; new Thread(() => desc.action(postfix, service)).Start(); }