public FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem) { Contract.Requires(propertyItem != null); // this.Config.GroupPlugins.ListPlugins AppProjectGenerator instance = (AppProjectGenerator)propertyItem.Instance; //if (instance.ListGenerators.Count == 1) // propertyItem.Value = instance.ListGenerators[0].Guid; ComboBox cbx = new ComboBox(); cbx.DisplayMemberPath = "Name"; cbx.SelectedValuePath = "Guid"; var _binding_lst = new Binding(); // bind to the Value property of the PropertyItem _binding_lst.Source = instance.ListGenerators; _binding_lst.ValidatesOnExceptions = false; _binding_lst.ValidatesOnDataErrors = false; _binding_lst.Mode = BindingMode.OneWay; BindingOperations.SetBinding(cbx, ComboBox.ItemsSourceProperty, _binding_lst); var _binding = new Binding("Value"); // bind to the Value property of the PropertyItem _binding.Source = propertyItem; _binding.ValidatesOnExceptions = true; _binding.ValidatesOnDataErrors = true; _binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; BindingOperations.SetBinding(cbx, ComboBox.SelectedValueProperty, _binding); return(cbx); }
private void SearchPathAndAdd(AppProjectGenerator appgen, INodeGenSettings ngs, IvPluginGenerator gen) { foreach (var t in gen.GetListNodeGenerationSettings()) { string modelPath = this.ModelPath; var searchPattern = t.SearchPathInModel; var is_found = SearchInModelPathByPattern(modelPath, searchPattern); if (is_found) { GeneratorSettings gs = new GeneratorSettings(this); gs.NodeSettingsVmGuid = t.Guid; gs.AppGeneratorGuid = appgen.Guid; _logger.LogTrace("Adding Node Settings. {Path} NodeSettingsVmGuid={NodeSettingsVmGuid} Name={Name}".CallerInfo(), t.SearchPathInModel, gs.NodeSettingsVmGuid, appgen.Name); #if DEBUG foreach (var ttt in ngs.ListGeneratorsSettings) { if (ttt.AppGeneratorGuid == appgen.Guid) { throw new Exception(); } } #endif ngs.ListGeneratorsSettings.Add(gs); gs.SettingsVm = t.GetAppGenerationNodeSettingsVm(gs.Settings); break; } } }
public override ITreeConfigNode NodeAddNew() { var node = new AppProjectGenerator(this.Parent); (this.Parent as AppProject).ListAppProjectGenerators.Add(node); this.GetUniqueName(AppProjectGenerator.DefaultName, node, (this.Parent as AppProject).ListAppProjectGenerators); this.SetSelected(node); return(node); }
public override ITreeConfigNode NodeAddClone() { var node = AppProjectGenerator.Clone(this.Parent, this, true, true); node.Parent = this.Parent; (this.Parent as AppProject).ListAppProjectGenerators.Add(node); this._Name = this._Name + "2"; this.SetSelected(node); return(node); }
public object Run(AppProjectGenerator node) { if (!string.IsNullOrWhiteSpace(node.PluginGuid)) { if (!string.IsNullOrWhiteSpace(node.PluginGeneratorGuid)) { Dictionary <string, object> dic_gs = new Dictionary <string, object>(); var cfg = (Config)node.GetConfig(); object objGen = CreateSettingsForAppProjectGenerator(cfg.Model, node, dic_gs, true); return(objGen); } } return(null); }
public AppProjectGenerator AddGenerator(string name, string pluginGuid, string generatorGuid, string outFile, string generationPath = null) { AppProjectGenerator node = new AppProjectGenerator(this); this.ListAppProjectGenerators.Add(node); if (generationPath != null) { node.RelativePathToGenFolder = generationPath; } node.PluginGuid = pluginGuid; node.PluginGeneratorGuid = generatorGuid; if (!string.IsNullOrWhiteSpace(outFile)) { node.GenFileName = outFile; } node.Name = name; return(node); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { AppProjectGenerator node = null; if (node_impl == null) { node = new AppProjectGenerator(this); } else { node = (AppProjectGenerator)node_impl; } node.Parent = this; this.ListAppProjectGenerators.Add(node); if (node_impl == null) { this.GetUniqueName(AppProjectGenerator.DefaultName, node, this.ListAppProjectGenerators); } this.SetSelected(node); return(node); }
private bool IsUnique(AppProjectGenerator val) { if (val.Parent == null) { return(true); } if (string.IsNullOrWhiteSpace(val.Name)) // handled by another rule { return(true); } var p = val.AppProject; foreach (var t in p.ListAppProjectGenerators) { if ((val.Guid != t.Guid) && (val.Name == t.Name)) { return(false); } } return(true); }
//private static object CreateSettingsForProject(ITreeConfigNode node, AppProject tt, Dictionary<string, object> dic_apgs, bool isShortVersion) //{ // TypeBuilder tbAppGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for app generators // foreach (var ttt in tt.ListAppProjectGenerators) // { // if (!string.IsNullOrWhiteSpace(ttt.PluginGuid)) // { // if (!string.IsNullOrWhiteSpace(ttt.PluginGeneratorGuid)) // { // Dictionary<string, object> dic_gs = new Dictionary<string, object>(); // object objGen = null; // objGen = CreateSettingsForAppProjectGenerator(node, ttt, dic_gs, isShortVersion); // if (dic_gs.Count > 0) // { // dic_apgs[ttt.Name] = objGen; // SettingsTypeBuilder.CreateProperty(tbAppGen, ttt.Name, typeof(Object), ttt.NameUi, ttt.Description); // } // } // } // } // SettingsTypeBuilder.CreateToString(tbAppGen, "Project"); // Type apgsType = tbAppGen.CreateType(); // var objAppGen = Activator.CreateInstance(apgsType); // foreach (var dt in dic_apgs) // { // apgsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objAppGen, new object[] { dt.Value }); // } // return objAppGen; //} private static object CreateSettingsForAppProjectGenerator(ITreeConfigNode node, AppProjectGenerator ttt, Dictionary <string, object> dic_gs, bool isShortVersion) { var nds = (IGetNodeSetting)node; TypeBuilder tbGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for generators foreach (var tttt in ttt.ListGenerators) { if (tttt.Generator == null) { continue; } if (isShortVersion && (tttt.Guid != ttt.PluginGeneratorGuid)) { continue; } IvPluginGenerator gen = tttt.Generator; var nsettings = nds.GetSettings(ttt.Guid); if (nsettings == null) { continue; } SettingsTypeBuilder.CreateProperty(tbGen, gen.Name, nsettings.GetType(), gen.NameUi, gen.Description); dic_gs[gen.Name] = nsettings; } SettingsTypeBuilder.CreateToString(tbGen, "Generator"); Type settingsType = tbGen.CreateType(); var objGen = Activator.CreateInstance(settingsType); foreach (var dt in dic_gs) { settingsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objGen, new object[] { dt.Value }); } return(objGen); }