Exemplo n.º 1
0
        private TextEditorBase GetTextEditorByExtension(string FileName)
        {
            // We cache the list, so create only once
            if (TextEditors.Count() == 0)
            {
                var list = from type in typeof(TextEditorBase).Assembly.GetTypes()
                           where type.IsSubclassOf(typeof(TextEditorBase))
                           select type;


                foreach (Type t in list)
                {
                    if (t != typeof(PlugInTextEditorWrapper))
                    {
                        TextEditorBase TE = (TextEditorBase)Activator.CreateInstance(t);
                        TextEditors.Add(TE);
                    }
                }
            }

            // Add all plugins TextEditors
            ObservableList <PlugInWrapper> PlugInsList = App.LocalRepository.GetSolutionPlugIns();

            foreach (PlugInWrapper PW in PlugInsList)
            {
                foreach (PlugInTextFileEditorBase TE in PW.TextEditors())
                {
                    PlugInTextEditorWrapper w = new PlugInTextEditorWrapper(TE);
                    PlugInTextEditorWrapper f = (PlugInTextEditorWrapper)TextEditors.Where(x => x is PlugInTextEditorWrapper ? ((PlugInTextEditorWrapper)x).GetEditorID() == w.GetEditorID() : false).FirstOrDefault();
                    if (f == null)
                    {
                        TextEditors.Add(w);
                    }
                }
            }

            //TODO: if there is more than one let the user pick
            string ext = Path.GetExtension(FileName).ToLower();

            foreach (TextEditorBase TE in TextEditors)
            {
                if (TE.Extensions != null)
                {
                    if (TE.Extensions.Contains(ext))
                    {
                        return(TE);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        void ScanTextEditors()
        {
            if (TextEditors == null)
            {
                TextEditors = new List <TextEditorBase>();

                var list = from type in typeof(TextEditorBase).Assembly.GetTypes()
                           where type.IsSubclassOf(typeof(TextEditorBase))
                           select type;


                foreach (Type t in list)
                {
                    if (t == typeof(PlugInTextEditorWrapper) || t == typeof(ValueExpression.ValueExpressionEditor))
                    {
                        continue;
                    }
                    if (t != typeof(ITextEditor))
                    {
                        TextEditorBase TE = (TextEditorBase)Activator.CreateInstance(t);
                        TextEditors.Add(TE);
                    }
                }

                // Add all plugins TextEditors
                ObservableList <PluginPackage> Plugins = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>();

                foreach (PluginPackage pluginPackage in Plugins)
                {
                    pluginPackage.PluginPackageOperations = new PluginPackageOperations(pluginPackage);

                    if (string.IsNullOrEmpty(((PluginPackageOperations)pluginPackage.PluginPackageOperations).PluginPackageInfo.UIDLL))
                    {
                        continue;
                    }

                    foreach (ITextEditor TE in PluginTextEditorHelper.GetTextFileEditors(pluginPackage))
                    {
                        PlugInTextEditorWrapper plugInTextEditorWrapper = new PlugInTextEditorWrapper(TE);
                        TextEditors.Add(plugInTextEditorWrapper);
                    }
                }
            }
        }
        void ScanTextEditors()
        {
            if (TextEditors == null)
            {
                TextEditors = new List <TextEditorBase>();

                var list = from type in typeof(TextEditorBase).Assembly.GetTypes()
                           where type.IsSubclassOf(typeof(TextEditorBase))
                           select type;


                foreach (Type t in list)
                {
                    if (t == typeof(PlugInTextEditorWrapper) || t == typeof(ValueExpression.ValueExpressionEditor))
                    {
                        continue;
                    }
                    if (t != typeof(ITextEditor))
                    {
                        TextEditorBase TE = (TextEditorBase)Activator.CreateInstance(t);
                        TextEditors.Add(TE);
                    }
                }

                // Add all plugins TextEditors
                ObservableList <PluginPackage> Plugins = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>();

                foreach (PluginPackage PP in Plugins)
                {
                    foreach (ITextEditor TE in PP.GetTextFileEditors())
                    {
                        PlugInTextEditorWrapper w = new PlugInTextEditorWrapper(TE);
                        //PlugInTextEditorWrapper f = (PlugInTextEditorWrapper)TextEditors.Where(x => x is PlugInTextEditorWrapper ? ((PlugInTextEditorWrapper)x).GetEditorID() == w.GetEditorID() : false).FirstOrDefault();


                        TextEditors.Add(w);
                    }
                }
            }
        }