Пример #1
0
        private void CreateDiagram()
        {
            diagram1.Items.Clear();

            foreach (var item in _processStepList.Select(processStep => new DiagramShape
            {
                Height = 100,
                Width = 100,
                Shape = BasicShapes.Rectangle,
                Tag = processStep,
                Content = processStep.Name
            }))
            {
                diagram1.Items.Add(item);
            }

            foreach (var flow in _flowList)
            {
                var connector = new DiagramConnector
                {
                    BeginItem  = diagram1.Items.FirstOrDefault(x => x.Tag == _processStepList.FirstOrDefault(y => y.Id == flow.FromProcessStep)),
                    EndItem    = diagram1.Items.FirstOrDefault(x => x.Tag == _processStepList.FirstOrDefault(y => y.Id == flow.ToProcessStep)),
                    Appearance = { BorderColor = Color.FromArgb(_rnd.Next(256), _rnd.Next(256), _rnd.Next(256)) }
                };

                diagram1.Items.Add(connector);
            }
            diagram1.ApplySugiyamaLayout();
        }
Пример #2
0
        /// <summary>
        /// 设置流程图里面所有项目的状态
        /// </summary>
        private void diagramMainState(bool state)
        {
            foreach (DiagramItem item in diagramMain.Items)
            {
                switch (item.GetType().ToString())
                {
                case "DevExpress.XtraDiagram.DiagramConnector":
                    DiagramConnector dConn = (DiagramConnector)item;
                    dConn.CanSelect = state;
                    break;

                case "DevExpress.XtraDiagram.DiagramShape":
                    DiagramShape dShape = (DiagramShape)item;
                    dShape.CanCopy   = state;
                    dShape.CanDelete = state;
                    dShape.CanMove   = state;
                    dShape.CanResize = state;
                    break;
                }
            }

            if (!state)
            {
                diagramPointerToolBarItem1.Checked = true;
            }

            diagramDocumentRibbonPageGroup1.Enabled  = state;
            diagramClipboardRibbonPageGroup1.Enabled = state;
            diagramFontRibbonPageGroup1.Enabled      = state;

            diagramConnectorToolBarItem1.Enabled      = state;
            diagramShapeToolSelectionBarItem1.Enabled = state;
        }
Пример #3
0
        void CreateConnections()
        {
            var          contentItems = diagramControl.Items.OfType <DiagramContentItem>();
            const double minThickness = 1, maxThickness = 8;
            var          groupedData = Data.GroupBy(x => new { x.Customer, x.ProductCategory }).ToArray();
            double       minCount    = groupedData.Min(x => x.Sum(d => d.Quantity));
            double       maxCount    = groupedData.Max(x => x.Sum(d => d.Quantity));

            foreach (var dataItem in groupedData)
            {
                var warehouseItem = contentItems.First(x => object.Equals(x.Content, dataItem.Key.Customer));
                var productItem   = contentItems.First(x => object.Equals(x.Content, dataItem.Key.ProductCategory));
                var connector     = new DiagramConnector()
                {
                    BeginArrow = null, EndArrow = null
                };
                diagramControl.Items.Add(connector);
                connector.ThemeStyleId        = warehouseItem.ThemeStyleId;
                connector.BeginItem           = warehouseItem;
                connector.BeginItemPointIndex = 1;
                connector.EndItem             = productItem;
                connector.EndItemPointIndex   = 3;
                connector.Type = ConnectorType.Curved;
                double quantity = dataItem.Sum(x => x.Quantity);
                connector.StrokeThickness = minThickness + (maxThickness - minThickness) * (quantity - minCount) / (maxCount - minCount);
            }
        }
Пример #4
0
        public DiagramConnector CreateConnector(string name, string lineDashArray, string source, string target, string lineColor, double lineWidth)
        {
            DiagramConnector connector = new DiagramConnector();

            connector.Id          = name;
            connector.SourceID    = source;
            connector.TargetID    = target;
            connector.Annotations = new List <DiagramConnectorAnnotation>()
            {
                new DiagramConnectorAnnotation()
                {
                }
            };
            connector.TargetDecorator = new DiagramDecorator()
            {
                Shape = DecoratorShapes.Arrow, Width = 5, Height = 5
            };
            connector.Style = new DiagramStrokeStyle()
            {
                StrokeWidth     = lineWidth,
                StrokeColor     = lineColor,
                StrokeDashArray = lineDashArray,
            };
            if (connector.Id != "connect33" && connector.Id != "connect34" && connector.Id != "connect35" && connector.Id != "connect36")
            {
                connector.TargetDecorator.Style = new DiagramShapeStyle()
                {
                    StrokeColor = "#A52A2A", Fill = "#A52A2A"
                };
            }
            return(connector);
        }
Пример #5
0
        private void _diagram_EditConnector(object sender, DiagramConnector e)
        {
            if (!this.isDesignMode)
            {
                return;
            }
            var obj = e.Tag as IFlowAction;

            //obj = OS.GetObject(obj);

            var view = Application.CreateDetailView(_os, obj, false);

            //编辑
            var svp = new ShowViewParameters(view);
            var dc  = new DialogController();

            dc.SaveOnAccept = false;
            dc.Accepting   += (s, e1) =>
            {
                e.Tag  = obj;
                e.Text = obj.Caption;
            };

            dc.Cancelling += (s, e1) =>
            {
                //ObjectSpace.Rollback();
            };
            svp.Controllers.Add(dc);
            //svp.NewWindowTarget = NewWindowTarget.Default;
            svp.TargetWindow = TargetWindow.NewModalWindow;
            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
        }
Пример #6
0
        public DiagramConnector CreateSwimlaneConnector(string id, string sourceID, string targetID, string label)
        {
            DiagramConnector connector = new DiagramConnector();

            connector.Id       = id;
            connector.Type     = Segments.Orthogonal;
            connector.SourceID = sourceID;
            connector.TargetID = targetID;
            if (sourceID == "node4" && targetID == "node7")
            {
                connector.SourcePortID = "Port1";
                connector.TargetPortID = "Port3";
            }
            if (label != "")
            {
                connector.Annotations = new List <DiagramConnectorAnnotation>()
                {
                    new DiagramConnectorAnnotation()
                    {
                        Content = label,
                        Style   = new DiagramTextStyle()
                        {
                            Fill = "white"
                        }
                    }
                };
            }
            return(connector);
        }
Пример #7
0
 /// <summary>
 /// 新增流程图连接线转节点
 /// </summary>
 /// <param name="lineIdInt">连接线Id</param>
 /// <param name="dConn">连接线的实例</param>
 private void InsertWorkFlowsLinePoint(SqlCommand cmd, int lineIdInt, DiagramConnector dConn)
 {
     for (int i = 0; i < dConn.IntermediatePoints.Count; i++)
     {
         cmd.CommandText = string.Format("insert into BS_WorkFlowsLinePoint(LineId, PositionX, PositionY, PointIndex) values ({0}, {1}, {2}, {3})", lineIdInt, dConn.IntermediatePoints[i].X, dConn.IntermediatePoints[i].Y, i);
         cmd.ExecuteNonQuery();
     }
 }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThingDiagramConnector"/> class.
        /// </summary>
        public ThingDiagramConnector(Thing thing, DiagramConnector baseConnector = null)
        {
            this.Thing = thing;

            if (baseConnector != null)
            {
                this.CopyConnectorsettings(baseConnector);
            }
        }
Пример #9
0
        public DiagramConnector CreateConnector(string id, string sourceID, string targetID)
        {
            DiagramConnector connector = new DiagramConnector();

            connector.Id       = id;
            connector.SourceID = sourceID;
            connector.TargetID = targetID;
            return(connector);
        }
Пример #10
0
        // Create Connectors to connect two logic gates
        private DiagramConnector createConnector(string id, DiagramPoint sourcePoint, DiagramPoint targetPoint, string sourceID, string targetID, string sourcePortID, string targetPortID, DiagramDecorator sourceDecorator, DiagramDecorator targetDecorator, DiagramConnectorAnnotation annotation, bool?segments, bool?isStraight)
        {
            // update connector properties
            DiagramConnector connector = new DiagramConnector();

            connector.Id = id;
            if (sourcePoint != null)
            {
                sourcePoint.Y         = sourcePoint.Y - 30;
                connector.SourcePoint = sourcePoint;
            }
            if (targetPoint != null)
            {
                targetPoint.Y         = targetPoint.Y - 30;
                connector.TargetPoint = targetPoint;
            }

            connector.SourceID     = sourceID;
            connector.TargetID     = targetID;
            connector.Type         = (isStraight == true) ? Segments.Straight : Segments.Orthogonal;
            connector.SourcePortID = sourcePortID;
            connector.TargetPortID = targetPortID;
            // update connector annotation properties
            connector.Annotations = new List <DiagramConnectorAnnotation>();
            connector.Annotations.Add(new DiagramConnectorAnnotation
            {
                Content = (annotation != null) ? annotation.Content : "",
                Offset  = 0,
                Margin  = new DiagramMargin()
                {
                    Left = (annotation != null && annotation.Margin != null) ? annotation.Margin.Left : 0,
                    Top  = (annotation != null && annotation.Margin != null) ? annotation.Margin.Top : 0,
                },
                Style = new DiagramTextStyle()
                {
                    Bold         = true,
                    FontFamily   = "Segoe UI",
                    TextWrapping = TextWrap.NoWrap,
                    FontSize     = 14
                }
            });
            // update connector decorators
            connector.SourceDecorator = sourceDecorator;
            connector.TargetDecorator = targetDecorator;
            // update connector segments
            if (segments == true)
            {
                List <DiagramSegment> segmentLists = new List <DiagramSegment>();
                segmentLists.Add(new DiagramSegment()
                {
                    Type = "Orthogonal", Length = 100, Direction = "Right"
                });
                connector.Segments = segmentLists;
            }
            return(connector);
        }
Пример #11
0
        /// <summary>
        /// 新增流程图连接线
        /// </summary>
        /// <param name="dConn">连接线的实例</param>
        /// <param name="autoIdInt">流程图Id</param>
        /// <param name="nodeIdInt">连接线的上级节点Id</param>
        /// <param name="levelNodeIdInt">连接线的下级节点Id</param>
        private int InsertWorkFlowsLine(SqlCommand cmd, DiagramConnector dConn, int autoIdInt, int nodeIdInt, int levelNodeIdInt)
        {
            cmd.CommandText = string.Format("insert into BS_WorkFlowsLine (WorkFlowsId, LineText, NodeId, LevelNodeId, LineType, Creator, GetTime, BeginPositionX, BeginPositionY, EndPositionX, EndPositionY, BackColor, ForeColor, FontName, FontSize, BeginPointIndex, EndPointIndex) values({0}, '{1}', {2}, {3}, {4}, {5}, getdate(), {6}, {7}, {8}, {9}, '{10}', '{11}', '{12}', {13}, {14}, {15})", autoIdInt, dConn.Text, nodeIdInt, levelNodeIdInt, DataTypeConvert.GetInt(dConn.Appearance.Name), SystemInfo.user.AutoId, dConn.BeginPoint.X, dConn.BeginPoint.Y, dConn.EndPoint.X, dConn.EndPoint.Y, DataTypeConvert.ColorToString(dConn.Appearance.BackColor), DataTypeConvert.ColorToString(dConn.Appearance.ForeColor), dConn.Appearance.Font.Name, DataTypeConvert.GetInt(dConn.Appearance.Font.Size), dConn.BeginItemPointIndex, dConn.EndItemPointIndex);
            cmd.ExecuteNonQuery();
            cmd.CommandText = "select @@IDENTITY";
            int lineIdInt = DataTypeConvert.GetInt(cmd.ExecuteScalar());

            InsertWorkFlowsLinePoint(cmd, lineIdInt, dConn);
            return(lineIdInt);
        }
 /// <summary>
 /// Copies the properties of the drawn connector.
 /// </summary>
 /// <param name="baseConnector">The <see cref="DiagramConnector"/> that this control is based on.</param>
 private void CopyConnectorsettings(DiagramConnector baseConnector)
 {
     this.Anchors             = baseConnector.Anchors;
     this.Angle               = baseConnector.Angle;
     this.BeginItemPointIndex = baseConnector.BeginItemPointIndex;
     this.BeginPoint          = baseConnector.BeginPoint;
     this.ConnectionPoints    = baseConnector.ConnectionPoints;
     this.EndItemPointIndex   = baseConnector.EndItemPointIndex;
     this.EndPoint            = baseConnector.EndPoint;
 }
Пример #13
0
        public void getConnector(DiagramConnector l)
        {
            string DiagramType = l.DiagramType;
            int    pos         = 0;
            string sKey        = "";
            string type        = "";
            string lineStyle   = "";
            string stereotype  = "";
            bool   isDefault   = false;
            bool   isEnabled   = false;

            foreach (KeyValueConfigurationElement configEntry in currentConfig.AppSettings.Settings)
            {
                sKey = configEntry.Key;
                string regex = DiagramType + "Connector([0-9]+)([a-zA-Z_0-9]+)";
                Match  match = Regex.Match(sKey, regex);
                if (match.Success)
                {
                    pos = Convert.ToInt16(match.Groups[1].Value);
                    switch (match.Groups[2].Value)
                    {
                    case "Type":
                        type = configEntry.Value;
                        break;

                    case "Stereotype":
                        stereotype = configEntry.Value;
                        break;

                    case "LineStyle":
                        lineStyle = configEntry.Value;
                        break;

                    case "IsDefault":
                        isDefault = false;
                        if (configEntry.Value == "True")
                        {
                            isDefault = true;
                        }

                        break;

                    case "IsEnabled":
                        isEnabled = false;
                        if (configEntry.Value == "True")
                        {
                            isEnabled = true;
                        }
                        l.Add(new Connector(type, stereotype, lineStyle, isDefault, isEnabled));
                        break;
                    }
                }
            }
            return;
        }
Пример #14
0
        private void DiagramDesignerControl_AddingNewItem(object sender, DevExpress.Xpf.Diagram.DiagramAddingNewItemEventArgs e)
        {
            DiagramConnector connector = e.Item as DiagramConnector;

            if (connector != null)
            {
                connector.BeginPointRestrictions = ConnectorPointRestrictions.KeepConnected;
                connector.EndPointRestrictions   = ConnectorPointRestrictions.KeepConnected;
                e.Cancel = connector.BeginItem == null || connector.EndItem == null;
            }
        }
Пример #15
0
        /// <summary>
        /// 设定节点和节点关系的条件
        /// </summary>
        private void btnEtc_Click(object sender, EventArgs e)
        {
            try
            {
                if (diagramMain.SelectedItems.Length < 1)
                {
                    MessageHandler.ShowMessageBox("请选择要操作的节点连接线后,再进行操作。");
                    return;
                }

                if (diagramMain.SelectedItems[0].GetType().ToString() != "DevExpress.XtraDiagram.DiagramConnector")
                {
                    MessageHandler.ShowMessageBox("请选择要操作的节点连接线后,再进行操作。");
                    return;
                }
                DiagramConnector dConn = (DiagramConnector)diagramMain.SelectedItems[0];

                if (dConn.BeginItem == null)
                {
                    MessageHandler.ShowMessageBox("请选择连接线的上级节点后,再进行操作。");
                    return;
                }

                if (((DiagramShape)dConn.BeginItem).Appearance.Name == "")
                {
                    MessageHandler.ShowMessageBox("请选择连接线的上级节点的业务模块后,再进行操作。");
                    diagramMain.ClearSelection();
                    diagramMain.SelectItem(dConn.BeginItem);
                    return;
                }

                string flowModuleIdStr = ((DiagramShape)dConn.BeginItem).Appearance.Name;
                if (flowModuleIdStr == "")
                {
                    MessageHandler.ShowMessageBox("请先设定连接线上级节点的业务模块后,再进行操作。");
                    diagramMain.ClearSelection();
                    diagramMain.SelectItem(dConn.BeginItem);
                    return;
                }

                //FrmWorkFlowsLineSet_Condition.flowModuleIdStr = flowModuleIdStr;
                //FrmWorkFlowsLineSet_Condition.oldConditionStr = dConn.Text;
                //FrmWorkFlowsLineSet_Condition condForm = new FrmWorkFlowsLineSet_Condition();
                //if (condForm.ShowDialog() == DialogResult.OK)
                //{
                //    dConn.Text = FrmWorkFlowsLineSet_Condition.flowModuleIdStr;
                //}
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(this.Text + "--设定节点和节点关系的条件错误。", ex);
            }
        }
Пример #16
0
 private void _diagram_DeleteConnector(object sender, DiagramConnector e)
 {
     if (!_isRefreshing)
     {
         var t = e.Tag as IFlowAction;
         if (t != null)
         {
             Flow.RemoveAction(t);
             t.Delete();
         }
     }
 }
Пример #17
0
        protected override void ReadValueCore()
        {
            var curr = Flow;

            isDesignMode = curr.IsDesignMode;

            var flow = (Flow as XPBaseObject);

            if (flow != null)
            {
                flow.Changed += Flow_Changed;
            }

            foreach (var item in curr.Nodes)
            {
                var ds = new DiagramShapeEx(SDLDiagramShapes.Procedure, item.X, item.Y, item.Width, item.Height);
                ds.Content = item.Caption;
                ds.Image   = item.GetImage();

                ds.Tag = item;
                _diagram.Items.Add(ds);
            }
            //SelectedForms = curr.Nodes.Select(x => x.Form).ToList();
            foreach (var item in curr.Actions)
            {
                var b    = _diagram.Items.Single(x => object.Equals(x.Tag, item.From));
                var e    = _diagram.Items.Single(x => object.Equals(x.Tag, item.To));
                var edge = new DiagramConnector(b, e);
                edge.Appearance.BorderSize            = 3;
                edge.Appearance.Options.UseBorderSize = true;
                edge.Text = item.Caption;

                //if (item.目标类型 == 目标类型.更新单据)
                //{
                //    edge.Appearance.Options.UseBackColor = true;
                //    edge.Appearance.ForeColor = Color.Red;
                //}

                edge.BeginItemPointIndex = item.BeginItemPointIndex;
                edge.EndItemPointIndex   = item.EndItemPointIndex;

                edge.Tag = item;
                _diagram.Items.Add(edge);
            }
            if (Flow is IAutoLayout)
            {
                _diagram.ApplyTreeLayout(new TreeLayoutSettings(40.0, 40.0, DevExpress.Diagram.Core.Direction.Down, 20), SplitToConnectedComponentsMode.AllComponents);
            }
        }
        public DiagramConnector CreateConnector(string name, string source, string target, string content, string type, string direction, string targetPort, double length)
        {
            DiagramConnector connector = new DiagramConnector();

            connector.Id       = name;
            connector.SourceID = source;
            connector.TargetID = target;
            connector.Style    = new DiagramStrokeStyle()
            {
                StrokeWidth = 2,
                StrokeColor = "#8D8D8D"
            };
            connector.Annotations = new List <DiagramConnectorAnnotation>()
            {
                new DiagramConnectorAnnotation()
                {
                    Content = content, Style = new DiagramTextStyle()
                    {
                        Fill = "white"
                    }
                }
            };
            connector.Style = new DiagramStrokeStyle()
            {
                StrokeColor = "#8D8D8D"
            };
            connector.TargetDecorator = new DiagramDecorator()
            {
                Shape = DecoratorShapes.Arrow
            };
            connector.TargetDecorator.Style = new DiagramShapeStyle()
            {
                Fill = "#8D8D8D", StrokeColor = "#8D8D8D"
            };
            connector.TargetPortID = targetPort;
            if (type == "Orthogonal")
            {
                connector.Type = Segments.Orthogonal;
                List <DiagramSegment> segment = new List <DiagramSegment>();
                segment.Add(new DiagramSegment()
                {
                    Direction = direction, Type = type, Length = length
                });
                connector.Segments = segment;
            }
            return(connector);
        }
Пример #19
0
        private void GetConnector(DiagramConnector l)
        {
            string diagramType = l.DiagramType;
            string type        = "";
            string lineStyle   = "";
            string stereotype  = "";
            bool   isDefault   = false;

            foreach (KeyValueConfigurationElement configEntry in CurrentConfig.AppSettings.Settings)
            {
                var    sKey  = configEntry.Key;
                string regex = diagramType + "Connector([0-9]+)([a-zA-Z_0-9]+)";
                Match  match = Regex.Match(sKey, regex);
                if (match.Success)
                {
                    switch (match.Groups[2].Value)
                    {
                    case "Type":
                        type = configEntry.Value;
                        break;

                    case "Stereotype":
                        stereotype = configEntry.Value;
                        break;

                    case "LineStyle":
                        lineStyle = configEntry.Value;
                        break;

                    case "IsDefault":
                        isDefault = false;
                        if (configEntry.Value == "True")
                        {
                            isDefault = true;
                        }

                        break;

                    case "IsEnabled":
                        bool isEnabled = configEntry.Value == "True";
                        l.Add(new Connector(type, stereotype, lineStyle, isDefault, isEnabled));
                        break;
                    }
                }
            }
        }
        public DiagramConnector AddConnector(string Id, string SourceID, string SourcePortID, string TargetID, Segments type, List <DiagramConnectorAnnotation> annotation, DiagramMargin margin, DiagramStrokeStyle style)
        {
            DiagramConnector connector = new DiagramConnector();

            connector.Id       = Id;
            connector.SourceID = SourceID;
            if (SourcePortID != "")
            {
                connector.SourcePortID = SourcePortID;
            }
            connector.TargetID    = TargetID;
            connector.Type        = type;
            connector.Annotations = annotation;
            connector.Style       = style;
            connector.Margin      = margin;
            return(connector);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="designer">Diagram designer.</param>
        /// <param name="sourceConnector">Source item of the relationship.</param>
        /// <param name="startPoint">Start point.</param>
        public DiagramConnectorAdorner(DiagramDesigner designer, DiagramConnector sourceConnector, Point startPoint)
            : base(designer)
        {
            this.diagramDesigner = designer;
            if (this.diagramDesigner.DataContext is IDiagramViewModel)
                diagramDesignerVM = this.diagramDesigner.DataContext as IDiagramViewModel;
            this.sourceConnector = sourceConnector;
            this.startPoint = startPoint;

            sourceItem = sourceConnector.DiagramItem;
            //if (sourceConnector.DiagramItem is ISelectable)
            //    this.sourceElement = (sourceConnector.DiagramItem as ISelectable).SelectedData;

            drawingPen = new Pen(Brushes.LightSlateGray, 1);
            drawingPen.LineJoin = PenLineJoin.Round;
            
            this.Cursor = Cursors.Cross;
        }
Пример #22
0
        private void _diagram_AddedConnector(object sender, DiagramConnector conn)
        {
            conn.Appearance.BorderSize            = 3;
            conn.Appearance.Options.UseBorderSize = true;

            #region 新建

            var obj = Flow.CreateAction((conn.BeginItem as DiagramShape).Tag as IFlowNode, (conn.EndItem as DiagramShape).Tag as IFlowNode);
            //_os.CreateObject<FlowAction>();
            //obj.From = ;
            //obj.To =;
            //obj.Caption = "生成" + obj.To.Caption;

            //obj.GenerateMapping(this.Application.Model.BOModel);

            //obj.Flow = (this.PropertyValue as Flow);

            var view = Application.CreateDetailView(_os, obj, false);
            var svp  = new ShowViewParameters(view);
            var dc   = new DialogController();
            dc.SaveOnAccept = false;
            dc.Accepting   += (s, e1) =>
            {
                conn.Tag  = obj;
                conn.Text = obj.Caption;
                obj.Save();
                _diagram.ClearSelection();
            };

            dc.Cancelling += (s, e1) =>
            {
                _os.Delete(obj);
                _diagram.DeleteSelectedItems();
            };
            svp.Controllers.Add(dc);
            //svp.NewWindowTarget = NewWindowTarget.Default;
            svp.TargetWindow = TargetWindow.NewModalWindow;
            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));

            #endregion
        }
        static DiagramConnector CreateDiagramConnector(DiagramItem beginItem, DiagramItem endItem, EmployeeRelationship employeeRelation)
        {
            DiagramConnector connector = new DiagramConnector();

            connector.BeginItem       = beginItem;
            connector.EndItem         = endItem;
            connector.BeginArrow      = connector.EndArrow = null;
            connector.Type            = ConnectorType.Straight;
            connector.StrokeThickness = DefaultStrokeThickness;
            connector.CanDelete       = connector.CanCopy = false;
            switch (employeeRelation)
            {
            case EmployeeRelationship.KnowEachOther:
                connector.StrokeDashArray = new DoubleCollection(new double[] { 4, 8 });
                connector.ThemeStyleId    = DiagramConnectorStyleId.Subtle2;
                break;

            case EmployeeRelationship.Friends:
                connector.ThemeStyleId = DiagramConnectorStyleId.Subtle3;
                break;
            }
            return(connector);
        }
Пример #24
0
        /// <summary>
        /// 刷新当前选择节点的属性
        /// </summary>
        private void diagramMain_SelectionChanged(object sender, DiagramSelectionChangedEventArgs e)
        {
            try
            {
                if (diagramMain.SelectedItems.Length > 0)
                {
                    if (btnNew.Enabled && IsRudoOrRedo)
                    {
                        btnRefresh_Click(null, null);
                        IsRudoOrRedo = false;
                        return;
                    }

                    //colorPickBackColor.ReadOnly = false;
                    //colorPickBackColor.Color = diagramMain.SelectedItems[0].Appearance.GetBackColor();
                    //colorPickFontColor.ReadOnly = false;
                    //colorPickFontColor.Color = diagramMain.SelectedItems[0].Appearance.ForeColor;

                    int autoId = 0;
                    switch (diagramMain.SelectedItems[0].GetType().ToString())
                    {
                    case "DevExpress.XtraDiagram.DiagramConnector":
                        DiagramConnector dConn = (DiagramConnector)diagramMain.SelectedItems[0];
                        textContent.ReadOnly = true;
                        textContent.Text     = "";
                        searchLookUpFlowModuleId.ReadOnly  = true;
                        searchLookUpFlowModuleId.EditValue = null;
                        memoText.ReadOnly = true;
                        memoText.Text     = dConn.Text;
                        btnEtc.Enabled    = true;
                        autoId            = DataTypeConvert.GetInt(dConn.CustomStyleId);

                        if (autoId > 0)
                        {
                            for (int i = 0; i < diagramMain.Items.Count; i++)
                            {
                                if (diagramMain.Items[i].GetType().ToString() == "DevExpress.XtraDiagram.DiagramConnector")
                                {
                                    if (diagramMain.SelectedItems[0] != diagramMain.Items[i] && autoId == DataTypeConvert.GetInt(diagramMain.Items[i].CustomStyleId))
                                    {
                                        autoId = 0;
                                        foreach (DiagramItem item in diagramMain.SelectedItems)
                                        {
                                            //dConn.Text = "";
                                            item.CustomStyleId   = "";
                                            item.Appearance.Name = "";
                                        }

                                        break;
                                    }
                                }
                            }
                        }

                        if (autoId > 0)
                        {
                            DataTable dConnTable = wfEditDAO.QueryWorkFlowNodeToNode_Single(autoId);
                            if (dConnTable.Rows.Count > 0)
                            {
                                lookUpCreator.EditValue = dConnTable.Rows[0]["Creator"];
                                dateGetTime.DateTime    = DataTypeConvert.GetDateTime(dConnTable.Rows[0]["GetTime"]);
                            }
                            else
                            {
                                lookUpCreator.ItemIndex = -1;
                                dateGetTime.DateTime    = DateTime.Now;
                            }
                        }
                        else
                        {
                            lookUpCreator.ItemIndex = -1;
                            dateGetTime.DateTime    = DateTime.Now;
                        }

                        PageHandle.PageVisible = false;
                        break;

                    case "DevExpress.XtraDiagram.DiagramShape":
                        DiagramShape dshape = (DiagramShape)diagramMain.SelectedItems[0];
                        textContent.ReadOnly = false;
                        textContent.Text     = dshape.Content;
                        searchLookUpFlowModuleId.ReadOnly = false;
                        //if (dShapeDic_WFId.ContainsKey(dshape))
                        //    searchLookUpFlowModuleId.EditValue = dShapeDic_WFId[dshape];
                        //else
                        //    searchLookUpFlowModuleId.EditValue = null;

                        searchLookUpFlowModuleId.EditValue = dshape.Appearance.Name;

                        memoText.ReadOnly = true;
                        memoText.Text     = "";
                        btnEtc.Enabled    = false;
                        dshape.CanRotate  = false;
                        autoId            = DataTypeConvert.GetInt(dshape.CustomStyleId);

                        if (autoId > 0)
                        {
                            for (int i = 0; i < diagramMain.Items.Count; i++)
                            {
                                if (diagramMain.Items[i].GetType().ToString() == "DevExpress.XtraDiagram.DiagramShape")
                                {
                                    if (diagramMain.SelectedItems[0] != diagramMain.Items[i] && autoId == DataTypeConvert.GetInt(diagramMain.Items[i].CustomStyleId))
                                    {
                                        autoId = 0;
                                        foreach (DiagramItem item in diagramMain.SelectedItems)
                                        {
                                            //dshape.Content = "";
                                            item.CustomStyleId   = "";
                                            item.Appearance.Name = "";
                                        }

                                        break;
                                    }
                                }
                            }
                        }

                        if (autoId > 0)
                        {
                            DataTable dConnTable = wfEditDAO.QueryWorkFlowNode_Single(autoId);
                            if (dConnTable.Rows.Count > 0)
                            {
                                lookUpCreator.EditValue = dConnTable.Rows[0]["Creator"];
                                dateGetTime.DateTime    = DataTypeConvert.GetDateTime(dConnTable.Rows[0]["GetTime"]);
                            }
                            else
                            {
                                lookUpCreator.ItemIndex = -1;
                                dateGetTime.DateTime    = DateTime.Now;
                            }
                        }
                        else
                        {
                            lookUpCreator.ItemIndex = -1;
                            dateGetTime.DateTime    = DateTime.Now;
                        }

                        PageHandle.PageVisible = true;
                        PageHandle.Text        = string.Format("节点【{0}】的处理人员", dshape.Content);
                        QueryNodeHandle(autoId);

                        break;
                    }
                }
                else
                {
                    //colorPickBackColor.ReadOnly = true;
                    //colorPickFontColor.ReadOnly = true;
                    textContent.ReadOnly = true;
                    textContent.Text     = "";
                    searchLookUpFlowModuleId.ReadOnly  = true;
                    searchLookUpFlowModuleId.EditValue = null;
                    memoText.ReadOnly       = true;
                    memoText.Text           = "";
                    btnEtc.Enabled          = false;
                    lookUpCreator.EditValue = null;
                    dateGetTime.EditValue   = null;

                    PageHandle.PageVisible = false;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(this.Text + "--刷新当前选择节点的属性错误。", ex);
            }
        }
Пример #25
0
        ///// <summary>
        ///// 设置选中节点的文本信息
        ///// </summary>
        private void searchLookUpFlowModuleId_Leave(object sender, EventArgs e)
        {
            try
            {
                if (diagramMain.SelectedItems.Length > 0)
                {
                    switch (diagramMain.SelectedItems[0].GetType().ToString())
                    {
                    case "DevExpress.XtraDiagram.DiagramShape":
                        DiagramShape dshape = (DiagramShape)diagramMain.SelectedItems[0];

                        //foreach (DiagramShape key in dShapeDic_WFId.Keys)
                        //{
                        //    if (key == dshape)
                        //    {
                        //        if (dShapeDic_WFId[key] == DataTypeConvert.GetString(searchLookUpFlowModuleId.EditValue))
                        //            return;
                        //    }
                        //    else
                        //    {
                        //        if (dShapeDic_WFId[key] == DataTypeConvert.GetString(searchLookUpFlowModuleId.EditValue))
                        //        {
                        //            MessageHandler.ShowMessageBox("流程图中的节点不能设置相同的业务模块,请重新操作。");
                        //            if (dShapeDic_WFId.ContainsKey(dshape))
                        //                searchLookUpFlowModuleId.EditValue = dShapeDic_WFId[dshape];
                        //            else
                        //                searchLookUpFlowModuleId.EditValue = null;
                        //            searchLookUpFlowModuleId.Focus();
                        //            return;
                        //        }
                        //    }
                        //}

                        //dshape.Content = DataTypeConvert.GetString(searchLookUpFlowModuleId.Text);
                        //if (dShapeDic_WFId.ContainsKey(dshape))
                        //    dShapeDic_WFId[dshape] = DataTypeConvert.GetString(searchLookUpFlowModuleId.EditValue);
                        //else
                        //    dShapeDic_WFId.Add(dshape, DataTypeConvert.GetString(searchLookUpFlowModuleId.EditValue));

                        dshape.Appearance.Name = DataTypeConvert.GetString(searchLookUpFlowModuleId.EditValue);

                        for (int i = 0; i < diagramMain.Items.Count; i++)
                        {
                            if (diagramMain.Items[i].GetType().ToString() == "DevExpress.XtraDiagram.DiagramConnector")
                            {
                                DiagramConnector dConn = (DiagramConnector)diagramMain.Items[i];
                                if (dConn.BeginItem == dshape)
                                {
                                    dConn.Text = "";
                                }
                            }
                        }

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(this.Text + "--设置选中节点的文本信息错误。", ex);
            }
        }
Пример #26
0
 private void _diagram_DeleteConnector(object sender, DiagramConnector e)
 {
     if (!_isRefreshing)
     {
         var t = e.Tag as IFlowAction;
         if (t != null)
         {
             Flow.RemoveAction(t);
             t.Delete();
         }
     }
 }
        public void setConnector(DiagramConnector l)
        {

            string DiagramType = l.DiagramType;
            string basicKey;
            string key;
            for (int i = 0; i < l.Count; i++)
            {
                if (l[i] == null) continue;
                Connector el = l[i];
                basicKey = DiagramType + "Connector" + (i + 1).ToString();

                key = basicKey+ "Type";
                if (! this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                this.currentConfig.AppSettings.Settings.Add(key, el.Type); 
                else  this.currentConfig.AppSettings.Settings[key].Value = el.Type; 

                key = basicKey + "Stereotype";
                if (! this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                    this.currentConfig.AppSettings.Settings.Add(key, el.Stereotype);
                else this.currentConfig.AppSettings.Settings[key].Value = el.Stereotype;

                key = basicKey + "LineStyle";
                if (!this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                    this.currentConfig.AppSettings.Settings.Add(key, el.LineStyle);
                else this.currentConfig.AppSettings.Settings[key].Value = el.LineStyle;


                key = basicKey + "IsDefault";
                if (! this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                    this.currentConfig.AppSettings.Settings.Add(key, el.IsDefault.ToString());
                else this.currentConfig.AppSettings.Settings[key].Value = el.IsDefault.ToString();

                key = basicKey + "IsEnabled";
                if (! this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                    this.currentConfig.AppSettings.Settings.Add(key, el.IsEnabled.ToString());
                else this.currentConfig.AppSettings.Settings[key].Value = el.IsEnabled.ToString();
                               
            }
            // delete unused entries
            int index = l.Count +1;
            while (true)
            {
            basicKey = DiagramType + "Connector" + index.ToString();
            if (this.currentConfig.AppSettings.Settings.AllKeys.Contains(basicKey+"Type"))
            {
                this.currentConfig.AppSettings.Settings.Remove(basicKey + "IsEnabled");
                this.currentConfig.AppSettings.Settings.Remove(basicKey + "IsDefault");
                this.currentConfig.AppSettings.Settings.Remove(basicKey + "Stereotype");
                this.currentConfig.AppSettings.Settings.Remove(basicKey + "Type");
                index = index + 1;
            }

            else {break;}
            }

        }
Пример #28
0
 /// <summary>
 /// Adds a connector to the <see cref="DiagramControl"/> item collection.
 /// </summary>
 /// <param name="connector">The connector to add</param>
 public void AddConnector(DiagramConnector connector)
 {
     this.AssociatedObject.Items.Add(connector);
 }
        public void getConnector(DiagramConnector l)
        {
            string DiagramType = l.DiagramType;
            int pos = 0;
            string sKey = "";
            string type = "";
            string lineStyle = "";
            string stereotype = "";
            bool isDefault = false;
            bool isEnabled = false;

            foreach (KeyValueConfigurationElement configEntry in currentConfig.AppSettings.Settings)
            {
                sKey = configEntry.Key;
                string regex = DiagramType +"Connector([0-9]+)([a-zA-Z_0-9]+)";
                Match match = Regex.Match(sKey, regex);
                if (match.Success)
                {
                    pos = Convert.ToInt16(match.Groups[1].Value);
                    switch (match.Groups[2].Value)
                    {
                        case "Type":
                            type = configEntry.Value;
                            break;
                        case "Stereotype":
                            stereotype = configEntry.Value;
                            break;
                        case "LineStyle":
                            lineStyle = configEntry.Value;
                            break;
                        case "IsDefault":
                            isDefault = false;
                            if (configEntry.Value == "True") isDefault = true;

                            break;
                        case "IsEnabled":
                            isEnabled = false;
                            if (configEntry.Value == "True") isEnabled = true;
                            l.Add(new Connector(type, stereotype, lineStyle, isDefault, isEnabled));
                            break;
                    }
                }
            }
            return;
            
        }
Пример #30
0
        public void setConnector(DiagramConnector l)
        {
            string DiagramType = l.DiagramType;
            string basicKey;
            string key;

            for (int i = 0; i < l.Count; i++)
            {
                if (l[i] == null)
                {
                    continue;
                }
                Connector el = l[i];
                basicKey = DiagramType + "Connector" + (i + 1).ToString();

                key = basicKey + "Type";
                if (!this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                {
                    this.currentConfig.AppSettings.Settings.Add(key, el.Type);
                }
                else
                {
                    this.currentConfig.AppSettings.Settings[key].Value = el.Type;
                }

                key = basicKey + "Stereotype";
                if (!this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                {
                    this.currentConfig.AppSettings.Settings.Add(key, el.Stereotype);
                }
                else
                {
                    this.currentConfig.AppSettings.Settings[key].Value = el.Stereotype;
                }

                key = basicKey + "LineStyle";
                if (!this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                {
                    this.currentConfig.AppSettings.Settings.Add(key, el.LineStyle);
                }
                else
                {
                    this.currentConfig.AppSettings.Settings[key].Value = el.LineStyle;
                }


                key = basicKey + "IsDefault";
                if (!this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                {
                    this.currentConfig.AppSettings.Settings.Add(key, el.IsDefault.ToString());
                }
                else
                {
                    this.currentConfig.AppSettings.Settings[key].Value = el.IsDefault.ToString();
                }

                key = basicKey + "IsEnabled";
                if (!this.currentConfig.AppSettings.Settings.AllKeys.Contains(key))
                {
                    this.currentConfig.AppSettings.Settings.Add(key, el.IsEnabled.ToString());
                }
                else
                {
                    this.currentConfig.AppSettings.Settings[key].Value = el.IsEnabled.ToString();
                }
            }
            // delete unused entries
            int index = l.Count + 1;

            while (true)
            {
                basicKey = DiagramType + "Connector" + index.ToString();
                if (this.currentConfig.AppSettings.Settings.AllKeys.Contains(basicKey + "Type"))
                {
                    this.currentConfig.AppSettings.Settings.Remove(basicKey + "IsEnabled");
                    this.currentConfig.AppSettings.Settings.Remove(basicKey + "IsDefault");
                    this.currentConfig.AppSettings.Settings.Remove(basicKey + "Stereotype");
                    this.currentConfig.AppSettings.Settings.Remove(basicKey + "Type");
                    index = index + 1;
                }

                else
                {
                    break;
                }
            }
        }
Пример #31
0
        /// <summary>
        /// Creates a <see cref="BinaryRelationshipDiagramConnector"/> from a given <see cref="BinaryRelationship"/>.
        /// </summary>
        /// <param name="relationship">The <see cref="BinaryRelationship"/> that defines this connector.</param>
        /// <param name="connector">The dummy <see cref="DiagramConnector"/> that was used as defenition for this connector.</param>
        private void CreateBinaryRelationshipDiagramConnector(BinaryRelationship relationship, DiagramConnector connector)
        {
            var newConnector = new BinaryRelationshipDiagramConnector(relationship, connector);

            this.Behavior.AddConnector(newConnector);
            this.SelectedItem = newConnector;
        }
Пример #32
0
        private void _diagram_EditConnector(object sender, DiagramConnector e)
        {
            if (!this.isDesignMode)
                return;
            var obj = e.Tag as IFlowAction;

            //obj = OS.GetObject(obj);

            var view = Application.CreateDetailView(_os, obj, false);

            //编辑
            var svp = new ShowViewParameters(view);
            var dc = new DialogController();
            dc.SaveOnAccept = false;
            dc.Accepting += (s, e1) =>
            {
                e.Tag = obj;
                e.Text = obj.Caption;
            };

            dc.Cancelling += (s, e1) =>
            {
                //ObjectSpace.Rollback();
            };
            svp.Controllers.Add(dc);
            //svp.NewWindowTarget = NewWindowTarget.Default;
            svp.TargetWindow = TargetWindow.NewModalWindow;
            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
        }
Пример #33
0
        /// <summary>
        /// 查询流程图信息
        /// </summary>
        private void QueryWorkFlowAllInfo()
        {
            if (TableWorkFlow.Rows.Count == 0 || bSWorkFlow.Current == null)
            {
                InitializationDiagram();
            }
            else
            {
                InitializationDiagram();

                //dConnDic.Clear();

                Dictionary <int, DiagramShape> dShapeDic_int = new Dictionary <int, DiagramShape>();
                DataTable wfNodeTable = wfEditDAO.QueryWorkFlowNode_WorkFlowId(currentAutoIdInt);
                foreach (DataRow dr in wfNodeTable.Rows)
                {
                    DiagramShape dshape = new DiagramShape();
                    dshape.Position             = new DevExpress.Utils.PointFloat(DataTypeConvert.GetInt(dr["PositionX"]), DataTypeConvert.GetInt(dr["PositionY"]));
                    dshape.Size                 = new Size(DataTypeConvert.GetInt(dr["Width"]), DataTypeConvert.GetInt(dr["Height"]));
                    dshape.Appearance.BackColor = DataTypeConvert.StringToColor(DataTypeConvert.GetString(dr["BackColor"]));
                    dshape.Appearance.ForeColor = DataTypeConvert.StringToColor(DataTypeConvert.GetString(dr["ForeColor"]));
                    dshape.Appearance.Font      = new Font(DataTypeConvert.GetString(dr["FontName"]), DataTypeConvert.GetInt(dr["FontSize"]));

                    dshape.Content         = DataTypeConvert.GetString(dr["NodeText"]);
                    dshape.CustomStyleId   = DataTypeConvert.GetInt(dr["AutoId"]);
                    dshape.Appearance.Name = DataTypeConvert.GetString(dr["FlowModuleId"]);
                    dshape.CanRotate       = false;
                    diagramMain.Items.Add(dshape);

                    dShapeDic_int.Add(DataTypeConvert.GetInt(dr["AutoId"]), dshape);
                    //dShapeDic_WFId.Add(dshape, DataTypeConvert.GetString(dr["FlowModuleId"]));
                }

                DataTable wfNodeToNodeTable = wfEditDAO.QueryWorkFlowNodeToNode_WorkFlowId(currentAutoIdInt);
                foreach (DataRow dr in wfNodeToNodeTable.Rows)
                {
                    DiagramConnector dConn = new DiagramConnector();
                    dConn.Text          = DataTypeConvert.GetString(dr["Condition"]);
                    dConn.CustomStyleId = DataTypeConvert.GetInt(dr["AutoId"]);

                    dConn.BeginItem = dShapeDic_int[DataTypeConvert.GetInt(dr["NodeId"])];
                    dConn.EndItem   = dShapeDic_int[DataTypeConvert.GetInt(dr["LevelNodeId"])];

                    dConn.BeginItemPointIndex  = DataTypeConvert.GetInt(dr["BeginPointIndex"]);
                    dConn.EndItemPointIndex    = DataTypeConvert.GetInt(dr["EndPointIndex"]);
                    dConn.BeginPoint           = new DevExpress.Utils.PointFloat(DataTypeConvert.GetInt(dr["BeginPositionX"]), DataTypeConvert.GetInt(dr["BeginPositionY"]));
                    dConn.EndPoint             = new DevExpress.Utils.PointFloat(DataTypeConvert.GetInt(dr["EndPositionX"]), DataTypeConvert.GetInt(dr["EndPositionY"]));
                    dConn.Appearance.BackColor = DataTypeConvert.StringToColor(DataTypeConvert.GetString(dr["BackColor"]));
                    dConn.Appearance.ForeColor = DataTypeConvert.StringToColor(DataTypeConvert.GetString(dr["ForeColor"]));
                    dConn.Appearance.Font      = new Font(DataTypeConvert.GetString(dr["FontName"]), DataTypeConvert.GetInt(dr["FontSize"]));
                    dConn.EndArrow             = DevExpress.Diagram.Core.ArrowDescriptions.Filled90;
                    dConn.Type = ConnectorType.RightAngle;

                    diagramMain.Items.Add(dConn);

                    //dConnDic.Add(dConn, DataTypeConvert.GetInt(dr["AutoId"]));
                }
            }

            diagramMain.ScrollPos = new Point(0, 0);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Cdp4DiagramConnector"/> class.
        /// </summary>
        public Cdp4DiagramConnector(IDiagramConnectorViewModel dataContext, Cdp4DiagramOrgChartBehavior behaviour, DiagramConnector baseConnector = null)
        {
            this.DataContext = dataContext;
            this.behaviour   = behaviour;
            if (baseConnector != null)
            {
                this.CopyConnectorsettings(baseConnector);
            }

            this.Initialize();
        }
        private void GetConnector(DiagramConnector l)
        {
            string diagramType = l.DiagramType;
            string type = "";
            string lineStyle = "";
            string stereotype = "";
            bool isDefault = false;

            foreach (KeyValueConfigurationElement configEntry in CurrentConfig.AppSettings.Settings)
            {
                var sKey = configEntry.Key;
                string regex = diagramType +"Connector([0-9]+)([a-zA-Z_0-9]+)";
                Match match = Regex.Match(sKey, regex);
                if (match.Success)
                {
                    switch (match.Groups[2].Value)
                    {
                        case "Type":
                            type = configEntry.Value;
                            break;
                        case "Stereotype":
                            stereotype = configEntry.Value;
                            break;
                        case "LineStyle":
                            lineStyle = configEntry.Value;
                            break;
                        case "IsDefault":
                            isDefault = false;
                            isDefault |= configEntry.Value == "True";

                            break;
                        case "IsEnabled":
                            var isEnabled = false;
                            isEnabled |= configEntry.Value == "True";
                            l.Add(new Connector(type, stereotype, lineStyle, isDefault, isEnabled));
                            break;
                    }
                }
            }
           
        }
Пример #36
0
        /// <summary>
        /// Creates a <see cref="BinaryRelationship"/>
        /// </summary>
        /// <param name="connector">The drawn <see cref="DiagramConnector"/> that is used as a template.</param>
        private async void CreateBinaryRelationship(DiagramConnector connector)
        {
            var beginItemContent = ((DiagramContentItem)connector?.BeginItem)?.Content as NamedThingDiagramContentItem;
            var endItemContent   = ((DiagramContentItem)connector?.EndItem)?.Content as NamedThingDiagramContentItem;

            if (beginItemContent == null || endItemContent == null)
            {
                // connector was drawn with either the source or target missing
                // remove the dummy connector
                this.Behavior.RemoveItem(connector);
                this.Behavior.ResetTool();
                return;
            }

            // send off the relationship
            Tuple <DomainOfExpertise, Participant> tuple;

            this.Session.OpenIterations.TryGetValue(this.Thing, out tuple);

            var binaryRelationship = new BinaryRelationship(Guid.NewGuid(), null, null)
            {
                Owner = tuple.Item1
            };

            if (this.PendingBinaryRelationshipRule != null)
            {
                binaryRelationship.Category.Add(this.PendingBinaryRelationshipRule.RelationshipCategory);
            }

            var iteration = this.Thing.Clone(false);

            iteration.Relationship.Add(binaryRelationship);

            binaryRelationship.Container = iteration;

            binaryRelationship.Source = beginItemContent.Thing;
            binaryRelationship.Target = endItemContent.Thing;

            var transactionContext   = TransactionContextResolver.ResolveContext(this.Thing);
            var containerTransaction = new ThingTransaction(transactionContext, iteration);

            containerTransaction.CreateOrUpdate(binaryRelationship);

            try
            {
                var operationContainer = containerTransaction.FinalizeTransaction();
                await this.Session.Write(operationContainer);

                // at this point relationship has gone through.

                if (this.Thing.Relationship.FirstOrDefault(r => r.Iid == binaryRelationship.Iid) is BinaryRelationship returedRelationship)
                {
                    this.CreateBinaryRelationshipDiagramConnector(returedRelationship, connector);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Creation of Binary Relationship failed: {ex.Message}",
                                "Creating Binary Relationship Failed",
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                // remove the dummy connector
                this.Behavior.RemoveItem(connector);
                this.Behavior.ResetTool();
                this.PendingBinaryRelationshipRule = null;
            }
        }
Пример #37
0
        private void _diagram_AddedConnector(object sender, DiagramConnector conn)
        {
            conn.Appearance.BorderSize = 3;
            conn.Appearance.Options.UseBorderSize = true;

            #region 新建

            var obj = Flow.CreateAction((conn.BeginItem as DiagramShape).Tag as IFlowNode, (conn.EndItem as DiagramShape).Tag as IFlowNode);
                //_os.CreateObject<FlowAction>();
            //obj.From = ;
            //obj.To =;
            //obj.Caption = "生成" + obj.To.Caption;

            //obj.GenerateMapping(this.Application.Model.BOModel);

            //obj.Flow = (this.PropertyValue as Flow);

            var view = Application.CreateDetailView(_os, obj, false);
            var svp = new ShowViewParameters(view);
            var dc = new DialogController();
            dc.SaveOnAccept = false;
            dc.Accepting += (s, e1) =>
            {
                conn.Tag = obj;
                conn.Text = obj.Caption;
                obj.Save();
                _diagram.ClearSelection();
            };

            dc.Cancelling += (s, e1) =>
            {
                _os.Delete(obj);
                _diagram.DeleteSelectedItems();
            };
            svp.Controllers.Add(dc);
            //svp.NewWindowTarget = NewWindowTarget.Default;
            svp.TargetWindow = TargetWindow.NewModalWindow;
            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));

            #endregion
        }
Пример #38
0
        protected override void ReadValueCore()
        {
            var curr = Flow;

            isDesignMode = curr.IsDesignMode;

            var flow = (Flow as XPBaseObject);

            if (flow != null)
                flow.Changed += Flow_Changed;

            foreach (var item in curr.Nodes)
            {
                var ds = new DiagramShapeEx(SDLDiagramShapes.Procedure, item.X, item.Y, item.Width,item.Height);
                ds.Content = item.Caption;
                ds.Image = item.GetImage();

                ds.Tag = item;
                _diagram.Items.Add(ds);
            }
            //SelectedForms = curr.Nodes.Select(x => x.Form).ToList();
            foreach (var item in curr.Actions)
            {
                var b = _diagram.Items.Single(x => object.Equals(x.Tag, item.From));
                var e = _diagram.Items.Single(x => object.Equals(x.Tag, item.To));
                var edge = new DiagramConnector(b, e);
                edge.Appearance.BorderSize = 3;
                edge.Appearance.Options.UseBorderSize = true;
                edge.Text = item.Caption;

                //if (item.目标类型 == 目标类型.更新单据)
                //{
                //    edge.Appearance.Options.UseBackColor = true;
                //    edge.Appearance.ForeColor = Color.Red;
                //}

                edge.BeginItemPointIndex = item.BeginItemPointIndex;
                edge.EndItemPointIndex = item.EndItemPointIndex;

                edge.Tag = item;
                _diagram.Items.Add(edge);
            }
            if (Flow is IAutoLayout)
            {
                _diagram.ApplyTreeLayout(new TreeLayoutSettings(40.0, 40.0, DevExpress.Diagram.Core.Direction.Down, 20), SplitToConnectedComponentsMode.AllComponents);

            }
        }