Пример #1
0
        // static method that for use by the WPF designer
        public static void CreateComponentEvent(
            IClass c, IDocument document,
            Type eventType, string eventMethodName, string body, out int lineNumber)
        {
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }
            if (eventType == null)
            {
                throw new ArgumentNullException("edesc");
            }

            CSharpDesignerGenerator gen = new CSharpDesignerGenerator();

            gen.CurrentClassPart = c;
            int line = gen.GetEventHandlerInsertionLine(c);

            int offset = document.GetLineSegment(line - 1).Offset;

            string tabs = SharpDevelop.DefaultEditor.Gui.Editor.SharpDevelopTextEditorProperties.Instance.IndentationString;

            tabs += tabs;

            document.Insert(offset, gen.CreateEventHandler(eventType, eventMethodName, body, tabs));
            lineNumber = line + gen.GetCursorLineAfterEventHandlerCreation();
        }
Пример #2
0
        public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
        {
            if (viewContent.SecondaryViewContents.Any(c => c is FormsDesignerViewContent))
            {
                return(new IViewContent[0]);
            }

            string fileExtension = String.Empty;
            string fileName      = viewContent.PrimaryFileName;

            fileExtension = Path.GetExtension(fileName).ToLowerInvariant();

            IDesignerLoaderProvider loader;
            IDesignerGenerator      generator;

            switch (fileExtension)
            {
            case ".cs":
                loader    = new NRefactoryDesignerLoaderProvider(SupportedLanguage.CSharp);
                generator = new CSharpDesignerGenerator();
                break;

            case ".vb":
                loader    = new NRefactoryDesignerLoaderProvider(SupportedLanguage.VBNet);
                generator = new VBNetDesignerGenerator();
                break;

            default:
                throw new ApplicationException("Cannot create content for " + fileExtension);
            }
            return(new IViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) });
        }
        // static method that for use by the WPF designer
        public static void CreateComponentEvent(
            IClass c, ITextEditor editor,
            Type eventType, string eventMethodName, string body, out int lineNumber)
        {
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            if (editor == null)
            {
                throw new ArgumentNullException("editor");
            }
            if (eventType == null)
            {
                throw new ArgumentNullException("edesc");
            }

            IDocument document = editor.Document;

            CSharpDesignerGenerator gen = new CSharpDesignerGenerator();

            gen.CurrentClassPart = c;
            int line = gen.GetEventHandlerInsertionLine(c);

            if (line > document.TotalNumberOfLines)
            {
                lineNumber = document.TotalNumberOfLines;
                return;
            }

            int offset = document.GetLine(line).Offset;

            string tabs = editor.Options.IndentationString;

            tabs += tabs;

            document.Insert(offset, gen.CreateEventHandler(eventType, eventMethodName, body, tabs));
            lineNumber = line + gen.GetCursorLineAfterEventHandlerCreation();
        }
		public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
		{
			if (viewContent.SecondaryViewContents.Any(c => c is AimDialogDesigner)) {
				return new IViewContent[0];
			}
			
			string fileExtension = String.Empty;
			string fileName      = viewContent.PrimaryFileName;
			
			fileExtension = Path.GetExtension(fileName).ToLowerInvariant();
			
			IDesignerLoaderProvider loader;
			IDesignerGenerator generator;
			
			switch (fileExtension) {
				case ".cs":
					loader    = new NRefactoryDesignerLoaderProvider(SupportedLanguage.CSharp);
					generator = new CSharpDesignerGenerator();
					break;
				default:
					throw new ApplicationException("Cannot create content for " + fileExtension);
			}
			return new IViewContent[] { new AimDialogDesigner(viewContent, loader, generator) };
		}
		// static method that for use by the WPF designer
		public static void CreateComponentEvent(
			IClass c, IDocument document,
			Type eventType, string eventMethodName, string body, out int lineNumber)
		{
			if (c == null)
				throw new ArgumentNullException("c");
			if (document == null)
				throw new ArgumentNullException("document");
			if (eventType == null)
				throw new ArgumentNullException("edesc");
			
			CSharpDesignerGenerator gen = new CSharpDesignerGenerator();
			
			gen.CurrentClassPart = c;
			int line = gen.GetEventHandlerInsertionLine(c);
			
			int offset = document.GetLineSegment(line - 1).Offset;
			
			string tabs = SharpDevelop.DefaultEditor.Gui.Editor.SharpDevelopTextEditorProperties.Instance.IndentationString;
			tabs += tabs;
			
			document.Insert(offset, gen.CreateEventHandler(eventType, eventMethodName, body, tabs));
			lineNumber = line + gen.GetCursorLineAfterEventHandlerCreation();
		}
		// static method that for use by the WPF designer
		public static void CreateComponentEvent(
			IClass c, ITextEditor editor,
			Type eventType, string eventMethodName, string body, out int lineNumber)
		{
			if (c == null)
				throw new ArgumentNullException("c");
			if (editor == null)
				throw new ArgumentNullException("editor");
			if (eventType == null)
				throw new ArgumentNullException("edesc");
			
			IDocument document = editor.Document;
			
			CSharpDesignerGenerator gen = new CSharpDesignerGenerator();
			
			gen.CurrentClassPart = c;
			int line = gen.GetEventHandlerInsertionLine(c);
			
			int offset = document.GetLine(line).Offset;
			
			string tabs = editor.Options.IndentationString;
			tabs += tabs;
			
			document.Insert(offset, gen.CreateEventHandler(eventType, eventMethodName, body, tabs));
			lineNumber = line + gen.GetCursorLineAfterEventHandlerCreation();
		}