public ConnectionShapeInfo[] GetConnectionShapeInfo()
        {
            var shapeInfos = new List<ConnectionShapeInfo>();
              var shapeInfo = new ConnectionShapeInfo() { ShapeType = ShapeType.Connection, ShapeCategory = ShapeCategory.Business, ToolTip = "业务域", IsChecked = true, IsEnabled = true };
              shapeInfo.SourceSvgBuffer = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,@"Resources\Svg\Butterfly.svg"));
              shapeInfo.SinkSvgBuffer = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Svg\Butterfly.svg"));
              shapeInfos.Add(shapeInfo);

              return shapeInfos.ToArray();
        }
Beispiel #2
0
        public Connection(Connector source, Connector sink,ConnectionShapeInfo connectionShapeInfo=null)
        {
            var connectionShapInfo = connectionShapeInfo;
            var designConnectionInfo = (DesignConnectionInfo)null;
            if (connectionShapeInfo != null)
            {
                designConnectionInfo=new DesignConnectionInfo(connectionShapInfo);
            }
            else
            {
                var shapInfo = new ConnectionShapeInfo();
                designConnectionInfo = new DesignConnectionInfo(shapInfo);
            }
            var currentDate = DateTime.Now;
            designConnectionInfo.CreateDate = currentDate;
            designConnectionInfo.ModifyDate = currentDate;
            designConnectionInfo.SourceID = source.ParentDesignItem.ID;
            designConnectionInfo.SourceOrientation = source.Orientation;
            designConnectionInfo.SinkID = sink.ParentDesignItem.ID;
            designConnectionInfo.SinkOrientation = sink.Orientation;
            this.ShapeInfoUnit = new ConnectionShapeInfoUnit(designConnectionInfo);
            if (designConnectionInfo.SourceSvgBuffer != null)
            {
                using (var stream = new MemoryStream(designConnectionInfo.SourceSvgBuffer))
                {
                    (this.ShapeInfoUnit as ConnectionShapeInfoUnit).SourceSvgDrawing = SvgHelper.CreateSvgViewBox(stream);
                }
            }
            if (designConnectionInfo.SinkSvgBuffer != null)
            {
                using (var stream = new MemoryStream(designConnectionInfo.SinkSvgBuffer))
                {
                    (this.ShapeInfoUnit as ConnectionShapeInfoUnit).SinkSvgDrawing = SvgHelper.CreateSvgViewBox(stream);
                }
            }
            this.SetBinding(Connection.TextProperty, BindingHelper.CreateBinding(designConnectionInfo, "Text"));
            this.SetBinding(DesignCanvas.ZIndexProperty, BindingHelper.CreateBinding(designConnectionInfo, "ZIndex"));
            designConnectionInfo.PropertyChanged += (obj, e) =>
            {
                if (e.PropertyName.Equals("PathGeometry"))
                {
                    UpdateAnchorPosition();
                }
            };

            this.ID = Guid.NewGuid();
            this.Source = source;
            this.Sink = sink;
            //base.Unloaded += new RoutedEventHandler(Connection_Unloaded); //Resolve the issue of swithing tabItem
            base.SelectChanged += (a, b) =>
            {
                if (this.IsSelected) ShowAdorner();
                else HideAdorner();
            };
        }
 public DesignConnectionInfo(ConnectionShapeInfo connectionShapeInfo)
     : this()
 {
     this.ShapeCategory = ShapeCategory.Connection;
     this.SerialNo = connectionShapeInfo.SerialNo;
     this.GroupID = connectionShapeInfo.GroupID;
     this.IsInGroup = connectionShapeInfo.IsInGroup;
     this.StyleKey = connectionShapeInfo.StyleKey;
     this.Style = connectionShapeInfo.Style;
     this.ToolTip = connectionShapeInfo.ToolTip;
     this.IsChecked = connectionShapeInfo.IsChecked;
     this.IsEnabled = connectionShapeInfo.IsEnabled;
     this.SourceSvgBuffer = connectionShapeInfo.SourceSvgBuffer;
     this.SinkSvgBuffer = connectionShapeInfo.SinkSvgBuffer;
 }
 public void LoadConnection(ConnectionShapeInfo[] shapeInfos)
 {
     this.canvas.LoadConnection(shapeInfos);
 }
 public void LoadConnection(ConnectionShapeInfo[] shapeInfos)
 {
     ConnectionShapeInfos = shapeInfos;
 }