/// <summary> /// Initializes a new instance of the <see cref="ReferencedAssembliesForm"/> class. /// </summary> /// <param name="externalAssembly">The external assembly.</param> /// <param name="referencedAssemblies">The referenced assemblies.</param> public ReferencedAssembliesForm(DotNetAssembly externalAssembly, AssemblyName[] referencedAssemblies) : this(ComponentType.Library) { Text += " for " + externalAssembly.Name; foreach (AssemblyName an in referencedAssemblies) { ComponentMetadataMap item = new ComponentMetadataMap(); item.Version = new VersionInfo(an.Version); ExternalComponent externalComponent = externalAssembly.Component.Model.FindExternalComponentByName(an.Name); if (externalComponent == null) { item.Name = "<select a model>"; } else { item.AlreadyExists = true; item.Name = externalComponent.Name; item.MetaData = externalComponent.MetaData; } item.InitialComponentType = ComponentType.Library; item.AssemblyName = an.Name; _assemblyBindings.Add(item); } dgAssemblies.DataSource = _assemblyBindings; }
/// <summary> /// Creates an instance of this command, passing the logger to write messages to. /// </summary> /// <param name="logger">The logger which messages should be written to.</param> public UpdateStatus(ILogger logger, ExternalComponent externalComponent, string thirdPartyStatus, bool componentAvailable) : base(logger) { ExternalComponent = externalComponent; ThirdPartyStatus = thirdPartyStatus; ComponentAvailable = componentAvailable; }
/// <summary> /// Met à jour les caractéristiques d'un composant externe à partir des metadonnées /// </summary> /// <param name="component"></param> internal void UpdateComponent(ExternalComponent component) { component.Name = _name; component.Version = _version; component.ModelMoniker = _id; component.Description = _description; }
public Tesseract304XpEngine(AppConfigManager appConfigManager, ComponentManager componentManager) : base(appConfigManager, componentManager) { TesseractExePath = "tesseract_xp.exe"; PlatformSupport = PlatformSupport.Windows; Component = new ExternalComponent("ocr", Path.Combine(TesseractBasePath, TesseractExePath), new DownloadInfo("tesseract_xp.exe.gz", Mirrors, 1.32, "98d15e4765caae864f16fa2ab106e3fd6adbe8c3", DownloadFormat.Gzip)); }
public OcrDependencyManager(AppConfigManager appConfigManager, IUserConfigManager userConfigManager) { this.appConfigManager = appConfigManager; this.userConfigManager = userConfigManager; ExternalComponent.InitBasePath(appConfigManager); Components = new OcrComponents(); Downloads = new OcrDownloads(); }
public GhostscriptPdfRenderer(IComponentInstallPrompt componentInstallPrompt, AppConfigManager appConfigManager, IErrorOutput errorOutput) { this.componentInstallPrompt = componentInstallPrompt; this.appConfigManager = appConfigManager; this.errorOutput = errorOutput; gsLibBytes = new Lazy <byte[]>(() => File.ReadAllBytes(Dependencies.GhostscriptComponent.Path)); ExternalComponent.InitBasePath(appConfigManager); }
public bool PromptToInstall(ExternalComponent component, string promptText) { if (MessageBox.Show(promptText, MiscResources.DownloadNeeded, MessageBoxButtons.YesNo) == DialogResult.Yes) { var progressForm = formFactory.Create <FDownloadProgress>(); progressForm.QueueFile(component); progressForm.ShowDialog(); } return(component.IsInstalled); }
/// <summary> /// Initializes a new instance of the <see cref="GetLastVersionCommand"/> class. /// </summary> /// <param name="shape">The shape.</param> public GetLastVersionCommand(object shape) { if (shape != null && shape is PresentationElement) { _externalComponent = ((PresentationElement)shape).ModelElement as ExternalComponent; if (_externalComponent != null) { _externalModel = _externalComponent.ReferencedModel; this._force = _externalComponent.MetaData.IsLastVersion(); } } }
public Tesseract302Engine(AppConfigManager appConfigManager, ComponentManager componentManager) : base(appConfigManager) { // Using the newer data since we just need the 302 engine for backwards compatibility LanguageData = TesseractLanguageData.V304; TesseractBasePath = Path.Combine(componentManager.BasePath, "tesseract-3.0.2"); TesseractExePath = "tesseract.exe"; TesseractHocrExtension = ".html"; PlatformSupport = PlatformSupport.Windows; CanInstall = false; Component = new ExternalComponent("ocr", Path.Combine(TesseractBasePath, TesseractExePath), null); LanguageComponents = LanguageData.Data.Select(x => new ExternalComponent($"ocr-{x.Code}", Path.Combine(TesseractBasePath, "tessdata", x.Filename.Replace(".gz", "")), null)); }
public Tesseract304Engine(AppConfigManager appConfigManager, ComponentManager componentManager) : base(appConfigManager) { LanguageData = TesseractLanguageData.V304; TesseractBasePath = Path.Combine(componentManager.BasePath, "tesseract-3.0.4"); TesseractExePath = "tesseract.exe"; PlatformSupport = PlatformSupport.ModernWindows; CanInstall = true; Component = new ExternalComponent("ocr", Path.Combine(TesseractBasePath, TesseractExePath), new DownloadInfo("tesseract.exe.gz", Mirrors, 1.32, "0b0fd21cd886c04c60ed5c3f38b9120b408139b3", DownloadFormat.Gzip)); LanguageComponents = LanguageData.Data.Select(x => new ExternalComponent($"ocr-{x.Code}", Path.Combine(TesseractBasePath, "tessdata", x.Filename.Replace(".gz", "")), new DownloadInfo(x.Filename, Mirrors, x.Size, x.Sha1, DownloadFormat.Gzip))); }
/// <summary> /// Création d'un composant externe à partir correspondant à un modèle /// </summary> /// <param name="model"></param> /// <returns></returns> internal ExternalComponent CreateComponent(CandleModel model) { ExternalComponent externalComponent = model.FindExternalComponent(_id); if (externalComponent != null) { return(externalComponent); } externalComponent = new ExternalComponent(model.Store); UpdateComponent(externalComponent); model.ExternalComponents.Add(externalComponent); externalComponent.UpdateFromModel(); return(externalComponent); }
/// <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; } } } }
// 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) { ExternalComponent externalComponent = e.ModelElement as ExternalComponent; if (externalComponent == null) { return; } // Cette régle ne s'applique pas quand on charge le modèle if (externalComponent.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.IsSerializing || externalComponent.Store.InUndoRedoOrRollback) { return; } // Test si on est pas en train d'insèrer des assemblies externes (voir ImportAssemblyCommand) object dummy; if (externalComponent.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.TryGetValue("Import assemblies", out dummy)) { return; } // Insertion d'un composant à partir de la toolbar dans ce cas, on affiche // un wizard de sélection de modèle. // TODO a voir si pas redondant avec la fenetre du repository ComponentModelMetadata metadata; if (externalComponent.MetaData == null && !RepositoryManager.Instance.ModelsMetadata.SelectModel(externalComponent, out metadata)) { // On annule toute l'insertion externalComponent.Store.TransactionManager.CurrentTransaction.Rollback(); return; } //// La synchro au chargement du modèle ne se fait que quand le modèle //// est chargé dans le designer (cf ComponentModelDocData.Load) ////RepositoryManager.SynchronizeExternalComponentFromServer(externalComponent); }
/// <summary> /// Execute the command /// </summary> public void Exec() { ExternalComponent system = _shape.ModelElement as ExternalComponent; if (system == null) { return; } using (Transaction transaction = system.Store.TransactionManager.BeginTransaction("Model affectation")) { ComponentModelMetadata metaData; if (!RepositoryManager.Instance.ModelsMetadata.SelectModel(system, out metaData)) { // On annule toute l'insertion system.Store.TransactionManager.CurrentTransaction.Rollback(); return; } transaction.Commit(); } }
/// <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) { if (e.DomainProperty.Id == ExternalComponent.VersionDomainPropertyId) { ExternalComponent sys = e.ModelElement as ExternalComponent; if (sys != null && sys.ModelMoniker != null) { object flag; if ( sys.Store.TransactionManager.CurrentTransaction.Context.ContextInfo.TryGetValue( "InExternalComponentChangeRule", out flag)) { return; } sys.Store.TransactionManager.CurrentTransaction.Context.ContextInfo["InExternalComponentChangeRule"] = true; if ( sys.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo. TryGetValue("InModelLoader", out flag)) { return; } CandleModel model = sys.ReferencedModel; if (model != null) { sys.UpdateFromModel(); } else { if (String.IsNullOrEmpty(sys.Name)) { sys.Name = "unknow model"; } } } } }
/// <summary> /// Edits the value. /// </summary> /// <param name="context">The context.</param> /// <param name="sp">The sp.</param> /// <param name="value">The value.</param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider sp, object value) { NodeShape shape = context.Instance as NodeShape; if (shape == null) { return(value); } ExternalComponent externalComponent = shape.ModelElement as ExternalComponent; if (externalComponent == null) { return(value); } _edSvc = (IWindowsFormsEditorService)sp.GetService(typeof(IWindowsFormsEditorService)); if (_edSvc != null) { _comboBox = new ListBox(); PopulateListBoxItems(externalComponent.ModelMoniker); if (_comboBox.Items.Count == 0) { return(value); } _comboBox.KeyDown += KeyDown; _comboBox.Leave += ValueChanged; _comboBox.DoubleClick += ValueChanged; _comboBox.Click += ValueChanged; _edSvc.DropDownControl(_comboBox); if (_comboBox.SelectedItem != null) { return(new Version(_comboBox.SelectedItem.ToString())); } } return(value); }
/// <summary> /// Initializes a new instance of the <see cref="ShowPropertiesCommand"/> class. /// </summary> /// <param name="shape">The shape.</param> public ShowPropertiesCommand(object shape) { if (shape == null) { return; } ExternalComponent ext = ((PresentationElement)shape).ModelElement as ExternalComponent; if (ext != null) { _metadata = ext.MetaData; return; } CandleModel model = ((PresentationElement)shape).ModelElement as CandleModel; if (model != null) { _metadata = model.MetaData; } }
/// <summary> /// Creates the external component. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public ExternalComponent CreateComponent(CandleModel model) { ExternalComponent externalComponent; if (_metaData != null) { // Recherche par l'id si possible externalComponent = model.FindExternalComponent(_metaData.Id); } else { // Sinon par le nom pour éviter des doublons externalComponent = model.FindExternalComponentByName(Name); } if (externalComponent != null) { return(externalComponent); } if (_metaData != null) { return(_metaData.CreateComponent(model)); } // Component par défaut avec le nom de l'assembly externalComponent = new ExternalComponent(model.Store); //ExternalPublicPort port = new ExternalPublicPort(model.Store); //port.Name = this.AssemblyName; //((ExternalBinaryComponent)externalComponent).Ports.Add(port); externalComponent.ModelMoniker = Guid.Empty; externalComponent.Name = AssemblyName; externalComponent.Version = Version; // Ajout au modèle model.ExternalComponents.Add(externalComponent); return(externalComponent); }
public bool PromptToInstall(ExternalComponent component, string promptText) { Console.WriteLine(ConsoleResources.ComponentNeeded, component.Id); return(false); }
/// <summary> /// Execute the command /// </summary> public void Exec() { // Affiche la fenetre de dialogue permettant de choisir les assemblies IAssemblySelectorDialog selector = ServiceLocator.Instance.GetService <IAssemblySelectorDialog>(); if (selector.ShowDialog(1)) // Une seule sélection possible { Assembly asm = selector.SelectedAssemblies[0]; using (Transaction transaction = _element.Store.TransactionManager.BeginTransaction("Update model version")) { // Mise à jour de la version du composant et son emplacement initial // et création des nouvelles dépendances (les dépendances actuelles ne seront pas touchées // mais il faudra s'assurer qu'elles soient bien à jour car la procédure ne vérifie que le nom // et ignore la version) _element.InitFromAssembly(asm, true /* creation des nouvelles dépendances*/); transaction.Commit(); } // Vérification si les assemblies existantes possédent la bonne version foreach (AssemblyName assemblyName in asm.GetReferencedAssemblies()) { // On ignore les assemblies systèmes if (Utils.StringCompareEquals(assemblyName.Name, "mscorlib") || assemblyName.Name.StartsWith("System", StringComparison.CurrentCultureIgnoreCase)) { continue; } // On regarde si cette assembly existe déjà dans le modèle DotNetAssembly eam = _element.Component.FindDotNetAssemblyModelFromAssembly(assemblyName); if (eam != null) { if (!assemblyName.Version.Equals((Version)eam.Version)) { using (Transaction transaction = _element.Store.TransactionManager.BeginTransaction("Update assembly version")) { eam.Version = new VersionInfo(assemblyName.Version); transaction.Commit(); } } } else { // Idem pour les composants externes ExternalComponent esm = _element.Component.Model.FindExternalComponentByName(assemblyName.Name); if (esm != null && esm.MetaData != null && esm.MetaData.ComponentType == ComponentType.Library) { if (!assemblyName.Version.Equals((Version)esm.Version)) { // Recherche si il existe un modèle avec la bonne version List <ComponentModelMetadata> versions = RepositoryManager.Instance.ModelsMetadata.Metadatas.GetAllVersions(esm.Id); ComponentModelMetadata metadata = versions.Find(delegate(ComponentModelMetadata m) { return(assemblyName.Version.Equals(m.Version)); }); using (Transaction transaction = _element.Store.TransactionManager.BeginTransaction("Update model version")) { if (metadata != null) { // OK on met a jour esm.Version = metadata.Version; } else // erreur On a pas trouvé de modéle { // Sauvegarde de la bonne version esm.Version = new VersionInfo(assemblyName.Version); // On force à null pour obliger l'utilisateur à sélectionner un // modéle esm.ModelMoniker = Guid.Empty; } transaction.Commit(); } } } } } // Demande si il faut aussi mettre à jour le n° de version du composant if (_element.Visibility == Visibility.Public) { if (MessageBox.Show(String.Format("Do you want to change the current version of the component from {0} to {1}", _element.Component.Model.Version, _element.Version), "Component version change", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (Transaction transaction = _element.Store.TransactionManager.BeginTransaction("Update model version")) { _element.Component.Model.Version = _element.Version; transaction.Commit(); } } } } }
public OcrDependencyManager(AppConfigManager appConfigManager) { ExternalComponent.InitBasePath(appConfigManager); Components = new OcrComponents(); Downloads = new OcrDownloads(); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationEditorDialog"/> class. /// </summary> /// <param name="externalComponent">The external component.</param> public ConfigurationEditorDialog(ExternalComponent externalComponent) { InitializeComponent(); Populate(null, externalComponent.ReferencedModel); }
/// <summary> /// Sélection d'un modèle /// </summary> /// <param name="component">The component.</param> /// <param name="metaData">The meta data.</param> /// <returns></returns> bool IModelsMetadata.SelectModel(ExternalComponent component, out ComponentModelMetadata metaData) { metaData = null; // Ici on veut saisir le fichier décrivant le système ComponentType?ct = null; if (component.MetaData != null) { ct = component.MetaData.ComponentType; } RepositoryTreeForm wizard = new RepositoryTreeForm(true, ct); if (wizard.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // On doit le créer if (wizard.SelectedItem == null) { // // Création d'un composant externe // if (component.Name == String.Empty) { PromptBox pb = new PromptBox("Name of the new component"); if (pb.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } // Vérification des doublons. if (_metadatas.NameExists(pb.Value)) { IIDEHelper ide = ServiceLocator.Instance.IDEHelper; if (ide != null) { ide.ShowMessage("This model already exists in this model."); } return(false); } component.Name = pb.Value; } // Création d'un modèle vide dans un répertoire temporaire string relativeModelFileName = component.Name + ModelConstants.FileNameExtension; string fn = Utils.GetTemporaryFileName(relativeModelFileName); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fn)); // Persistence du modèle CandleModel model = ModelLoader.CreateModel(component.Name, component.Version); component.ModelMoniker = model.Id; SerializationResult result = new SerializationResult(); CandleSerializationHelper.Instance.SaveModel(result, model, fn); // Et ouverture du modèle ServiceLocator.Instance.ShellHelper.Solution.DTE.ItemOperations.OpenFile(fn, EnvDTE.Constants.vsViewKindDesigner); } else // Sinon affectation { metaData = wizard.SelectedItem; ExternalComponent externalComponent = component.Model.FindExternalComponent(metaData.Id); if (externalComponent != null) { IIDEHelper ide = ServiceLocator.Instance.IDEHelper; if (ide != null) { ide.ShowMessage("This model already exists in this model."); } return(false); } metaData.UpdateComponent(component); } return(true); // On ne passe pas dans le rollback } return(false); }