private NonPersistentCollectionSource CreateCollectionSource(ShowNodesEventParameter para) { var session = Session; var forms = para.Application.Model.BOModel.Where( x => x.TypeInfo.IsPersistent && typeof(I单据).IsAssignableFrom(x.TypeInfo.Type)) .Select(x => new FormInfo(session) { FullName = x.TypeInfo.FullName, Caption = x.Caption, BaseTypeCaption = x.BaseClass.Caption, BaseTypeName = x.BaseClass.TypeInfo.FullName }).ToArray(); var xpc = new XPCollection <FormInfo>(session, forms.Where(x => !para.SelectedForms.OfType <FlowNode>().Select(t => t.Form).Contains(x.FullName))); var cs = new NonPersistentCollectionSource(para.ObjectSpace, typeof(FormInfo), xpc); return(cs); }
public void ShowNodesView(ShowNodesEventParameter para) { var listViewId = para.Application.FindListViewId(typeof(FormInfo)); NonPersistentCollectionSource cs = CreateCollectionSource(para); var p = para; p.ViewParameter.CreatedView = para.Application.CreateListView(listViewId, cs, false); p.ViewParameter.CreatedView.Caption = "选择单据"; p.ViewParameter.NewWindowTarget = NewWindowTarget.Separate; p.ViewParameter.TargetWindow = TargetWindow.NewModalWindow; var dc = new DialogController(); dc.SaveOnAccept = false; dc.AcceptAction.SelectionDependencyType = para.SingleSelect ? SelectionDependencyType.RequireSingleObject : SelectionDependencyType.RequireMultipleObjects; dc.Accepting += (s, e1) => { var x = 20; var y = 20; if (e1.AcceptActionArgs.SelectedObjects.Count == 1) { x = (int)para.MouseClickPoint.X; y = (int)para.MouseClickPoint.Y; } var i = 0; foreach (var item in e1.AcceptActionArgs.SelectedObjects) { var selected = (item as FormInfo); if (selected != null) { //创建一个结点 var node = (this as IFlow).CreateNode(x, y, 64, 64, selected.FullName, selected.Caption); object single = null; if (para.Shape == null) { single = para.CreateShape(node); //new DiagramShapeEx(SDLDiagramShapes.Procedure, node.X, node.Y, node.Width, // node.Height); //single.Image = node.GetImage(); //_diagram.Items.Add(single); //_diagram.SelectItem(single); } else { single = para.Shape; } para.UpdateShape(node, single); //single.Content = node.Caption; //single.Tag = node; } x += 200; i++; if (i % 5 == 0) { x = 20; y += 200; } } }; para.ViewParameter.Controllers.Add(dc); }