Пример #1
0
        private static void Main()
        {
            var viewPath     = $"{BasePath}/Views/Inheritance.cs.docx";
            var documentPath = $"{BasePath}/Documents/Inheritance.docx";

#if DEBUG
            string documentViewer = null; // NET35 and NET45 will automatically search for a Docx viewer.
            //var documentViewer = @"C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"; // NETCOREAPP3_1 and NET6_0 won't.

            Ide.Start(viewPath, documentPath, null, typeof(MyDocument), f => ((MyDocument)f).MyProperty = "The code", documentViewer);
#else
            var myDocument = DocumentFactory.Create <MyDocument>(viewPath);
            myDocument.MyProperty = "The Code";

            // It's possible to generate a file or a stream.

            // 1. Generate a file
            // myDocument.Generate(documentPath);

            //2. Generate an output stream.
            using (var outputStream = myDocument.Generate())
            {
                using (var outputFile = File.Open(documentPath, FileMode.Create))
                {
                    outputFile.Write(outputStream.GetBuffer(), 0, (int)outputStream.Length);
                }
            }
#endif
        }
Пример #2
0
        private static void Main()
        {
#if DEBUG
            var viewPath     = $"{BasePath}/Views/Model.cs.docx";
            var documentPath = $"{BasePath}/Documents/Model.docx";
            var model        = CreateViewModel();

            string documentViewer = null; // NET35 and NET45 will automatically search for a Docx viewer.
            //var documentViewer = @"C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"; // NETCOREAPP3_1 and NET6_0 won't.

            Ide.Start(viewPath, documentPath, model, null, null, documentViewer);
#else
            var startTime     = DateTime.Now;
            var documentCount = 100;

            // Single threaded performance test.
            for (int i = 0; i < documentCount; ++i)
            {
                GenerateDocument(i);
            }

            // Multi threaded performance test.
            //Parallel.For(0, documentCount, GenerateDocument);

            var totalSeconds = (DateTime.Now - startTime).TotalSeconds;
            Console.WriteLine($"Generated {documentCount} documents in {totalSeconds:N2}s ({documentCount / totalSeconds:N2} documents/s).");
            Console.ReadKey();
#endif
        }
Пример #3
0
        private static void Main()
        {
#if DEBUG
            var viewPath     = $"{BasePath}\\Views\\Model.cs.docx";
            var documentPath = $"{BasePath}\\Documents\\Model.docx";
            var model        = CreateViewModel();

            Ide.Start(viewPath, documentPath, model);
#else
            var startTime     = DateTime.Now;
            var documentCount = 100;

            // Single threaded performance test.
            for (int i = 0; i < documentCount; ++i)
            {
                GenerateDocument(i);
            }

            // Multi threaded performance test.
            //Parallel.For(0, documentCount, GenerateDocument);

            var totalSeconds = (DateTime.Now - startTime).TotalSeconds;
            Console.WriteLine($"Generated {documentCount} documents in {totalSeconds:N2}s ({documentCount / totalSeconds:N2} documents/s).");
            Console.ReadKey();
#endif
        }
Пример #4
0
        private static void Main()
        {
            var viewPath     = $"{BasePath}/Views/Inheritance.cs.docx";
            var documentPath = $"{BasePath}/Documents/Inheritance.docx";

#if DEBUG
            Ide.Start(viewPath, documentPath, null, typeof(MyDocument), f => ((MyDocument)f).MyProperty = "The code");
#else
            var myDocument = DocumentFactory.Create <MyDocument>(viewPath);
            myDocument.MyProperty = "The Code";

            // It's possible to generate a file or a stream.

            // 1. Generate a file
            // myDocument.Generate(documentPath);

            //2. Generate an output stream.
            using (var outputStream = myDocument.Generate())
            {
                using (var outputFile = File.Open(documentPath, FileMode.Create))
                {
                    outputFile.Write(outputStream.GetBuffer(), 0, (int)outputStream.Length);
                }
            }
#endif
        }
		internal static async Task<ISymbol> GetSymbolAtCaret (Ide.Gui.Document doc)
		{
			if (doc == null)
				return null;
			var info = await RefactoringSymbolInfo.GetSymbolInfoAsync (doc, doc.Editor);
			return info.Symbol ?? info.DeclaredSymbol;
		}
Пример #6
0
		public override bool TryFix (ConstructFixer fixer, SyntaxNode syntaxTree, Ide.Gui.Document document, int location, ref int newOffset)
		{
			foreach (var invocationExpression in syntaxTree.FindToken (location).Parent.AncestorsAndSelf ().OfType<InvocationExpressionSyntax> ()) {
				if (invocationExpression != null) {
					if (!invocationExpression.ArgumentList.OpenParenToken.IsMissing && invocationExpression.ArgumentList.CloseParenToken.IsMissing) {

						var insertionOffset = invocationExpression.Span.End - 1;

						newOffset = insertionOffset;

						var text = ")";
						newOffset++;
						var expressionStatement = invocationExpression.Parent as ExpressionStatementSyntax;
						if (expressionStatement != null) {
							if (expressionStatement.SemicolonToken.IsMissing)
								text = ");";
							newOffset++;
						}
						document.Editor.InsertText (insertionOffset, text);
						return true;
					}

				}
			}
			return false;
		}
Пример #7
0
        private static void ExecuteTemplates(out WeakReference loadContextRef)
        {
            var loadCtx = new TestAssemblyLoadContext(Path.GetDirectoryName(typeof(Program).Assembly.Location));

            DocumentFactory.LoadContext = loadCtx;

            var viewPath       = $"{BasePath}/Views/Tutorial.cs.docx";
            var documentPath   = $"{BasePath}/Documents/Tutorial.docx";
            var imageDirectory = $"{BasePath}/Images";

#if DEBUG
            Ide.Start(viewPath, documentPath, null, null, f => f.ImageDirectory = imageDirectory);
#else
            DocumentBase document = DocumentFactory.Create(viewPath);
            document.ImageDirectory = imageDirectory;
            document.Generate(documentPath);
#endif
            loadContextRef = new WeakReference(loadCtx);

            Console.WriteLine("---------------------Assemblies Loaded In the Default Context-------------------------------");
            var assemblyNames = AssemblyLoadContext.Default.Assemblies.Select(s => s.FullName).ToArray();
            Console.WriteLine(string.Join(Environment.NewLine, assemblyNames));

            Console.WriteLine("---------------------Assemblies Loaded In Context-------------------------------");
            assemblyNames = loadCtx.Assemblies.Select(s => s.FullName).ToArray();
            Console.WriteLine(string.Join(Environment.NewLine, assemblyNames));

            loadCtx.Unload();
            DocumentFactory.LoadContext = null;
        }
		internal static async System.Threading.Tasks.Task<INamedTypeSymbol> GetNamedTypeAtCaret (Ide.Gui.Document doc)
		{
			if (doc == null)
				return null;
			var info = await RefactoringSymbolInfo.GetSymbolInfoAsync (doc, doc.Editor);
			var sym = info.Symbol ?? info.DeclaredSymbol;
			return sym as INamedTypeSymbol;
		}
Пример #9
0
 public void Dispose()
 {
     if (Ide != null)
     {
         Ide.Quit();
     }
     MessageFilter.Revoke();
 }
Пример #10
0
 public InfMDFe()
 {
     Ide      = new Ide();
     Emit     = new Emit();
     InfModal = new InfModal();
     InfDoc   = new InfDoc();
     Tot      = new Tot();
     Versao   = VersaoServicoMDFe.Ve100;
 }
Пример #11
0
        public override IEnumerable<CodeAction> GetActions(Ide.Gui.Document document, object refactoringContext, ICSharpCode.NRefactory.TextLocation loc, System.Threading.CancellationToken cancellationToken)
        {
            if (!DLanguageBinding.IsDFile(document.FileName))
                yield break;

            var imports = GetSolutions(document); //it may be a bit too slow
            foreach(var i in imports)
                yield return new InnerAction(i);
        }
		public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Ide.Editor.Extension.KeyDescriptor descriptor)
		{
			base.InsertCompletionText (window, ref ka, descriptor);
			factory.Ext.Editor.GetContent<CSharpTextEditorIndentation> ().DoReSmartIndent ();
			if (this.CompletionText.Contains ("\n")) {
				
				factory.Ext.Editor.GetContent<CSharpTextEditorIndentation> ().DoReSmartIndent (factory.Ext.Editor.GetLine (factory.Ext.Editor.CaretLine).NextLine.Offset);
			}
		}
Пример #13
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            GraphEditorPanel.Hide();
            meniu1.Hide();
            Examples.Hide();

            Ide.BringToFront();
            Ide.Show();
            Sidebar.Show();
        }
Пример #14
0
		void HandleDocumentOpened (object sender, Ide.Gui.DocumentEventArgs e)
		{
			if (e.Document.Project == null)
				return;
			var repo = VersionControlService.GetRepository (e.Document.Project);
			if (repo == null)
				return;
			var item = new VersionControlItem (repo, e.Document.Project, e.Document.FileName, false);
			DiffView.AttachViewContents (e.Document, item);
		}
Пример #15
0
 /// <summary>
 /// Is called by Visual Studio on demand.
 /// </summary>
 protected override void Initialize()
 {
     XLog.Init();
     XContextMonitor.Init(this);
     Ide.Init(this);
     Persistence.Init(this);
     ServerManager.Init(this);
     MenuCommands.Initialize(this);
     ServerManager.Update();
     base.Initialize();
 }
		static async Task<RefactoringSymbolInfo> GetNamedTypeAtCaret (Ide.Gui.Document doc)
		{
			if (doc == null)
				return null;
			var info = await RefactoringSymbolInfo.GetSymbolInfoAsync (doc, doc.Editor);

			if (info.Node?.Parent.IsKind (SyntaxKind.SimpleBaseType) != true)
				return null;
			    
			return info;
		}
Пример #17
0
		public static CodeGenerator CreateGenerator (Ide.Gui.Document doc)
		{
			MimeTypeExtensionNode node;
			if (!generators.TryGetValue (doc.Editor.MimeType, out node))
				return null;

			var result = (CodeGenerator)node.CreateInstance ();
			result.UseSpaceIndent = doc.Editor.TabsToSpaces;
			result.EolMarker = doc.Editor.EolMarker;
			result.TabSize = doc.Editor.Options.TabSize;
			result.Compilation = doc.Compilation;
			return result;
		}
Пример #18
0
        private static void Main()
        {
            var viewPath     = $"{BasePath}/Views/Inheritance.cs.docx";
            var documentPath = $"{BasePath}/Documents/Inheritance.docx";

#if DEBUG
            Ide.Start(viewPath, documentPath, null, typeof(MyDocument), f => ((MyDocument)f).MyProperty = "The code");
#else
            var myDocument = DocumentFactory.Create <MyDocument>(viewPath);
            myDocument.MyProperty = "The Code";
            myDocument.Generate(documentPath);
#endif
        }
Пример #19
0
        private static void Main()
        {
            var viewPath       = $"{BasePath}/Views/Tutorial.cs.docx";
            var documentPath   = $"{BasePath}/Documents/Tutorial.docx";
            var imageDirectory = $"{BasePath}/Images";

#if DEBUG
            Ide.Start(viewPath, documentPath, null, null, f => f.ImageDirectory = imageDirectory);
#else
            DocumentBase document = DocumentFactory.Create(viewPath);
            document.ImageDirectory = imageDirectory;
            document.Generate(documentPath);
#endif
        }
Пример #20
0
 private void EnableButton_Click(object sender, EventArgs e)
 {
     Ide.StatusBar_Set("Enable starts...");
     if (ServerManager.CanEnable())
     {
         Thread.Sleep(250);
         XLog.DeleteLogfile();
         Thread.Sleep(1250);
         ServerManager.EnableServer();
         Ide.StatusBar_Set("Enable succeeded");
     }
     else
     {
         Ide.StatusBar_Set("Enable failed, because the settings are invalid.");
     }
 }
Пример #21
0
		// CorrectIndenting is completely unused in the entire MonoDevelopment code environment - doesn't have to be implemented

		/// <summary>
		/// Used for formatting selected code
		/// </summary>
		public override void OnTheFlyFormat(Ide.Gui.Document _doc, int startOffset, int endOffset)
		{
			var doc = _doc.Editor.Document;
			
			DFormattingPolicy policy = null;
			TextStylePolicy textStyle = null;

			if(_doc.HasProject)
			{
				policy = _doc.Project.Policies.Get<DFormattingPolicy>(Indentation.DTextEditorIndentation.mimeTypes);
				textStyle = _doc.Project.Policies.Get<TextStylePolicy>(Indentation.DTextEditorIndentation.mimeTypes);
			}
			else
			{
				policy = PolicyService.GetDefaultPolicy<DFormattingPolicy> (Indentation.DTextEditorIndentation.mimeTypes);
				textStyle = PolicyService.GetDefaultPolicy<TextStylePolicy> (Indentation.DTextEditorIndentation.mimeTypes);
			}
			
			if(IndentCorrectionOnly)
			{
				using(doc.OpenUndoGroup())
				using(var r = doc.CreateReader())
					D_Parser.Formatting.Indent.IndentEngineWrapper.CorrectIndent(r, 
						startOffset, endOffset, 
						doc.Replace, policy.Options, 
						new TextStyleAdapter(textStyle) { KeepAlignmentSpaces = policy.KeepAlignmentSpaces });
				return;
			}
			
			var ast = _doc.GetDAst();
			
			if(ast == null)
				return;
			
			var formattingVisitor = new DFormattingVisitor(policy.Options, new DocAdapt(doc), ast, new TextStyleAdapter(textStyle));
			
			formattingVisitor.CheckFormattingBoundaries = true;
			var dl = doc.OffsetToLocation(startOffset);
			formattingVisitor.FormattingStartLocation = new CodeLocation(dl.Column, dl.Line);
			dl = doc.OffsetToLocation(endOffset);
			formattingVisitor.FormattingEndLocation = new CodeLocation(dl.Column, dl.Line);
			
			formattingVisitor.WalkThroughAst();
			
			using(doc.OpenUndoGroup())
				formattingVisitor.ApplyChanges(doc.Replace);
		}
Пример #22
0
        private static void Main()
        {
            var viewPath       = $"{BasePath}/Views/Tutorial.cs.docx";
            var documentPath   = $"{BasePath}/Documents/Tutorial.docx";
            var imageDirectory = $"{BasePath}/Images";

#if DEBUG
            string documentViewer = null; // NET35 and NET45 will automatically search for a Docx viewer.
            //var documentViewer = @"C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"; // NETCOREAPP3_1 and NET6_0 won't.

            Ide.Start(viewPath, documentPath, null, null, f => f.ImageDirectory = imageDirectory, documentViewer);
#else
            DocumentBase document = DocumentFactory.Create(viewPath);
            document.ImageDirectory = imageDirectory;
            document.Generate(documentPath);
#endif
        }
Пример #23
0
		public override bool TryFix (ConstructFixer fixer, SyntaxNode syntaxTree, Ide.Gui.Document document, int location, ref int newOffset)
		{
			foreach (var breakStatementSyntax in syntaxTree.FindToken (location).Parent.AncestorsAndSelf ().OfType<BreakStatementSyntax> ()) {
				if (breakStatementSyntax.SemicolonToken.IsMissing) {
					var insertionOffset = breakStatementSyntax.Span.End - 1;
					newOffset = insertionOffset;
					newOffset++;
					document.Editor.InsertText (insertionOffset, ";");
					return true;
				}
			}
			foreach (var breakStatementSyntax in syntaxTree.FindToken (location).Parent.AncestorsAndSelf ().OfType<ContinueStatementSyntax> ()) {
				if (breakStatementSyntax.SemicolonToken.IsMissing) {
					var insertionOffset = breakStatementSyntax.Span.End - 1;
					newOffset = insertionOffset;
					newOffset++;
					document.Editor.InsertText (insertionOffset, ";");
					return true;
				}
			}
			return false;
		}
		/// <summary>
		/// Creates a new AnnotationMargin
		/// </summary>
		/// <param name="repo">
		/// A <see cref="Repository"/>: The repo to use for annotation
		/// </param>
		/// <param name="editor">
		/// A <see cref="Mono.TextEditor.TextEditor"/>: The editor to which the margin belongs
		/// </param>
		/// <param name="doc">
		/// A <see cref="Ide.Gui.Document"/>: The document to be annotated
		/// </param>
		public AnnotationMargin (Repository repo, Mono.TextEditor.TextEditor editor, Ide.Gui.Document doc)
		{
			this.repo = repo;
			this.width = 0;
			this.editor = editor;
			annotations = new List<string> ();
			UpdateAnnotations (null, null);
			
			tooltipProvider = new AnnotationTooltipProvider (this);
			
			editor.Document.TextReplacing += EditorDocumentTextReplacing;
			editor.Document.LineChanged += EditorDocumentLineChanged;
			editor.Caret.PositionChanged += EditorCarethandlePositionChanged;
			editor.TooltipProviders.Add (tooltipProvider);

			doc.Saved += UpdateAnnotations;
			
			layout = new Pango.Layout (editor.PangoContext);
			layout.FontDescription = editor.Options.Font;
			
			lineNumberBgGC = new Gdk.GC (editor.GdkWindow);
			lineNumberBgGC.RgbFgColor = editor.ColorStyle.LineNumber.BackgroundColor;
			
			lineNumberGC = new Gdk.GC (editor.GdkWindow);
			lineNumberGC.RgbFgColor = editor.ColorStyle.LineNumber.Color;
			
			lineNumberHighlightGC = new Gdk.GC (editor.GdkWindow);
			lineNumberHighlightGC.RgbFgColor = editor.ColorStyle.LineNumberFgHighlighted;
			
			locallyModifiedGC = new Gdk.GC (editor.GdkWindow);
			locallyModifiedGC.RgbFgColor = editor.ColorStyle.LineDirtyBg;
		}
Пример #25
0
 private void DisableButton_Click(object sender, EventArgs e)
 {
     Ide.StatusBar_Set("Disable starts...");
     ServerManager.DisableServer();
     Ide.StatusBar_Set("Disable succeeded");
 }
Пример #26
0
		/// <summary>
		/// Searches for open documents and locates the ConnectedServicesViewContent for the given project
		/// </summary>
		internal static ConnectedServicesViewContent LocateServiceView (DotNetProject project, out Ide.Gui.Document documentView)
		{
			documentView = null;
			foreach (var view in IdeApp.Workbench.Documents) {
				var servicesView = view.PrimaryView.GetContent<ConnectedServicesViewContent> ();
				if (servicesView != null && servicesView.Project == project) {
					documentView = view;
					return servicesView;
				}
			}

			return null;
		}
Пример #27
0
        /// <summary>
        /// Parsing json objects from current string
        /// </summary>
        public List <Product> JsonGrabbingProcess()
        {
            List <Product> _products = new List <Product>();

            try
            {
                string text = System.IO.File.ReadAllText(@"D:\\Project\\WebDeneme\\Totvs\\TOTVSLabSalesProject\\sample.json");

                dynamic coreArray = JsonConvert.DeserializeObject(text);


                foreach (var jsonProduct in coreArray)
                {
                    Product product = new Product();

                    //[JsonProperty("valorTotal")]
                    Complemento complemento = new Complemento {
                        ValorTotal = jsonProduct.complemento["valorTotal"]
                    };

                    //[JsonProperty("dets")]
                    List <Det> detList = new List <Det>();
                    foreach (var detInnerCol in jsonProduct.dets)
                    {
                        Det det = new Det {
                            NItem = detInnerCol.nItem
                        };

                        Prod prod = new Prod
                        {
                            IndTot = detInnerCol.prod["indTot"],
                            QCom   = detInnerCol.prod["qCom"],
                            UCom   = detInnerCol.prod["uCom"],
                            VProd  = detInnerCol.prod["vProd"],
                            VUnCom = detInnerCol.prod["vUnCom"],
                            XProd  = detInnerCol.prod["xProd"]
                        };

                        det.Prod = prod;

                        detList.Add(det);
                    }

                    //[JsonProperty("emit")]
                    Emit emit = new Emit
                    {
                        Cnpj  = jsonProduct.emit["cnpj"],
                        XFant = jsonProduct.emit["xFant"]
                    };

                    //[JsonProperty("enderEmit")]
                    EnderEmit enderEmit = new EnderEmit()
                    {
                        Fone    = jsonProduct.emit["enderEmit"]["fone"],
                        XBairro = jsonProduct.emit["enderEmit"]["xBairro"],
                        XLgr    = jsonProduct.emit["enderEmit"]["xLgr"],
                        XMun    = jsonProduct.emit["enderEmit"]["xMun"],
                        XPais   = jsonProduct.emit["enderEmit"]["xPais"],
                        Uf      = jsonProduct.emit["enderEmit"]["uf"]
                    };
                    emit.EnderEmit = enderEmit;

                    //[JsonProperty("ide")]
                    Ide ide = new Ide
                    {
                        NatOp = jsonProduct.ide["natOp"]
                    };

                    //[JsonProperty("dhEmi")]
                    DhEmi dhEmi = new DhEmi
                    {
                        Date = jsonProduct.ide["dhEmi"]["$date"]
                    };
                    ide.DhEmi = dhEmi;

                    //[JsonProperty("infAdic")]
                    InfAdic infAdic = new InfAdic
                    {
                        InfCpl = jsonProduct.infAdic["infCpl"]
                    };

                    //[JsonProperty("icmsTot")]
                    IcmsTot icmsTot = new IcmsTot
                    {
                        VDesc      = jsonProduct.total["icmsTot"]["vDesc"],
                        VFrete     = jsonProduct.total["icmsTot"]["vFrete"],
                        VOutro     = jsonProduct.total["icmsTot"]["vOutro"],
                        VProd      = jsonProduct.total["icmsTot"]["vProd"],
                        VSeg       = jsonProduct.total["icmsTot"]["vSeg"],
                        VTotTrib   = jsonProduct.total["icmsTot"]["vTotTrib"],
                        Vbc        = jsonProduct.total["icmsTot"]["vbc"],
                        Vbcst      = jsonProduct.total["icmsTot"]["vbcst"],
                        Vcofins    = jsonProduct.total["icmsTot"]["vcofins"],
                        Vicms      = jsonProduct.total["icmsTot"]["vicms"],
                        VicmsDeson = jsonProduct.total["icmsTot"]["vicmsDeson"],
                        Vii        = jsonProduct.total["icmsTot"]["vii"],
                        Vipi       = jsonProduct.total["icmsTot"]["vipi"],
                        Vnf        = jsonProduct.total["icmsTot"]["vnf"],
                        Vpis       = jsonProduct.total["icmsTot"]["vpis"],
                        Vst        = jsonProduct.total["icmsTot"]["vst"]
                    };

                    //[JsonProperty("total")]
                    Total total = new Total
                    {
                        IcmsTot = icmsTot
                    };

                    //[JsonProperty("complemento")]
                    product.VersaoDocumento = jsonProduct.versaoDocumento;

                    product.Complemento = complemento;
                    product.Dets        = detList;
                    product.Emit        = emit;
                    product.Ide         = ide;
                    product.InfAdic     = infAdic;
                    product.Total       = total;
                    _products.Add(product);
                }
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("Directory not found");
            }
            catch (IOException)
            {
                Console.WriteLine("File read error - ioexception");
            }
            catch (OutOfMemoryException)
            {
                Console.WriteLine("File read error - memoryexception");
            }

            return(_products);
        }
		public FindMemberOverloadsHandler (Ide.Gui.Document doc, IMember entity)
		{
			this.doc = doc;
			this.entity = entity;
		}
Пример #29
0
			static Projects.Project DetermineRealProject (Ide.Gui.Document doc)
			{
				// try to search for a shared project
				var allProjects = IdeApp.Workspace.GetAllItems<SharedAssetsProject> ();
				var projects = new List<SharedAssetsProject> (allProjects.Where (p => p.IsFileInProject (doc.FileName)));
				if (projects.Count > 0)
					return projects [0];
				
				return doc.Project;
			}
Пример #30
0
    public static object GetOp(string right)
    {
        if (XString.Eq(right
                       , "NL"
                       , "NewLine"
                       ))
        {
            var result = "\r\n";
            return(result);
        }
        else if (XString.Eq(right
                            , "CR"
                            , "CarriageReturn"
                            ))
        {
            var result = "\r";
            return(result);
        }
        else if (XString.Eq(right
                            , "LF"
                            , "LineFeed"
                            ))
        {
            var result = "\n";
            return(result);
        }
        else if (XString.Eq(right
                            , "HT"
                            , "Tab"
                            ))
        {
            var result = "\t";
            return(result);
        }
        else if (XString.Eq(right
                            , "SP"
                            , "Space"
                            ))
        {
            var result = " ";
            return(result);
        }
        else if (XString.Eq(right
                            , "CO"
                            , "Comma"
                            ))
        {
            var result = ",";
            return(result);
        }
        else if (XString.Eq(right
                            , "SC"
                            , "SemiColon"
                            ))
        {
            var result = ";";
            return(result);
        }
        else if (XString.Eq(right
                            , "FS"
                            , "FullStop"
                            ))
        {
            var result = ".";
            return(result);
        }
        else if (XString.Eq(right
                            , "SO"
                            , "Solidus"
                            ))
        {
            var result = "/";
            return(result);
        }
        else if (XString.Eq(right
                            , "RS"
                            , "ReverseSolidus"
                            ))
        {
            var result = "\\";
            return(result);
        }
        else if (XString.Eq(right
                            , "a.text"
                            , "ActiveDocument.Selection.Text"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.Text);
        }
        else if (XString.Eq(right
                            , "a.line"
                            , "ActiveDocument.Selection.CurrentLine"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.CurrentLine.ToString());
        }
        else if (XString.Eq(right
                            , "a.col"
                            , "ActiveDocument.Selection.CurrentColumn"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.CurrentColumn.ToString());
        }
        else if (XString.Eq(right
                            , "a.topline"
                            , "ActiveDocument.Selection.TopLine"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.TopLine.ToString());
        }
        else if (XString.Eq(right
                            , "a.bottomline"
                            , "ActiveDocument.Selection.BottomLine"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.BottomLine.ToString());
        }
        else if (XString.Eq(right
                            , "a.rangecount"
                            , "ActiveDocument.Selection.TextRangesCount"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.TextRanges.Count.ToString());
        }
        else if (XString.Eq(right
                            , "a.topchar"
                            , "ActiveDocument.Selection.TopCharOffset"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.TopPoint.AbsoluteCharOffset.ToString());
        }
        else if (XString.Eq(right
                            , "a.bottomchar"
                            , "ActiveDocument.Selection.BottomCharOffset"
                            ))
        {
            var selection = ActiveDocument_GetSelection();
            return(selection.BottomPoint.AbsoluteCharOffset.ToString());
        }

        //else if (XString.Eq(right
        //, "test"
        //, "Line_GetLineIndexByCharIndex"
        //))
        //{
        //    var tdoc2 = Dte.ActiveDocument.Object("TextDocument") as TextDocument;
        //    var ep2 = tdoc2.CreateEditPoint();
        //    ep2.MoveToAbsoluteOffset(1);
        //    var line = ep2.Line;
        //}

        else if (XString.Eq(right
                            , "s.items"
                            , "SolutionExplorer.Selection.Items"
                            ))
        {
            var result = Ide.SolutionExplorer_GetItems();
            return(result);
        }
        else if (XString.Eq(right
                            , "s.itemcount"
                            , "SolutionExplorer.Selection.ItemCount"
                            ))
        {
            var result = Ide.SolutionExplorer_GetItemCount();
            return(result);
        }
        else if (XString.Eq(right
                            , "docs"
                            , "Editor.OpenDocuments"))
        {
            var result = OpenDocuments_Get();
            return(result);
        }
        else if (XString.Eq(right
                            , "doccount"
                            , "Editor.OpenDocumentCount"))
        {
            var result = OpenDocumentCount_Get();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.Id"
                            ))
        {
            return(ServerWindow.Text);
        }
        else if (XString.Eq(right
                            , "Server.State"
                            ))
        {
            var result = ServerManager.ServerState.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.Handle"
                            ))
        {
            var result = ServerWindow.Handle.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.Class"
                            ))
        {
            var result = ServerWindow.GetWindowClassName();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.LogEnabled"
                            ))
        {
            var result = XLog.Enabled ? "1" : "0";
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.LogfileExists"
                            ))
        {
            var result = XLog.Exists ? "1" : "0";
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.LogFile"
                            ))
        {
            var result = XLog.LogFile.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.Marker"
                            ))
        {
            var result = Persistence.Marker.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.Version"
                            ))
        {
            var result = Persistence.Version.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.SupportGetOps"
                            ))
        {
            var result = Persistence.SupportGetOps ? "1" : "0";
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.SupportSetOps"
                            ))
        {
            var result = Persistence.SupportSetOps ? "1" : "0";
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.RequestEncoding"
                            ))
        {
            var result = Persistence.RequestEncoding.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.ResponseEncoding"
                            ))
        {
            var result = Persistence.ResponseEncoding.ToString();
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.ClaimMarkerInRequest"
                            ))
        {
            var result = Persistence.ClaimMarkerInRequest ? "1" : "0";
            return(result);
        }
        else if (XString.Eq(right
                            , "Server.IncludeMarkerInResponse"
                            ))
        {
            var result = Persistence.IncludeMarkerInResponse ? "1" : "0";
            return(result);
        }
        return("");
    }
		public FindExtensionMethodHandler (Ide.Gui.Document doc, ITypeDefinition entity)
		{
			this.doc = doc;
			this.entity = entity;
		}
Пример #32
0
    public static string SolutionExplorer_GetSelectedItemCount()
    {
        var result = Ide.SolutionExplorer_GetItemCount();

        return(result);
    }
Пример #33
0
 public override void Run(Ide.Gui.Document document, ICSharpCode.NRefactory.TextLocation loc)
 {
     ApplySolution(Title, document);
 }
Пример #34
0
 public void Wait()
 {
     Ide.WaitForStatusMessage(ToMessages(), TimeOutSeconds, PollStepSeconds);
 }
		async void Editor_LineShown (object sender, Ide.Editor.LineEventArgs e)
		{
			if (LinksShown) {
				var line = e.Line;
				foreach (var segment in await RequestLinksAsync (line.Offset, line.Length, default (CancellationToken))) {
					var marker = Editor.TextMarkerFactory.CreateLinkMarker (Editor, segment.Offset, segment.Length, delegate { segment.Activate (); });
					marker.OnlyShowLinkOnHover = true;
					Editor.AddMarker (marker);
					markers.Add (marker);
				}
			}
		}
Пример #36
0
    public void Handle_CopyData(ref Message m)
    {
        XLog.Log($"Begin Request: {RequestNumber}");
        RequestNumber++;
        var cdsRequest = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT));

        var request         = "";
        var requestEncoding = Persistence.RequestEncoding;

        XLog.Log($"RequestEncoding: {requestEncoding}");
        if (requestEncoding == IdexEncoding.Ansi)
        {
            request = Marshal.PtrToStringAnsi(cdsRequest.lpData);
        }
        else
        {
            request = Marshal.PtrToStringUni(cdsRequest.lpData);
        }

        XLog.Log($"ClaimMarkerInRequest: {Persistence.ClaimMarkerInRequest}");
        if (Persistence.ClaimMarkerInRequest)
        {
            if (XString.StartsWith(request, Marker))
            {
                XLog.Log($"Eliminate Marker: {Marker}");
                request = request.Substring(Marker.Length).Trim();
            }
            else
            {
                XLog.Log($"Marker is expected but not present. Request is denied.");
                return;
            }
        }

        XLog.Log($"Parse Request");
        string requestServerId = "";
        string requestClientId = "";
        var    requestLines    = XString.SplitIntoLines(request);

        if (requestLines.Length >= 3)
        {
            for (int i = 0; i < 3; i++)
            {
                string requestLine = requestLines[i];
                string left, right;
                XString.ParseAssoc(requestLine, out left, out right);
                if (XString.Eq(left, "ServerId") || XString.Eq(left, "sid"))
                {
                    requestServerId = right;
                }
                else if (XString.Eq(left, "ClientId") || XString.Eq(left, "cid"))
                {
                    requestClientId = right;
                }
            }
        }

        XLog.Log($"Identify client");
        IntPtr clientHandle = IntPtr.Zero;

        if (requestClientId != "")
        {
            XLog.Log($"ClientId: {requestClientId}");
            clientHandle = Native.FindWindow(null, requestClientId);
        }
        if (clientHandle == IntPtr.Zero)
        {
            XLog.Log($"Cannot find client");
            return;
        }
        XLog.Log($"ClientHandle: {clientHandle}");

        var response = "";

        foreach (var actionLine in requestLines)
        {
            if (XString.StartsWith(actionLine, "o ", "g ", "s "))
            {
                var actionPrefix = actionLine.Substring(0, 2).Trim();
                var actionBody   = actionLine.Substring(2).Trim();
                if (XString.Eq(actionPrefix, "o"))
                {
                    XLog.Log($"Execute action: {actionPrefix} {actionBody}");
                    response += actionBody;
                }
                else if (XString.Eq(actionPrefix, "g"))
                {
                    if (Persistence.SupportGetOps)
                    {
                        XLog.Log($"Execute action: {actionPrefix} {actionBody}");
                        var result = Ide.TryGetOp(actionBody);
                        response += result;
                    }
                }
                else if (XString.Eq(actionPrefix, "s"))
                {
                    if (Persistence.SupportSetOps)
                    {
                        XLog.Log($"Execute action: {actionPrefix} {actionBody}");
                        string left, right;
                        XString.ParseAssoc(actionBody, out left, out right);
                        Ide.TrySetOp(left, right);
                    }
                }
            }
            else if (XString.StartsWith(actionLine, "Document."))
            {
                string rest         = actionLine.Substring(9);
                int    openBracket  = rest.IndexOf('(');
                string functionName = rest.Substring(0, openBracket);
                rest = rest.Substring(openBracket + 1);
                int closingBracket = rest.IndexOf(')');
                rest = rest.Substring(0, closingBracket);
                var args = rest.Split(',');
                if (XString.Eq(functionName
                               , "SetSelectedRange"))
                {
                    int startIndex = int.Parse(args[0]);
                    int endIndex   = int.Parse(args[1]);
                    Ide.Document_SetSelectedRange(startIndex, endIndex);
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedRange"))
                {
                    int startIndex = 0;
                    int endIndex   = 0;
                    Ide.Document_GetSelectedRange(out startIndex, out endIndex);
                    response += startIndex + "," + endIndex;
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedText"))
                {
                    string text = Ide.Document_GetSelectedText();
                    response += text;
                }
                else if (XString.Eq(functionName
                                    , "ReplaceSelectedText"))
                {
                    Ide.Document_ReplaceSelectedText();
                }
                else if (XString.Eq(functionName
                                    , "DeleteSelectedText"))
                {
                    Ide.Document_DeleteSelectedText();
                }
                else if (XString.Eq(functionName
                                    , "GetLineIndexByChar"
                                    ))
                {
                    int charIndex = int.Parse(args[0]);
                    int lineIndex = Ide.Document_GetLineIndexByChar(charIndex);
                    response += lineIndex.ToString();
                }
                else if (XString.Eq(functionName
                                    , "GetLine"
                                    ))
                {
                    int    lineIndex   = int.Parse(args[0]);
                    string lineContent = Ide.Document_GetLine(lineIndex);
                    response += lineContent.ToString();
                }
                else if (XString.Eq(functionName
                                    , "SelectLine"
                                    ))
                {
                    int lineIndex = int.Parse(args[0]);
                    Ide.Document_SelectLine(lineIndex);
                }
                else if (XString.Eq(functionName
                                    , "GetLineLength"
                                    ))
                {
                    int charIndex = int.Parse(args[0]);
                    int charCount = Ide.Document_GetLineLength(charIndex);
                    response += charCount.ToString();
                }
                else if (XString.Eq(functionName
                                    , "GetCharIndexByLine"
                                    ))
                {
                    int lineIndex = int.Parse(args[0]);
                    int charIndex = Ide.Document_GetCharIndexByLine(lineIndex);
                    response += charIndex.ToString();
                }
                else if (XString.Eq(functionName
                                    , "GetTextLength"
                                    ))
                {
                    int charCount = Ide.Document_GetTextLength();
                    response += charCount.ToString();
                }
                else if (XString.Eq(functionName
                                    , "GetText"
                                    ))
                {
                    string chars = Ide.Document_GetText();
                    response += chars;
                }
                else if (XString.Eq(functionName
                                    , "ScrollToEnd"
                                    ))
                {
                    Ide.Document_ScrollToEnd();
                }
                else if (XString.Eq(functionName
                                    , "GetCaretLineIndex"
                                    ))
                {
                    response += Ide.Document_GetCaretLineIndex();
                }
                else if (XString.Eq(functionName
                                    , "GetCaretColumnIndex"
                                    ))
                {
                    response += Ide.Document_GetCaretColumnIndex();
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedStartLineIndex"
                                    ))
                {
                    response += Ide.Document_GetSelectedStartLineIndex();
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedEndLineIndex"
                                    ))
                {
                    response += Ide.Document_GetSelectedEndLineIndex();
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedRangeCount"
                                    ))
                {
                    response += Ide.Document_GetSelectedRangeCount();
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedStartCharIndex"
                                    ))
                {
                    response += Ide.Document_GetSelectedStartCharIndex();
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedEndCharIndex"
                                    ))
                {
                    response += Ide.Document_GetSelectedEndCharIndex();
                }
                else if (XString.Eq(functionName
                                    , "GetOpenDocuments"
                                    ))
                {
                    response += Ide.Document_GetOpenDocuments();
                }
            }
            else if (XString.StartsWith(actionLine, "SolutionExplorer."))
            {
                string   functionName = null;
                string[] args         = null;
                ParseActionLine(actionLine, "SolutionExplorer.",
                                out functionName, out args);

                if (XString.Eq(functionName
                               , "GetSelectedItems"
                               ))
                {
                    response += Ide.SolutionExplorer_GetSelectedItems();
                }
                else if (XString.Eq(functionName
                                    , "GetSelectedItemCount"
                                    ))
                {
                    response += Ide.SolutionExplorer_GetSelectedItemCount();
                }
            }
            else if (XString.StartsWith(actionLine, "Base."))
            {
                string   functionName = null;
                string[] args         = null;
                ParseActionLine(actionLine, "Base.",
                                out functionName, out args);

                if (XString.Eq(functionName
                               , "GetServerId"
                               ))
                {
                    response += Ide.Base_GetServerId();
                }
                else if (XString.Eq(functionName
                                    , "SetServerId"
                                    ))
                {
                    string serverId = args[0];
                    Ide.Base_SetServerId(serverId);
                }
                else if (XString.Eq(functionName
                                    , "GetServerHandle"
                                    ))
                {
                    response += Ide.Base_GetServerHandle();
                }
            }
            else if (XString.StartsWith(actionLine, "Output."))
            {
                string   functionName = null;
                string[] args         = null;
                ParseActionLine(actionLine, "Output.",
                                out functionName, out args);

                if (XString.Eq(functionName
                               , "WriteCR"
                               ))
                {
                    response += Ide.Output_WriteCR();
                }
                else if (XString.Eq(functionName
                                    , "WriteLF"
                                    ))
                {
                    response += Ide.Output_WriteLF();
                }
                else if (XString.Eq(functionName
                                    , "WriteCRLF"
                                    ))
                {
                    response += Ide.Output_WriteCRLF();
                }
                else if (XString.Eq(functionName
                                    , "WriteHT"
                                    ))
                {
                    response += Ide.Output_WriteHT();
                }
                else if (XString.Eq(functionName
                                    , "WriteSP"
                                    ))
                {
                    response += Ide.Output_WriteSP();
                }
                else if (XString.Eq(functionName
                                    , "Write"
                                    ))
                {
                    string text = args[0].Trim('"');
                    response += Ide.Output_Write(text);
                }
            }
        }

        XLog.Log($"IncludeMarkerInResponse: {Persistence.IncludeMarkerInResponse}");
        if (Persistence.IncludeMarkerInResponse)
        {
            response += Marker + "\r\n";
        }

        var responseEncoding = Persistence.ResponseEncoding;

        XLog.Log($"ResponseEncoding: {responseEncoding}");
        var sizeInBytes     = (response.Length + 1) * 2;
        var responsePointer = IntPtr.Zero;

        try
        {
            if (responseEncoding == IdexEncoding.Ansi)
            {
                responsePointer = Marshal.StringToCoTaskMemAnsi(response);
            }
            else
            {
                responsePointer = Marshal.StringToCoTaskMemUni(response);
            }

            var cds = new COPYDATASTRUCT();
            cds.cbData = sizeInBytes;
            cds.lpData = responsePointer;
            Native.SendMessage(clientHandle, WM_COPYDATA, IntPtr.Zero, ref cds);
            int errorCode = Marshal.GetLastWin32Error();
            if (errorCode != 0)
            {
                XLog.Log($"SendMessage Code: {errorCode}");
            }
        }
        finally
        {
            XLog.Log($"Free native objects");
            if (responseEncoding == IdexEncoding.Ansi)
            {
                Marshal.ZeroFreeCoTaskMemAnsi(responsePointer);
            }
            else
            {
                Marshal.ZeroFreeCoTaskMemUnicode(responsePointer);
            }
        }
        XLog.Log($"End Request");
    }
Пример #37
0
		public override void OnTheFlyFormat (Ide.Gui.Document doc, int startOffset, int endOffset)
		{
		}
		public static CodeGenerator CreateGenerator (Ide.Gui.Document doc)
		{
			return CreateGenerator (doc.Editor, doc);
		}
Пример #39
0
 public void AddIde(string ideName, Ide ide, PhysicsModelLoadMode loadMode)
 {
     if (loadMode == PhysicsModelLoadMode.Dff)
     {
         foreach (var obj in ide.Objs)
         {
             var dff = GetDff(obj.ModelName + ".dff");
             if (dff != null)
             {
                 this.assetCollection.RegisterDff(obj.Id, dff);
                 this.actions.Add(world =>
                 {
                     try
                     {
                         this.dffMeshes[dff] = world.CreateMesh(dff);
                     }
                     catch (Exception)
                     {
                         this.logger.LogTrace($"Unable to locate dff {obj.ModelName}");
                     }
                 });
             }
         }
     }
     else
     {
         foreach (var obj in ide.Objs)
         {
             if (this.namedColCombos.ContainsKey(obj.ModelName.ToLower()))
             {
                 var colCombo = this.namedColCombos[obj.ModelName.ToLower()];
                 if (colCombo.Header.BoxCount + colCombo.Header.SphereCount + colCombo.Header.FaceCount > 0)
                 {
                     this.assetCollection.RegisterCol(obj.Id, colCombo);
                     this.actions.Add(world =>
                     {
                         try
                         {
                             var meshes       = world.CreateMesh(colCombo);
                             var resultMeshes = new List <IPhysicsMesh>();
                             if (meshes.Item1 != null)
                             {
                                 resultMeshes.Add(meshes.Item1);
                             }
                             if (meshes.Item2 != null)
                             {
                                 resultMeshes.Add(meshes.Item2);
                             }
                             this.colMeshes[colCombo] = resultMeshes.ToArray();
                         }
                         catch (Exception)
                         {
                             this.logger.LogTrace($"Unable to locate col {obj.ModelName.ToLower()} in {ideName}");
                         }
                     });
                 }
             }
             else
             {
                 this.logger.LogTrace($"Unable to find col {obj.ModelName.ToLower()} in {ideName}");
             }
         }
     }
 }
		public FindDerivedSymbolsHandler (Ide.Gui.Document doc, IMember entity)
		{
			//this.doc = doc;
			this.entity = entity;
		}