总结实习经历,为以后面试准备

在2013年6月至2013年12月底,我在上海冠信电子系统有限公司(上海图元软件公司)实习,期间有一定收获,现在记录下来,以备将来面试之用。

1,流程图 

 总结实习经历,为以后面试准备

左右滑动track和view会触发2个事件,栅格缩放会触发一个事件,扫视和缩放也会触发一个事件。

 private void tsiZoomTrack_ValueChanged(object sender, EventArgs e)

        {

            int ratio100 = TrackValueConvertToRatio(this.tsiZoomTrack.Value);

            this.tsiZoomRatio.Text = string.Format("{0,3}%", ratio100);

            InitTsiZoomRatio();

            Get_CurrentZoomRatio(ratio100);

            if (this.overviewControl1.Diagram != null)

                this.overviewControl1.Diagram.View.Magnification = (float)ratio100;

        }



        private void tsiZoomView_Click(object sender, EventArgs e)

        {

            if (!this.overViewControlPanel.Visible)

            {

             

                overViewControlPanel.Location = new Point(this.diagram1.Width - overViewControlPanel.Width, this.diagram1.Height - overViewControlPanel.Height);

                overViewControlPanel.Show();

            }

            else

            {

                overViewControlPanel.Hide();

            }

        }



        private void overviewControl1_ViewPortBoundsChanged(ViewPortBoundsChangedEventArgs evtArgs)

        {

            int newValue = RatioConvertToTrackValue((int)this.overviewControl1.Diagram.View.Magnification);

            if (newValue != this.tsiZoomTrack.Value)

            {

                this.tsiZoomTrack.Value = newValue;

            }

        }



        private void diagram1_SizeChanged(object sender, EventArgs e)

        {

            overViewControlPanel.Location = new Point(this.diagram1.Width - overViewControlPanel.Width, this.diagram1.Height - overViewControlPanel.Height);

        }
View Code

 

  zoomtrack和zoomview之间有转换的关系如下:

      private int RatioConvertToTrackValue(int ratio100)

        {

            if (ratio100 < 100)

                //return (int)(((ratio100 * 4F - 400) / 10) + 0.5);

                if (((ratio100 * 4F - 400) / 10) > ((int)(ratio100 * 4F - 400) / 10) - 0.5)

                {

                    return (int)((ratio100 * 4F - 400) / 10);

                }

                else

                {

                    return (int)((ratio100 * 4F - 400) / 10) - 1;

                }

            else

                return (int)(((ratio100 * 2F - 200) / 10) + 0.5);

        }

        private int TrackValueConvertToRatio(int trackValue)

        {

            if (trackValue < 0)

                return (int)(100 + (int)(trackValue * 25) / 10);

            else

                return (int)(100 + (int)(trackValue * 50) / 10);

        }
View Code

2,智能编辑器

总结实习经历,为以后面试准备

本智能编辑器能够实现高亮显示,智能提示和对函数重载的处理。主要是利用三方库进行字符串处理。

同时我们需要使用xml文件来定义字符串的高亮处理。

<?xml version="1.0" encoding="utf-8"?>

<ArrayOfConfigLanguage>

  <ConfigLanguage name="verilog" StartComment="//" TriggersActivators=" ;.=()">

    <formats>

      <!--<format name="class" Font="Courier New, 10pt" FontColor="Black" />-->

      <format name="Text" Font="Courier New, 10pt" FontColor="Black" />

      <format name="Whitespace" Font="Courier New, 10pt" FontColor="Black" />

      <format name="KeyWord" Font="Courier New, 10pt" FontColor="Blue" />

      <format name="ImageProcessor" Font="Courier New, 10pt" FontColor="Blue" UseCustomControl="true" />

      <format name="String" Font="Courier New, 10pt, style=Bold" FontColor="Red" BorderColor="Red" />

      <format name="Number" Font="Courier New, 10pt, style=Bold" FontColor="Navy" />

      <format name="Error" Font="Courier New, 10pt" FontColor="Black" underline="Wave" LineColor="Red" />

      <format name="Operator" Font="Courier New, 10pt" FontColor="Black" />

      <format name="Comment" Font="Courier New, 10pt, style=Bold" FontColor="Green" />

      <format name="PreprocessorKeyword" Font="Courier New, 10pt" FontColor="Gray" />

      <format name="SelectedText" Font="Courier New, 10pt" BackColor="Highlight" FontColor="HighlightText" />

      <format name="CommentXML" Font="Courier New, 10pt, style=Bold" FontColor="Gray" />

      <format name="CollapsedText" Font="Courier New, 10pt" FontColor="Black" BorderColor="Gray" BorderStyle="Solid" />

    </formats>

    <extensions>

      <extension>va</extension>

    </extensions>

    <lexems>

      <lexem BeginBlock="&gt;" Type="Operator" />

      <lexem BeginBlock="#" Type="Operator" />

      <lexem BeginBlock="=" Type="Operator" />

      <lexem BeginBlock="+" Type="Operator" />

      <lexem BeginBlock="-" Type="Operator" />

      <lexem BeginBlock="/" Type="Operator" />

      <lexem BeginBlock="*" Type="Operator" />

      <lexem BeginBlock="!=" Type="Operator" />

      <lexem BeginBlock="==" Type="Operator" />

      <lexem BeginBlock="-=" Type="Operator" />

      <lexem BeginBlock="+=" Type="Operator" />

      <lexem BeginBlock="=-" Type="Operator" />

      <lexem BeginBlock="=+" Type="Operator" />

      <lexem BeginBlock="*=" Type="Operator" />

      <lexem BeginBlock="/=" Type="Operator" />

      <lexem BeginBlock="=*" Type="Operator" />

      <lexem BeginBlock="=/" Type="Operator" />

      <lexem BeginBlock="++" Type="Operator" />

      <lexem BeginBlock="--" Type="Operator" />

      <lexem BeginBlock=";" Type="Operator" />

      <lexem BeginBlock=":" Type="Operator" />

      <lexem BeginBlock="." Type="Operator" DropContextChoiceList="true" />

      <lexem BeginBlock="," Type="Operator" />

      <lexem BeginBlock="*/" Type="Error" Priority="-10" />

      <lexem BeginBlock="/*" EndBlock="*/" Type="Comment" OnlyLocalSublexems="true" IsComplex="true" IsCollapsable="true" CollapseName="/*...*/" AllowTriggers="false">

        <SubLexems>

          <lexem BeginBlock="/*" Type="Comment" />

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock=")" Type="Error" Priority="-10" />

      <lexem BeginBlock="(" EndBlock=")" Type="Operator" IsComplex="true" IsCollapsable="false"  DropContextPrompt="true" CollapseName="(...)">

        <SubLexems>

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="&quot;" EndBlock="(&quot;)|(@&quot;)" Type="String" IsEndRegex="true" IsComplex="true" OnlyLocalSublexems="true" IndentationGuideline="true">

        <SubLexems>

          <lexem BeginBlock="\" EndBlock="&quot;" Type="String" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="'" EndBlock="'" Type="String" IsComplex="true" OnlyLocalSublexems="true">

        <SubLexems>

          <lexem BeginBlock="\" EndBlock=".+" IsEndRegex="true" Priority="2" Type="String" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="@&quot;" EndBlock="(&quot;)|(@&quot;)" Type="String" IsEndRegex="true" OnlyLocalSublexems="true" IsComplex="true">

        <SubLexems>

          <lexem BeginBlock="\n" IsBeginRegex="true" />

          <lexem BeginBlock="&quot;" EndBlock="&quot;" Type="String" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="[" EndBlock="]" Type="Operator" IsComplex="true" IsCollapsable="false"  DropContextPrompt="true" CollapseName="[...]">

        <SubLexems>

          <lexem BeginBlock="\" EndBlock="&quot;" Type="String" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="//" EndBlock="\n" IsEndRegex="true" Type="Comment" IsComplex="true" OnlyLocalSublexems="true" AllowTriggers="false" />

      <lexem ID="1041" EndBlock="#endregion" Type="PreprocessorKeyword" IsComplex="true" IsCollapsable="true">

        <SubLexems>

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="#endregion" Type="Error" Priority="-10" />

      <lexem BeginBlock="#endif" Type="Error" Priority="-10" />

      <lexem BeginBlock="#else" Type="Error" Priority="-10" />

      <lexem ID="1044" EndBlock="#endif" Type="PreprocessorKeyword" IsComplex="true">

        <SubLexems>

          <lexem BeginBlock="#else" Type="PreprocessorKeyword" />

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="#region" EndBlock="\n" Type="PreprocessorKeyword" IsEndRegex="true" OnlyLocalSublexems="true" IsComplex="true" IsCollapsable="true" AutoNameExpression="(#region)\s*(?&lt;text&gt;.*).*(?&lt;!\n)\n" AutoNameTemplate="${text}" IsCollapseAutoNamed="true" CollapseName="Unnamed Region" NextID="1041" IndentationGuideline="true">

        <SubLexems>

          <lexem BeginBlock=".*(?&lt;!\n)" IsBeginRegex="true" Type="Text" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="#if" EndBlock="\n" Type="PreprocessorKeyword" IsEndRegex="true" OnlyLocalSublexems="true" IsComplex="true" IsCollapsable="true" AutoNameExpression="(#if)\s*(?&lt;text&gt;.*).*(?&lt;!\n)\n" AutoNameTemplate="If ${text}" IsCollapseAutoNamed="true" CollapseName="Incorrect if-def" NextID="1044">

        <SubLexems>

          <lexem BeginBlock=".*(?&lt;!\n)" IsBeginRegex="true" Type="Text" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="(\s(?&lt;!\n))+" IsBeginRegex="true" Type="Whitespace" />

      <lexem ID="1" EndBlock="param>" Type="Comment" IsComplex="true" IsEndRegex="true" IsCollapsable="true">

        <SubLexems>

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="/// " EndBlock="\n"  Type="Comment" OnlyLocalSublexems="true" IsComplex="true" AllowTriggers="false" NextID="1">

        <SubLexems>

          <lexem BeginBlock="&lt;" EndBlock="&gt;" Type="Comment" FormatName="CommentXML" IsComplex="true" OnlyLocalSublexems="true" IndentationGuideline="true" />

        </SubLexems>

      </lexem>

      <!--<lexem BeginBlock="///" EndBlock="///&lt;p" Type="Comment" IsEndRegex="true"

       IsComplex="true" IsCollapsable="true" AutoNameExpression="\s*(?&lt;text>.*).*\n" AutoNameTemplate="${text} "

       IsCollapseAutoNamed="true" CollapseName="#Region">

        <SubLexems>

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>-->

      <lexem ID="1124" BeginBlock="[0-9]+" EndBlock=".*" IsPseudoEnd="true" IsEndRegex="true" IsBeginRegex="true" Type="Number" IsComplex="true" OnlyLocalSublexems="true">

        <SubLexems>

          <lexem BeginBlock="x" EndBlock="[0-9a-fA-F]+" IsEndRegex="true" Type="Number" Priority="5" />

          <lexem BeginBlock="." EndBlock="[0-9]+" IsEndRegex="true" Type="Number" Priority="5" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="}" Type="Error" Priority="-10" /><!--Type="KeyWord"-->

      <lexem ID="256" BeginBlock="{" EndBlock="}"  IsComplex="true" IsCollapsable="true"  DropContextPrompt="true" Indent="true" CollapseName="{...}" IndentationGuideline="true" AutoFormatStartNewLine="true">

        <SubLexems>

          <lexem BeginBlock="\n" IsBeginRegex="true" />

        </SubLexems>

      </lexem>

      <lexem BeginBlock="alias" Type="KeyWord" />

      <lexem BeginBlock="always" Type="KeyWord" />

      <lexem BeginBlock="always_comb" Type="KeyWord" />

      <lexem BeginBlock="always_ff" Type="KeyWord" />

      <lexem BeginBlock="always_latch" Type="KeyWord" />

      <lexem BeginBlock="and" Type="KeyWord" />

      <lexem BeginBlock="assert" Type="KeyWord" />

      <lexem BeginBlock="assign" Type="KeyWord" />

      <lexem BeginBlock="assume" Type="KeyWord" />

      <lexem BeginBlock="automatic" Type="KeyWord" />

      <lexem BeginBlock="before" Type="KeyWord" />

      <lexem BeginBlock="begin" Type="KeyWord" />

      <lexem BeginBlock="bind" Type="KeyWord" />

      <lexem BeginBlock="bins" Type="KeyWord" />

      <lexem BeginBlock="binsof" Type="KeyWord" />

      <lexem BeginBlock="bit" Type="KeyWord" />

      <lexem BeginBlock="break" Type="KeyWord" />

      <lexem BeginBlock="buf" Type="KeyWord" />

      <lexem BeginBlock="bufif0" Type="KeyWord" />

      <lexem BeginBlock="bufif1" Type="KeyWord" />

      <lexem BeginBlock="byte" Type="KeyWord" />

      <lexem BeginBlock="case" Type="KeyWord" />

      <lexem BeginBlock="casex" Type="KeyWord" />

      <lexem BeginBlock="cell" Type="KeyWord" />

      <lexem BeginBlock="chandle" Type="KeyWord" />

      <lexem BeginBlock="class" Type="KeyWord" />

      <lexem BeginBlock="clocking" Type="KeyWord" />

      <lexem BeginBlock="cmos" Type="KeyWord" />

      <lexem BeginBlock="config" Type="KeyWord" />

      <lexem BeginBlock="const" Type="KeyWord" />

      <lexem BeginBlock="constraint" Type="KeyWord" />

      <lexem BeginBlock="context" Type="KeyWord" />

      <lexem BeginBlock="continue" Type="KeyWord" />

      <lexem BeginBlock="cover" Type="KeyWord" />

      <lexem BeginBlock="covergroup" Type="KeyWord" />

      <lexem BeginBlock="coverpoint" Type="KeyWord" />

      <lexem BeginBlock="cross" Type="KeyWord" />

      <lexem BeginBlock="deassign" Type="KeyWord" />

      <lexem BeginBlock="default" Type="KeyWord" />

      <lexem BeginBlock="defparam" Type="KeyWord" />

      <lexem BeginBlock="design" Type="KeyWord" />

      <lexem BeginBlock="disable" Type="KeyWord" />

      <lexem BeginBlock="dist" Type="KeyWord" />

      <lexem BeginBlock="do" Type="KeyWord" />

      <lexem BeginBlock="edge" Type="KeyWord" />

      <lexem BeginBlock="else" Type="KeyWord" />

      <lexem BeginBlock="endtable" Type="KeyWord" />

      <lexem BeginBlock="end" Type="KeyWord" />

      <lexem BeginBlock="endclass" Type="KeyWord" />

      <lexem BeginBlock="endspecify" Type="KeyWord" />

      <lexem BeginBlock="endcase" Type="KeyWord" />

      <lexem BeginBlock="endclocking" Type="KeyWord" />

      <lexem BeginBlock="endconfig" Type="KeyWord" />

      <lexem BeginBlock="endfunction" Type="KeyWord" />

      <lexem BeginBlock="endgenerate" Type="KeyWord" />

      <lexem BeginBlock="else" Type="KeyWord" />

      <lexem BeginBlock="endgroup" Type="KeyWord" />

      <lexem BeginBlock="endinterface" Type="KeyWord" />

      <lexem BeginBlock="endmodule" Type="KeyWord" />

      <lexem BeginBlock="endpackage" Type="KeyWord" />

      <lexem BeginBlock="endprimitive" Type="KeyWord" />

      <lexem BeginBlock="endprogram" Type="KeyWord" />

      <lexem BeginBlock="endproperty" Type="KeyWord" />

      <lexem BeginBlock="endspecify" Type="KeyWord" />

      <lexem BeginBlock="endsequence" Type="KeyWord" />

      <lexem BeginBlock="endtask" Type="KeyWord" />

      <lexem BeginBlock="enum" Type="KeyWord" />

      <lexem BeginBlock="event" Type="KeyWord" />

      <lexem BeginBlock="expect" Type="KeyWord" />

      <lexem BeginBlock="export" Type="KeyWord" />

      <lexem BeginBlock="extends" Type="KeyWord" />

      <lexem BeginBlock="extern" Type="KeyWord" />

      <lexem BeginBlock="final" Type="KeyWord" />

      <lexem BeginBlock="first_match" Type="KeyWord" />

      <lexem BeginBlock="for" Type="KeyWord" />

      <lexem BeginBlock="force" Type="KeyWord" />

      <lexem BeginBlock="foreach" Type="KeyWord" />

      <lexem BeginBlock="forever" Type="KeyWord" />

      <lexem BeginBlock="fork" Type="KeyWord" />

      <lexem BeginBlock="forkjoin" Type="KeyWord" />

      <lexem BeginBlock="function" Type="KeyWord" />

      <lexem BeginBlock="generate" Type="KeyWord" />

      <lexem BeginBlock="genvar" Type="KeyWord" />

      <lexem BeginBlock="highz0" Type="KeyWord" />

      <lexem BeginBlock="highz1" Type="KeyWord" />

      <lexem BeginBlock="if" Type="KeyWord" />

      <lexem BeginBlock="iff" Type="KeyWord" />

      <lexem BeginBlock="ifnone" Type="KeyWord" />

      <lexem BeginBlock="ignore_bins" Type="KeyWord" />

      <lexem BeginBlock="illegal_bins" Type="KeyWord" />

      <lexem BeginBlock="import" Type="KeyWord" />

      <lexem BeginBlock="incdir" Type="KeyWord" />

      <lexem BeginBlock="include" Type="KeyWord" />

      <lexem BeginBlock="initial" Type="KeyWord" />

      <lexem BeginBlock="input" Type="KeyWord" />

      <lexem BeginBlock="inout" Type="KeyWord" />

      <lexem BeginBlock="inside" Type="KeyWord" />

      <lexem BeginBlock="instance" Type="KeyWord" />

      <lexem BeginBlock="int" Type="KeyWord" />

      <lexem BeginBlock="integer" Type="KeyWord" />

      <lexem BeginBlock="interface" Type="KeyWord" />

      <lexem BeginBlock="intersect" Type="KeyWord" />

      <lexem BeginBlock="join" Type="KeyWord" />

      <lexem BeginBlock="join_any" Type="KeyWord" />

      <lexem BeginBlock="join_none" Type="KeyWord" />

      <lexem BeginBlock="large" Type="KeyWord" />

      <lexem BeginBlock="liblist" Type="KeyWord" />

      <lexem BeginBlock="library" Type="KeyWord" />

      <lexem BeginBlock="local" Type="KeyWord" />

      <lexem BeginBlock="localparam" Type="KeyWord" />

      <lexem BeginBlock="logic" Type="KeyWord" />

      <lexem BeginBlock="longint" Type="KeyWord" />

      <lexem BeginBlock="macromodule" Type="KeyWord" />

      <lexem BeginBlock="matches" Type="KeyWord" />

      <lexem BeginBlock="medium" Type="KeyWord" />

      <lexem BeginBlock="modport" Type="KeyWord" />

      <lexem BeginBlock="module" Type="KeyWord" />

      <lexem BeginBlock="nand" Type="KeyWord" />

      <lexem BeginBlock="negedge" Type="KeyWord" />

      <lexem BeginBlock="new" Type="KeyWord" />

      <lexem BeginBlock="nmos" Type="KeyWord" />

      <lexem BeginBlock="nor" Type="KeyWord" />

      <lexem BeginBlock="noshowcancelled" Type="KeyWord" />

      <lexem BeginBlock="not" Type="KeyWord" />

      <lexem BeginBlock="notif0" Type="KeyWord" />

      <lexem BeginBlock="notif1" Type="KeyWord" />

      <lexem BeginBlock="null" Type="KeyWord" />

      <lexem BeginBlock="or" Type="KeyWord" />

      <lexem BeginBlock="out" Type="KeyWord" />

      <lexem BeginBlock="package" Type="KeyWord" />

      <lexem BeginBlock="packed" Type="KeyWord" />

      <lexem BeginBlock="parameter" Type="KeyWord" />

      <lexem BeginBlock="pmos" Type="KeyWord" />

      <lexem BeginBlock="posedge" Type="KeyWord" />

      <lexem BeginBlock="primitive" Type="KeyWord" />

      <lexem BeginBlock="priority" Type="KeyWord" />

      <lexem BeginBlock="program" Type="KeyWord" />

      <lexem BeginBlock="property" Type="KeyWord" />

      <lexem BeginBlock="protected" Type="KeyWord" />

      <lexem BeginBlock="pull0" Type="KeyWord" />

      <lexem BeginBlock="pull1" Type="KeyWord" />

      <lexem BeginBlock="pulldown" Type="KeyWord" />

      <lexem BeginBlock="pullup" Type="KeyWord" />

      <lexem BeginBlock="pulsestyle_onevent" Type="KeyWord" />

      <lexem BeginBlock="pulsestyle_ondetect" Type="KeyWord" />

      <lexem BeginBlock="pure" Type="KeyWord" />

      <lexem BeginBlock="rand" Type="KeyWord" />

      <lexem BeginBlock="randc" Type="KeyWord" />

      <lexem BeginBlock="randcase" Type="KeyWord" />

      <lexem BeginBlock="randsequence" Type="KeyWord" />

      <lexem BeginBlock="rcmos" Type="KeyWord" />

      <lexem BeginBlock="real" Type="KeyWord" />

      <lexem BeginBlock="realtime" Type="KeyWord" />

      <lexem BeginBlock="ref" Type="KeyWord" />

      <lexem BeginBlock="reg" Type="KeyWord" />

      <lexem BeginBlock="release" Type="KeyWord" />

      <lexem BeginBlock="repeat" Type="KeyWord" />

      <lexem BeginBlock="return" Type="KeyWord" />

      <lexem BeginBlock="rnmos" Type="KeyWord" />

      <lexem BeginBlock="rpmos" Type="KeyWord" />

      <lexem BeginBlock="rtran" Type="KeyWord" />

      <lexem BeginBlock="rtranif0" Type="KeyWord" />

      <lexem BeginBlock="rtranif1" Type="KeyWord" />

      <lexem BeginBlock="scalared" Type="KeyWord" />

      <lexem BeginBlock="sequence" Type="KeyWord" />

      <lexem BeginBlock="shortint" Type="KeyWord" />

      <lexem BeginBlock="shortreal" Type="KeyWord" />

      <lexem BeginBlock="showcancelled" Type="KeyWord" />

      <lexem BeginBlock="signed" Type="KeyWord" />

      <lexem BeginBlock="small" Type="KeyWord" />

      <lexem BeginBlock="solve" Type="KeyWord" />

      <lexem BeginBlock="specify" Type="KeyWord" />

      <lexem BeginBlock="specparm" Type="KeyWord" />

      <lexem BeginBlock="static" Type="KeyWord" />

      <lexem BeginBlock="string" Type="KeyWord" />

      <lexem BeginBlock="strong0" Type="KeyWord" />

      <lexem BeginBlock="strong1" Type="KeyWord" />

      <lexem BeginBlock="struct" Type="KeyWord" />

      <lexem BeginBlock="super" Type="KeyWord" />

      <lexem BeginBlock="supply0" Type="KeyWord" />

      <lexem BeginBlock="supply1" Type="KeyWord" />

      <lexem BeginBlock="table" Type="KeyWord" />

      <lexem BeginBlock="tagged" Type="KeyWord" />

      <lexem BeginBlock="task" Type="KeyWord" />

      <lexem BeginBlock="this" Type="KeyWord" />

      <lexem BeginBlock="throughout" Type="KeyWord" />

      <lexem BeginBlock="time" Type="KeyWord" />

      <lexem BeginBlock="timeprecision" Type="KeyWord" />

      <lexem BeginBlock="timeunit" Type="KeyWord" />

      <lexem BeginBlock="tran" Type="KeyWord" />

      <lexem BeginBlock="tranif0" Type="KeyWord" />

      <lexem BeginBlock="tranif1" Type="KeyWord" />

      <lexem BeginBlock="tri" Type="KeyWord" />

      <lexem BeginBlock="tri0" Type="KeyWord" />

      <lexem BeginBlock="tri1" Type="KeyWord" />

      <lexem BeginBlock="triand" Type="KeyWord" />

      <lexem BeginBlock="trior" Type="KeyWord" />

      <lexem BeginBlock="trireg" Type="KeyWord" />

      <lexem BeginBlock="type" Type="KeyWord" />

      <lexem BeginBlock="typedef" Type="KeyWord" />

      <lexem BeginBlock="union" Type="KeyWord" />

      <lexem BeginBlock="unique" Type="KeyWord" />

      <lexem BeginBlock="unsigned" Type="KeyWord" />

      <lexem BeginBlock="use" Type="KeyWord" />

      <lexem BeginBlock="var" Type="KeyWord" />

      <lexem BeginBlock="vectored" Type="KeyWord" />

      <lexem BeginBlock="virtual" Type="KeyWord" />

      <lexem BeginBlock="void" Type="KeyWord" />

      <lexem BeginBlock="wait" Type="KeyWord" />

      <lexem BeginBlock="wait_order" Type="KeyWord" />

      <lexem BeginBlock="wand" Type="KeyWord" />

      <lexem BeginBlock="weak0" Type="KeyWord" />

      <lexem BeginBlock="weak1" Type="KeyWord" />

      <lexem BeginBlock="while" Type="KeyWord" />

      <lexem BeginBlock="wildcard" Type="KeyWord" />

      <lexem BeginBlock="wire" Type="KeyWord" />

      <lexem BeginBlock="with" Type="KeyWord" />

      <lexem BeginBlock="within" Type="KeyWord" />

      <lexem BeginBlock="wor" Type="KeyWord" />

      <lexem BeginBlock="xnor" Type="KeyWord" />

      <lexem BeginBlock="xor" Type="KeyWord" />

    </lexems>

    <splits>

      <split>@"</split>

      <split>&lt;img</split>

      <split>/&gt;</split>

      <split>+=</split>

      <split>/=</split>

      <split>=/</split>

      <split>*=</split>

      <split>=*</split>

      <split>==</split>

      <split>!=</split>

      <split>=+</split>

      <split>-=</split>

      <split>++</split>

      <split>-=</split>

      <split>=-</split>

      <split>--</split>

      <split>/*</split>

      <split>*/</split>

      <split>//</split>

      <split>#if</split>

      <split>#endif</split>

      <split>#else</split>

      <split>#region</split>

      <split>#endregion</split>

      <split>///</split>

    </splits>

    <AutoReplaceTriggers>

      <AutoReplaceTrigger From="teh" To="the" />

      <AutoReplaceTrigger From="itn" To="int" />

    </AutoReplaceTriggers>

    <CodeSnippetsContainer>

      <CodeSnippetsContainer Name="Container 1">

        <CodeSnippetsContainer Name="Container11">

          <CodeSnippet Format="1.0.0">

            <Header>

              <Title>lock</Title>

              <Shortcut>lock</Shortcut>

              <Description>Code snippet for lock statement</Description>

              <Author>Microsoft Corporation</Author>

              <SnippetTypes>

                <SnippetType>Expansion</SnippetType>

                <SnippetType>SurroundsWith</SnippetType>

              </SnippetTypes>

            </Header>

            <Snippet>

              <Declarations>

                <Literal>

                  <ID>expression</ID>

                  <ToolTip>Expression to evaluate</ToolTip>

                  <Default>this</Default>

                </Literal>

              </Declarations>

              <Code Language="csharp"><![CDATA[lock ($expression$)

    {

        $selected$ $end$

    }]]></Code>

            </Snippet>

          </CodeSnippet>

          <CodeSnippet Format="1.0.0">

            <Header>

              <Title>namespace</Title>

              <Shortcut>namespace</Shortcut>

              <Description>Code snippet for namespace</Description>

              <Author>Microsoft Corporation</Author>

              <SnippetTypes>

                <SnippetType>Expansion</SnippetType>

                <SnippetType>SurroundsWith</SnippetType>

              </SnippetTypes>

            </Header>

            <Snippet>

              <Declarations>

                <Literal>

                  <ID>name</ID>

                  <ToolTip>Namespace name</ToolTip>

                  <Default>MyNamespace</Default>

                </Literal>

              </Declarations>

              <Code Language="csharp"><![CDATA[namespace $name$

    {

        $selected$ $end$

    }]]></Code>

            </Snippet>

          </CodeSnippet>

        </CodeSnippetsContainer>

        <CodeSnippet Format="1.0.0">

          <Header>

            <Title>for</Title>

            <Shortcut>for</Shortcut>

            <Description>Code snippet for 'for' loop</Description>

            <Author>Microsoft Corporation</Author>

            <SnippetTypes>

              <SnippetType>Expansion</SnippetType>

              <SnippetType>SurroundsWith</SnippetType>

            </SnippetTypes>

          </Header>

          <Snippet>

            <Declarations>

              <Literal>

                <ID>index</ID>

                <ToolTip>Index</ToolTip>

                <Default>i</Default>

              </Literal>

              <Literal>

                <ID>max</ID>

                <ToolTip>Max length</ToolTip>

                <Default>length</Default>

              </Literal>

            </Declarations>

            <Code Language="csharp"><![CDATA[for (int $index$ = 0; $index$ < $max$; $index$++)

            {

            $selected$ $end$

            }]]></Code>

          </Snippet>

        </CodeSnippet>

      </CodeSnippetsContainer>

      <CodeSnippetsContainer Name="Container 2">

        <CodeSnippet Format="1.0.0">

          <Header>

            <Title>struct</Title>

            <Shortcut>struct</Shortcut>

            <Description>Code snippet for struct</Description>

            <Author>Microsoft Corporation</Author>

            <SnippetTypes>

              <SnippetType>Expansion</SnippetType>

              <SnippetType>SurroundsWith</SnippetType>

            </SnippetTypes>

          </Header>

          <Snippet>

            <Declarations>

              <Literal>

                <ID>name</ID>

                <ToolTip>Struct name</ToolTip>

                <Default>MyStruct</Default>

              </Literal>

            </Declarations>

            <Code Language="csharp"><![CDATA[struct $name$

    {

        $selected$$end$

    }]]></Code>

          </Snippet>

        </CodeSnippet>

      </CodeSnippetsContainer>

      <CodeSnippet Format="1.0.0">

        <Header>

          <Title>if</Title>

          <Shortcut>if</Shortcut>

          <Description>Code snippet for if statement</Description>

          <Author>Microsoft Corporation</Author>

          <SnippetTypes>

            <SnippetType>Expansion</SnippetType>

            <SnippetType>SurroundsWith</SnippetType>

          </SnippetTypes>

        </Header>

        <Snippet>

          <Declarations>

            <Literal>

              <ID>expression</ID>

              <ToolTip>Expression to evaluate</ToolTip>

              <Default>true</Default>

            </Literal>

          </Declarations>

          <Code Language="csharp"><![CDATA[if ($expression$)

    {

        $selected$ $end$

    }]]></Code>

        </Snippet>

      </CodeSnippet>

      <CodeSnippet Format="1.0.0">

        <Header>

          <Title>try</Title>

          <Shortcut>try</Shortcut>

          <Description>Code snippet for try catch</Description>

          <Author>Microsoft Corporation</Author>

          <SnippetTypes>

            <SnippetType>Expansion</SnippetType>

            <SnippetType>SurroundsWith</SnippetType>

          </SnippetTypes>

        </Header>

        <Snippet>

          <Declarations>

            <Literal>

              <ID>expression</ID>

              <ToolTip>Exception type</ToolTip>

            </Literal>

          </Declarations>

          <Code Language="csharp"><![CDATA[try 

    {            

        $selected$

    }

    catch ($expression$)

    {

        $end$

        throw;

    }]]></Code>

        </Snippet>

      </CodeSnippet>

    </CodeSnippetsContainer>

  </ConfigLanguage>

</ArrayOfConfigLanguage>
View Code

 

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Xml;

using System.IO;

using Syncfusion.Windows.Forms.Edit;

using Syncfusion.Windows.Forms.Edit.Enums;

using Syncfusion.Windows.Forms.Edit.Utils.CodeSnippets;

using Syncfusion.XmlSerializersCreator;

using Syncfusion.Windows.Forms.Edit.Interfaces;

using System.Data.SqlClient;

using System.Collections.Generic;

using System.Text;

using System.Data.Sql;

using System.Xml.Linq;

using System.Xml.XPath;

//using CodeSnippetsDemo.MyEvent;

using Syncfusion.Windows.Forms.Edit.Implementation.Parser;

using System.Linq;

using System.Text.RegularExpressions;



namespace CodeSnippetsDemo

{

    public class Model

    {

        //private XElement root;



        //public XElement Root

        //{

        //    get { return root; }

        //    set { root = value; }

        //}

        private int lineComment;



        public int LineComment

        {

            get { return lineComment; }

            set { lineComment = value; }

        }

        private bool commentStart;



        public bool CommentStart

        {

            get { return commentStart; }

            set { commentStart = value; }

        }

        private Syncfusion.Windows.Forms.Edit.EditControl editControl1;



        public Syncfusion.Windows.Forms.Edit.EditControl EditControl1

        {

            get { return editControl1; }

            set { editControl1 = value; }

        }

        private static XElement root = new XElement("Root");



        public static XElement Root

        {

            get { return root; }

            set { root = value; }

        }

        private XElement currentNew;



        public XElement CurrentNew

        {

            get { return currentNew; }

            set { currentNew = value; }

        }

        private XElement currentCls;



        public XElement CurrentCls

        {

            get { return currentCls; }

            set { currentCls = value; }

        }

        private List<string> current = new List<string>();

        private List<string> previous = new List<string>();

        public void InitialText()

        {

            //this.editControl1.Invalidate();

            //this.editControl1.Update();

            //XmlDocument xmlDoc = new XmlDocument();

            //xmlDoc.Load("..\\..\\Verilog.xml");//加载xml文件,路径未指定时默认在当前项目环境下



            XElement currentParentNode = root;

            currentCls = null;

            //XElement currentChild = null;

            //root.Add(currentNew);

            //bool innerFuc = false;

            //bool innerClass = false;

            int lineID = 0;

            current.Clear();

            List<string> clsNames = new List<string>();



            foreach (string item in this.EditControl1.Lines)

            {

                if (item.Contains("class "))

                {

                    clsNames.Add(GetWordByLine(2, item.Trim()));

                }

            }

            foreach (string item in this.EditControl1.Lines)

            {



                ILexem lex;

                ILexemLine lexemLine = this.EditControl1.GetLine(lineID + 1);

                IList list = lexemLine.LineLexems;

                //if (GetWordNumByLine(item) > 1)

                foreach (object lexem in list)

                {

                    lex = (ILexem)lexem;

                    if (lex.Config.Format.Name == "Text")

                    {

                        if (clsNames.Contains(lex.Text))

                        {

                            //lex.Config.Format.FontColor = Color.ForestGreen;

                            this.EditControl1.SetTextColor(new Point(lex.Column, lineID + 1), new Point(lex.Column + lex.Length, lineID + 1), Color.Brown);

                        }

                        else

                        {

                            this.EditControl1.SetTextColor(new Point(lex.Column, lineID + 1), new Point(lex.Column + lex.Length, lineID + 1), Color.Black);

                        }

                    }

                    else

                    {

                        this.EditControl1.SetTextColor(new Point(lex.Column, lineID + 1), new Point(lex.Column + lex.Length, lineID + 1), lex.Config.Format.FontColor);

                    }

                }

                lineID++;

                switch (GetWordByLine(1, item))

                {

                    case "class":



                        if (item.Trim().Contains(" "))

                        {

                            currentCls = new XElement(GetWordByLine(2, item.Trim()));

                            if (root.Descendants(GetWordByLine(2, item.Trim())).Count() <= 0)

                            {

                                currentNew = new XElement(GetWordByLine(2, item.Trim()));

                                current.Add(GetWordByLine(2, item.Trim()));

                                XAttribute type = new XAttribute("Type", "class");

                                XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                currentNew.Add(type);

                                currentNew.Add(lineNumber);

                                root.Add(currentNew);

                                currentParentNode = currentNew;

                            }

                        }

                        break;

                    case "struct":

                        if (item.Trim().Contains(" "))

                        {

                            currentNew = new XElement(GetWordByLine(2, item.Trim()));

                            current.Add(GetWordByLine(2, item.Trim()));

                            XAttribute type = new XAttribute("Type", "class");

                            XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                            currentNew.Add(type);

                            currentNew.Add(lineNumber);

                            currentParentNode.Add(currentNew);

                            currentParentNode = currentNew;

                        }

                        break;

                    case "function":



                        if (GetWordNumByLine(item) > 2 && root.Element(currentCls.Name).Element(GetWordByLine(3, item.Trim())) != null && root.Element(currentCls.Name).Element(GetWordByLine(3, item.Trim())).Attribute("Name").Value != item.Trim()

                           || GetWordNumByLine(item) > 2 && root.Element(currentCls.Name).Element(GetWordByLine(3, item.Trim())) == null)

                        {

                            currentNew = new XElement(GetWordByLine(3, item));

                            XAttribute funName = new XAttribute("Name", item.Replace(';', ' ').Trim());

                            XAttribute funType = new XAttribute("Type", GetWordByLine(2, item));

                            XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                            XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                            XAttribute category = new XAttribute("Category", "Method");

                            currentNew.Add(funName);

                            currentNew.Add(funType);

                            currentNew.Add(parentClass);

                            currentNew.Add(lineNumber);

                            currentNew.Add(category);

                            if (GetParameters(item).Count > 0)

                            {

                                XAttribute para = new XAttribute("ParametersType", this.GetVirtualParametersType(GetParameters(item)));

                                currentNew.Add(para);

                            }

                            else

                            {

                                XAttribute para = new XAttribute("ParametersType", " ");

                                currentNew.Add(para);

                            }

                            //形参的所有类型

                            if (GetParameters(item).Count > 0)

                            {

                                XElement para = new XElement("Parameters");

                                XAttribute paraCount = new XAttribute("ParaCount", GetParameters(item).Count);

                                foreach (string paras in GetParameters(item))

                                {

                                    string[] args;

                                    args = paras.Split(' ');

                                    if (args.Length == 3)

                                    {

                                        XElement parameter = new XElement("Parameter");

                                        XAttribute paraPreType = new XAttribute("PreType", args[0].Trim());

                                        XAttribute paraType = new XAttribute("Type", args[1].Trim());

                                        XAttribute paraName = new XAttribute("Name", args[2].Trim());

                                        parameter.Add(paraPreType);

                                        parameter.Add(paraType);

                                        parameter.Add(paraName);

                                        para.Add(parameter);

                                    }

                                    if (args.Length == 2)

                                    {

                                        XElement parameter = new XElement("Parameter");

                                        XAttribute paraType = new XAttribute("Type", args[0].Trim());

                                        XAttribute paraName = new XAttribute("Name", args[1].Trim());

                                        parameter.Add(paraType);

                                        parameter.Add(paraName);

                                        para.Add(parameter);

                                    }

                                }

                                para.Add(paraCount);

                                currentNew.Add(para);

                            }

                            else

                            {

                                XElement para = new XElement("Parameters");

                                currentNew.Add(para);

                            }

                            //ovreride

                            int lexems = GetWordNumByLine(item);

                            OverRideMethod(currentParentNode, currentCls, item, lexems);

                           // currentParentNode = currentNew;

                        }

                        //}

                        else if (GetWordNumByLine(item) < 3 && GetWordNumByLine(item) > 1 && root.Element(currentCls.Name).Element(GetWordByLine(2, item.Trim())) != null

                            && root.Element(currentCls.Name).Element(GetWordByLine(2, item.Trim())).Attribute("Name").Value != item.Trim()

                           || GetWordNumByLine(item) < 3 && GetWordNumByLine(item) > 1 && root.Element(currentCls.Name).Element(GetWordByLine(2, item.Trim())) == null)

                        {

                            currentNew = new XElement(GetWordByLine(2, item));

                            XAttribute funName = new XAttribute("Name", item.Replace(';', ' ').Trim());

                            XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                            XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                            XAttribute category = new XAttribute("Category", "Method");

                            currentNew.Add(funName);

                            currentNew.Add(parentClass);

                            currentNew.Add(lineNumber);

                            currentNew.Add(category);

                            if (GetParameters(item).Count > 0)

                            {

                                XAttribute para = new XAttribute("ParametersType", this.GetVirtualParametersType(GetParameters(item)));

                                currentNew.Add(para);

                            }

                            else

                            {

                                XAttribute para = new XAttribute("ParametersType", " ");

                                currentNew.Add(para);

                            }

                            if (GetParameters(item).Count > 0)

                            {

                                XElement para = new XElement("Parameters");

                                XAttribute paraCount = new XAttribute("ParaCount", GetParameters(item).Count);

                                foreach (string paras in GetParameters(item))

                                {

                                    string[] args;

                                    args = paras.Split(' ');

                                    if (args.Length == 3)

                                    {

                                        XElement parameter = new XElement("Parameter");

                                        XAttribute paraPreType = new XAttribute("PreType", args[0].Trim());

                                        XAttribute paraType = new XAttribute("Type", args[1].Trim());

                                        XAttribute paraName = new XAttribute("Name", args[2].Trim());

                                        parameter.Add(paraPreType);

                                        parameter.Add(paraType);

                                        parameter.Add(paraName);

                                        para.Add(parameter);

                                    }

                                    if (args.Length == 2)

                                    {

                                        XElement parameter = new XElement("Parameter");

                                        XAttribute paraType = new XAttribute("Type", args[0].Trim());

                                        XAttribute paraName = new XAttribute("Name", args[1].Trim());

                                        parameter.Add(paraType);

                                        parameter.Add(paraName);

                                        para.Add(parameter);

                                    }

                                }

                                para.Add(paraCount);

                                //currentNew.Add(para);

                            }

                            else

                            {

                                XElement para = new XElement("Parameters");

                                currentNew.Add(para);

                            }

                            int lexems = GetWordNumByLine(item);

                            if (item.Contains("new"))

                            {

                                if (root.Element(currentCls.Name).Element(GetWordByLine(2, item)) != null)

                                {



                                }

                                else

                                {

                                    currentParentNode.Add(currentNew);

                                }



                            }

                            else

                            {

                                OverRideMethod(currentParentNode, currentCls, item, lexems);

                            }

                            //currentParentNode.Add(currentNew);

                             //currentParentNode = currentNew;

                        }

                        break;

                    case "module":



                        break;

                    case "task":

                        if (GetWordNumByLine(item) < 3 && GetWordNumByLine(item) > 1 && root.Descendants(GetWordByLine(2, item.Trim())).Count() <= 0)

                        {

                            currentNew = new XElement(GetWordByLine(2, item));

                            XAttribute funName = new XAttribute("Name", item.Replace(';', ' ').Trim());

                            XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Parent.Name);

                            XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                            XAttribute category = new XAttribute("Category", "Method");

                            currentNew.Add(funName);

                            currentNew.Add(parentClass);

                            currentNew.Add(lineNumber);

                            currentNew.Add(category);

                            if (GetParameters(item).Count > 0)

                            {

                                XElement para = new XElement("Parameters");

                                XAttribute paraCount = new XAttribute("ParaCount", GetParameters(item).Count);

                                foreach (string paras in GetParameters(item))

                                {

                                    string[] args;

                                    args = paras.Split(' ');

                                    if (args.Length == 3)

                                    {

                                        XElement parameter = new XElement("Parameter");

                                        XAttribute paraPreType = new XAttribute("PreType", args[0].Trim());

                                        XAttribute paraType = new XAttribute("Type", args[1].Trim());

                                        XAttribute paraName = new XAttribute("Name", args[2].Trim());

                                        parameter.Add(paraPreType);

                                        parameter.Add(paraType);

                                        parameter.Add(paraName);

                                        para.Add(parameter);

                                    }

                                    if (args.Length == 2)

                                    {

                                        XElement parameter = new XElement("Parameter");

                                        XAttribute paraType = new XAttribute("Type", args[0].Trim());

                                        XAttribute paraName = new XAttribute("Name", args[1].Trim());

                                        parameter.Add(paraType);

                                        parameter.Add(paraName);

                                        para.Add(parameter);

                                    }

                                }

                                para.Add(paraCount);

                                currentNew.Add(para);

                            }

                            else

                            {

                                XElement para = new XElement("Parameters");

                                currentNew.Add(para);

                            }

                            currentParentNode.Add(currentNew);

                            //currentParentNode = currentNew;

                        }

                        break;

                    case "table":



                        break;

                    case "package":



                        break;

                    case "generate":



                        break;

                    case "config":



                        break;

                    case "clocking":



                        break;

                    case "endclass":

                        //if (currentNew != null)

                        //    currentParentNode = currentNew.Parent.Parent;

                        break;

                    case "endfunction":

                        //currentParentNode = currentNew.Parent;

                        break;

                    case "endtask":

                        //currentParentNode = currentNew.Parent;

                        break;

                    case "///":

                        //TODO:很多问题

                        if (string.IsNullOrEmpty(item.Replace('/', ' ').Trim()))

                        {

                            lineComment = this.editControl1.CurrentLine;

                            commentStart = true;

                        }

                        if (this.editControl1.CurrentLineText.Length > 2 && this.editControl1.CurrentLineText == item)

                        {

                            string thisline = this.editControl1.Lines[this.editControl1.CurrentLine - 1];

                            string commentValue = thisline.Replace('/', ' ').Trim();

                            if (!string.IsNullOrEmpty(commentValue) && commentValue != "<summary>")

                            {



                                if (xel.Element("Comment") == null)

                                {

                                    XElement xelComment = new XElement("Comment");



                                    XAttribute xattName = new XAttribute("CommentValue", commentValue);

                                    XAttribute xattType = new XAttribute("Type", xelComment.Name);

                                    XAttribute xattLine = new XAttribute("lineNum", this.editControl1.CurrentLine);

                                    xelComment.Add(xattName);

                                    xelComment.Add(xattType);

                                    xelComment.Add(xattLine);

                                    xel.Add(xelComment);



                                    root.Element(xel.Name).Add(xel);



                                    currentParentNode.Add(xel);

                                    //currentParentNode = currentNew;

                                }

                                else

                                {

                                    xel.Element("Comment").Remove();

                                    if (root.Descendants("current_status").Count() >= 1)

                                    {

                                        //root.Element("Packet").Element(xel.Name).Element("Comment").Remove();



                                        XElement xelComment = new XElement("Comment");



                                        XAttribute xattName = new XAttribute("CommentValue", commentValue);

                                        XAttribute xattType = new XAttribute("Type", xelComment.Name);

                                        XAttribute xattLine = new XAttribute("lineNum", this.editControl1.CurrentLine);

                                        xelComment.Add(xattName);

                                        xelComment.Add(xattType);

                                        xelComment.Add(xattLine);

                                        xel.Add(xelComment);

                                        if (root.Element(currentCls.Name).Element(xel.Name) != null )

                                        {

                                            if (root.Element(currentCls.Name).Elements(xel.Name).Count() >= 0)

                                            {

                                                IEnumerable<XElement> elements = root.Element(currentCls.Name).Elements(xel.Name);

                                                foreach (var element in elements)

                                                {

                                                    if (element.Attribute("ParametersType").Value == xel.Attribute("ParametersType").Value)

                                                    {

                                                        element.Remove();

                                                        root.Element(currentCls.Name).Add(xel);

                                                    }

                                                }

                                            }

                                            

                                        }

                                        else

                                        {

                                            root.Element(currentCls.Name).Element(xel.Name).Add(xel);

                                        }

                                    }

                                    //currentParentNode.Add(xel);

                                    //currentParentNode = currentNew;

                                }

                            }

                        }



                        break;



                    default:

                        string fieldName = null;

                        string subcomment = null;

                        if (item.Contains("["))

                        {

                            fieldName = GetWordByLine(3, item.Trim()).Trim();

                        }

                        else

                        {

                            fieldName = GetWordByLine(2, item.Trim()).Trim();



                        }

                        if (item.Contains("//"))

                        {

                            subcomment = item.Substring(0, item.Trim().IndexOf("//"));

                        }

                        // if (fieldName == "=" || string.IsNullOrEmpty(fieldName) || string.IsNullOrEmpty(subcomment) && fieldName == "=" || string.IsNullOrEmpty(fieldName)) break;

                        string RegStrings = "^[A-Za-z_$]+$";

                        Regex regex = new Regex(RegStrings, RegexOptions.IgnoreCase);

                        Match m = regex.Match(fieldName);

                        if (m.Success)

                        {

                            if (root.Element(currentCls.Name).Descendants(fieldName).Count() <= 0)  //TODO:不同类下面的具体field method

                            {

                                if (!string.IsNullOrEmpty(item.Trim()))

                                {

                                    if (!item.Contains("="))

                                    {

                                        if (!item.Contains("."))

                                        {

                                            if (!item.Contains("//"))

                                            {

                                                #region



                                                if (GetWordNumByLine(item) > 2)

                                                {

                                                    XElement feild = new XElement(GetWordByLine(3, item));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(3, item));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, item) + GetWordByLine(2, item));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                if (GetWordNumByLine(item) < 3 && GetWordNumByLine(item) > 1)

                                                {

                                                    XElement feild = new XElement(GetWordByLine(2, item));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(2, item));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, item));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                #endregion

                                            }

                                            else

                                            {

                                                #region



                                                string sub = item.Substring(0, item.IndexOf("//"));

                                                if (GetWordNumByLine(sub) > 2 && !string.IsNullOrEmpty(sub))

                                                {

                                                    XElement feild = new XElement(GetWordByLine(3, sub));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(3, sub));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, sub) + GetWordByLine(2, sub));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                if (GetWordNumByLine(item) < 3 && GetWordNumByLine(sub) > 1 && !string.IsNullOrEmpty(sub))

                                                {

                                                    XElement feild = new XElement(GetWordByLine(2, sub));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(2, sub));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, sub));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                #endregion

                                            }

                                        }





                                    }

                                    else

                                    {

                                        string sub = item.Substring(0, item.IndexOf("="));



                                        if (!item.Contains("."))

                                        {

                                            if (!item.Contains("//"))

                                            {

                                                #region



                                                if (GetWordNumByLine(sub) > 2)

                                                {

                                                    XElement feild = new XElement(GetWordByLine(3, sub));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(3, sub));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, sub) + GetWordByLine(2, sub));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                if (GetWordNumByLine(sub) < 3 && GetWordNumByLine(sub) > 1)

                                                {

                                                    XElement feild = new XElement(GetWordByLine(2, sub));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(2, sub));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, sub));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                #endregion

                                            }

                                            else

                                            {

                                                #region



                                                //string sub = item.Substring(0, item.IndexOf("//"));

                                                if (GetWordNumByLine(sub) > 2 && !string.IsNullOrEmpty(sub))

                                                {

                                                    XElement feild = new XElement(GetWordByLine(3, sub));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(3, sub));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, sub) + GetWordByLine(2, sub));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                if (GetWordNumByLine(item) < 3 && GetWordNumByLine(sub) > 1 && !string.IsNullOrEmpty(sub) && !item.Contains("///"))

                                                {

                                                    XElement feild = new XElement(GetWordByLine(2, sub));

                                                    XAttribute fldName = new XAttribute("Name", GetWordByLine(2, sub));

                                                    XAttribute fldType = new XAttribute("Type", GetWordByLine(1, sub));

                                                    XAttribute parentClass = new XAttribute("ParentClass", currentParentNode.Name);

                                                    XAttribute lineNumber = new XAttribute("LineNumber", lineID);

                                                    XAttribute category = new XAttribute("Category", "Field");

                                                    feild.Add(fldName);

                                                    feild.Add(fldType);

                                                    feild.Add(parentClass);

                                                    feild.Add(lineNumber);

                                                    feild.Add(category);

                                                    currentParentNode.Add(feild);

                                                }

                                                #endregion

                                            }

                                        }

                                    }

                                }

                            }

                        }

                        break;

                }

            }

            //if (this.CommentStart && string.IsNullOrEmpty(this.editControl1.Lines[this.LineComment - 1].Replace('/', ' ').Trim()))

            //{

            //    int line = this.LineComment;



            //    if (line != 1)

            //    {

            //        while (string.IsNullOrEmpty(this.editControl1.Lines[line]))

            //        {

            //            line++;

            //        }

            //        xdoc = new XmlDocument();

            //        xdoc.LoadXml(root.ToString());

            //        XmlNodeReader reader = new XmlNodeReader(xdoc);

            //        XElement rootNode = XElement.Load(reader);

            //        if (!string.IsNullOrEmpty(GetWordByLine(1, this.editControl1.Lines[line])))

            //        {



            //            if (GetWordByLine(1, this.editControl1.Lines[line]) == "function")

            //            {



            //                //XDocument xdoc = XDocument.Load(root.ToString());

            //                if (GetWordNumByLine(this.editControl1.Lines[line]) > 2)

            //                {

            //                    string FuncName = GetWordByLine(3, this.editControl1.Lines[line]);

            //                    IEnumerable<XElement> targetNodes = from target in rootNode.Descendants(FuncName)

            //                                                        select target;

            //                    foreach (var item in targetNodes)

            //                    {

            //                        if (item.Element("Parameters").Attribute("ParaCount").Value == "2")

            //                        {

            //                            xel = item;

            //                        }

            //                    }

            //                }

            //            }

            //        }

            //    }

            //}

        }



        private void OverRideMethod(XElement currentParentNode, XElement currentCls, string item, int lexems)

        {

            List<string> types = new List<string>();



            IEnumerable<XElement> elements = root.Element(currentCls.Name).Elements(GetWordByLine(lexems, item.Trim()));

            foreach (var element in elements)

            {



                types.Add(element.Attribute("ParametersType").Value);

            }

            if (types.Contains(this.GetVirtualParametersType(GetParameters(item))))

            {

               

            }

            else

            {

                currentParentNode.Add(currentNew);

            }



            // ||root.Element(currentCls.Name).Descendants(GetWordByLine(lexems, item.Trim())).Count() <= 0&&root.Element(currentCls.Name).Element(GetWordByLine(lexems,item)).Attribute("Name").Value!=item.Replace(';',' ').Trim()

            if (root.Element(currentCls.Name).Descendants(GetWordByLine(lexems, item.Trim())).Count() <= 0

               )

            {

                currentParentNode.Add(currentNew);

            }





        }

        //public XmlAttribute CreateAttribute(XmlNode node, string attributeName, string value)

        //{

        //    try

        //    {

        //        XmlDocument doc = node.OwnerDocument;

        //        XmlAttribute attr = null;

        //        attr = doc.CreateAttribute(attributeName);

        //        attr.Value = value;

        //        node.Attributes.SetNamedItem(attr);

        //        return attr;

        //    }

        //    catch (Exception err)

        //    {

        //        string desc = err.Message;

        //        return null;

        //    }

        //}



        private XElement xel;



        public XElement Xel

        {

            get { return xel; }

            set { xel = value; }

        }

        private static XmlDocument xdoc;



        public static XmlDocument Xdoc

        {

            get { return xdoc; }

            set { xdoc = value; }

        }

        private string GetWordByLine(int num, string line)

        {

            string[] strText;

            List<string> strList = new List<string>();

            if (!string.IsNullOrEmpty(line.Trim()))

            {

                if (line.Contains(";"))

                {

                    line = line.Replace(';', ' ').Trim();

                    if (!line.Contains("("))

                    {

                        if (line.Trim().Contains(" "))

                        {

                            strText = line.Trim().Split(' ');

                            strList.AddRange(strText);

                            List<string> list = new List<string>();

                            foreach (string item in strList)

                            {

                                if (item != "")

                                {

                                    list.Add(item);

                                }

                            }

                            if (num < list.Count + 1)

                                return list[num - 1].Trim();

                            else

                                return "";

                        }

                        else

                        {

                            return line.Trim();

                        }

                    }

                    else

                    {

                        line = line.Substring(0, line.IndexOf("(")).Trim();

                        if (line.Trim().Contains(" "))

                        {

                            strText = line.Trim().Split(' ');

                            strList.AddRange(strText);

                            List<string> list = new List<string>();

                            foreach (string item in strList)

                            {

                                if (item != "")

                                {

                                    list.Add(item);

                                }

                            }

                            if (num < list.Count + 1)

                                return list[num - 1].Trim();

                            else

                                return "";

                        }

                        else

                        {

                            return line.Trim();

                        }

                    }

                }

                else

                {

                    if (!line.Contains("("))

                    {

                        if (line.Trim().Contains(" "))

                        {

                            strText = line.Trim().Split(' ');

                            strList.AddRange(strText);

                            List<string> list = new List<string>();

                            foreach (string item in strList)

                            {

                                if (item != "")

                                {

                                    list.Add(item);

                                }

                            }

                            if (num < list.Count + 1)

                                return list[num - 1].Trim();

                            else

                                return "";

                        }

                        else

                        {

                            return line.Trim();

                        }

                    }

                    else

                    {

                        line = line.Substring(0, line.IndexOf("(")).Trim();

                        if (line.Trim().Contains(" "))

                        {

                            strText = line.Trim().Split(' ');

                            strList.AddRange(strText);

                            List<string> list = new List<string>();

                            foreach (string item in strList)

                            {

                                if (item != "")

                                {

                                    list.Add(item);

                                }

                            }

                            if (num < list.Count + 1)

                                return list[num - 1].Trim();

                            else

                                return "";

                        }

                        else

                        {

                            return line.Trim();

                        }

                    }

                }



            }

            return "";

        }



        private int GetWordNumByLine(string line)

        {

            string[] strText;

            List<string> strList = new List<string>();

            if (!string.IsNullOrEmpty(line.Trim()))

            {

                if (!line.Contains("("))

                {

                    if (line.Contains(";"))

                    {

                        strText = line.Replace(';', ' ').Trim().Split(' ');

                        strList.AddRange(strText);

                        List<string> list = new List<string>();

                        foreach (string item in strList)

                        {

                            if (item != "")

                            {

                                list.Add(item);

                            }

                        }

                        int length = list.Count;

                        return length;

                    }

                    else

                    {

                        strText = line.Trim().Split(' ');

                        strList.AddRange(strText);

                        List<string> list = new List<string>();

                        foreach (string item in strList)

                        {

                            if (item != "")

                            {

                                list.Add(item);

                            }

                        }

                        int length = list.Count;

                        return length;

                    }

                }

                else

                {

                    line = line.Substring(0, line.IndexOf("(")).Trim();

                    if (line.Contains(";"))

                    {

                        strText = line.Replace(';', ' ').Trim().Split(' ');

                        strList.AddRange(strText);

                        List<string> list = new List<string>();

                        foreach (string item in strList)

                        {

                            if (item != "")

                            {

                                list.Add(item);

                            }

                        }

                        int length = list.Count;

                        return length;

                    }

                    else

                    {

                        strText = line.Trim().Split(' ');

                        strList.AddRange(strText);

                        List<string> list = new List<string>();

                        foreach (string item in strList)

                        {

                            if (item != "")

                            {

                                list.Add(item);

                            }

                        }

                        int length = list.Count;

                        return length;

                    }

                }

            }

            return 0;

        }

        private string GetClsNameOfInstanse(int currentLine)

        {

            for (int i = currentLine - 1; i >= 0; i--)

            {

                if (this.EditControl1.Lines[i].Contains("class "))

                {

                    return this.GetWordByLine(2, this.EditControl1.Lines[i]);

                }

            }

            return "";

        }

        private List<string> GetParameters(string lineText)

        {

            List<string> parameters = new List<string>();

            if (lineText.Contains("(") && lineText.Contains(")"))

            {

                int index = lineText.IndexOf("(");

                int index2 = lineText.IndexOf(")");

                lineText = lineText.Substring(index + 1, index2 - index - 1);

                if (!string.IsNullOrEmpty(lineText.Trim()))

                {

                    if (lineText.Trim().Contains(","))

                    {

                        parameters.AddRange(lineText.Split(','));

                        return parameters;

                    }

                    else

                    {

                        parameters.Add(lineText.Trim());

                        return parameters;

                    }

                }

            }

            return parameters;

        }

        // 如何获取方法体的xu参数类型



        private string GetVirtualParametersType(List<string> param)

        {

            string paraType = "";

            if (param.Count > 0)

            {

                foreach (string item in param)

                {

                    string[] str = item.Trim().Split(' ');

                    paraType = paraType + str[0].Trim() + " ";

                }

                return paraType;

            }

            return "";

        }

        //获取成员方法的实参的类型

        private string GetRealParametersType(List<string> param)

        {

            string paraType = "";

            List<string> para = new List<string>();

            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(Root.ToString());

            if (param.Count > 0)

            {

                foreach (string item in param)

                {

                    foreach (XmlNode node in xdoc.SelectNodes("//" + item))

                    {

                        if (node.Attributes["ParentClass"] != null)

                        {

                            node.Attributes["ParentClass"].Value = GetClassMembersParent(this.EditControl1.CurrentLine);

                            paraType = paraType + node.Attributes["Type"].Value + " ";

                        }

                    }

                }

                return paraType;

            }

            return "null";

        }

        private string GetClassMembersParent(int lineNum)

        {

            for (int i = lineNum - 1; i > 0; i--)

            {

                if (this.EditControl1.Lines[i].Contains("class "))

                {

                    return GetWordByLine(2, this.EditControl1.Lines[i]);

                }

            }

            return "";

        }

    }

}
View Code

 

 所有这些是自己为了方便记载下来,仅供以后自己参考使用。

 

你可能感兴趣的:(面试)