public void TestSerializeSchemaPropertyValueCollection() { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream ms = new System.IO.MemoryStream(); SchemaPropertyValueCollection obj1 = new SchemaPropertyValueCollection(); SCGroup group = SCObjectGenerator.PrepareGroupObject(); foreach (string key in group.Properties.GetAllKeys()) { obj1.Add(group.Properties[key]); } bf.Serialize(ms, obj1); ms.Seek(0, System.IO.SeekOrigin.Begin); var obj2 = (SchemaPropertyValueCollection)bf.Deserialize(ms); Assert.AreEqual(obj1.Count, obj2.Count); var keys1 = obj1.GetAllKeys(); foreach (var key in keys1) { Assert.IsTrue(obj2.ContainsKey(key)); Assert.AreEqual(obj1[key].StringValue, obj2[key].StringValue); } }
private void RenderAllTabs(SchemaObjectBase data, Scene currentScene) { string defaultKey = string.Empty; // this.tabStrip.SelectedKey; Dictionary <string, SchemaPropertyValueCollection> tabGroup = data.Properties.GroupByTab(); this.tabStrip.TabPages.Clear(); foreach (SchemaTabDefine tab in data.Schema.Tabs) { SchemaPropertyValueCollection properties = null; if (tabGroup.TryGetValue(tab.Name, out properties) == false) { properties = new SchemaPropertyValueCollection(); } Control panel = this.RenderOnePanel(tab, properties, currentScene); RelaxedTabPage item = new RelaxedTabPage() { Title = tab.Description, }; item.Controls.Add(panel); this.tabStrip.TabPages.Add(item); } if (this.tabStrip.TabPages.Count > 0) { this.tabStrip.ActiveTabPageIndex = 0; } }
private Control RenderOnePanel(SchemaTabDefine tab, SchemaPropertyValueCollection properties, Scene currentScene) { HtmlGenericControl panel = new HtmlGenericControl("div"); panel.ID = tab.Name; panel.Style["width"] = "100%"; panel.Style["height"] = "100%"; PropertyForm pForm = new PropertyForm() { AutoSaveClientState = false }; pForm.ID = tab.Name + "_Form"; if (currentScene.Items[this.tabStrip.ID].Recursive == true) { pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly; } pForm.Properties.CopyFrom(properties.ToPropertyValues()); PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection(); layouts.LoadLayoutSectionFromConfiguration("DefalutLayout"); pForm.Layouts.InitFromLayoutSectionCollection(layouts); pForm.Style["width"] = "100%"; pForm.Style["height"] = "400"; panel.Controls.Add(pForm); return(panel); }
/// <summary> /// 使用指定的<see cref="DESchemaDefine"/>初始化<see cref="SchemaPropertyValueCollection"/>的新实例 /// </summary> /// <returns></returns> public SchemaPropertyValueCollection ToProperties() { SchemaPropertyValueCollection properties = new SchemaPropertyValueCollection(); this.Properties.ForEach(pd => properties.Add(new SchemaPropertyValue(pd))); return(properties); }
/// <summary> /// 使用指定的<see cref="SchemaDefine"/>初始化<see cref="SchemaPropertyValueCollection"/>的新实例 /// </summary> /// <returns></returns> public SchemaPropertyValueCollection ToProperties() { SchemaPropertyValueCollection properties = new SchemaPropertyValueCollection(); this.Properties.ForEach(pd => properties.Add(new SchemaPropertyValue(pd))); return properties; }
public static void CopyFrom(this SchemaPropertyValueCollection pcProperties, ClientPropertyValueCollection clientProperties) { pcProperties.NullCheck("pcProperties"); foreach (var ppt in clientProperties) { pcProperties[ppt.Key].StringValue = ppt.StringValue; } }
///// <summary> ///// 处理ID的变更 ///// </summary> //protected override void OnIDChanged() //{ // this._AllParentRelations = null; // this._AllParents = null; // this._CurrentlParents = null; //} protected override SchemaPropertyValueCollection GetProperties() { if (this._Properties == null) { this._Properties = ((DESchemaDefine)this.Schema).ToProperties(); } return(this._Properties); }
private SchemaPropertyValueCollection TabGroup(SchemaPropertyValueCollection propertyValues, string groupName) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); foreach (var property in propertyValues) { if (property.Definition.Tab == groupName) { result.Add(property); } } return(result); }
public SchemaPropertyValueCollection ToProperties() { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); this.ForEach(p => { SchemaPropertyDefine pd = new SchemaPropertyDefine { Name = p.Name, Description = p.Description, DefaultValue = p.DefaultValue }; result.Add(new SchemaPropertyValue(pd)); }); return(result); }
private void RenderTabs(HashSet <string> schemaTypes, SchemaPropertyValueCollection propertyValues, HashSet <string> tabNames) { if (tabNames.Count > 0) { var tabs = ObjectSchemaSettings.GetConfig().Schemas[schemaTypes.First()].Tabs; foreach (string item in tabNames) { RelaxedTabPage tabPage = new RelaxedTabPage() { Title = tabs[item].Description, TagKey = item }; this.tabs.TabPages.Add(tabPage); PropertyForm pForm = new PropertyForm() { AutoSaveClientState = false }; pForm.ID = tabPage.TagKey + "_Form"; pForm.ReadOnly = this.EditEnabled == false; //// if (currentScene.Items[this.tabStrip.ID].Recursive == true) //// pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly; var pageValues = TabGroup(propertyValues, item).ToPropertyValues(); pForm.Properties.CopyFrom(pageValues); pForm.ShowCheckBoxes = true; PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection(); layouts.LoadLayoutSectionFromConfiguration("DefalutLayout"); pForm.Layouts.InitFromLayoutSectionCollection(layouts); pForm.Style["width"] = "100%"; pForm.Style["height"] = "400"; tabPage.Controls.Add(pForm); } this.tabs.ActiveTabPageIndex = 0; } }
private void RenderAllTabs(SchemaObjectBase data, bool readOnly) { Dictionary <string, SchemaPropertyValueCollection> tabGroup = data.Properties.GroupByTab(); this.tabs.TabPages.Clear(); foreach (SchemaTabDefine tab in data.Schema.Tabs) { SchemaPropertyValueCollection properties = null; if (tabGroup.TryGetValue(tab.Name, out properties) == false) { properties = new SchemaPropertyValueCollection(); } this.RenderOnePanel(tab, properties, readOnly); } if (tabs.TabPages.Count > 0) { tabs.ActiveTabPageIndex = 0; } }
private SchemaPropertyValueCollection GetCommonValues(SchemaObjectCollection objects, List <SchemaPropertyDefineConfigurationElement> propertyDefines) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); HashSet <string> pool = new HashSet <string>(); foreach (var item in propertyDefines) { pool.Clear(); SchemaPropertyValue val = null; foreach (var obj in objects) { val = obj.Properties[item.Name]; pool.Add(val.StringValue); } result.Add(pool.Count == 1 ? val : new SchemaPropertyValue(val.Definition)); } return(result); }
private void RenderAllTabs(DESchemaObjectBase data, bool readOnly) { string defaultKey = this.tabStrip.SelectedKey; Dictionary <string, SchemaPropertyValueCollection> tabGroup = data.Properties.GroupByTab(); this.tabStrip.TabStrips.Clear(); foreach (SchemaTabDefine tab in data.Schema.Tabs) { SchemaPropertyValueCollection properties = null; if (tabGroup.TryGetValue(tab.Name, out properties) == false) { properties = new SchemaPropertyValueCollection(); } Control panel = this.RenderOnePanel(tab, this.panelContainer, properties, readOnly); var item = new TabStripItem() { Key = tab.Name, Text = tab.Description, ControlID = panel.ClientID, Tag = panel.Controls[0].ClientID }; this.tabStrip.TabStrips.Add(item); if (defaultKey.IsNullOrEmpty()) { defaultKey = item.Key; } } if (defaultKey.IsNotEmpty()) { this.tabStrip.SelectedKey = defaultKey; } }
private Control RenderOnePanel(SchemaTabDefine tab, SchemaPropertyValueCollection properties, bool readOnly) { RelaxedTabPage tabPage = new RelaxedTabPage() { Title = tab.Description, TagKey = tab.Name }; this.tabs.TabPages.Add(tabPage); PropertyForm pForm = new PropertyForm() { AutoSaveClientState = false }; pForm.ID = tab.Name + "_Form"; //// if (currentScene.Items[this.tabStrip.ID].Recursive == true) //// pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly; pForm.Properties.CopyFrom(properties.ToPropertyValues()); PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection(); layouts.LoadLayoutSectionFromConfiguration("DefalutLayout"); pForm.Layouts.InitFromLayoutSectionCollection(layouts); pForm.Style["width"] = "100%"; pForm.Style["height"] = "400"; tabPage.Controls.Add(pForm); pForm.ReadOnly = readOnly; return(tabPage); }
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); this.Response.Cache.SetCacheability(HttpCacheability.NoCache); PropertyEditorHelper.AttachToPage(this); if (this.IsPostBack == false && this.IsCallback == false) { string[] ids = Request.Params.GetValues("ids"); if (ids != null) { this.objNum.InnerText = ids.Length.ToString(); var objects = DbUtil.LoadObjects(ids); HashSet <string> schemaTypes = GetSchemaTypes(objects); HashSet <string> groupNames = GetCommonGroups(schemaTypes); List <SchemaPropertyDefineConfigurationElement> propertyDefines = GetPropertyDefines(groupNames); SchemaPropertyValueCollection propertyValues = GetCommonValues(objects, propertyDefines); HashSet <string> tabNames = GetTabNames(propertyDefines); RenderTabs(schemaTypes, propertyValues, tabNames); this.ViewState["ids"] = ids; this.ViewState["schemaTypes"] = schemaTypes; this.objectDetails.Value = JSONSerializerExecute.Serialize(objects); } } else { HashSet <string> schemaTypes = this.ViewState["schemaTypes"] as HashSet <string>; if (schemaTypes != null) { HashSet <string> groupNames = GetCommonGroups(schemaTypes); List <SchemaPropertyDefineConfigurationElement> propertyDefines = GetPropertyDefines(groupNames); } } }
private void RenderAllTabs(SchemaObjectBase data, Scene currentScene) { string defaultKey = string.Empty; // this.tabStrip.SelectedKey; Dictionary<string, SchemaPropertyValueCollection> tabGroup = data.Properties.GroupByTab(); this.tabStrip.TabPages.Clear(); foreach (SchemaTabDefine tab in data.Schema.Tabs) { SchemaPropertyValueCollection properties = null; if (tabGroup.TryGetValue(tab.Name, out properties) == false) properties = new SchemaPropertyValueCollection(); Control panel = this.RenderOnePanel(tab, properties, currentScene); RelaxedTabPage item = new RelaxedTabPage() { Title = tab.Description, }; item.Controls.Add(panel); this.tabStrip.TabPages.Add(item); } if (this.tabStrip.TabPages.Count > 0) { this.tabStrip.ActiveTabPageIndex = 0; } }
private Control RenderOnePanel(SchemaTabDefine tab, Control container, SchemaPropertyValueCollection properties, bool readOnly) { HtmlGenericControl panel = new HtmlGenericControl("div"); panel.ID = tab.Name; panel.Style["width"] = "100%"; panel.Style["height"] = "100%"; this.panelContainer.Controls.Add(panel); PropertyForm pForm = new PropertyForm() { AutoSaveClientState = false }; pForm.ID = tab.Name + "_Form"; pForm.ReadOnly = readOnly; //// if (currentScene.Items[this.tabStrip.ID].Recursive == true) //// pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly; pForm.Properties.CopyFrom(properties.ToPropertyValues()); PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection(); layouts.LoadLayoutSectionFromConfiguration("DefalutLayout"); pForm.Layouts.InitFromLayoutSectionCollection(layouts); pForm.Style["width"] = "100%"; pForm.Style["height"] = "400"; panel.Controls.Add(pForm); return panel; }
private void RenderTabs(HashSet<string> schemaTypes, SchemaPropertyValueCollection propertyValues, HashSet<string> tabNames) { if (tabNames.Count > 0) { var tabs = ObjectSchemaSettings.GetConfig().Schemas[schemaTypes.First()].Tabs; foreach (string item in tabNames) { RelaxedTabPage tabPage = new RelaxedTabPage() { Title = tabs[item].Description, TagKey = item }; this.tabs.TabPages.Add(tabPage); PropertyForm pForm = new PropertyForm() { AutoSaveClientState = false }; pForm.ID = tabPage.TagKey + "_Form"; pForm.ReadOnly = this.EditEnabled == false; //// if (currentScene.Items[this.tabStrip.ID].Recursive == true) //// pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly; var pageValues = TabGroup(propertyValues, item).ToPropertyValues(); pForm.Properties.CopyFrom(pageValues); pForm.ShowCheckBoxes = true; PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection(); layouts.LoadLayoutSectionFromConfiguration("DefalutLayout"); pForm.Layouts.InitFromLayoutSectionCollection(layouts); pForm.Style["width"] = "100%"; pForm.Style["height"] = "400"; tabPage.Controls.Add(pForm); } this.tabs.ActiveTabPageIndex = 0; } }
private Control RenderOnePanel(SchemaTabDefine tab, SchemaPropertyValueCollection properties, bool readOnly) { RelaxedTabPage tabPage = new RelaxedTabPage() { Title = tab.Description, TagKey = tab.Name }; this.tabs.TabPages.Add(tabPage); PropertyForm pForm = new PropertyForm() { AutoSaveClientState = false }; pForm.ID = tab.Name + "_Form"; //// if (currentScene.Items[this.tabStrip.ID].Recursive == true) //// pForm.ReadOnly = currentScene.Items[this.tabStrip.ID].ReadOnly; pForm.Properties.CopyFrom(properties.ToPropertyValues()); PropertyLayoutSectionCollection layouts = new PropertyLayoutSectionCollection(); layouts.LoadLayoutSectionFromConfiguration("DefalutLayout"); pForm.Layouts.InitFromLayoutSectionCollection(layouts); pForm.Style["width"] = "100%"; pForm.Style["height"] = "400"; tabPage.Controls.Add(pForm); pForm.ReadOnly = readOnly; return tabPage; }
public static void CopyTo(this SchemaPropertyValueCollection pcProperties, ClientPropertyValueCollection clientProperties) { pcProperties.NullCheck("pcProperties"); pcProperties.ForEach(pcpv => clientProperties.Add(pcpv.ToClientPropertyValue())); }
private void RenderAllTabs(SchemaObjectBase data, bool readOnly) { string defaultKey = this.tabStrip.SelectedKey; Dictionary<string, SchemaPropertyValueCollection> tabGroup = data.Properties.GroupByTab(); this.tabStrip.TabStrips.Clear(); foreach (SchemaTabDefine tab in data.Schema.Tabs) { SchemaPropertyValueCollection properties = null; if (tabGroup.TryGetValue(tab.Name, out properties) == false) properties = new SchemaPropertyValueCollection(); Control panel = this.RenderOnePanel(tab, this.panelContainer, properties, readOnly); TabStripItem item = new TabStripItem() { Key = tab.Name, Text = tab.Description, ControlID = panel.ClientID, Tag = panel.Controls[0].ClientID }; this.tabStrip.TabStrips.Add(item); if (defaultKey.IsNullOrEmpty()) defaultKey = item.Key; } if (defaultKey.IsNotEmpty()) this.tabStrip.SelectedKey = defaultKey; }
private SchemaPropertyValueCollection TabGroup(SchemaPropertyValueCollection propertyValues, string groupName) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); foreach (var property in propertyValues) { if (property.Definition.Tab == groupName) { result.Add(property); } } return result; }
private void RenderAllTabs(SchemaObjectBase data, bool readOnly) { Dictionary<string, SchemaPropertyValueCollection> tabGroup = data.Properties.GroupByTab(); this.tabs.TabPages.Clear(); foreach (SchemaTabDefine tab in data.Schema.Tabs) { SchemaPropertyValueCollection properties = null; if (tabGroup.TryGetValue(tab.Name, out properties) == false) properties = new SchemaPropertyValueCollection(); this.RenderOnePanel(tab, properties, readOnly); } if (tabs.TabPages.Count > 0) tabs.ActiveTabPageIndex = 0; }
private SchemaPropertyValueCollection GetCommonValues(SchemaObjectCollection objects, List<SchemaPropertyDefineConfigurationElement> propertyDefines) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); HashSet<string> pool = new HashSet<string>(); foreach (var item in propertyDefines) { pool.Clear(); SchemaPropertyValue val = null; foreach (var obj in objects) { val = obj.Properties[item.Name]; pool.Add(val.StringValue); } result.Add(pool.Count == 1 ? val : new SchemaPropertyValue(val.Definition)); } return result; }