Esempio n. 1
0
 static void LoadThread()
 {
     try {
         InitializeIcons(AddInTree.GetTreeNode("/Workspace/Icons"));
     } catch (TreePathNotFoundException) {
     }
 }
Esempio n. 2
0
        public void Attach(ITextEditor editor)
        {
            this.editor       = editor;
            inspectionManager = new IssueManager(editor);
            codeManipulation  = new CodeManipulation(editor);
            renderer          = new CaretReferenceHighlightRenderer(editor);

            // Patch editor options (indentation) to project-specific settings
            if (!editor.ContextActionProviders.IsReadOnly)
            {
                contextActionProviders = AddInTree.BuildItems <IContextActionProvider>("/SharpDevelop/ViewContent/TextEditor/C#/ContextActions", null);
                editor.ContextActionProviders.AddRange(contextActionProviders);
            }

            // Create instance of options adapter and register it as service
            var formattingPolicy = CSharpFormattingPolicies.Instance.GetProjectOptions(
                SD.ProjectService.FindProjectContainingFile(editor.FileName));

            options = new CodeEditorFormattingOptionsAdapter(editor.Options, formattingPolicy.OptionsContainer);
            var textEditor = editor.GetService <TextEditor>();

            if (textEditor != null)
            {
                var textViewServices = textEditor.TextArea.TextView.Services;

                // Unregister any previous ITextEditorOptions instance from editor, if existing, register our impl.
                textViewServices.RemoveService(typeof(ITextEditorOptions));
                textViewServices.AddService(typeof(ITextEditorOptions), options);

                // Set TextEditor's options to same object
                originalEditorOptions = textEditor.Options;
                textEditor.Options    = options;
            }
        }
        public static bool IsSearchable(string fileName)
        {
            if (fileName == null)
            {
                return(false);
            }

            if (excludedFileExtensions == null)
            {
                excludedFileExtensions = AddInTree.BuildItems <string>("/AddIns/DefaultTextEditor/Search/ExcludedFileExtensions", null, false);
            }
            string extension = Path.GetExtension(fileName);

            if (extension != null)
            {
                foreach (string excludedExtension in excludedFileExtensions)
                {
                    if (String.Compare(excludedExtension, extension, true) == 0)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        public static string BrowseForStylesheetFile()
        {
            using (OpenFileDialog dialog = new OpenFileDialog()) {
                dialog.AddExtension    = true;
                dialog.Multiselect     = false;
                dialog.CheckFileExists = true;
                dialog.Title           = ResourceService.GetString("ICSharpCode.XmlEditor.AssignXSLT.Title");

                AddInTreeNode node = AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter");
                if (node != null)
                {
                    string xmlFileFilter  = GetFileFilter(node, "Xml");
                    string allFilesFilter = GetFileFilter(node, "AllFiles");
                    string xslFileFilter  = GetFileFilter(node, "Xsl");

                    dialog.Filter      = String.Join("|", xslFileFilter, xmlFileFilter, allFilesFilter);
                    dialog.FilterIndex = 1;
                }

                if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK)
                {
                    return(dialog.FileName);
                }
            }

            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// Returns a File Dialog filter that can be used to filter on all registered project formats
        /// </summary>
        public static string GetAllProjectsFilter(object caller)
        {
            AddInTreeNode addinTreeNode = AddInTree.GetTreeNode("/SharpDevelop/Workbench/Combine/FileFilter");
            StringBuilder b             = new StringBuilder(StringParser.Parse("${res:SharpDevelop.Solution.AllKnownProjectFormats}|"));
            bool          first         = true;

            foreach (Codon c in addinTreeNode.Codons)
            {
                string ext = c.Properties.Get("extensions", "");
                if (ext != "*.*" && ext.Length > 0)
                {
                    if (!first)
                    {
                        b.Append(';');
                    }
                    else
                    {
                        first = false;
                    }
                    b.Append(ext);
                }
            }
            foreach (string entry in addinTreeNode.BuildChildItems(caller))
            {
                b.Append('|');
                b.Append(entry);
            }
            return(b.ToString());
        }
Esempio n. 6
0
 public static ContextMenuStrip CreateContextMenu(object owner, string addInTreePath)
 {
     if (addInTreePath == null)
     {
         return(null);
     }
     try
     {
         List <MenuItemDescriptor> descriptors = AddInTree.BuildItems <MenuItemDescriptor>(addInTreePath, owner, true);
         ContextMenuStrip          contextMenu = new ContextMenuStrip();
         contextMenu.Items.Add(new ToolStripMenuItem("dummy"));
         contextMenu.Opening += delegate
         {
             contextMenu.Items.Clear();
             AddItemsToMenu(contextMenu.Items, descriptors);
         };
         contextMenu.Opened += ContextMenuOpened;
         contextMenu.Closed += ContextMenuClosed;
         return(contextMenu);
     }
     catch (TreePathNotFoundException)
     {
         MessageService.ShowError("Warning tree path '" + addInTreePath + "' not found.");
         return(null);
     }
 }
        /// <summary>
        /// Returns a File Dialog filter that can be used to filter on all registered project formats
        /// </summary>
        public static string GetAllProjectsFilter(object caller, bool includeSolutions)
        {
            var filters = AddInTree.BuildItems <FileFilterDescriptor>("/SharpDevelop/Workbench/Combine/FileFilter", null);

            if (!includeSolutions)
            {
                filters.RemoveAll(f => f.ContainsExtension(".sln"));
            }
            StringBuilder b     = new StringBuilder(StringParser.Parse("${res:SharpDevelop.Solution.AllKnownProjectFormats}|"));
            bool          first = true;

            foreach (var filter in filters)
            {
                string ext = filter.Extensions;
                if (ext != "*.*" && ext.Length > 0)
                {
                    if (!first)
                    {
                        b.Append(';');
                    }
                    else
                    {
                        first = false;
                    }
                    b.Append(ext);
                }
            }
            foreach (var filter in filters)
            {
                b.Append('|');
                b.Append(filter.ToString());
            }
            return(b.ToString());
        }
Esempio n. 8
0
 static void GetDescriptors()
 {
     if (debuggers == null)
     {
         debuggers = (DebuggerDescriptor[])AddInTree.BuildItems("/SharpDevelop/Services/DebuggerService/Debugger", null, false).ToArray(typeof(DebuggerDescriptor));
     }
 }
Esempio n. 9
0
        internal static void Save(OpenedFile file)
        {
            Debug.Assert(file != null);

            using (SaveFileDialog fdiag = new SaveFileDialog()) {
                fdiag.OverwritePrompt = true;
                fdiag.AddExtension    = true;

                string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string));
                fdiag.Filter = String.Join("|", fileFilters);
                for (int i = 0; i < fileFilters.Length; ++i)
                {
                    if (fileFilters[i].IndexOf(Path.GetExtension(file.FileName)) >= 0)
                    {
                        fdiag.FilterIndex = i + 1;
                        break;
                    }
                }

                if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    string fileName = fdiag.FileName;
                    if (!FileService.CheckFileName(fileName))
                    {
                        return;
                    }
                    if (FileUtility.ObservedSave(new NamedFileOperationDelegate(file.SaveToDisk), fileName) == FileOperationResult.OK)
                    {
                        FileService.RecentOpen.AddLastFile(fileName);
                        MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}");
                    }
                }
            }
        }
Esempio n. 10
0
        public static void AddItemsToNavigation(NavBarControl ribbon, object owner, string addInTreePath)
        {
            var adapter     = GetUIElementAdapter(ribbon);
            var descriptors = AddInTree.BuildItems <NavItemDescriptor>(addInTreePath, owner, false);
            List <NavItemDescriptor> removerItem = new List <NavItemDescriptor>();

            foreach (var descriptor in descriptors)
            {
                List <object> subRemoverItem = new List <object>();
                foreach (NavItemDescriptor subItem in descriptor.SubItems)
                {
                    if (!AuthorizationManager.CheckAccess(subItem.Codon.Id, "Read"))
                    {
                        subRemoverItem.Add(subItem);
                    }
                }
                foreach (var item in subRemoverItem)
                {
                    descriptor.SubItems.Remove(item);
                }

                if (descriptor.SubItems.Count <= 0)
                {
                    removerItem.Add(descriptor);
                }
            }
            foreach (var item in removerItem)
            {
                descriptors.Remove(item);
            }
            BuildParts(adapter, descriptors);
        }
        public void LoadPreferences()
        {
            List <IPreferenceSheet> sheets = AddInTree.BuildItems <IPreferenceSheet>("/FdoToolbox/Preferences", this);

            _view.Sheets = sheets;
            //Properties prop = Prop.Get("Base.AddIn.Options", new Properties());
        }
Esempio n. 12
0
        static Action <FileTemplateOptions> ReadAction(XmlElement el)
        {
            switch (el.Name)
            {
            case "RunCommand":
                if (el.HasAttribute("path"))
                {
                    try {
                        ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null);
                        return(fileCreateInformation => {
                            command.Owner = fileCreateInformation;
                            command.Run();
                        });
                    } catch (TreePathNotFoundException ex) {
                        MessageService.ShowWarning(ex.Message + " - in " + el.OwnerDocument.DocumentElement.GetAttribute("fileName"));
                        return(null);
                    }
                }
                else
                {
                    ProjectTemplate.WarnAttributeMissing(el, "path");
                    return(null);
                }

            default:
                ProjectTemplate.WarnObsoleteNode(el, "Unknown action element is ignored");
                return(null);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Ribbon Initial 初始化Ribbon界面
        /// </summary>
        public void RibbonInitial()
        {
            RibbonContainer.ApplicationMenu = menu;

            #region 添加Pad到ApplicationMenu-View中
            RibbonApplicationMenuItem viewItem = new RibbonApplicationMenuItem();
            viewItem.Header = StringParser.Parse("${res:Ribbon.ApplicationMenu.View}");
            viewItem.Name   = "View";
            RibbonContainer.ApplicationMenu.Items.Add(viewItem);

            foreach (PadDescriptor content in AddInTree.BuildItems <PadDescriptor>(padsPath, this, false))
            {
                if (content != null)
                {
                    ShowPad(content);
                    viewItem.Items.Add(new PadToRibbon(content));
                }
            }

            #endregion

            #region 界面样式
            RibbonApplicationMenuItem styleItem = new RibbonApplicationMenuItem();
            styleItem.Header = StringParser.Parse("${res:Ribbon.ApplicationMenu.Themes}");
            styleItem.Name   = "Theme";
            RibbonContainer.ApplicationMenu.Items.Add(styleItem);
            #endregion

            RibbonService.AddItemsToRibbon(RibbonContainer, this, ribbonPath);
        }
Esempio n. 14
0
        private object ConvertEntity(object soruceObject, string sourceOjbectName, string targetObjectName)
        {
            IObjectSpace obojectSpace = new ODataObjectSpace();
            var          targetType   = obojectSpace.ResolveType(targetObjectName);
            var          targetObject = Activator.CreateInstance(targetType);

            obojectSpace.SetEntityId(targetObjectName, targetObject, Guid.NewGuid());
            var mappingList = GetMappingList(sourceOjbectName, targetObjectName);

            foreach (var mappingItem in mappingList)
            {
                SetProperValue(soruceObject, mappingItem.SourceAttributeName, targetObject, mappingItem.TargetAttributeName);
            }
            string convertPath = "/ConvertObject/" + targetObjectName;

            if (AddInTree.ExistsTreeNode(convertPath))
            {
                var descriptor = AddInTree.BuildItems <IObjectConvert>(convertPath, null);
                if (descriptor != null && descriptor.Count() > 0)
                {
                    descriptor.First().ConvertObject(soruceObject, targetObject);
                }
            }
            SetFieldValue(targetObject, "CreatedOn", DateTime.Now);
            SetFieldValue(targetObject, "CreatedById", AuthorizationManager.CurrentUserId);
            SetFieldValue(targetObject, "OwnerId", AuthorizationManager.CurrentUserId);
            SetFieldValue(targetObject, "ModifiedOn", DateTime.Now);
            SetFieldValue(targetObject, "ModifiedById", AuthorizationManager.CurrentUserId);
            return(targetObject);
        }
Esempio n. 15
0
 public static System.Windows.Forms.ContextMenuStrip CreateContextMenu(object owner, string addInTreePath)
 {
     if (string.IsNullOrEmpty(addInTreePath))
     {
         return(null);
     }
     System.Windows.Forms.ContextMenuStrip result;
     try
     {
         System.Collections.Generic.List <MenuItemDescriptor> destriptors = AddInTree.BuildItems <MenuItemDescriptor>(addInTreePath, owner, true);
         System.Windows.Forms.ContextMenuStrip menuStrip = new System.Windows.Forms.ContextMenuStrip();
         menuStrip.Opening += delegate
         {
             menuStrip.Items.Clear();
             MenuService.AddItemsToMenu(menuStrip.Items, destriptors);
         }
         ;
         result = menuStrip;
     }
     catch (System.Exception)
     {
         result = null;
     }
     return(result);
 }
Esempio n. 16
0
 static void EnsureIntialize()
 {
     if (_controllerDescriptors == null)
     {
         _controllerDescriptors = AddInTree.BuildDictionaryItems <ControllerDescriptor>("/Controllers", null, false);
     }
 }
Esempio n. 17
0
        static void CreateDefaultProjectContentReferences()
        {
            IList <string> defaultReferences = AddInTree.BuildItems <string>("/SharpDevelop/Services/ParserService/SingleFileGacReferences", null, false);

            foreach (string defaultReference in defaultReferences)
            {
                ReferenceProjectItem item = new ReferenceProjectItem(null, defaultReference);
                defaultProjectContent.AddReferencedContent(ParserService.GetProjectContentForReference(item));
            }
            if (WorkbenchSingleton.Workbench != null)
            {
                WorkbenchSingleton.Workbench.ActiveViewContentChanged += delegate {
                    if (WorkbenchSingleton.Workbench.ActiveViewContent != null)
                    {
                        string file = WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName;
                        if (file != null)
                        {
                            IParser parser = GetParser(file);
                            if (parser != null && parser.Language != null)
                            {
                                defaultProjectContent.Language       = parser.Language;
                                defaultProjectContent.DefaultImports = parser.Language.CreateDefaultImports(defaultProjectContent);
                            }
                        }
                    }
                };
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Gets the current ambience.
        /// This method is thread-safe.
        /// </summary>
        /// <returns>Returns a new ambience object (ambience objects are never reused to ensure their thread-safety).
        /// Never returns null, in case of errors the <see cref="NetAmbience"/> is used.</returns>
        public static IAmbience GetCurrentAmbience()
        {
            IAmbience ambience;

            if (UseProjectAmbienceIfPossible)
            {
                ICSharpCode.SharpDevelop.Project.IProject p = ICSharpCode.SharpDevelop.Project.ProjectService.CurrentProject;
                if (p != null)
                {
                    ambience = p.GetAmbience();
                    if (ambience != null)
                    {
                        return(ambience);
                    }
                }
            }
            string language = DefaultAmbienceName;

            try {
                ambience = (IAmbience)AddInTree.BuildItem("/SharpDevelop/Workbench/Ambiences/" + language, null);
            } catch (TreePathNotFoundException) {
                ambience = null;
            }
            if (ambience == null && Gui.WorkbenchSingleton.MainWin32Window != null)
            {
                MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Services.AmbienceService.AmbienceNotFoundError}");
            }
            return(ambience ?? new NetAmbience());
        }
Esempio n. 19
0
        public void Install(bool isUpdate)
        {
            foreach (string identity in addIn.Manifest.Identities.Keys)
            {
                ICSharpCode.Core.AddInManager.AbortRemoveUserAddInOnNextStart(identity);
            }
            if (isPackage)
            {
                string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.AddInInstallTemp,
                                                addIn.Manifest.PrimaryIdentity);
                if (Directory.Exists(targetDir))
                {
                    Directory.Delete(targetDir, true);
                }
                Directory.CreateDirectory(targetDir);
                FastZip fastZip = new FastZip();
                fastZip.CreateEmptyDirectories = true;
                fastZip.ExtractZip(fileName, targetDir, null);

                addIn.Action = AddInAction.Install;
                if (!isUpdate)
                {
                    AddInTree.InsertAddIn(addIn);
                }
            }
            else
            {
                ICSharpCode.Core.AddInManager.AddExternalAddIns(new AddIn[] { addIn });
            }
        }
Esempio n. 20
0
        /// <summary>
        /// See <see cref="CabShellApplication{T,S}.AfterShellCreated"/>
        /// </summary>
        protected override void AfterShellCreated()
        {
            base.AfterShellCreated();
            InitializeShell();

            RootWorkItem.Items.Add(Shell, UIExtensionSiteNames.Shell);

            Program.SetInitialState("加载应用模块……");
            addInTree = new AddInTree();
            RootWorkItem.Services.Add <AddInTree>(addInTree);
            RootWorkItem.Services.Add <IContentMenuService>(new XtraContentMenuService(RootWorkItem, Shell.barManager));

            RootWorkItem.Items.Add(Shell.BarManager, UIExtensionSiteNames.Shell_Bar_Manager);
            RootWorkItem.Items.Add(Shell.BarManager.MainMenu, UIExtensionSiteNames.Shell_Bar_Mainmenu);
            RootWorkItem.Items.Add(Shell.BarManager.StatusBar, UIExtensionSiteNames.Shell_Bar_Status);
            RootWorkItem.Items.Add(Shell.BarManager, UIExtensionSiteNames.Shell_Manager_BarManager);
            RootWorkItem.Items.Add(Shell.DockManager, UIExtensionSiteNames.Shell_Manager_DockManager);
            RootWorkItem.Items.Add(Shell.TabbedMdiManager, UIExtensionSiteNames.Shell_Manager_TabbedMdiManager);
            RootWorkItem.Items.Add(Shell.NaviWorkspace, UIExtensionSiteNames.Shell_NaviPane_Navibar);

            RootWorkItem.Workspaces.Add(new MdiWorkspace(Shell), UIExtensionSiteNames.Shell_Workspace_Main);
            RootWorkItem.Workspaces.Add(Shell.DockWorkspace, UIExtensionSiteNames.Shell_Workspace_Dockable);
            RootWorkItem.Workspaces.Add(Shell.NaviWorkspace, UIExtensionSiteNames.Shell_Workspace_NaviPane);
            RootWorkItem.Workspaces.Add(new XtraWindowWorkspace(Shell), UIExtensionSiteNames.Shell_Workspace_Window);

            Program.SetInitialState("正在初始化用户使用界面……");
            RegisterCommandHandler();
            RegisterViews();
            RegisterUIElements();
            RegisterUISite(); // 构建用户界面并添加UI构建服务

            Program.CloseLoginForm();
        }
Esempio n. 21
0
 static IconService()
 {
     try {
         InitializeIcons(AddInTree.GetTreeNode("/Workspace/Icons"));
     } catch (TreePathNotFoundException) {
     }
 }
Esempio n. 22
0
        public void ListCodons(string path)
        {
            CodonLV.Items.Clear();
            if (path == null)
            {
                ExtTextBox.Text = "Extension : ";
                return;
            }

            ExtTextBox.Text = "Extension : " + path;

            AddInTreeNode node = AddInTree.GetTreeNode(path, false);

            if (node == null)
            {
                return;
            }
            foreach (Codon c in node.Codons)
            {
                ListViewItem lvi = new ListViewItem(c.Name);
                lvi.Tag = c;
                lvi.SubItems.Add(c.Id);

                lvi.SubItems.Add(c.Properties.Contains("class") ? c.Properties["class"] : "");

                lvi.SubItems.Add(string.Join(";", c.Conditions.Select(a => a.Name + ": " + a.Action)));
                lvi.SubItems.Add(c.Properties.Contains("label") ? c.Properties["label"] : "");
                CodonLV.Items.Add(lvi);
            }
        }
        /// <summary>
        /// Tries to find the local string resource set used for ICSharpCode.Core resource access.
        /// </summary>
        /// <param name="sourceFileName">The name of the source code file which to find the ICSharpCode.Core resource set for.</param>
        /// <returns>A <see cref="ResourceSetReference"/> that describes the referenced resource set. The contained file name may be <c>null</c> if the file cannot be determined.</returns>
        public static ResourceSetReference GetICSharpCodeCoreLocalResourceSet(string sourceFileName)
        {
            IProject project = ProjectFileDictionaryService.GetProjectForFile(sourceFileName);

            if (project == null || String.IsNullOrEmpty(project.Directory))
            {
                return(EmptyLocalResourceSetReference);
            }

            string localFile;
            ResourceSetReference local = null;

            if (!NRefactoryAstCacheService.CacheEnabled || !cachedLocalResourceSets.TryGetValue(project, out local))
            {
                foreach (string relativePath in AddInTree.BuildItems <string>("/AddIns/ResourceToolkit/ICSharpCodeCoreResourceResolver/LocalResourcesLocations", null, false))
                {
                    if ((localFile = FindICSharpCodeCoreResourceFile(Path.GetFullPath(Path.Combine(project.Directory, relativePath)))) != null)
                    {
                        local = new ResourceSetReference(ICSharpCodeCoreLocalResourceSetName, localFile);
                        if (NRefactoryAstCacheService.CacheEnabled)
                        {
                            cachedLocalResourceSets.Add(project, local);
                        }
                        break;
                    }
                }
            }

            return(local ?? EmptyLocalResourceSetReference);
        }
Esempio n. 24
0
 static void GetDescriptors()
 {
     if (debuggers == null)
     {
         debuggers = AddInTree.BuildItems <DebuggerDescriptor>("/SharpDevelop/Services/DebuggerService/Debugger", null, false).ToArray();
     }
 }
Esempio n. 25
0
        public static void UpdateTemplates()
        {
            string        dataTemplateDir = FileUtility.Combine(PropertyService.DataDirectory, "templates", "file");
            List <string> files           = FileUtility.SearchDirectory(dataTemplateDir, "*.xft");

            foreach (string templateDirectory in AddInTree.BuildItems <string>(ProjectTemplate.TemplatePath, null, false))
            {
                if (!Directory.Exists(templateDirectory))
                {
                    Directory.CreateDirectory(templateDirectory);
                }
                files.AddRange(FileUtility.SearchDirectory(templateDirectory, "*.xft"));
            }
            FileTemplates.Clear();
            foreach (string file in files)
            {
                try {
                    FileTemplates.Add(new FileTemplate(file));
                } catch (XmlException ex) {
                    MessageService.ShowError("Error loading template file " + file + ":\n" + ex.Message);
                } catch (TemplateLoadException ex) {
                    MessageService.ShowError("Error loading template file " + file + ":\n" + ex.ToString());
                } catch (Exception e) {
                    MessageService.ShowError(e, "Error loading template file " + file + ".");
                }
            }
            FileTemplates.Sort();
        }
Esempio n. 26
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ribbonControl1.Pages.Clear();
            navBarControl1.Groups.Clear();

            _application.MainWorkspace = new MdiWorkspace(tabbedView1, this);

            RibbonManager.AddItemsToMenu(ribbonControl1, _application, "/Workbench/MainMenu", null);
            NavItemManager.AddItemsToNavigation(navBarControl1, _application, "/Workbench/Navigation");

            var startCommands = AddInTree.BuildItems <ICommand>("/Workbench/StartCommands", null);

            startCommands.ForEach(command => command.Run());

            LoadingFormManager.EndLoading();
            WindowState = FormWindowState.Maximized;
            Activate();
            //restore layout
            this._Config.RestoreFormLayout(ConfigKey.Main_Form_Layout, this);
            this._Config.RestoreRibbonLayOut(this.ribbonControl1, ConfigKey.Main_Form_Ribbon);
            this._Config.RestoreNavBarLayout(this.navBarControl1, ConfigKey.Main_Form_Navbar);

            InitLoginUser();
            InitApplicationButton();
        }
Esempio n. 27
0
        public void ListCodons(string path)
        {
            CodonLV.Items.Clear();
            if (path == null)
            {
                ExtLabel.Text = "Extension : ";
                return;
            }

            ExtLabel.Text = "Extension : " + path;

            AddInTreeNode node = AddInTree.GetTreeNode(path, false);

            if (node == null)
            {
                return;
            }
            foreach (Codon c in node.Codons)
            {
                ListViewItem lvi = new ListViewItem(c.Name);
                lvi.Tag = c;
                lvi.SubItems.Add(c.Id);

                lvi.SubItems.Add(c.Properties.Contains("class") ? c.Properties["class"] : "");

                foreach (ICondition condition in c.Conditions)
                {
                    lvi.SubItems.Add(condition.Name + ", " + condition.Action);
                }
                CodonLV.Items.Add(lvi);
            }
        }
Esempio n. 28
0
        public override void Run()
        {
            if (System.Windows.Forms.Form.ActiveForm.Modal)
            {
                return;
            }


            IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;

            if (window != null)
            {
                if (window.ViewContent.IsViewOnly)
                {
                    return;
                }
                if (window.ViewContent is ICustomizedCommands)
                {
                    if (((ICustomizedCommands)window.ViewContent).SaveAsCommand())
                    {
                        return;
                    }
                }
                using (SaveFileDialog fdiag = new SaveFileDialog())
                {
                    fdiag.OverwritePrompt = true;
                    fdiag.AddExtension    = true;

                    string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(this)).ToArray(typeof(string));
                    fdiag.Filter = String.Join("|", fileFilters);
                    for (int i = 0; i < fileFilters.Length; ++i)
                    {
                        if (fileFilters[i].IndexOf(Path.GetExtension(window.ViewContent.FileName == null ? window.ViewContent.UntitledName : window.ViewContent.FileName)) >= 0)
                        {
                            fdiag.FilterIndex = i + 1;
                            break;
                        }
                    }

                    if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                    {
                        string fileName = fdiag.FileName;



                        if (!FileService.CheckFileName(fileName))
                        {
                            return;
                        }

                        if (FileUtility.ObservedSave(new NamedFileOperationDelegate(window.ViewContent.Save), fileName) == FileOperationResult.OK)
                        {
                            FileService.RecentOpen.AddLastFile(fileName);

                            MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}");
                        }
                    }
                }
            }
        }
Esempio n. 29
0
        public static ProjectBehavior LoadBehaviorsForProject(IProject project, ProjectBehavior defaultBehavior)
        {
            List <ProjectBehavior> behaviors = AddInTree.BuildItems <ProjectBehavior>(AddInPath, project, false);
            ProjectBehavior        first = null, current = null;

            foreach (var behavior in behaviors)
            {
                behavior.SetProject(project);
                if (first == null)
                {
                    first = behavior;
                }
                else
                {
                    current.SetNext(behavior);
                }
                current = behavior;
            }
            if (current == null)
            {
                return(defaultBehavior);
            }
            current.SetNext(defaultBehavior);
            return(first);
        }
Esempio n. 30
0
        public static void SaveFileAs(IWorkbenchWindow window)
        {
            using (SaveFileDialog fdiag = new SaveFileDialog()) {
                fdiag.OverwritePrompt = true;
                fdiag.AddExtension    = true;

                fdiag.Filter = String.Join("|", (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string)));

                string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string));
                fdiag.Filter = String.Join("|", fileFilters);
                for (int i = 0; i < fileFilters.Length; ++i)
                {
                    if (fileFilters[i].IndexOf(Path.GetExtension(window.ViewContent.FileName == null ? window.ViewContent.UntitledName : window.ViewContent.FileName)) >= 0)
                    {
                        fdiag.FilterIndex = i + 1;
                        break;
                    }
                }

                if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    string fileName = fdiag.FileName;
                    // currently useless, because the fdiag.FileName can't
                    // handle wildcard extensions :(
                    if (Path.GetExtension(fileName).StartsWith("?") || Path.GetExtension(fileName) == "*")
                    {
                        fileName = Path.ChangeExtension(fileName, "");
                    }

                    window.ViewContent.Save(fileName);

                    MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}");
                }
            }
        }