コード例 #1
0
        public void Open(FileInfo oprFile)
        {
            Initialize();

            _oprFile = oprFile;

            Opr.Load(_oprFile, out _models, out _connections);
        }
コード例 #2
0
        public void Save()
        {
            bool saveRelativePaths = true;

            if (_oprFile != null)
            {
                Opr.Save(_oprFile, saveRelativePaths, _models, _connections.ToArray());
            }

            _oprUnsaved = false;
        }
コード例 #3
0
        void DoRun(object sender, DoWorkEventArgs e)
        {
            Canceled = false;

            if (!_oprfile.Exists)
            {
                throw new FileNotFoundException(_oprfile.FullName);
            }

            _components = new List <IBaseLinkableComponent>();
            ITimeSpaceComponent triggered = null;

            List <UIModel>      models;
            List <UIConnection> connections;

            Opr.Load(_oprfile, out models, out connections);

            if (models == null || models.Count == 0)
            {
                throw new InvalidDataException("No models found in " + _oprfile.FullName);
            }

            if (Canceled)
            {
                return;
            }

            Dictionary <UIModel, ITimeSpaceComponent> modelcomponents
                = new Dictionary <UIModel, ITimeSpaceComponent>();

            foreach (UIModel model in models)
            {
                model.LinkableComponent.StatusChanged += new EventHandler <LinkableComponentStatusChangeEventArgs>(LinkableComponent_StatusChanged);

                _components.Add(model.LinkableComponent);

                modelcomponents.Add(model, model.LinkableComponent);

                if (model.IsTrigger)
                {
                    triggered = model.LinkableComponent;
                }
            }

            ITimeSpaceComponent provider, acceptor;

            foreach (UIConnection connection in connections)
            {
                provider = modelcomponents[connection.SourceModel];
                acceptor = modelcomponents[connection.TargetModel];

                foreach (Link pair in connection.Links)
                {
                    pair.Source.AddConsumer(pair.Target);
                    pair.Target.Provider = pair.Source;
                }
            }

            //prepare

            foreach (ITimeSpaceComponent iComponent in _components)
            {
                iComponent.Prepare();
            }

            if (triggered == null)
            {
                throw new InvalidOperationException("No trigger specified");
            }

            if (Canceled)
            {
                return;
            }

            // See comment on WaitingForFinish additional state
            while (triggered.Status != LinkableComponentStatus.Finishing &&
                   triggered.Status != LinkableComponentStatus.Failed)
            {
                if (Canceled)
                {
                    return;
                }
                triggered.Update();
            }

            foreach (ITimeSpaceComponent iComponent in _components)
            {
                iComponent.Finish();

                if (iComponent is IDisposable)
                {
                    ((IDisposable)iComponent).Dispose();
                }
            }
        }