Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
		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);
			}
		}
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
		/// <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;
		}
Ejemplo n.º 7
0
        public static void CopyFrom(this SchemaPropertyValueCollection pcProperties, ClientPropertyValueCollection clientProperties)
        {
            pcProperties.NullCheck("pcProperties");

            foreach (var ppt in clientProperties)
            {
                pcProperties[ppt.Key].StringValue = ppt.StringValue;
            }
        }
Ejemplo n.º 8
0
        ///// <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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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;
            }
        }
Ejemplo n.º 12
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;
            }
        }
Ejemplo n.º 13
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;
            }
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        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);
                }
            }
        }
Ejemplo n.º 17
0
		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;
			}
		}
Ejemplo n.º 18
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;
        }
Ejemplo n.º 19
0
		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;
			}
		}
Ejemplo n.º 20
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;
		}
Ejemplo n.º 21
0
        public static void CopyTo(this SchemaPropertyValueCollection pcProperties, ClientPropertyValueCollection clientProperties)
        {
            pcProperties.NullCheck("pcProperties");

            pcProperties.ForEach(pcpv => clientProperties.Add(pcpv.ToClientPropertyValue()));
        }
Ejemplo n.º 22
0
        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;
        }
Ejemplo n.º 23
0
		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;
		}
Ejemplo n.º 24
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;
		}
Ejemplo n.º 25
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;
		}