// Ajout de l'élément /// <summary> /// Alerts listeners that a rule has been used. /// </summary> /// <param name="e">An ElementAddedEventArgs that contains the event data.</param> public override void ElementAdded(ElementAddedEventArgs e) { #region Condition // Test the element SoftwareComponent component = e.ModelElement as SoftwareComponent; if (component == null) { return; } // Teste si on est en train de charger le modèle if (component.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.IsSerializing || component.Store.InUndoRedoOrRollback || component.Store.TransactionManager.CurrentTransaction.Context.ContextInfo.ContainsKey( "InitializeComponentWizard")) { return; } #endregion #region Traitement ShowComponentWizard(component); #endregion }
/// <summary> /// Shows the component wizard. /// </summary> /// <param name="component">The component.</param> /// <remarks> /// Ce traitement peut-être appelé soit lors de l'insertion d'un composant avec le designer soit à l'ouverture d'un modèle dont /// le nom du composant est un '?' (cas du template). Dans ce dernier cas, on ne passe pas par une règle car une règle déclenchée /// lors de l'ouverture du document ne notifie pas le designer des changements (car le designer ne s'aboone aux notifications qu'après /// le chargement du doc. /// </remarks> public static void ShowComponentWizard(SoftwareComponent component) { if (component.Name != "?") { return; } component.Store.TransactionManager.CurrentTransaction.Context.ContextInfo["InitializeComponentWizard"] = true; // Wizard pour demander le namespace et la version ApplicationNamespaceForm form = new ApplicationNamespaceForm(component); if (form.ShowDialog() != DialogResult.OK) { throw new CanceledByUser(); } // Demande du namespace component.Namespace = form.Namespace; component.Name = form.ApplicationName; // Mise à jour de la définition du système CandleModel def = component.Model; if (def != null) { def.IsLibrary = form.IsLibrary; def.Version = form.Version; def.Comment = form.Description; def.Url = form.URL; def.Name = form.ApplicationName; def.Path = form.DomainPath; } }
/// <summary> /// Merge des fichiers xml /// </summary> /// <param name="result">Fichier xml initial</param> /// <param name="component">The component.</param> /// <returns></returns> internal static XmlDocument MergeDeclaredConfigurations(XmlDocument result, SoftwareComponent component) { // Merge des configurations des layers foreach (AbstractLayer layer in component.Layers) { result = MergeConfiguration(result, layer.Configurations); } // Récupération des configurations des librairies externes ReferenceWalker walker = new ReferenceWalker(ReferenceScope.Runtime, new ConfigurationMode()); ConfigurationVisitor visitor = new ConfigurationVisitor(false); walker.Traverse(visitor, component.Model); result = MergeConfiguration(result, visitor.Configurations); // Il faut toujours placer la configSection en premier XmlNode cfgNode = result.SelectSingleNode("/configuration"); if (cfgNode != null) { XmlNode cs = cfgNode.SelectSingleNode("configSections"); if (cs != null) { cfgNode.RemoveChild(cs); cfgNode.InsertAfter(cs, null); } } return(result); }
private Microsoft.Msagl.Drawing.Color ConvertSystemDrawingToMsaglColor(SoftwareComponent component) { string colorName = component.Color.Name; Type type = typeof(Microsoft.Msagl.Drawing.Color); PropertyInfo property = type.GetProperty(colorName); Microsoft.Msagl.Drawing.Color adaptedColor = (Microsoft.Msagl.Drawing.Color)property.GetValue(null); return(adaptedColor); }
/// <summary> /// Initializes a new instance of the <see cref="ShowStrategiesCommand"/> class. /// </summary> /// <param name="component">The component.</param> /// <param name="element">The element.</param> /// <param name="fileName">Name of the file.</param> public ShowStrategiesCommand(SoftwareComponent component, object element, string fileName) { this._component = component; PresentationElement pel = element as PresentationElement; if (pel != null) { this._model = pel.ModelElement as CandleElement; } }
/// <summary> /// Permet de résoudre un type en retournant son nom complet /// </summary> /// <param name="component">The component.</param> /// <param name="typeName">Name of the type.</param> /// <returns></returns> public static string ResolveTypeName(SoftwareComponent component, string typeName) { DataType typeRef = component.FindGlobalType(typeName); if (typeRef != null) { typeName = typeRef.FullName; } return(typeName); }
public void Build(Model model) { foreach (ComponentSpecification spec in specifications) { SoftwareComponent component = BuildComponent(model, spec); if (component != null) { model.SoftwareComponents.Add(component); } } }
public virtual void RemoveComponent(SoftwareComponent component) { if (!this.softwareComponents.Contains(component)) { return; } this.CurrentCapacityUsed -= component.CapacityConsumption; this.CurrentMemoryUsed -= component.MemoryConsumption; this.softwareComponents.Remove(component); }
public bool CanTakeSoftware(SoftwareComponent softwareComponent) { bool haveEnoughCapacity = (softwareComponent.CapacityConsumption + this.Capcity) <= this.MaxCapacity; bool haveEnoughMemory = (softwareComponent.MemoryConsumtion + this.Memory) <= this.MaxMemory; if (haveEnoughCapacity && haveEnoughMemory) { return(true); } return(false); }
/// <summary> /// Création du composant principal initialisé à partir d'une assembly /// </summary> private void CreateComponent() { using (Transaction transaction = _model.Store.TransactionManager.BeginTransaction("Init main component")) { // Création du composant _component = new SoftwareComponent(_model.Store); _component.Name = "?"; // Pour forcer le wizard _model.Component = _component; // Force la transaction pour afficher le wizard transaction.Commit(); } }
public void AttachSoftwareToHardware(SoftwareComponent softwareComponent) { HardwareComponent componentToAttachTo = this.HardwareComponents.FirstOrDefault(x => x.Name == softwareComponent.HardwareName); if (componentToAttachTo == null) { return; } componentToAttachTo.AddComponent(softwareComponent); }
public virtual void AddComponent(SoftwareComponent component) { if (this.CurrentCapacityUsed + component.CapacityConsumption > this.MaximumCapacity || this.CurrentMemoryUsed + component.MemoryConsumption > this.MaximumMemory) { return; } this.softwareComponents.Add(component); this.CurrentCapacityUsed += component.CapacityConsumption; this.CurrentMemoryUsed += component.MemoryConsumption; }
/// <summary> /// Get Telebox or Reader firmware version /// </summary> /// <param name="component"></param> /// <returns></returns> public string GetVersion(SoftwareComponent component) { _Logger.AddText(string.Format("Send GetVersion message"), Messagetype.ToKiosk); MethodInfo mi = GetType().GetMethod("GetVersion"); String strVersion = _clsUsbComm.SendReceiveCommand(mi, new object[] { component }); if (string.IsNullOrEmpty(strVersion)) { throw new TimeoutException("GerVersion command not response"); } _Logger.AddText(strVersion, Messagetype.Message); return(strVersion); }
private static void AddSoftware(List <HardwareComponent> hardware, List <string> input) { SoftwareComponent currentSoftwareComponent = SoftwareFactory.CreateSoftware(input); if (hardware.Any(h => h.Name == currentSoftwareComponent.HardwareComponent)) { var currenthardComponent = hardware.First(h => h.Name == currentSoftwareComponent.HardwareComponent); if (currenthardComponent.CanTakeSoftware(currentSoftwareComponent)) { currenthardComponent.AddSoftwareComponent(currentSoftwareComponent); } } }
private static void ReleaseSoftwareFromHardware(string[] commands, List <HardwareComponent> hardwareComponents, List <SoftwareComponent> softwareComponents) { string desiredHardwareName = commands[1]; string softwareToRemoveName = commands[2]; HardwareComponent desiredComponent = hardwareComponents.FirstOrDefault(x => x.Name == desiredHardwareName); SoftwareComponent unwantedSoftware = softwareComponents.FirstOrDefault(x => x.Name == softwareToRemoveName); if (desiredComponent.Softwares.Any(x => x.Name == softwareToRemoveName)) { desiredComponent.Softwares.Remove(unwantedSoftware); } desiredComponent.ReleaseSoftware(unwantedSoftware); }
private SoftwareComponent BuildComponent(Model model, ComponentSpecification spec) { List <AssemblyPointer> componentPointers = new List <AssemblyPointer>(); List <SoftwareComponent> subcomponents = new List <SoftwareComponent>(); foreach (ComponentSpecification subSpec in spec.Subcomponents) { SoftwareComponent subcomponent = BuildComponent(model, subSpec); if (subcomponent != null) { subcomponents.Add(subcomponent); } } foreach (string assemblyname in spec.Assemblies) { if (assemblyname.Contains("*")) { Regex regex = new Regex(assemblyname); foreach (AssemblyPointer pointer in model.AllAssemblies().Where(x => regex.Match(x.GetName().Name).Success)) { if (pointer.Component() == null) { componentPointers.Add(pointer); pointer.AddProperty("Component", spec.Name); } } } else { AssemblyPointer pointer = model.FindPointerByName(assemblyname); if (pointer != null && pointer.Component() == null) { componentPointers.Add(pointer); pointer.AddProperty("Component", spec.Name); } } } try { SoftwareComponent component = new SoftwareComponent(spec.Name, componentPointers, spec.Color, subcomponents); return(component); } catch (ArgumentException e) { return(null); } }
/// <summary> /// Alerts listeners that a property for an element has changed. /// </summary> /// <param name="e">Provides data for the ElementPropertyChanged event.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { SoftwareComponent model = e.ModelElement as SoftwareComponent; if (model == null) { return; } if (e.DomainProperty.Id == SoftwareComponent.NamespaceDomainPropertyId) { OnNameChanged(e, model); } }
/// <summary> /// Initializes a new instance of the <see cref="ImportWsdlCommand"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="obj">The obj.</param> public ImportWsdlCommand(IServiceProvider serviceProvider, object obj) { this._serviceProvider = serviceProvider; _nodeShape = obj as ISupportArrangeShapes; if (obj is SoftwareComponentShape) { this._component = ((SoftwareComponentShape)obj).ModelElement as SoftwareComponent; _model = _component.Model; } else if (obj is Diagram) { this._model = ((Diagram)obj).ModelElement as CandleModel; } }
private void ResetViews() { // Reset Treeview if (SelectedItem != null) { SoftwareComponent component = Model.FindComponentByName((string)SelectedItem.Header); if (component != null) { SelectedItem.Foreground = new SolidColorBrush(ConvertSystemDrawingToWindowsMediaColor(component.Color)); } else if (ParentItem != null && (string)ParentItem.Header == "Groups" && SelectedItem.Items.Cast <TreeViewItem>().Any(x => Model.FindPointerByPrettyName((string)x.Header).HasErrors)) { SelectedItem.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0)); } else { SelectedItem.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)); } } SelectedItem = null; // Clean TabControl tabControl.Opacity = 25; propertiesGrid.Visibility = Visibility.Hidden; errorsGrid.Visibility = Visibility.Hidden; errorsGrid.Items.Clear(); errorsGrid.Columns.Clear(); TabItem itemErrors = (TabItem)tabControl.Items.GetItemAt(1); itemErrors.Visibility = Visibility.Hidden; // Reset nodes to non highlighted mode foreach (VNode node in GraphViewer.Entities.Where(x => x is VNode).Cast <VNode>()) { node.Node.Label.FontColor = Microsoft.Msagl.Drawing.Color.Black; node.Node.Attr.FillColor = Microsoft.Msagl.Drawing.Color.White; } foreach (var edge in GraphViewer.Entities.Where(x => x is IViewerEdge).Cast <IViewerEdge>()) { if (edge.Edge.Attr.Color != Microsoft.Msagl.Drawing.Color.Red) { edge.Edge.Attr.Color = Microsoft.Msagl.Drawing.Color.Black; } } }
/// <summary> /// Populates the specified current component. /// </summary> /// <param name="currentComponent">The current component.</param> /// <param name="model">The model.</param> private void Populate(SoftwareComponent currentComponent, CandleModel model) { _currentComponent = currentComponent; lstInheritedConfigurations.AutoGenerateColumns = false; lstConfigurations.AutoGenerateColumns = false; if (currentComponent != null) { foreach (SoftwareLayer layer in currentComponent.Layers) { ColLayer.Items.Add(layer.Name); } colVisibility.Items.Add(Visibility.Public); colVisibility.Items.Add(Visibility.Private); // Remplissage des configurations courantes _items = new ItemList(); foreach (SoftwareLayer layer in currentComponent.Layers) { foreach (ConfigurationPart cfg in layer.Configurations) { Item item = new Item(); item.ConfigName = cfg.Name; item.XmlContent = cfg.XmlContent; item.LayerName = layer.Name; item.LayerId = layer.Id; item.InitialEnabled = item.Enabled = cfg.Enabled; item.IsExternal = false; item.Visibility = cfg.Visibility; _items.Add(item); } } lstConfigurations.DataSource = _items; } else // On enlève cette page { tabControl1.TabPages.RemoveAt(0); } // Configurations externes ReferenceWalker walker = new ReferenceWalker(ReferenceScope.Runtime, new ConfigurationMode()); ConfigurationVisitor visitor = new ConfigurationVisitor(true); walker.Traverse(visitor, model); lstInheritedConfigurations.DataSource = visitor.Configurations.FindAll(delegate(ConfigurationPart p) { return(p.Enabled); }); }
public void AddSoftwareToHardware(string hardwareName, SoftwareComponent software) { HardwareComponent hardware = null; if (this.hardwareByName.TryGetValue(hardwareName, out hardware)) { if (hardware.AddSoftware(software)) { this.CapacityInUse += software.CapacityConsumation; this.MemoryInUse += software.MemoryConsumation; this.AddedSoftware++; } } }
/// <summary> /// Creates the layer. /// </summary> /// <param name="component">The component.</param> /// <param name="package">The package.</param> /// <returns></returns> public SoftwareLayer CreateLayer(SoftwareComponent component, LayerPackage package) { SoftwareLayer layer = null; if (rbPres.Checked) { layer = new PresentationLayer(component.Store); } else if (rbUI.Checked) { layer = new UIWorkflowLayer(component.Store); } else if (rbDAL.Checked) { layer = new DataAccessLayer(component.Store); } else if (rbBLL.Checked) { layer = new BusinessLayer(component.Store); } else if (rbModels.Checked) { layer = new DataLayer(component.Store); } else if (rbInterface.Checked) { layer = new InterfaceLayer(component.Store); ((InterfaceLayer)layer).Level = (short)(package.Level + 1); package.InterfaceLayer = (InterfaceLayer)layer; } Layer tmp = layer as Layer; if (tmp != null) { package = component.LayerPackages.Find(delegate(LayerPackage p) { return(p.Level == tmp.Level); }); if (package == null) { package = new LayerPackage(component.Store); package.Level = tmp.Level; component.LayerPackages.Add(package); } package.Layers.Add(tmp); } component.Layers.Add(layer); return(layer); }
public void ReleaseSoftwareComponent(string hardwareComponentName, string softwareComponentName) { HardwareComponent hardwareComponent = this.HardwareComponents.FirstOrDefault(x => x.Name == hardwareComponentName); if (hardwareComponent == null) { return; } SoftwareComponent softwareComponent = hardwareComponent.GetSoftwareComponent(softwareComponentName); if (softwareComponent == null) { return; } hardwareComponent.RemoveComponent(softwareComponent); }
public virtual SoftwareComponent CreateSoftwareComponentComponent(string[] inputArgs) { SoftwareComponent newComponent = null; string[] componentData = inputArgs[1].Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); switch (inputArgs[0]) { case "RegisterExpressSoftware": newComponent = this.CreateExpressSoftware(componentData); break; case "RegisterLightSoftware": newComponent = this.CreateLightSoftware(componentData); break; } return(newComponent); }
/// <summary> /// Initializes a new instance of the <see cref="ManageConfigurationCommand"/> class. /// </summary> /// <param name="shape">The shape.</param> public ManageConfigurationCommand(object shape) { if (shape != null) { _component = ((PresentationElement)shape).ModelElement as SoftwareComponent; if (_component == null) { CandleModel model = ((PresentationElement)shape).ModelElement as CandleModel; if (model != null) { _component = model.SoftwareComponent; } else { _externalComponent = ((PresentationElement)shape).ModelElement as ExternalComponent; } } } }
private TreeViewItem SetTreeViewComponentItem(SoftwareComponent component) { TreeViewItem componentItem = new TreeViewItem(); componentItem.Header = component.Name; //Color Management if (component.Color.Name != "Black") { componentItem.Foreground = new SolidColorBrush(ConvertSystemDrawingToWindowsMediaColor(component.Color)); } // Groups build if (component.HasGroups) { TreeViewItem groupsItem = new TreeViewItem(); groupsItem.Header = "Groups"; foreach (AssemblyPointerGroup group in component.AssemblyPointerGroups) { groupsItem.Items.Add(SetTreeViewGroupItem(group)); } componentItem.Items.Add(groupsItem); } // Subcomponents build if (component.HasSubcomponents) { TreeViewItem subcomponentsItem = new TreeViewItem(); subcomponentsItem.Header = "Subcomponents"; foreach (SoftwareComponent subcomponent in component.Subcomponents) { subcomponentsItem.Items.Add(SetTreeViewComponentItem(subcomponent)); } componentItem.Items.Add(subcomponentsItem); } return(componentItem); }
private static void OnNameChanged(ElementPropertyChangedEventArgs e, SoftwareComponent model) { string oldName = (string)e.OldValue; if (oldName != "?" && (model.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.IsSerializing || model.Store.InUndoRedoOrRollback)) { return; } string newName = (string)e.NewValue; foreach (SoftwareLayer layer in model.Layers) { if (oldName == "?") { if (layer.Name == "?") { LayerPackage lp = null; if (layer is Layer) { lp = ((Layer)layer).LayerPackage; } layer.Name = StrategyManager.GetInstance(layer.Store).NamingStrategy.CreateLayerName(lp, layer, null); // Le namespace sera mis à jour via la regle LayerNameChangeRule. } else { layer.Namespace = StrategyManager.GetInstance(model.Store).NamingStrategy.CreateNamespace(newName, layer.Name, layer); } } else if (layer.Namespace.StartsWith(oldName)) { layer.Namespace = newName + layer.Namespace.Substring(oldName.Length); } } }
public static void ReleaseSoftwareComponent(List <HardwareComponent> computer, string command) { string[] tokens = command.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()) .ToArray(); string hardwareName = tokens[0]; string softwareName = tokens[1]; if (computer.Any(h => h.Name == hardwareName)) { HardwareComponent hardware = computer.Where(h => h.Name == hardwareName).First(); if (hardware.SeeSoftware().Any(s => s.Name == softwareName)) { SoftwareComponent software = hardware.SeeSoftware().Where(s => s.Name == softwareName).First(); hardware.RemoveSoftwareComponent(software); hardware.UsedCapacity -= software.CapacityConsumption; hardware.UsedMemory -= software.MemoryConsumption; } } }
/// <summary> /// Sets the component. /// </summary> /// <param name="component">The component.</param> internal void SetComponent(SoftwareComponent component) { if (_component == component) { return; } if (_component != null && _component.Store != null) { _component.Store.EventManagerDirectory.ElementPropertyChanged.Remove( new EventHandler <ElementPropertyChangedEventArgs>(OnPropertyChanged)); } _component = component; if (_component != null && _component.Store != null) { _component.Store.EventManagerDirectory.ElementPropertyChanged.Add( new EventHandler <ElementPropertyChangedEventArgs>(OnPropertyChanged)); } }
/// <summary> /// </summary> /// <param name="e">Provides data for the ElementDeleted event.</param> public override void ElementDeleted(ElementDeletedEventArgs e) { LayerPackage layerPackage = e.ModelElement as LayerPackage; if (layerPackage == null) { return; } if (layerPackage.Store.InUndoRedoOrRollback) { return; } SoftwareComponent component = CandleModel.GetInstance(layerPackage.Store).SoftwareComponent; if (component != null) { // Suppression de la couche d'interface AbstractLayer interfaceLayer = null; foreach (AbstractLayer al in component.Layers) { ISortedLayer sl = al as ISortedLayer; if (sl != null && sl.Level == layerPackage.LayerLevel) { interfaceLayer = al; break; } } if (interfaceLayer != null) { interfaceLayer.Delete(); } IList <PresentationViewsSubject> shapes = PresentationViewsSubject.GetLinksToPresentation(component); foreach (PresentationViewsSubject link in shapes) { ((SoftwareComponentShape)link.Presentation).ArrangeShapes(); } } }