public FunctionContainer(
            StorageObjectID storageobjectID,
            EditorFile file,
            IFactory <IContainer> factory,

            FunctionCodeTools functioncodetools,

            FactorySet <FunctionSource> functionsources_factoryset,
            ViewerSet <FunctionSource> functionsources_viewerset
            ) :
            base(
                storageobjectID,
                file,
                factory,
                ItemName,
                ItemCodeName
                )
        {
            this.functioncodetools = functioncodetools;

            var obj =
                file.Storage[storageobjectID];

            functionsources =
                new BoundList <FunctionSource>(
                    obj.GetOrMake("function-sources").ID,
                    file,
                    functionsources_factoryset,
                    functionsources_viewerset
                    );
        }
Exemple #2
0
        public EditorFile(
            IStorageGraph storage,
            FactorySet <IContainer> containerfactoryset,
            bool isnewfile = false
            )
        {
            this.storage             = storage;
            this.containerfactoryset = containerfactoryset;

            var obj = storage[storage.Root];

            containers =
                new BoundList <IContainer>(
                    storage.Root,
                    this,
                    containerfactoryset,
                    new ViewerSet <IContainer>()
                    );

            containers.Bind();

            if (isnewfile)
            {
                containers.CreateAllObjects();
            }
        }
Exemple #3
0
        public PolylineContainer(
            StorageObjectID storageobjectID,
            EditorFile file,
            IFactory <IContainer> factory,

            FactorySet <PolylineData> polylines_factoryset,
            ViewerSet <PolylineData> polylines_viewerset
            ) :
            base(
                storageobjectID,
                file,
                factory,
                ItemName,
                ItemCodename
                )
        {
            var obj =
                file.Storage[storageobjectID];

            polylines =
                new BoundList <PolylineData>(
                    obj.GetOrMake("polylines").ID,
                    file,
                    polylines_factoryset,
                    polylines_viewerset
                    );
        }
Exemple #4
0
        public ScreenContainer(
            StorageObjectID storageobjectID,
            EditorFile file,
            IFactory <IContainer> factory,
            FactorySet <IScreen> screens_factoryset,
            ViewerSet <IScreen> screens_viewerset
            ) :
            base(
                storageobjectID,
                file,
                factory,
                ItemName,
                ItemCodeName
                )
        {
            var obj =
                file.Storage[storageobjectID];

            screens =
                new BoundList <IScreen>(
                    obj.GetOrMake("screens").ID,
                    file,
                    screens_factoryset,
                    screens_viewerset
                    );
        }
Exemple #5
0
 public static IFactory <IContainer> CreateFactory(
     FactorySet <PolylineData> polylines_factoryset,
     ViewerSet <PolylineData> polylines_viewerset
     ) =>
 new CtorFactory <IContainer, PolylineContainer>(
     ItemName,
     polylines_factoryset,
     polylines_viewerset
     );
Exemple #6
0
 public static IFactory <IContainer> CreateFactory(
     FactorySet <IScreen> screens_factoryset,
     ViewerSet <IScreen> screens_viewerset
     ) =>
 new CtorFactory <IContainer, ScreenContainer>(
     ItemName,
     screens_factoryset,
     screens_viewerset
     );
 public static IFactory <IContainer> CreateFactory(
     FunctionCodeTools functioncodetools,
     FactorySet <FunctionSource> functionsources_factoryset,
     ViewerSet <FunctionSource> functionsources_viewerset
     ) =>
 new CtorFactory <IContainer, FunctionContainer>(
     ItemName,
     functioncodetools,
     functionsources_factoryset,
     functionsources_viewerset
     );
Exemple #8
0
        public T Create(string type)
        {
            var storageobjectID =
                FactorySet.Init(type, StorageObjectID, File);

            hub_obj.Add(Objects.Count.ToString(), storageobjectID);

            while (!map_storageobjectID.ContainsKey(storageobjectID))
            {
                Thread.Sleep(20);
            }

            return(this[storageobjectID]);
        }
        public static IFactory <IContainer> CreateFactory(
            FactorySet <ITrack> tracks_factoryset,
            ViewerSet <ITrack> tracks_viewerset,

            FactorySet <ITrackController> controllers_factoryset,
            ViewerSet <ITrackController> controllers_viewerset
            ) =>
        new CtorFactory <IContainer, TrackControllerContainer>(
            ItemName,
            tracks_factoryset,
            tracks_viewerset,
            controllers_factoryset,
            controllers_viewerset
            );
Exemple #10
0
 public BoundList(
     StorageObjectID storageobjectID,
     EditorFile file,
     FactorySet <T> factoryset,
     ViewerSet <T> viewerset
     ) :
     this(
         storageobjectID,
         file,
         factoryset,
         viewerset,
         null
         )
 {
 }
        public TrackControllerContainer(
            StorageObjectID storageobjectID,
            EditorFile file,
            IFactory <IContainer> factory,

            FactorySet <ITrack> tracks_factoryset,
            ViewerSet <ITrack> tracks_viewerset,

            FactorySet <ITrackController> controllers_factoryset,
            ViewerSet <ITrackController> controllers_viewerset
            ) :
            base(
                storageobjectID,
                file,
                factory,
                ItemName,
                ItemCodeName
                )
        {
            var obj = file.Storage[storageobjectID];

            settings =
                new TrackControllerSettings(
                    obj.GetOrMake("settings"),
                    file
                    );

            tracks =
                new BoundList <ITrack>(
                    obj.GetOrMake("tracks").ID,
                    file,
                    tracks_factoryset,
                    tracks_viewerset
                    );

            controllers =
                new BoundList <ITrackController>(
                    obj.GetOrMake("controllers").ID,
                    file,
                    controllers_factoryset,
                    controllers_viewerset
                    );
        }
Exemple #12
0
        private BoundList(
            StorageObjectID storageobjectID,
            EditorFile file,
            FactorySet <T> factoryset,
            ViewerSet <T> viewerset,
            BoundList <T> master
            ) :
            base(
                storageobjectID,
                file,
                null     //TODO
                )
        {
            this.factoryset = factoryset;
            this.viewerset  = viewerset;
            this.master     = master;

            hub_obj = File.Storage[StorageObjectID];

            var propertybinders =
                new Dictionary <string, PropertyBinder <string> >();

            listener_add =
                hub_obj.CreateListen(
                    IOEvent.ChildAdded,
                    (key, objID) => {
                int i = int.Parse(key);

                if (Objects.Count > i &&
                    Objects.HasItemAt(i) &&
                    Objects[i].StorageObjectID == objID)
                {
                    return;
                }

                var obj =
                    master == null ?
                    FactorySet.Load(objID, File) :
                    master[objID];

                var namedobj =
                    obj as INamedObject;

                if (namedobj != null)
                {
                    if (master == null)
                    {
                        var name_obj =
                            File
                            .Storage
                            [objID]
                            .GetOrMake("name");

                        var name_val = name_obj.ReadAllString();

                        if (map_name.ContainsKey(name_val))
                        {
                            if (master == null)
                            {
                                if (AutomaticallyAvoidNameCollisionsWithUnderlines)
                                {
                                    name_val += "_";
                                }
                                else
                                {
                                    throw new ArgumentException($"Name \"{name_val}\" already in use.");
                                }
                            }
                        }

                        name_obj.WriteAllString(name_val);

                        var binder = namedobj.Name.Bind(name_obj);
                        namedobj.Name.AfterChange += propertybinders.Rename;
                        propertybinders.Add(binder.Property.Value, binder);
                    }
                }

                if (Objects.Contains(obj))
                {
                    throw new InvalidOperationException();
                }

                Objects.Insert(i, obj);

                if (master == null)
                {
                    if (isallowedtobindobjects)
                    {
                        obj.Bind();
                    }
                }
            }
                    );

            listener_remove =
                hub_obj.CreateListen(
                    IOEvent.ChildRemoved,
                    (key, objID) => {
                var i = int.Parse(key);

                var obj =
                    Objects.FirstOrDefault(_ => _.StorageObjectID == objID);

                if (obj != null)
                {
                    var namedobj =
                        obj as INamedObject;

                    if (namedobj != null)
                    {
                        if (master == null)
                        {
                            namedobj.Name.AfterChange -= propertybinders.Rename;

                            propertybinders[namedobj.Name.Value].Dispose();
                            propertybinders.Remove(namedobj.Name.Value);
                        }
                    }

                    if (master == null)
                    {
                        obj.Unbind();
                    }

                    Objects.Remove(obj);
                }
            }
                    );

            listener_move =
                hub_obj
                .Graph
                .CreateListen(
                    msg => {
                var old_i = int.Parse(msg.Relation);
                var new_i = int.Parse(msg.NewRelation);

                Objects.Move(old_i, new_i);
            },
                    hub_obj.ID,
                    IOEvent.ChildRekeyed
                    );

            Objects.ItemInserted += (obj, i) => {
                if (!hub_obj.HasChild(obj.StorageObjectID))
                {
                    if (master == null)
                    {
                        throw new InvalidOperationException();
                    }

                    hub_obj.Add(i.ToString(), obj.StorageObjectID);
                }

                var namedobj =
                    obj as INamedObject;

                if (namedobj != null)
                {
                    namedobj.Name.BeforeChange += Object_Renaming;
                    namedobj.Name.AfterChange  += Object_Renamed;

                    map_name.Add(namedobj.Name.Value, obj);
                    map_name_inverse.Add(obj, namedobj.Name.Value);
                }

                map_storageobjectID.Add(obj.StorageObjectID, obj);
                map_storageobjectID_inverse.Add(obj, obj.StorageObjectID);
            };

            Objects.ItemWithdrawn += (obj, i) => {
                if (hub_obj.HasChild(obj.StorageObjectID))
                {
                    hub_obj.Remove(obj.StorageObjectID);
                }

                var namedobj =
                    obj as INamedObject;

                if (namedobj != null)
                {
                    namedobj.Name.BeforeChange -= Object_Renaming;
                    namedobj.Name.AfterChange  -= Object_Renamed;

                    namedobj.Name.AfterChange -= propertybinders.Rename;

                    map_name.Remove(namedobj.Name.Value);
                    map_name_inverse.Remove(obj);
                }

                map_storageobjectID.Remove(obj.StorageObjectID);
                map_storageobjectID_inverse.Remove(obj);
            };

            Objects.ItemMoved += (item, oldindex, newindex) => {
                var sign = Math.Sign(newindex - oldindex);

                for (int i = oldindex; i != newindex; i += sign)
                {
                    if (isallowedtobindobjects)
                    {
                        throw new NotImplementedException();
                    }
                    else
                    {
                        // The bound list is still loading items from storage.
                        // The 'moving' is really just initialization to sync with
                        // the back-end store, if the code ran this else clause.
                    }
                }
            };
        }