2018-01-18 Bpmn-JS修改生成的XML、.net(c#) winform文本框输入、AngularJS 事件、伸缩框的设置、DevExpress中GridView上的右键菜单

第一组:刘聪 Bpmn-JS修改生成的XML

1:修改dc:Bound、di:waypoint标签,去掉bpmndi:BPMNLabel(保留其子标签)

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('' : ' />');
      writer.append('>');
      if (hasBody) {

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

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

          if (indent) {
              writer
                .unindent()
                .appendIndent();
          }
      }
      writer.append('');
      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('');
      writer.appendNewLine();
  }
};

2.去掉outgoing、incoming标签和内容。

ReferenceSerializer.prototype.serializeTo = function (writer) {
    if ("outgoing,incoming".indexOf(nsName(this.ns)) < 0) {
        writer
          .appendIndent()
          .append('<' + nsName(this.ns) + '>' + this.element.id + '')
          .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:修改标签里面的属性名称:

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有关。newDiagramXML默认为:

var newDiagramXML = "\n\n  \n    \n  \n  \n    \n      \n    \n  \n";

第二组:冯佳丽 .net(c#) winform文本框输入

转载

C#的winform中控制TextBox中只能输入数字(加上固定位数和首位不能为0)
给个最简单的方法:

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 == ' '))//不输入输入除了数字之外的所有非法字符的判断
            {
                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("编号不能以0开头!"); return;
                        }
                        e.Handled = false; return;
                    }
                    else
                    {
                        MessageBox.Show("编号最多只能输入5位数字!");
                    }
                }
            }
            else
            {
                MessageBox.Show("编号只能输入数字!");
            }
           
        }

也可以用正则表达式:

C#Winform下用正则表达式限制TextBox只能输入数字 昨天,在网上特别是园子里搜了下如何在Winform下限制TextBox只能输入数字的功能。可是结果基本上都是在web的环境下用正则表达式实现的,而在Winform的平台下,好像没有发现。 就自己循着思路实现了下。

首先,先定义一个string,用来表示数字的正则表达式:

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

然后再定义一个string,用来记录TextBox原来的内容,以便在输入非数字的时候,文本框的内容可以恢复到原来的值(我不知道TextBox怎么恢复到上一次的内容,只能采用这个笨办法了):

privatestring param1 =null;

接着,我们就可以在textBox的TextChanged事件中判断输入的是否是数字,如果是数字,那么就把文本框的内容保存在param1中;如果不是数字,那么取消这次输入,即重新设置文本框的内容为param1:

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

            if (!m.Success)   // 输入的不是数字
            {
                this.textBoxParam1.Text = param1;   // textBox内容不变

                // 将光标定位到文本框的最后
                this.textBoxParam1.SelectionStart =this.textBoxParam1.Text.Length;
             }
            else   // 输入的是数字
            {
                 param1 =this.textBoxParam1.Text;   // 将现在textBox的值保存下来
             }
         }

网页里面:


其实服务器控件也能加上onkeydown与up等事件的
这样就行了 只能输入小数与数字


第三组:吴景霞 AngularJS 事件

ng-click 指令
ng-click 指令定义了 AngularJS 点击事件。
AngularJS 实例

{{ count }}

ng-hide 指令用于设置应用部分是否可见。
ng-hide="true" 设置 HTML 元素不可见。
ng-hide="false" 设置 HTML 元素可见。

AngularJS 实例

名:
姓名:

Full Name: {{firstName + " " + lastName}}

应用解析:
第一部分 personController与控制器章节类似。

应用有一个默认属性: $scope.myVar = false;
ng-hide 指令设置

元素及两个输入域是否可见, 根据 myVar 的值 (true 或 false) 来设置是否可见。
toggle() 函数用于切换 myVar 变量的值(true 和 false)。
ng-hide="true" 让元素 不可见。

显示 HTML 元素

ng-show 指令可用于设置应用中的一部分是否可见 。
ng-show="false" 可以设置 HTML 元素 不可见。
ng-show="true" 可以以设置 HTML 元素可见。

以下实例使用了 ng-show 指令:

AngularJS 实例

名:
姓:

姓名: {{firstName + " " + lastName}}


第四组:傅云 伸缩框的设置

伸缩框的代码

 

第五组:王炳钧 DevExpress中GridView上的右键菜单

网址: https://www.cnblogs.com/kkun/archive/2010/01/14/1647570.html

如上图,先选中GridView,不是GridControl,在属性窗口中,选择事件窗口,注册事件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(); 
                    } 
                }

你可能感兴趣的:(2018-01-18 Bpmn-JS修改生成的XML、.net(c#) winform文本框输入、AngularJS 事件、伸缩框的设置、DevExpress中GridView上的右键菜单)