2018-01-18 Bpmn-JS修改生成的XML痹束、.net(c#) winform文本框輸入、AngularJS 事件讶请、伸縮框的設(shè)置祷嘶、DevExpress中GridView上的右鍵菜單

第一組:劉聰 Bpmn-JS修改生成的XML

1:修改dc:Bound、di:waypoint標(biāo)簽夺溢,去掉bpmndi:BPMNLabel(保留其子標(biāo)簽)

ElementSerializer.prototype.serializeTo = function(writer) {
  var hasBody = this.body.length,
      indent = !(this.body.length === 1 && this.body[0] instanceof BodySerializer);
  if ("dc:Bounds,di:waypoint".indexOf(nsName(this.ns)) >= 0) {
      writer
   .appendIndent()
   .append('<omg' + nsName(this.ns));

      this.serializeAttributes(writer);

      //writer.append(hasBody ? '>' : ' />');
      writer.append('>');
      if (hasBody) {

          if (indent) {
              writer
                .appendNewLine()
                .indent();
          }

          forEach(this.body, function (b) {
              b.serializeTo(writer);
          });

          if (indent) {
              writer
                .unindent()
                .appendIndent();
          }
      }
      writer.append('</omg' + nsName(this.ns) + '>');
      writer.appendNewLine();
  }
  else if ("bpmndi:BPMNLabel".indexOf(nsName(this.ns)) >= 0)
  {
      if (hasBody) {
          if (indent) {
              writer
                .appendNewLine()
                .indent();
          }
          forEach(this.body, function (b) {
              b.serializeTo(writer);
          });
          if (indent) {
              writer
                .unindent()
                .appendIndent();
          }      
  }
}
  else {
      writer
        .appendIndent()
        .append('<' + nsName(this.ns));
      this.serializeAttributes(writer);
      //writer.append(hasBody ? '>' : ' />');
      writer.append('>');
      if (hasBody) {
          if (indent) {
              writer
                .appendNewLine()
                .indent();
          }
          forEach(this.body, function (b) {
              b.serializeTo(writer);
          });
          if (indent) {
              writer
                .unindent()
                .appendIndent();
          }
      }
      writer.append('</' + nsName(this.ns) + '>');
      writer.appendNewLine();
  }
};

2.去掉outgoing论巍、incoming標(biāo)簽和內(nèi)容。

ReferenceSerializer.prototype.serializeTo = function (writer) {
    if ("outgoing,incoming".indexOf(nsName(this.ns)) < 0) {
        writer
          .appendIndent()
          .append('<' + nsName(this.ns) + '>' + this.element.id + '</' + nsName(this.ns) + '>')
          .appendNewLine();
    };
}  

3.去掉BPMN2

function nsName(ns) {
  if (isString(ns)) {
    return ns;
  } else {      
      return ((ns.prefix && "bpmn2".indexOf(ns.prefix)<0)? ns.prefix + ':' : '') + ns.localName;     
  }
}  

4:修改標(biāo)簽里面的屬性名稱:

ElementSerializer.prototype.serializeAttributes = function(writer) {
 var attrs = this.attrs,
     root = !this.parent;

 if (root) {
   attrs = getNsAttrs(this.namespaces).concat(attrs);
 }
 
 forEach(attrs, function (a) {
     if ("camunda".indexOf(a.name.prefix) >= 0) { a.name.prefix = "activiti"; }
     if ("xmlns:camunda".indexOf(a.name) >= 0) { a.name = "xmlns:activiti" }
     if ("xmlns:dc".indexOf(a.name) >= 0) { a.name = "xmlns:omgdc" }
     if ("xmlns:di".indexOf(a.name) >= 0) { a.name = "xmlns:omgdi" }
     if ("xmlns:bpmn2".indexOf(a.name) >= 0) { a.name = "xmlns" }
     //if ("camunda:candidateGroups".indexOf(a.name) >= 0) { a.name = "activiti:candidateGroups" }
   writer
     .append(' ')  

     .append(nsName(a.name)).append('="').append(a.value).append('"');
 });
};

備注:生成的xml與openDiagram(newDiagramXML)中的newDiagramXML有關(guān)风响。newDiagramXML默認(rèn)為:

var newDiagramXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bpmn2:definitions xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:bpmn2=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:dc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:camunda=\"http://camunda.org/schema/1.0/bpmn\"  xmlns:di=\"http://www.omg.org/spec/DD/20100524/DI\" xsi:schemaLocation=\"http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd\" id=\"sample-diagram\" targetNamespace=\"http://bpmn.io/schema/bpmn\">\n  <bpmn2:process id=\"Process_1\" isExecutable=\"false\">\n    <!-- <bpmn2:startEvent id=\"StartEvent_1\"/>-->\n  </bpmn2:process>\n  <bpmndi:BPMNDiagram id=\"BPMNDiagram_1\">\n    <bpmndi:BPMNPlane id=\"BPMNPlane_1\" bpmnElement=\"Process_1\">\n      <!--<bpmndi:BPMNShape id=\"_BPMNShape_StartEvent_2\" bpmnElement=\"StartEvent_1\">\n        <dc:Bounds height=\"36.0\" width=\"36.0\" x=\"412.0\" y=\"240.0\"/>\n      </bpmndi:BPMNShape>-->\n    </bpmndi:BPMNPlane>\n  </bpmndi:BPMNDiagram>\n</bpmn2:definitions>";

第二組:馮佳麗 .net(c#) winform文本框輸入

轉(zhuǎn)載

C#的winform中控制TextBox中只能輸入數(shù)字(加上固定位數(shù)和首位不能為0)
給個(gè)最簡單的方法:

private void textBox3_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    //阻止從鍵盤輸入鍵
    e.Handled = true;
    if(e.KeyChar>='0' && e.KeyChar <='9')
    {
        e.Handled = false;
    }

}

或者

private void tbID_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == ' '))//不輸入輸入除了數(shù)字之外的所有非法字符的判斷
            {
                e.Handled = true;
            }
        }

多條件的:

private void TxtUser_KeyPress(object sender, KeyPressEventArgs e)
        {
            //阻止從鍵盤輸入鍵
           e.Handled = true;
            if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar == (char)8))
            {
                if ((e.KeyChar == (char)8)) { e.Handled = false; return; }
                else
                {
                    int len = TxtUser.Text.Length;
                    if (len < 5)
                    {
                        if (len == 0 && e.KeyChar != '0')
                        {
                            e.Handled = false; return;
                        }
                        else if(len == 0)
                        {
                            MessageBox.Show("編號(hào)不能以0開頭嘉汰!"); return;
                        }
                        e.Handled = false; return;
                    }
                    else
                    {
                        MessageBox.Show("編號(hào)最多只能輸入5位數(shù)字!");
                    }
                }
            }
            else
            {
                MessageBox.Show("編號(hào)只能輸入數(shù)字状勤!");
            }
           
        }

也可以用正則表達(dá)式:

C#Winform下用正則表達(dá)式限制TextBox只能輸入數(shù)字 昨天鞋怀,在網(wǎng)上特別是園子里搜了下如何在Winform下限制TextBox只能輸入數(shù)字的功能〕炙眩可是結(jié)果基本上都是在web的環(huán)境下用正則表達(dá)式實(shí)現(xiàn)的密似,而在Winform的平臺(tái)下,好像沒有發(fā)現(xiàn)葫盼。 就自己循著思路實(shí)現(xiàn)了下残腌。

首先,先定義一個(gè)string贫导,用來表示數(shù)字的正則表達(dá)式:

privatestring pattern =@"^[0-9]*$";

然后再定義一個(gè)string抛猫,用來記錄TextBox原來的內(nèi)容,以便在輸入非數(shù)字的時(shí)候脱盲,文本框的內(nèi)容可以恢復(fù)到原來的值(我不知道TextBox怎么恢復(fù)到上一次的內(nèi)容邑滨,只能采用這個(gè)笨辦法了):

privatestring param1 =null;

接著,我們就可以在textBox的TextChanged事件中判斷輸入的是否是數(shù)字钱反,如果是數(shù)字掖看,那么就把文本框的內(nèi)容保存在param1中匣距;如果不是數(shù)字,那么取消這次輸入哎壳,即重新設(shè)置文本框的內(nèi)容為param1:

        privatevoid textBoxParam1_TextChanged(object sender, EventArgs e)
        {
             Match m = Regex.Match(this.textBoxParam1.Text, pattern);   // 匹配正則表達(dá)式

            if (!m.Success)   // 輸入的不是數(shù)字
            {
                this.textBoxParam1.Text = param1;   // textBox內(nèi)容不變

                // 將光標(biāo)定位到文本框的最后
                this.textBoxParam1.SelectionStart =this.textBoxParam1.Text.Length;
             }
            else   // 輸入的是數(shù)字
            {
                 param1 =this.textBoxParam1.Text;   // 將現(xiàn)在textBox的值保存下來
             }
         }

網(wǎng)頁里面:

<asp:textbox id="TextBox1" onkeyup="if(isNaN(value))execCommand('undo')" runat="server"
Width="80px" onafterpaste="if(isNaN(value))execCommand('undo')"></asp:textbox>

其實(shí)服務(wù)器控件也能加上onkeydown與up等事件的
這樣就行了 只能輸入小數(shù)與數(shù)字


第三組:吳景霞 AngularJS 事件

ng-click 指令
ng-click 指令定義了 AngularJS 點(diǎn)擊事件毅待。
AngularJS 實(shí)例

<div ng-app="" ng-controller="myCtrl">
<button ng-click="count = count + 1">點(diǎn)我!</button>
<p>{{ count }}</p>
</div>

ng-hide 指令用于設(shè)置應(yīng)用部分是否可見归榕。
ng-hide="true" 設(shè)置 HTML 元素不可見尸红。
ng-hide="false" 設(shè)置 HTML 元素可見。

AngularJS 實(shí)例

<div ng-app="myApp" ng-controller="personCtrl">
<button ng-click="toggle()">隱藏/顯示</button>
<p ng-hide="myVar">
名: <input type="text" ng-model="firstName"><br>
姓名: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
    $scope.firstName = "John",
    $scope.lastName = "Doe"
    $scope.myVar = false;
    $scope.toggle = function() {
        $scope.myVar = !$scope.myVar;
    };
});
</script> 

應(yīng)用解析:
第一部分 personController與控制器章節(jié)類似刹泄。

應(yīng)用有一個(gè)默認(rèn)屬性: $scope.myVar = false;
ng-hide 指令設(shè)置 <p>元素及兩個(gè)輸入域是否可見外里, 根據(jù) myVar 的值 (true 或 false) 來設(shè)置是否可見。
toggle() 函數(shù)用于切換 myVar 變量的值(true 和 false)特石。
ng-hide="true" 讓元素 不可見盅蝗。

顯示 HTML 元素

ng-show 指令可用于設(shè)置應(yīng)用中的一部分是否可見 。
ng-show="false" 可以設(shè)置 HTML 元素 不可見姆蘸。
ng-show="true" 可以以設(shè)置 HTML 元素可見墩莫。

以下實(shí)例使用了 ng-show 指令:

AngularJS 實(shí)例

<div ng-app="myApp" ng-controller="personCtrl">
<button ng-click="toggle()">隱藏/顯示</button>
<p ng-show="myVar">
名: <input type="text" ng-model="firstName"><br>
姓: <input type="text" ng-model="lastName"><br>
<br>
姓名: {{firstName + " " + lastName}}
</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
    $scope.firstName = "John",
    $scope.lastName = "Doe"
    $scope.myVar = true;
    $scope.toggle = function() {
        $scope.myVar = !$scope.myVar;
    }
});
</script> 

第四組:傅云 伸縮框的設(shè)置

伸縮框的代碼

 <script type="text/javascript">
           $(function () {
               $('#iframe2')[0].style.visibility = 'hidden';
               //$('#iframe1')[0].style.visibility = 'hidden';
               //FieldSetVisual('iframe1', 'fset_ShipInportInfo', 'img_ShipInportInfo', 'outdiv');
               FieldSetVisual('iframe2', 'fset_ShipInportInfo2', 'img_ShipInportInfo2');
               $('#iframe1')[0].style.visibility = 'hidden';
               FieldSetVisual('iframe1', 'fset_ShipInportInfo', 'img_ShipInportInfo');
           })
           // 設(shè)置FieldSet高度方法,支持IE瀏覽器逞敷、Firefox 
           // 參數(shù)1:pTableID狂秦,F(xiàn)ieldSet內(nèi)部div或table的id 
           // 參數(shù)2:pFieldSetID,F(xiàn)ieldSet的ID 
           // 參數(shù)3:pImageID推捐,圖片的ID裂问,展開或收縮后更新圖片SRC 
</script>

第五組:王炳鈞 DevExpress中GridView上的右鍵菜單

網(wǎng)址: https://www.cnblogs.com/kkun/archive/2010/01/14/1647570.html

如上圖,先選中GridView,不是GridControl,在屬性窗口中,選擇事件窗口,注冊(cè)事件MouseUp

代碼如下,其中popupMenu_ResumeGrid為DevExpress.XtraBars.PopupMenu

gridView_ResumeCollection為private DevExpress.XtraGrid.Views.Grid.GridView

private void gridView_ResumeCollection_MouseUp(object sender, MouseEventArgs e) { 
            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi =this.gridView_ResumeCollection.CalcHitInfo(e.Location); 
            if (hi.InRow && e.Button == MouseButtons.Right) { 
                popupMenu_ResumeGrid.ShowPopup(Control.MousePosition); 
            } 
        }

備注序列化和反序列化代碼

IFormatter formatter = new BinaryFormatter(); 
                using (Stream stream = new FileStream(ResumeCollection.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read)) { 
                    if (stream.Length > 0) { 
                        formatter.Serialize(stream, new object()); 
                        //ResumeCollection = (ResumeCollection)formatter.Deserialize(stream); 
                        stream.Close(); 
                    } 
                }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市牛柒,隨后出現(xiàn)的幾起案子愕秫,更是在濱河造成了極大的恐慌,老刑警劉巖焰络,帶你破解...
    沈念sama閱讀 218,546評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件戴甩,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡闪彼,警方通過查閱死者的電腦和手機(jī)甜孤,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,224評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來畏腕,“玉大人缴川,你說我怎么就攤上這事∶柘冢” “怎么了把夸?”我有些...
    開封第一講書人閱讀 164,911評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長铭污。 經(jīng)常有香客問我恋日,道長膀篮,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,737評(píng)論 1 294
  • 正文 為了忘掉前任岂膳,我火速辦了婚禮誓竿,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘谈截。我一直安慰自己筷屡,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,753評(píng)論 6 392
  • 文/花漫 我一把揭開白布簸喂。 她就那樣靜靜地躺著毙死,像睡著了一般。 火紅的嫁衣襯著肌膚如雪喻鳄。 梳的紋絲不亂的頭發(fā)上规哲,一...
    開封第一講書人閱讀 51,598評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音诽表,去河邊找鬼。 笑死隅肥,一個(gè)胖子當(dāng)著我的面吹牛竿奏,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播腥放,決...
    沈念sama閱讀 40,338評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼泛啸,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了秃症?” 一聲冷哼從身側(cè)響起候址,我...
    開封第一講書人閱讀 39,249評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎种柑,沒想到半個(gè)月后岗仑,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,696評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡聚请,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,888評(píng)論 3 336
  • 正文 我和宋清朗相戀三年荠雕,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片驶赏。...
    茶點(diǎn)故事閱讀 40,013評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡炸卑,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出煤傍,到底是詐尸還是另有隱情盖文,我是刑警寧澤,帶...
    沈念sama閱讀 35,731評(píng)論 5 346
  • 正文 年R本政府宣布蚯姆,位于F島的核電站五续,受9級(jí)特大地震影響洒敏,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜返帕,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,348評(píng)論 3 330
  • 文/蒙蒙 一桐玻、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧荆萤,春花似錦镊靴、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,929評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至敞峭,卻和暖如春踊谋,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背旋讹。 一陣腳步聲響...
    開封第一講書人閱讀 33,048評(píng)論 1 270
  • 我被黑心中介騙來泰國打工殖蚕, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人沉迹。 一個(gè)月前我還...
    沈念sama閱讀 48,203評(píng)論 3 370
  • 正文 我出身青樓睦疫,卻偏偏與公主長得像,于是被迫代替她去往敵國和親鞭呕。 傳聞我的和親對(duì)象是個(gè)殘疾皇子蛤育,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,960評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容