Ejemplo n.º 1
0
 /// <summary>
 /// Returns true if the specified plugin is a FilePlugin and points to the same file.
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public override bool Equals(PluginBase p)
 {
     if (p is FilePlugin)
         return ((FilePlugin)p).ScriptPath == ScriptPath;
     else
         return false;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks whether a <see cref="PluginBase">Plugin</see> is already registered with
 /// the controller.
 /// </summary>
 /// <param name="plugin">The plugin to check</param>
 /// <returns>True if the Plugin is already registered with the controller, false otherwise.</returns>
 private bool IsPluginRegistered(PluginBase plugin)
 {
     System.Type pt = plugin.GetType();
     foreach (PluginBase loadedPlugin in plugins)
     {
         if (pt == loadedPlugin.GetType())
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public void InsertSnippet()
        {
            var editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());

            editor.AddText(SnippetBody.Length, SnippetBody);

            using (TextToFind textToFind = new TextToFind(editor.GetCurrentPos().Value - SnippetBody.Length, editor.GetCurrentPos().Value, Placeholder))
            {
                Position placeholderPosition = editor.FindText(0, textToFind);
                editor.SetSelection(placeholderPosition.Value + Placeholder.Length, placeholderPosition.Value);
            }
        }
Ejemplo n.º 4
0
        internal static void MakeNewDocument(Object list, String delimiter, bool IncludeFileName)
        {
            ListView ls = list as ListView;

            if (ls == null)
            {
                return;
            }

            // Откроем новый документ
            Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_MENUCOMMAND, 0, NppMenuCmd.IDM_FILE_NEW);

            int    currentDocIndex  = 0;
            IntPtr currentScintilla = PluginBase.GetCurrentScintilla();

            Win32.SendMessage(currentScintilla, SciMsg.SCI_SETCODEPAGE, 0, 65001);

            int currentView = GetCurrentView(currentScintilla) - 1;

            currentDocIndex = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETCURRENTDOCINDEX, 0, currentView);

            int currentPosition = 0;

            for (int i = 0; i < ls.CheckedItems.Count; i++)
            {
                StringBuilder sb       = new StringBuilder();
                StringBuilder fileName = new StringBuilder(Win32.MAX_PATH);

                sb.Append(delimiter + " ");

                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SWITCHTOFILE, 0, ls.CheckedItems[i].Text);
                //Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_ACTIVATEDOC, currentView, i);
                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFILENAME, 0, fileName);

                if (IncludeFileName)
                {
                    sb.Append(fileName.ToString());
                }
                sb.AppendLine();

                currentPosition = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_GETCURRENTPOS, 0, 0);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_SELECTALL, 0, 0);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_COPY, 0, 0);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_SETSEL, -1, currentPosition);

                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_ACTIVATEDOC, currentView, currentDocIndex);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_ADDTEXT, (int)sb.Length, sb);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_PASTE, 0, 0);

                sb       = null;
                fileName = null;
            }
        }
Ejemplo n.º 5
0
 private void DeleteAllCachedScripts()
 {
     string[] cachedFiles = Directory.GetFiles(Path.Combine(PluginBase.GetPath <UpdaterPlug>(), "DbScripts"), $"package.*.zip");
     foreach (string file in cachedFiles)
     {
         try
         {
             File.Delete(file);
         }
         catch { }
     }
 }
Ejemplo n.º 6
0
        internal static void CommandMenuInit()
        {
            // must add menu item in foreground thread
            PluginBase.SetCommand(0, "Code::Stats settings", SettingsPopup, new ShortcutKey(false, false, false, Keys.None));
            idMyDlg = 0;

            // finish initializing in background thread
            Task.Run(() =>
            {
                InitializeAsync();
            });
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Manage key(s) and sequence or identity.
 /// </summary>
 /// <param name="IsGeneric"></param>
 /// <param name="dataContract"></param>
 /// <param name="xplugin"></param>
 /// <param name="dataMappingType"></param>
 /// <param name="xmapper"></param>
 /// <param name="keyNames"></param>
 /// <param name="sequence"></param>
 internal PrimaryKeyInfo(
     bool IsGeneric, DataContract dataContract, PluginBase xplugin, Type dataMappingType, SqlNamingMapper xmapper,
     string keyNames, string sequence)
 {
     Plugin          = xplugin;
     SqlNamingMapper = xmapper;
     DataItemType    = dataContract.Key.DataItemType;
     DataContract    = dataContract;
     SetKeys(keyNames, xmapper, dataMappingType);
     SetSequence(xplugin, xmapper, sequence);
     SetPkMemberInfo(IsGeneric, dataContract);
 }
        public IEnumerable <SearchEngine> Get()
        {
            if (searchEngines != null)
            {
                return(searchEngines);
            }

            string filePath = Path.Combine(PluginBase.GetPath <SpiderLogPlug>(), "SearchEngines.json");
            string json     = File.ReadAllText(filePath, Encoding.UTF8);

            return(searchEngines = JsonSerializer.Deserialize <List <SearchEngine> >(json));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Plugin"></param>
 /// <param name="Factory"></param>
 /// <param name="ConnectionString"></param>
 /// <param name="BareTableName"></param>
 /// <param name="TableOwner"></param>
 /// <param name="DataContract"></param>
 internal TableMetaDataKey(
     PluginBase Plugin, DbProviderFactory Factory, string ConnectionString,
     string BareTableName, string TableOwner, DataContract DataContract
     )
 {
     this.Plugin           = Plugin;
     this.Factory          = Factory;
     this.ConnectionString = ConnectionString;
     this.BareTableName    = BareTableName;
     this.TableOwner       = TableOwner;
     this.DataContract     = DataContract;
 }
Ejemplo n.º 10
0
        static internal void CommandMenuInit()
        {
            // Initialization of your plugin commands
            // You should fill your plugins commands here

            //
            // Firstly we get the parameters from your plugin config file (if any)
            //

            // get path of plugin configuration
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();

            // if config path doesn't exist, we create it
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }

            // make your plugin config file full file path name
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");

            // get the parameter value from plugin config
            bNumericHighlight = (Win32.GetPrivateProfileInt(sectionName, keyName, 0, iniFilePath) != 0);

            // with function :
            // SetCommand(int index,                            // zero based number to indicate the order of command
            //            string commandName,                   // the command name that you want to see in plugin menu
            //            NppFuncItemDelegate functionPointer,  // the symbol of function (function pointer) associated with this command. The body should be defined below. See Step 4.
            //            ShortcutKey *shortcut,                // optional. Define a shortcut to trigger this command
            //            bool check0nInit                      // optional. Make this menu item be checked visually
            //            );
            PluginBase.SetCommand(0, "Hello Notepad++", DummyEDIfile);
            PluginBase.SetCommand(1, "Highlight numeric values", ToggleMenuItem1, false); idToggle = 1;

            PluginBase.SetCommand(2, "Dockable Dialog Demo", DockableDlgDemo); idFrmLexer = 2;

            // Here you insert a separator
            PluginBase.SetCommand(3, "---", null);

            // Shortcut :
            // Following makes the command bind to the shortcut Alt-F
            PluginBase.SetCommand(4, "About", aboutmessage);

            //
            if (bNumericHighlight)
            {
                ToggleMenuItem1();
            }
            ;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns a list of SourceLine structs that contains names of externally described files
        /// in the searchResult field of the data structure
        /// </summary>
        /// <returns>SourceLine(s) from current file containing EXTNAME</returns>
        private static List <SourceLine> ParseCurrentFileForExtName()
        {
            const int         MINIMUM_LINE_LENGTH_FOR_EXTNAME = 12;
            const short       END_OF_FILE  = 0;
            int               line         = 0;
            List <SourceLine> lines        = new List <SourceLine>();
            IntPtr            curScintilla = PluginBase.GetCurrentScintilla();

            while (true)
            {
                int lineLength = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_LINELENGTH, ++line, 0);
                if (lineLength == END_OF_FILE)
                {
                    break;
                }
                else if (lineLength < MINIMUM_LINE_LENGTH_FOR_EXTNAME)
                {
                    continue;
                }

                StringBuilder sb = new StringBuilder(lineLength);
                Win32.SendMessage(curScintilla, SciMsg.SCI_GETLINE, line, sb);

                if (sb == null)
                {
                    break;
                }

                string sourceStatement = sb.ToString().ToUpper();

                if (sourceStatement.Contains("EXTNAME("))
                {
                    SourceLine result = new SourceLine()
                    {
                        statement    = sourceStatement,
                        searchResult = IBMiUtilities.ExtractString(sourceStatement, "EXTNAME('", "')"),
                        lineNumber   = line
                    };
                    if (sourceStatement.Contains("ALIAS"))
                    {
                        result.alias = true;
                    }
                    else
                    {
                        result.alias = false;
                    }

                    lines.Add(result);
                }
            }
            return(lines);
        }
Ejemplo n.º 12
0
        void newBtn_Click(object sender, EventArgs e)
        {
            using (var input = new ScripNameInput())
            {
                if (input.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string scriptName = NormalizeScriptName(input.ScriptName ?? "New Script");

                int index = Directory.GetFiles(CSScriptHelper.ScriptsDir, scriptName + "*.cs").Length;

                string newScript = Path.Combine(CSScriptHelper.ScriptsDir, scriptName + ".cs");
                if (index != 0)
                {
                    int count = 0;
                    do
                    {
                        count++;
                        index++;
                        newScript = Path.Combine(CSScriptHelper.ScriptsDir, string.Format("{0}{1}.cs", scriptName, index));
                        if (count > 10)
                        {
                            MessageBox.Show("Too many script files with the similar name already exists.\nPlease specify a different file name or clean up some existing scripts.", "CS-Script");
                        }
                    }while (File.Exists(newScript));
                }

                var p = new Process();
                p.StartInfo.FileName  = "dotnet";
                p.StartInfo.Arguments = Config.Instance.ClasslessScriptByDefault ?
                                        $"\"{Runtime.cscs_asm}\" -new:toplevel \"{newScript}\"" :
                                        $"\"{Runtime.cscs_asm}\" -new:console \"{newScript}\"";

                p.StartInfo.UseShellExecute = false;
                p.StartInfo.CreateNoWindow  = true;
                p.Start();
                p.WaitForExit();

                try
                {
                    PluginBase.Editor.Open(newScript);
                }
                catch
                {
                }
                PluginBase.GetCurrentDocument().GrabFocus();

                loadBtn.PerformClick();
            }
        }
Ejemplo n.º 13
0
            public AutocompleteForm()
            {
                try
                {
                    // Get the position of the overall window
                    RECT mainWindowPosition;
                    GetWindowRect(PluginBase.GetCurrentScintilla(), out mainWindowPosition);
                    // Get the cursor postion, offset from the window position
                    int currentPos   = (int)Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GETCURRENTPOS, 0, 0);
                    int caretOffsetX = (int)Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_POINTXFROMPOSITION, 0, currentPos);
                    int caretOffsetY = (int)Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_POINTYFROMPOSITION, 0, currentPos);
                    // Get the height of each line in pixels, so the autocomplete pop-up can be offset to fall underneath the current line
                    int lineHeight = (int)Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_TEXTHEIGHT, 0, 0);

                    // Determine coordinates for placing the autocomplete popup, by adding aLl the offsets to the NPP window coordinates
                    int positionX = mainWindowPosition.Left + caretOffsetX;
                    int positionY = mainWindowPosition.Top + caretOffsetY + lineHeight;

                    // Configure WinForms attributes
                    MaximizeBox     = false;
                    MinimizeBox     = false;
                    FormBorderStyle = FormBorderStyle.None;
                    Size            = new Size(400, 100);
                    StartPosition   = FormStartPosition.Manual;
                    Location        = new System.Drawing.Point(positionX, positionY);
                    AutoScroll      = true;
                    //KeyPreview = true;

                    // Add a ListBox for autocomplete suggestions
                    _suggestions      = new ListBox();
                    _suggestions.Dock = System.Windows.Forms.DockStyle.Fill;
                    _suggestions.SelectedIndexChanged += new EventHandler(_suggestions_SelectedIndexChanged);
                    _suggestions.DoubleClick          += new EventHandler(_suggestions_DoubleClick);
                    Controls.Add(_suggestions);

                    // Store the original word and its starting point, so that it can later be replaced or restored
                    int cursorPosition = (int)Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GETCURRENTPOS, 0, 0);
                    _wordStartPosition = (int)Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_WORDSTARTPOSITION, cursorPosition, 1);
                    _originalWord      = "";
                    int    bufferCapacity = 1024;
                    string currentWord    = "";
                    using (Sci_TextRange textRange = new Sci_TextRange(_wordStartPosition, cursorPosition, bufferCapacity))
                    {
                        Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GETTEXTRANGE, 0, textRange.NativePointer);
                        _originalWord = textRange.lpstrText;
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("An error occurred with the GoAutocomplete plugin:\n\n" + e.Message);
                }
            }
        public void InitCommandMenu()
        {
            SetIniFilePath();
            syncViewWithCaretPosition       = (Win32.GetPrivateProfileInt("Options", "SyncViewWithCaretPosition", 0, iniFilePath) != 0);
            markdownPreviewForm.CssFileName = Win32.ReadIniValue("Options", "CssFileName", iniFilePath, "style.css");
            markdownPreviewForm.ZoomLevel   = Win32.GetPrivateProfileInt("Options", "ZoomLevel", 130, iniFilePath);
            PluginBase.SetCommand(0, "About", ShowAboutDialog, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand(1, "Toggle Markdown Panel", TogglePanelVisible);
            PluginBase.SetCommand(2, "Synchronize viewer with caret position", SyncViewWithCaret, syncViewWithCaretPosition);
            PluginBase.SetCommand(3, "Edit Settings", EditSettings);

            idMyDlg = 1;
        }
Ejemplo n.º 15
0
        public void Bind(ShaderParam param, PluginBase.GameObjects.Material mat)
        {
            _mat = mat;
            bsParameter.DataSource = param;

            var textures = _mat.Root.FindChildrenWithInterface<ITexture>();
            var names = new List<string>();
            foreach (var texture in textures)
            {
                names.Add(texture.Name);
            }
            bsTextures.DataSource = names;
        }
Ejemplo n.º 16
0
        static public void SetCalltipTime(int milliseconds)
        {
            var    document = Npp.GetCurrentDocument();
            IntPtr sci      = PluginBase.GetCurrentScintilla();
            var    ttt      = document.GetMouseDwellTime();

            //Color: 0xBBGGRR

            document.CallTipSetFore(new Colour(0, 0, 0));
            document.CallTipSetBack(new Colour(0xE3, 0xE3, 0xE3));

            document.SetMouseDwellTime(milliseconds);
        }
Ejemplo n.º 17
0
 /// <param name="image">Image</param>
 /// <param name="imagePath">Path to image</param>
 /// <param name="filterId">Filter uuid</param>
 /// <param name="encoding">Encoding for analysis</param>
 public Sidecar(IMediaImage image, string imagePath, Guid filterId, Encoding encoding)
 {
     _image        = image;
     _imagePath    = imagePath;
     _filterId     = filterId;
     _encoding     = encoding;
     _sidecar      = image.CicmMetadata ?? new CICMMetadataType();
     _plugins      = GetPluginBase.Instance;
     _fi           = new FileInfo(imagePath);
     _fs           = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
     _imgChkWorker = new Checksum();
     _aborted      = false;
 }
Ejemplo n.º 18
0
        private void ExecuteCommand(string command)
        {
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);
            string           selectedText     = scintillaGateway.GetSelText();
            int    positionStar = scintillaGateway.GetSelectionStart();
            int    positionEnd  = scintillaGateway.GetSelectionEnd();
            string newText      = command.Replace("|", selectedText);

            scintillaGateway.ReplaceSel(newText);
            scintillaGateway.SetSelection(positionStar + command.Substring(0, command.IndexOf('|')).Length, positionEnd + command.Substring(0, command.IndexOf('|')).Length);
            //scintillaGateway.SetSelectionEnd(position + command.Substring(0, command.IndexOf('|')).Length);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Lint <paramref name="files"/> without trying to autodetect the language
        /// </summary>
        /// <param name="files">the files to lint</param>
        /// <param name="language">the language to use</param>
        public static void LintFiles(IEnumerable <string> files, string language)
        {
            language = language.ToLower();

            foreach (var linter in GetLinters(language))
            {
                linter.LintAsync(files, results => PluginBase.RunAsync(() =>
                {
                    ApplyLint(results);
                    EventManager.DispatchEvent(linter, new DataEvent(EventType.Command, "LintingManager.FilesLinted", files));
                }));
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 初始化部分服务
        /// </summary>
        private static void MakeItWork(IHyperaiApplication app)
        {
            // NOTE: search all units here
            app.Provider.GetRequiredService <IUnitService>().SearchForUnits();
            IBotService service = app.Provider.GetRequiredService <IBotService>();

            foreach (Type type in PluginManager.Instance.GetManagedPlugins())
            {
                PluginBase plugin = PluginManager.Instance.Activate(type);
                plugin.ConfigureBots(service.Builder);
                logger.LogInformation("Plugin ({}) activated.", plugin.Context.Meta.Identity);
            }
        }
Ejemplo n.º 21
0
        private void AddPluginButton(PluginBase p)
        {
            var offsetX = (pnlPlugins.Controls.Count % 3) * 16;             // 3 per row
            var offsetY = (pnlPlugins.Controls.Count / 3) * 16;
            var btn     = new ButtonPlugin(p);

            offsetX     += (pnlPlugins.Controls.Count % 3) * btn.Width;
            offsetY     += (pnlPlugins.Controls.Count / 3) * btn.Height;
            btn.Location = new Point(offsetX, offsetY);
            btn.Click   += ButtonPlugin_Click;

            pnlPlugins.Controls.Add(btn);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// 构造一个插件实例并对其提供服务
 /// </summary>
 /// <param name="type">已注册的插件类型</param>
 public PluginBase Activate(Type type)
 {
     if (plugins.ContainsKey(type))
     {
         PluginBase plugin = (PluginBase)Activator.CreateInstance(type);
         plugin.Context = plugins[type];
         return(plugin);
     }
     else
     {
         throw new InvalidOperationException("Argument type for a plugin has not regeristered yet.");
     }
 }
Ejemplo n.º 23
0
 private void startPlugins()
 {
     pluginThreads = plugins.Values.Where(plugin => plugin.RequiresRun).Select(plugin =>
     {
         var thread = new Thread(plugin.Run)
         {
             Name         = xmlRpcClient.Name + " " + PluginBase.GetName(plugin.GetType()),
             IsBackground = true
         };
         thread.Start();
         return(thread);
     }).ToList();
 }
Ejemplo n.º 24
0
        private void Detect()
        {
            IrssLog.Info("Attempting to detect Input Plugins ...");

            CheckBox checkBox;

            for (int row = 1; row < gridPlugins.RowsCount; row++)
            {
                PluginBase plugin = gridPlugins.Rows[row].Tag as PluginBase;

                try
                {
                    if (plugin == null)
                    {
                        throw new InvalidOperationException(String.Format("Invalid grid data, row {0} contains no plugin in tag",
                                                                          row));
                    }

                    PluginBase.DetectionResult detected = plugin.Detect();

                    if (detected == PluginBase.DetectionResult.DevicePresent)
                    {
                        IrssLog.Info("Plugin {0}: detected", plugin.Name);
                    }
                    if (detected == PluginBase.DetectionResult.DeviceException)
                    {
                        IrssLog.Warn("Plugin {0}: exception during Detect()", plugin.Name);
                    }

                    // Receive
                    checkBox = gridPlugins[row, ColReceive] as CheckBox;
                    if (checkBox != null)
                    {
                        checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false);
                    }

                    // Transmit
                    checkBox = gridPlugins[row, ColTransmit] as CheckBox;
                    if (checkBox != null)
                    {
                        checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false);
                    }
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                }
            }

            IrssLog.Info("Input Plugins detection completed...");
        }
Ejemplo n.º 25
0
        public static string GetLineWithSelection(int line)
        {
            IntPtr        curScintilla = PluginBase.GetCurrentScintilla();
            int           lineLength   = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_LINELENGTH, line, 0);
            StringBuilder sb           = new StringBuilder(lineLength);

            Win32.SendMessage(curScintilla, SciMsg.SCI_GETLINE, line, sb);

            line = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_POSITIONFROMLINE, line, 0);
            lineLength--;
            Win32.SendMessage(curScintilla, SciMsg.SCI_SETSELECTION, line, line + lineLength);

            return(sb.ToString().Substring(0, lineLength));
        }
Ejemplo n.º 26
0
        internal static void formatSqlCommand()
        {
            StringBuilder textBuffer = null;

            IntPtr currentScintilla = PluginBase.GetCurrentScintilla();

            //apparently calling with null pointer returns selection buffer length: http://www.scintilla.org/ScintillaDoc.html#SCI_GETSELTEXT
            int  selectionBufferLength = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_GETSELTEXT, 0, 0);
            bool isSelection           = false;

            if (selectionBufferLength > 1)
            {
                textBuffer = new StringBuilder(selectionBufferLength);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_GETSELTEXT, 0, textBuffer);
                isSelection = true;
            }
            else
            {
                //Do as they say here:
                //http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXT
                int docBufferLength = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_GETTEXT, 0, 0);
                textBuffer = new StringBuilder(docBufferLength);
                Win32.SendMessage(currentScintilla, SciMsg.SCI_GETTEXT, docBufferLength, textBuffer);
                isSelection = false;
            }

            bool          errorsEncountered = false;
            bool          abortReplacement  = false;
            StringBuilder outBuffer         = new StringBuilder(_formattingManager.Format(textBuffer.ToString(), ref errorsEncountered));

            if (errorsEncountered)
            {
                if (MessageBox.Show(_generalResourceManager.GetString("ParseErrorWarningMessage"), _generalResourceManager.GetString("ParseErrorWarningMessageTitle"), MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    abortReplacement = true;
                }
            }

            if (!abortReplacement)
            {
                if (isSelection)
                {
                    Win32.SendMessage(currentScintilla, SciMsg.SCI_REPLACESEL, 0, outBuffer);
                }
                else
                {
                    Win32.SendMessage(currentScintilla, SciMsg.SCI_SETTEXT, 0, outBuffer);
                }
            }
        }
Ejemplo n.º 27
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            nps.IniFilePath = Path.GetFullPath(sbIniFilePath.ToString());
            if (!Directory.Exists(nps.IniFilePath))
            {
                Directory.CreateDirectory(nps.IniFilePath);
            }
            nps.IniFilePath = Path.Combine(nps.IniFilePath, Main.PluginName + ".ini");

            nps.ReadSettings();
            nps.WriteSettings();

            int cmdIdx = 0;

            PluginBase.SetCommand(cmdIdx++, "Json: Pretty", FormatPrettyJsonMenu);
            PluginBase.SetCommand(cmdIdx++, "Json: Pretty (sorted)", FormatPrettyJsonSortedMenu);
            PluginBase.SetCommand(cmdIdx++, "Json: Minify", FormatMiniJsonMenu);
            PluginBase.SetCommand(cmdIdx++, "Json: Validate", ValidateJsonMenu);
            PluginBase.SetCommand(cmdIdx++, "---", null);
            PluginBase.SetCommand(cmdIdx++, "Xml: Pretty", FormatPrettyXmlMenu);
            PluginBase.SetCommand(cmdIdx++, "Xml: Pretty (sorted)", FormatPrettyXmlSortedMenu);
            PluginBase.SetCommand(cmdIdx++, "Xml: Minify", FormatMiniXmlMenu);
            PluginBase.SetCommand(cmdIdx++, "Xml: Validate", ValidateXMLMenu);
            PluginBase.SetCommand(cmdIdx++, "---", null);
            PluginBase.SetCommand(cmdIdx++, "Base64/Gzip -> String", B64GzipStringMenu);
            PluginBase.SetCommand(cmdIdx++, "Base64/Gzip -> Pretty Json", B64GzipPrettyJsonMenu);
            PluginBase.SetCommand(cmdIdx++, "String -> Base64/Gzip", B64GzipPayloadMenu);
            PluginBase.SetCommand(cmdIdx++, "---", null);
            PluginBase.SetCommand(cmdIdx++, "Blob -> String", BlobStringMenu);
            PluginBase.SetCommand(cmdIdx++, "String -> Blob", BlobPayloadMenu);
            PluginBase.SetCommand(cmdIdx++, "---", null);
            PluginBase.SetCommand(cmdIdx++, "Detect Indentation", DetectMenu);
            PluginBase.SetCommand(cmdIdx++, "Set Tabs", SetTabsMenu);
            PluginBase.SetCommand(cmdIdx++, "Set Spaces", SetSpacesMenu);
            nps.AutodetectCmdId = cmdIdx++;
            PluginBase.SetCommand(nps.AutodetectCmdId, "Enable Indent Autodetect", AutodetectEnableMenu, nps.EnableAutoDetect);
            PluginBase.SetCommand(cmdIdx++, "---", null);
            nps.SizeDetectCmdId = cmdIdx++;
            PluginBase.SetCommand(nps.SizeDetectCmdId, "Enable File Size Autodetect", SizeDetectEnableMenu, nps.EnableSizeDetect);
            PluginBase.SetCommand(cmdIdx++, "---", null);
            PluginBase.SetCommand(cmdIdx++, "Settings...", SettingsMenu);
            //SubmenuCmdId = cmdIdx++;
            //PluginBase.SetCommand(SubmenuCmdId, "Sub menu", NoOpMenu);
            //SubmenuItem = cmdIdx++;
            //PluginBase.SetCommand(SubmenuItem, "Sub menu item", NoOpMenu);
            //PluginBase.SetCommand(1, "Pretty Json: Format", prettyJson, new ShortcutKey(false, false, false, Keys.None));
        }
Ejemplo n.º 28
0
        private void fontsListBox_DoubleClick(object sender, EventArgs e)
        {
            var selectedFont = fontsListBox.SelectedItem as ObjectView <Font>;

            if (selectedFont != null)
            {
                try
                {
                    if (downloadFont)
                    {
                        var folderBrowserDialog = new FolderBrowserDialog();
                        folderBrowserDialog.SelectedPath = GetCurrentPath();
                        if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                        {
                            var selectedFolder = folderBrowserDialog.SelectedPath;
                            if (Directory.Exists(selectedFolder))
                            {
                                FontLoader.UnpackFontToFolder(selectedFolder, selectedFont.Object);
                                var fontRelativePath = GetFontRelativePath(GetCurrentPath(), selectedFolder);

//                                MessageBox.Show(string.Format("{0}\n {1}\n {2}", GetCurrentPath(), selectedFolder,
//                                    fontRelativePath));

                                var curScintilla = PluginBase.GetCurrentScintilla();

                                var insertTextBuilder = new StringBuilder();
                                insertTextBuilder.AppendLine(selectedFont.Object.import.Replace(COMMON_IMPORT_PATH, fontRelativePath));

                                Win32.SendMessage(curScintilla, SciMsg.SCI_REPLACESEL, 0, insertTextBuilder);
                            }
                        }
                    }
                    else
                    {
                        var curScintilla = PluginBase.GetCurrentScintilla();

                        var insertTextBuilder = new StringBuilder();
                        insertTextBuilder.AppendLine(selectedFont.Object.import);
                        insertTextBuilder.AppendLine(selectedFont.Object.comments);

                        Win32.SendMessage(curScintilla, SciMsg.SCI_REPLACESEL, 0, insertTextBuilder);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString(), "Exception message", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 29
0
        internal static void PluginReady()
        {
            NppListener = new NppListener();

            ToolbarSearchForm = new ToolbarSearchForm();
            FlyingSearchForm  = null;

            NppListener.AssignHandle(PluginBase.nppData._nppHandle);

            ToolbarSearchForm.CheckToolbarVisiblity();
            RecalcRepeatLastCommandMenuItem();

            Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GRABFOCUS, 0, 0);
        }
Ejemplo n.º 30
0
 public FeedbackState(SimulationLifecycleManager simulationLifecycleManager,
                      PluginBase photonPlugin,
                      Messenger messenger,
                      ITAlertPlayerManager playerManager,
                      RoomSettings roomSettings,
                      AnalyticsServiceManager analytics)
     : base(photonPlugin,
            messenger,
            playerManager,
            roomSettings,
            analytics)
 {
     _simulationLifecycleManager = simulationLifecycleManager;
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Gets the word where the current cursor is located (the word is selected and the edit focus is lost
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentWord2()
        {
            StringBuilder sb = new StringBuilder(128);

            if (Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETCURRENTWORD, 128, sb) != IntPtr.Zero)
            {
                Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GRABFOCUS, 0, 0);
                return(sb.ToString());
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 32
0
        private IEnumerable <string> GetTabLines()
        {
            IntPtr scintilla = PluginBase.GetCurrentScintilla();

            int linesCount = (int)Win32.SendMessage(scintilla, SciMsg.SCI_GETLINECOUNT, 0, 0);

            for (int i = 0; i < linesCount; i++)
            {
                int           lineLength = (int)Win32.SendMessage(scintilla, SciMsg.SCI_LINELENGTH, i, 0);
                StringBuilder sb         = new StringBuilder(lineLength);
                Win32.SendMessage(scintilla, SciMsg.SCI_GETLINE, i, sb);
                yield return(sb.ToString().Substring(0, lineLength).TrimEnd('\r', '\n')); // trim carriage return
            }
        }
Ejemplo n.º 33
0
 public Output(PluginBase plgBase)
 {
     pluginBase = plgBase;
       InitializeComponent();
 }
Ejemplo n.º 34
0
 public void Bind(ShaderParam param, PluginBase.GameObjects.Material mat)
 {
     _mat = mat;
     bsParameter.DataSource = param;
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Will initiate loading of assemblies from currently connected server if current connection was updated in main application
 /// </summary>
 /// <param name="sender">Instance of class <see cref="MainControl"/></param>
 /// <param name="e">Event arguments</param>
 void MainControl_ConnectionUpdated(object sender, PluginBase.ConnectionUpdatedEventArgs e)
 {
     ExecuteMethod(RetrieveAssemblies);
 }
Ejemplo n.º 36
0
 public Settings(PluginBase plgBase)
 {
     pluginBase = plgBase;
       InitializeComponent();
 }
Ejemplo n.º 37
0
 public static void AddPlugin(PluginBase plugin)
 {
     PluginList.Add(plugin);
 }
Ejemplo n.º 38
0
        private void UpdateDatabase(IDbConnection connection, PluginBase plugin)
        {
            var assembly = plugin.GetType().Assembly;

            logger.Info("Update database: {0}", assembly.FullName);

            // todo: sql
            var provider = ProviderFactory.Create<SqlServerCeTransformationProvider>(connection, null);

            using (var migrator = new Migrator(provider, assembly))
            {
                // запрещаем выполнять миграции, для которых не указано "пространство имен"
                if (migrator.AvailableMigrations.Any())
                {
                    var migrationsInfo = assembly.GetCustomAttribute<MigrationAssemblyAttribute>();
                    if (migrationsInfo == null || string.IsNullOrWhiteSpace(migrationsInfo.Key))
                        logger.Error("Assembly {0} contains invalid migration info", assembly.FullName);
                }

                migrator.Migrate();
            }
        }
Ejemplo n.º 39
0
        public void PluginCreation_ShouldInitializeCrmServiceProvider()
        {
            m_plugin = new Mock<PluginBase>(typeof(Entity)) { CallBase = true }.Object;

            Assert.That(CrmServiceProvider.Current.GetService(typeof(ICrmServiceContextFactory)),
                                                                Is.InstanceOf<CrmServiceContextFactory>());
            Assert.That(CrmServiceProvider.Current.GetService(typeof(IPluginContextFactory)),
                                                                Is.InstanceOf<PluginContextFactory>());
            Assert.That(CrmServiceProvider.Current.GetService(typeof(IPluginExecutorFactory)),
                                                                Is.InstanceOf<PluginExecutorFactory>());
            Assert.That(CrmServiceProvider.Current.GetService(typeof(IBusinessConfiguratorAbsractFactory)),
                                                                Is.InstanceOf<BusinessConfiguratorAbsractFactory>());
            Assert.That(CrmServiceProvider.Current.GetService(typeof(ICrmPluginEventExtractor)),
                                                                Is.InstanceOf<CrmPluginEventExtractor>());
            Assert.That(CrmServiceProvider.Current.GetService(typeof(ICrmCache)), Is.InstanceOf<CrmDeleteCache>());
        }
Ejemplo n.º 40
0
        public void Init()
        {
            var pluginMock = new Mock<PluginBase>(typeof(Entity)) { CallBase = true };
            pluginMock.Protected().Setup<ICrmServiceProvider>("GetServiceProvider")
                                  .Returns(CreateCrmServiceProviderMock());

            m_plugin = pluginMock.Object;
        }