Esempio n. 1
0
 public void SetView(ProjectModule module, LayoutSimulation sim)
 {
     if (module.Implementation is LayoutModel)
     {
         LayoutModel      layoutModel = (LayoutModel)module.Implementation;
         LayoutSimulation layoutSim;
         if (sim != null)
         {
             layoutSim = sim;
             moduleSimulations[module] = sim;
         }
         else if (!moduleSimulations.TryGetValue(module, out layoutSim))
         {
             SimulationModel simModel = new SimulationModel();
             layoutSim = new LayoutSimulation(simModel, layoutModel);
             moduleSimulations[module] = layoutSim;
         }
         SimulationThread newThread = new SimulationThread(layoutSim.SimulationModel);
         newThread.Start();
         SimulationThread oldThread = simThread;
         simThread = newThread;
         if (oldThread != null)
         {
             oldThread.RequestStop();
         }
         this.CurrentModule = module;
         ToolboxModel.UpdateCurrent(module);
         LayoutCanvas.SetView(layoutModel, layoutSim);
     }
     else
     {
         throw new InvalidOperationException("cannot view this module type");
     }
 }
Esempio n. 2
0
        public WindowModel()
        {
            this.Project = new Project();
            Transaction    xn   = new Transaction();
            IProjectAccess proj = xn.RequestWriteAccess(this.Project);
            ProjectModule  currentModule;

            using (xn.Start()) {
                currentModule = proj.AddModule("main", new LayoutModel());
            }

            this.LayoutCanvas = new LayoutCanvasModel(this);
            this.ToolboxModel = new ToolboxModel(this);
            this.ToolbarModel = new ToolbarModel(this);
            this.simThread    = null;

            menus.Add(new ProjectMenu(this));
            SetView(currentModule);
        }