Exemple #1
0
        private Project CreateAplayProject(Services.Project srvProject)
        {
            Project aplayProject = new Project()
            {
                Id            = srvProject.Id,
                ProjectDetail = new ProjectDetail(srvProject.ProjectDetail.Name,
                                                  srvProject.ProjectDetail.CreatedBy, srvProject.ProjectDetail.CreationDate),
                SheetManager = new SheetManager()
            };

            var sheet = _sheetFactory.Create();

            sheet.Name = "Sheet 1 " + DateTime.Now.ToLongTimeString();
            aplayProject.SheetManager.Sheets.Add(sheet);


            var blockFrom = _blockSymbolFactory.Create(sheet);

            blockFrom.PositionX = 100.0;
            blockFrom.PositionY = 100.0;

            var outputConnectorFrom = _connectorFactory.Create(sheet);

            var blockTo = _blockSymbolFactory.Create(sheet);

            blockTo.PositionX = 400;
            blockTo.PositionY = 100;

            var inputConnectorTo = _connectorFactory.Create(sheet);


            var connection = _connectionFactory.Create(sheet);

            connection.From = outputConnectorFrom;
            connection.To   = inputConnectorTo;

            //inputConnectorTo.Connections.Add(connection);
            //outputConnectorFrom.Connections.Add(connection);

            blockTo.Connectors.Add(inputConnectorTo);
            blockFrom.Connectors.Add(outputConnectorFrom);

            //aplayProject.SheetManager.Sheets[0].Connections.Add(connection);

            aplayProject.SheetManager.Sheets[0].BlockSymbols.Add(blockFrom);
            aplayProject.SheetManager.Sheets[0].BlockSymbols.Add(blockTo);



            return(aplayProject);
        }
Exemple #2
0
        private void UndoServiceOnActiveStateChanged(object sender, ActiveStateChangedEventArgs e)
        {
            foreach (var change in e.ChangeSet.Where(c => c.OwnerId == Id))
            {
                APlay.Common.Logging.Logger.LogDesigned(2,
                                                        "ActiveStateChanged received and updated state. OwnerId: " + change.OwnerId,
                                                        "AplayTest.Server.Sheet");


                if (change.ChangeReason == ChangeReason.InsertAt)
                {
                    if (change.Undoable is BlockSymbolUndoable)
                    {
                        BlockSymbols.Insert(change.IndexAt,
                                            _blockSymbolFactory.Create((BlockSymbolUndoable)change.Undoable, e.ChangeSet));
                    }
                    else if (change.Undoable is ConnectionUndoable)
                    {
                        Connections.Insert(change.IndexAt,
                                           _connectionFactory.Create((ConnectionUndoable)change.Undoable, e.ChangeSet));
                    }
                }
                else if (change.ChangeReason == ChangeReason.RemoveAt)
                {
                    if (change.Undoable is BlockSymbolUndoable)
                    {
                        BlockSymbols.RemoveAt(change.IndexAt);
                        _blockSymbolFactory.Remove(change.Undoable.Id);
                    }
                    else if (change.Undoable is ConnectionUndoable)
                    {
                        Connections.RemoveAt(change.IndexAt);
                        _connectionFactory.Remove(change.Undoable.Id);
                    }
                }

                var storedObject = change.Undoable as SheetUndoable;

                if (storedObject != null)
                {
                    if (change.ChangeReason == ChangeReason.Update)
                    {
                        Name = storedObject.Name;
                    }
                }

                Dump();
            }
        }