Example #1
0
        void Update(object sender, EventArgs e)
        {
            ISimpleCollection newCollection = new SimpleCollection(objectsPath, linksPath, false);

            if (simpleCollection.Actual < newCollection.Actual)
            {
                newCollection.Load(objectsPath, linksPath);
                //Add new
                foreach (SimpleObject obj in newCollection.Objects)
                {
                    SimpleObject obj2 = null;
                    try
                    {
                        obj2 = simpleCollection.Objects.First(f => f.Id == obj.Id);
                    }
                    catch (Exception) //Doesn't matter
                    {
                        AddNew(obj);
                    }
                }
                //Delete old
                foreach (SimpleObject obj in simpleCollection.Objects)
                {
                    try
                    {
                        newCollection.Objects.First(f => f.Id == obj.Id);
                    } catch (Exception) //Doesn't matter
                    {
                        DeleteOld(obj);
                    }
                }
                //Add new links
                foreach (SimpleLink link in newCollection.Links)
                {
                    SimpleLink link2 = null;
                    try
                    {
                        link2 = simpleCollection.Links.First(f => f.Id == link.Start * maxId + link.End);
                    }
                    catch (Exception) //Doesn't matter
                    {
                        AddNewLink(link);
                    }
                }
                //Delete old links
                foreach (SimpleLink link in simpleCollection.Links)
                {
                    try
                    {
                        newCollection.Links.First(f => f.Id == link.Id);
                    }
                    catch (Exception) //Doesn't matter
                    {
                        DeleteOldLink(link);
                    }
                }

                simpleCollection = newCollection;
            }
        }
Example #2
0
        private void LoadSnapObstacleData(ISimpleCollection <string, string> loadFrom, SnapObstacle so)
        {
            string          prefix = so.Name + ".";
            SnapDescription sd;

            string isSnappedString = loadFrom.Get(prefix + isSnappedValueName);
            bool   isSnapped       = bool.Parse(isSnappedString);

            if (isSnapped)
            {
                string       snappedToString = loadFrom.Get(prefix + snappedToValueName);
                SnapObstacle snappedTo       = FindObstacle(snappedToString);

                string             horizontalEdgeString = loadFrom.Get(prefix + horizontalEdgeValueName);
                HorizontalSnapEdge horizontalEdge       = (HorizontalSnapEdge)Enum.Parse(typeof(HorizontalSnapEdge), horizontalEdgeString, true);

                string           verticalEdgeString = loadFrom.Get(prefix + verticalEdgeValueName);
                VerticalSnapEdge verticalEdge       = (VerticalSnapEdge)Enum.Parse(typeof(VerticalSnapEdge), verticalEdgeString, true);

                string xOffsetString = loadFrom.Get(prefix + xOffsetValueName);
                int    xOffset       = int.Parse(xOffsetString, CultureInfo.InvariantCulture);

                string yOffsetString = loadFrom.Get(prefix + yOffsetValueName);
                int    yOffset       = int.Parse(yOffsetString, CultureInfo.InvariantCulture);

                sd = new SnapDescription(snappedTo, horizontalEdge, verticalEdge, xOffset, yOffset);
            }
            else
            {
                sd = null;
            }

            this.obstacles[so] = sd;

            string leftString = loadFrom.Get(prefix + leftValueName);
            int    left       = int.Parse(leftString, CultureInfo.InvariantCulture);

            string topString = loadFrom.Get(prefix + topValueName);
            int    top       = int.Parse(topString, CultureInfo.InvariantCulture);

            string widthString = loadFrom.Get(prefix + widthValueName);
            int    width       = int.Parse(widthString, CultureInfo.InvariantCulture);

            string heightString = loadFrom.Get(prefix + heightValueName);
            int    height       = int.Parse(heightString, CultureInfo.InvariantCulture);

            Rectangle newBounds = new Rectangle(left, top, width, height);

            so.RequestBoundsChange(newBounds);

            if (sd != null)
            {
                ParkObstacle(so, sd);
            }
        }
Example #3
0
 // Requires that all SnapObstacles are already placed in this.obstacles
 public void Save(ISimpleCollection <string, string> saveTo)
 {
     foreach (SnapObstacle obstacle in this.obstacles.Keys)
     {
         // TODO: how do we 'erase' something that has this property set to false, for full generality?
         if (obstacle.EnableSave)
         {
             SaveSnapObstacleData(saveTo, obstacle);
         }
     }
 }
Example #4
0
        public ViewportManager(IViewportFactory viewportFactory,
                               IIdGenerator IdGenerator,
                               ISimpleCollectionFactory collectionFactory)
        {
            _idGenerator     = IdGenerator;
            _viewportFactory = viewportFactory;

            _viewportCollection = collectionFactory.Create <IViewportModel>(48);

            _viewportsForDestruction = new List <ulong>();
        }
Example #5
0
        private void LoadSnapObstacleData(ISimpleCollection<string, string> loadFrom, SnapObstacle so)
        {
            string prefix = so.Name + ".";
            SnapDescription sd;

            string isSnappedString = loadFrom.Get(prefix + isSnappedValueName);
            bool isSnapped = bool.Parse(isSnappedString);

            if (isSnapped)
            {
                string snappedToString = loadFrom.Get(prefix + snappedToValueName);
                SnapObstacle snappedTo = FindObstacle(snappedToString);

                string horizontalEdgeString = loadFrom.Get(prefix + horizontalEdgeValueName);
                HorizontalSnapEdge horizontalEdge = (HorizontalSnapEdge)Enum.Parse(typeof(HorizontalSnapEdge), horizontalEdgeString, true);

                string verticalEdgeString = loadFrom.Get(prefix + verticalEdgeValueName);
                VerticalSnapEdge verticalEdge = (VerticalSnapEdge)Enum.Parse(typeof(VerticalSnapEdge), verticalEdgeString, true);

                string xOffsetString = loadFrom.Get(prefix + xOffsetValueName);
                int xOffset = int.Parse(xOffsetString, CultureInfo.InvariantCulture);

                string yOffsetString = loadFrom.Get(prefix + yOffsetValueName);
                int yOffset = int.Parse(yOffsetString, CultureInfo.InvariantCulture);

                sd = new SnapDescription(snappedTo, horizontalEdge, verticalEdge, xOffset, yOffset);
            }
            else
            {
                sd = null;
            }

            this.obstacles[so] = sd;

            string leftString = loadFrom.Get(prefix + leftValueName);
            int left = int.Parse(leftString, CultureInfo.InvariantCulture);

            string topString = loadFrom.Get(prefix + topValueName);
            int top = int.Parse(topString, CultureInfo.InvariantCulture);

            string widthString = loadFrom.Get(prefix + widthValueName);
            int width = int.Parse(widthString, CultureInfo.InvariantCulture);

            string heightString = loadFrom.Get(prefix + heightValueName);
            int height = int.Parse(heightString, CultureInfo.InvariantCulture);

            Rectangle newBounds = new Rectangle(left, top, width, height);
            so.RequestBoundsChange(newBounds);

            if (sd != null)
            {
                ParkObstacle(so, sd);
            }
        }
Example #6
0
        public void Load(ISimpleCollection <string, string> loadFrom)
        {
            SnapObstacle[] newObstacles = new SnapObstacle[this.obstacles.Count];
            this.obstacles.Keys.CopyTo(newObstacles, 0);

            foreach (SnapObstacle obstacle in newObstacles)
            {
                if (obstacle.EnableSave)
                {
                    LoadSnapObstacleData(loadFrom, obstacle);
                }
            }
        }
Example #7
0
        public CameraManager(ICameraFactory cameraFactory,
                             IIdGenerator idGenerator,
                             ISimpleCollectionFactory collectionFactory)

        {
            _idGenerator   = idGenerator;
            _cameraFactory = cameraFactory;

            _camera2DCollection = collectionFactory.Create <ICameraModel2D>(32);
            _camera3DCollection = collectionFactory.Create <ICameraModel3D>(16);

            _camerasToDestroy = new List <ulong>();
        }
Example #8
0
        public RenderStageManager(IFrameworkMessenger frameworkMessenger,
                                  IIdGenerator idGenerator,
                                  ISystemComponents veldridComponents,
                                  IRenderStageModelFactory renderStageModelFactory,
                                  ISimpleCollectionFactory collectionFactory)
        {
            _frameworkMessenger      = frameworkMessenger;
            _idGenerator             = idGenerator;
            _systemComponents        = veldridComponents;
            _renderStageModelFactory = renderStageModelFactory;

            _renderStageCollection = collectionFactory.Create <IRenderStageModel>(48);

            _drawStagesToAutoClearDynamicQueues = new List <ulong>();

            _stagesForDestruction = new List <Tuple <ulong, bool> >();
        }
Example #9
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            simpleCollection = new SimpleCollection(objectsPath, linksPath, true);

            int tric = (int)Math.Sqrt(simpleCollection.Objects.Count);
            int x = -1, y = 0;

            foreach (SimpleObject obj in simpleCollection.Objects)
            {
                SettingsDesignerItemViewModel box = new SettingsDesignerItemViewModel();
                box.Parent = window1ViewModel.DiagramViewModel;
                box.Left   = start + step * ++x;
                box.Top    = start + step * y;
                if (x >= tric)
                {
                    x = -1; y++; raws++;
                }
                box.Id = obj.Id;
                window1ViewModel.DiagramViewModel.Items.Add(box);
            }
            foreach (SimpleLink link in simpleCollection.Links)
            {
                SettingsDesignerItemViewModel firstObj  = null;
                SettingsDesignerItemViewModel secondObj = null;
                try
                {
                    firstObj  = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(f => f.Id == link.Start);
                    secondObj = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(s => s.Id == link.End);
                }
                catch (Exception)
                {
                    continue; //:)
                }
                if (null != firstObj && null != secondObj)
                {
                    ConnectorViewModel con1 = new ConnectorViewModel(firstObj.RightConnector, secondObj.TopConnector);
                    con1.Parent = window1ViewModel.DiagramViewModel;
                    con1.Id     = maxId * firstObj.Id + secondObj.Id; //:)
                    window1ViewModel.DiagramViewModel.Items.Add(con1);
                }
            }
        }
Example #10
0
        private void SaveSnapObstacleData(ISimpleCollection<string, string> saveTo, SnapObstacle so)
        {
            string prefix = so.Name + ".";
            SnapDescription sd = this.obstacles[so];

            bool isSnappedValue = (sd != null);            
            saveTo.Set(prefix + isSnappedValueName, isSnappedValue.ToString(CultureInfo.InvariantCulture));

            if (isSnappedValue)
            {
                saveTo.Set(prefix + snappedToValueName, sd.SnappedTo.Name);
                saveTo.Set(prefix + horizontalEdgeValueName, sd.HorizontalEdge.ToString());
                saveTo.Set(prefix + verticalEdgeValueName, sd.VerticalEdge.ToString());
                saveTo.Set(prefix + xOffsetValueName, sd.XOffset.ToString(CultureInfo.InvariantCulture));
                saveTo.Set(prefix + yOffsetValueName, sd.YOffset.ToString(CultureInfo.InvariantCulture));
            }

            saveTo.Set(prefix + leftValueName, so.Bounds.Left.ToString(CultureInfo.InvariantCulture));
            saveTo.Set(prefix + topValueName, so.Bounds.Top.ToString(CultureInfo.InvariantCulture));
            saveTo.Set(prefix + widthValueName, so.Bounds.Width.ToString(CultureInfo.InvariantCulture));
            saveTo.Set(prefix + heightValueName, so.Bounds.Height.ToString(CultureInfo.InvariantCulture));
        }
Example #11
0
        private void SaveSnapObstacleData(ISimpleCollection <string, string> saveTo, SnapObstacle so)
        {
            string          prefix = so.Name + ".";
            SnapDescription sd     = this.obstacles[so];

            bool isSnappedValue = (sd != null);

            saveTo.Set(prefix + isSnappedValueName, isSnappedValue.ToString(CultureInfo.InvariantCulture));

            if (isSnappedValue)
            {
                saveTo.Set(prefix + snappedToValueName, sd.SnappedTo.Name);
                saveTo.Set(prefix + horizontalEdgeValueName, sd.HorizontalEdge.ToString());
                saveTo.Set(prefix + verticalEdgeValueName, sd.VerticalEdge.ToString());
                saveTo.Set(prefix + xOffsetValueName, sd.XOffset.ToString(CultureInfo.InvariantCulture));
                saveTo.Set(prefix + yOffsetValueName, sd.YOffset.ToString(CultureInfo.InvariantCulture));
            }

            saveTo.Set(prefix + leftValueName, so.Bounds.Left.ToString(CultureInfo.InvariantCulture));
            saveTo.Set(prefix + topValueName, so.Bounds.Top.ToString(CultureInfo.InvariantCulture));
            saveTo.Set(prefix + widthValueName, so.Bounds.Width.ToString(CultureInfo.InvariantCulture));
            saveTo.Set(prefix + heightValueName, so.Bounds.Height.ToString(CultureInfo.InvariantCulture));
        }
Example #12
0
 // Requires that all SnapObstacles are already placed in this.obstacles
 public void Save(ISimpleCollection<string, string> saveTo)
 {
     foreach (SnapObstacle obstacle in this.obstacles.Keys)
     {
         // TODO: how do we 'erase' something that has this property set to false, for full generality?
         if (obstacle.EnableSave)
         {
             SaveSnapObstacleData(saveTo, obstacle);
         }
     }
 }
Example #13
0
        public void Load(ISimpleCollection<string, string> loadFrom)
        {
            SnapObstacle[] newObstacles = new SnapObstacle[this.obstacles.Count];
            this.obstacles.Keys.CopyTo(newObstacles, 0);

            foreach (SnapObstacle obstacle in newObstacles)
            {
                if (obstacle.EnableSave)
                {
                    LoadSnapObstacleData(loadFrom, obstacle);
                }
            }
        }
 public void Add(int _, ISimpleCollection <ICommandDescriptor> __)
 => throw new Exception();
 public UniqueNameCommandArgumentCountDictionary(ICommandDescriptor descriptor)
 {
     Descriptor           = descriptor;
     DescriptorCollection = new FakeCollection <ICommandDescriptor>(Descriptor.AsSingleEnumerable());
 }