GetManifestResourceStream 获取项目资源为null
使用Stream s = assembly.GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + resourceName) 获取资源文件,返回流为null,如图所示:
解决方案
设置资源文件的 属性,将生成操作属性值设置为嵌入的资源,如图所示:
再次运行程序,发现返回流不再是null,如图所示:
Python.xshd文件
本项目是准备写个简单的python编辑器,刚开始动手,有些丑:
分享写的初版样式文件Python.xshd,后续还会继续更新,大家可以据此按需修改:
<?xml version="1.0"?>
<SyntaxDefinition name="Python" extensions=".py" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"><Color name="Comment" foreground="#008000" /> <!-- Green --><Color name="String" foreground="#F2981D" /> <!-- Orange --><Color name="Label" foreground="#000DBA" /> <!-- Blue --><Color name="Note" foreground="#F2981D" /> <!-- Orange --><Color name="Keywords_true" foreground="#2E9AFE" /> <!-- Blue --><Color name="Keywords_print" foreground="#D7DF01" /> <!-- Yellow --><Color name="Keywords_def" foreground="#045FB4" /> <!-- Blue --><Color name="Keywords_int" foreground="#04B486" /> <!-- Green --><Color name="Keywords_file" foreground="#00BFFF" /> <!-- Cyan --><Color name="KeywordsStructure" foreground="#B404AE" /> <!-- Purple --><Color name="KeywordsApi" foreground="#D7DF01" /> <!-- Yellow --><Color name="KeywordsDigit" foreground="#99CC99" /> <!-- This is the main ruleset. --><RuleSet><Span color="Comment" begin="#" /><Span color="Note" multiline="true" begin=""""" end=""""" /><Span color="Note" multiline="true" begin="'''" end="'''" /><!--<Delimiters>:</Delimiters>--><Span color="String"><Begin>"</Begin><End>"</End><RuleSet><!-- nested span for escape sequences --><Span begin="\\" end="." /> </RuleSet></Span><Span color="String"><Begin>'</Begin><End>'</End><RuleSet><!-- nested span for escape sequences --><Span begin="\\" end="." /></RuleSet></Span><Keywords color="Keywords_true"><Word>True</Word><Word>False</Word><Word>None</Word></Keywords><Keywords color="Keywords_print"><Word>print</Word><Word>exec</Word></Keywords><Keywords color="Keywords_def"><Word>and</Word><Word>class</Word><Word>def</Word><Word>is</Word><Word>lambda</Word><Word>not</Word><Word>or</Word></Keywords><Keywords color="KeywordsStructure"><Word>as</Word><Word>assert</Word><Word>break</Word><Word>continue</Word><Word>del</Word><Word>elif</Word><Word>else</Word><Word>except</Word><Word>finally</Word><Word>for</Word><Word>from</Word><Word>global</Word><Word>if</Word><Word>import</Word><Word>in</Word><Word>pass</Word><Word>raise</Word><Word>return</Word><Word>triple</Word><Word>try</Word><Word>while</Word><Word>with</Word><Word>yield</Word></Keywords><Keywords color="Keywords_int"><Word>staticmethod</Word><Word>int</Word><Word>str</Word><Word>super</Word><Word>property</Word><Word>tuple</Word><Word>bool</Word><Word>type</Word><Word>bytearray</Word><Word>float</Word><Word>list</Word><Word>frozenset</Word><Word>classmethod</Word><Word>complex</Word><Word>set</Word><Word>dict</Word><Word>object</Word><Word>slice</Word></Keywords><Keywords color="Keywords_file"><Word>basestring</Word><Word>execfile</Word><Word>file</Word><Word>raw_input</Word><Word>reduce</Word><Word>unicode</Word><Word>long</Word><Word>xrange</Word><Word>cmp</Word></Keywords><Keywords color="KeywordsApi"><Word>abs</Word><Word>divmod</Word><Word>input</Word><Word>open</Word><Word>all</Word><Word>enumerate</Word><Word>ord</Word><Word>any</Word><Word>eval</Word><Word>isinstance</Word><Word>pow</Word><Word>sum</Word><Word>issubclass</Word><Word>print</Word><Word>bin</Word><Word>iter</Word><Word>filter</Word><Word>len</Word><Word>range</Word><Word>unichr</Word><Word>callable</Word><Word>format</Word><Word>locals</Word><Word>chr</Word><Word>reload</Word><Word>vars</Word><Word>getattr</Word><Word>map</Word><Word>repr</Word><Word>globals</Word><Word>max</Word><Word>reversed</Word><Word>zip</Word><Word>compile</Word><Word>hasattr</Word><Word>memoryview</Word><Word>round</Word><Word>__import__</Word><Word>hash</Word><Word>min</Word><Word>delattr</Word><Word>help</Word><Word>next</Word><Word>setattr</Word><Word>hex</Word><Word>dir</Word><Word>id</Word><Word>oct</Word><Word>sorted</Word><Word>fopen</Word></Keywords><!-- Digits --><Rule color="KeywordsDigit">\b0[xX][0-9a-fA-F]+ # hex number| \b( \d+(\.[0-9]+)? #number with optional floating point| \.[0-9]+ #or just starting with floating point)([eE][+-]?[0-9]+)? # optional exponent</Rule></RuleSet>
</SyntaxDefinition>
希望本文对大家有帮助,上文若有不妥之处,欢迎指正
分享决定高度,学习拉开差距