コード例 #1
0
 public static StartSymbol CreateStartSymbol(EditingContext context)
 {
     StartSymbol start = new StartSymbol();
     FakeRoot fakeRoot = new FakeRoot { StartNode = new StartNode() };
     ModelTreeManager manager = context.Services.GetService<ModelTreeManager>();
     start.ModelItem = new FakeModelItemImpl(manager, typeof(FakeRoot), fakeRoot, null).Properties["StartNode"].Value;
     start.Name = "StartSymbol";
     start.Focusable = true;
     start.Context = context;
     start.DataContext = start;
     return start;
 }
コード例 #2
0
        public static StartSymbol CreateStartSymbol(EditingContext context)
        {
            StartSymbol start    = new StartSymbol();
            FakeRoot    fakeRoot = new FakeRoot {
                StartNode = new StartNode()
            };
            ModelTreeManager manager = context.Services.GetService <ModelTreeManager>();

            start.ModelItem   = new FakeModelItemImpl(manager, typeof(FakeRoot), fakeRoot, null).Properties["StartNode"].Value;
            start.Name        = "StartSymbol";
            start.Focusable   = true;
            start.Context     = context;
            start.DataContext = start;
            return(start);
        }
        void CreateStartSymbol()
        {
            //Instantiate the start symbol
            StartSymbol start = System.Activities.Core.Presentation.StartSymbol.CreateStartSymbol(this.Context);

            start.Text     = "Start";
            this.flowStart = start.ModelItem;
            DragDropHelper.SetCompositeView(start, this);
            modelElement.Add(flowStart, start);
            start.SizeChanged += new SizeChangedEventHandler(ChildSizeChanged);
            this.StartSymbol   = start;
            PopulateConnectionPoints(this.StartSymbol, null);
            this.StartSymbol.MouseEnter += new MouseEventHandler(ChildElement_MouseEnter);
            this.StartSymbol.MouseLeave += new MouseEventHandler(ChildElement_MouseLeave);

            //Getting the View state information.
            object locationOfShape = this.ViewStateService.RetrieveViewState(this.ModelItem, shapeLocation);
            object sizeOfShape     = this.ViewStateService.RetrieveViewState(this.ModelItem, shapeSize);

            if (locationOfShape != null)
            {
                Point locationPt = (Point)locationOfShape;
                FreeFormPanel.SetLocation(this.StartSymbol, locationPt);
            }
            else
            {
                //Set the location of the start symbol.
                this.StartSymbol.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
                double startHeight   = this.StartSymbol.DesiredSize.Height;
                double startWidth    = this.StartSymbol.DesiredSize.Width;
                Point  startPoint    = new Point(panel.MinWidth / 2, startSymbolTopMargin + startHeight / 2);
                Point  startLocation = SnapVisualToGrid(this.StartSymbol, startPoint, new Point(-1, -1), false);
                FreeFormPanel.SetLocation(this.StartSymbol, startLocation);
                this.internalViewStateChange = true;
                this.StoreShapeViewState(this.ModelItem, startLocation);
                this.internalViewStateChange = false;
            }
            if (sizeOfShape != null)
            {
                FreeFormPanel.SetChildSize(this.StartSymbol, (Size)sizeOfShape);
            }
        }