internal void UpdateFromStore(Microsoft.VisualStudio.Modeling.Store store)
 {
     try
     {
         DocViewPowerOverlay.UpdateFrom(store.ElementDirectory.AllElements, this.powerOverlay);
     }
     catch
     {
         this.IsPowerOverlayVisible = false;
     }
 }
        private void CreateOverlay(DslShell.VSDiagramView view)
        {
            this.powerOverlayHost = new ElementHost
            {
                Left                 = 10,
                Top                  = 10,
                Anchor               = AnchorStyles.Top | AnchorStyles.Left,
                AutoSize             = true,
                Child                = this.powerOverlay = new DocViewPowerOverlay(),
                BackColor            = System.Drawing.Color.White,
                BackColorTransparent = false,
                Visible              = false
            };

            view.Controls.Add(powerOverlayHost);
            this.powerOverlayHost.BringToFront();
        }
        internal static bool UpdateFrom(System.Collections.IEnumerable elements, DocViewPowerOverlay view)
        {
            if (elements == null || view == null)
            {
                return(false);
            }
            OverlayModel overlayModel = new OverlayModel();

            try
            {
                foreach (GadgeteerHardware hw in elements.OfType <GadgeteerHardware>())
                {
                    if (hw.GadgeteerPartDefinition.Power.Count > 0)
                    {
                        foreach (Definitions.PowerRequirements requirements in hw.GadgeteerPartDefinition.Power)
                        {
                            PowerRequirementsModel model;

                            if (!overlayModel.Requirements.TryGetValue(requirements.Voltage, out model))
                            {
                                overlayModel.Requirements[requirements.Voltage] = model = new PowerRequirementsModel {
                                    Voltage = requirements.Voltage
                                }
                            }
                            ;

                            model.Typical += requirements.TypicalCurrent;
                            model.Maximum += requirements.MaximumCurrent;
                        }
                    }
                    else
                    {
                        if (hw is MainboardBase)
                        {
                            overlayModel.MissingModels.Add(string.Format("{0} ({1})", ((MainboardBase)hw).Name, hw.GadgeteerPartDefinition.Name));
                            overlayModel.MissingMainboardCount++;
                        }
                        else if (hw is ModuleBase)
                        {
                            overlayModel.MissingModels.Add(string.Format("{0} ({1})", ((ModuleBase)hw).Name, hw.GadgeteerPartDefinition.Name));
                            overlayModel.MissingModuleCount++;
                        }
                    }
                }

                if (overlayModel.MissingModels.Count > 0)
                {
                    foreach (var model in overlayModel.Requirements.Values)
                    {
                        model.TypicalMore = model.MaximumMore = true;
                    }
                }

                view.DataContext = overlayModel;
            }
            catch
            {
                return(false);
            }

            return(overlayModel.Requirements.Count > 0);
        }