Read() 공개 메소드

public Read ( ObjectReader reader, XmlElement elem ) : void
reader ObjectReader
elem System.Xml.XmlElement
리턴 void
예제 #1
0
        void AddActionGroup(XmlElement groupElem)
        {
            ObjectReader reader = new ObjectReader(this, FileFormat.Native);

            Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup();
            actionGroup.Read(reader, groupElem);
            actionGroups.Add(actionGroup);
        }
예제 #2
0
 protected void ReadActionGroups(ObjectReader reader, XmlElement elem)
 {
     if (reader.Format == FileFormat.Native)
     {
         if (actionGroups == null)
         {
             actionGroups = new ActionGroupCollection();
             actionGroups.SetOwner(this);
             actionGroups.ActionGroupAdded   += OnGroupAdded;
             actionGroups.ActionGroupRemoved += OnGroupRemoved;
             actionGroups.ActionGroupChanged += OnGroupChanged;
         }
         else
         {
             actionGroups.Clear();
         }
         foreach (XmlElement groupElem in elem.SelectNodes("action-group"))
         {
             ActionGroup actionGroup = new ActionGroup();
             actionGroup.Read(reader, groupElem);
             actionGroups.Add(actionGroup);
         }
     }
 }
예제 #3
0
        void Read(XmlDocument doc)
        {
            loading = true;
            string basePath = fileName != null?Path.GetDirectoryName(fileName) : null;

            try {
                string fn = fileName;
                Close();
                fileName = fn;

                XmlNode node = doc.SelectSingleNode("/stetic-interface");
                if (node == null)
                {
                    throw new ApplicationException(Catalog.GetString("Not a Stetic file according to node name."));
                }

                // Load configuration options
                foreach (XmlNode configNode in node.SelectNodes("configuration/*"))
                {
                    XmlElement config = configNode as XmlElement;
                    if (config == null)
                    {
                        continue;
                    }

                    if (config.LocalName == "images-root-path")
                    {
                        imagesRootPath = config.InnerText;
                    }
                    else if (config.LocalName == "target-gtk-version")
                    {
                        targetGtkVersion = config.InnerText;
                    }
                }

                // Load the assembly directories
                resolver = new AssemblyResolver(app);
                foreach (XmlElement libElem in node.SelectNodes("import/assembly-directory"))
                {
                    string dir = libElem.GetAttribute("path");
                    if (dir.Length > 0)
                    {
                        if (basePath != null && !Path.IsPathRooted(dir))
                        {
                            dir = Path.Combine(basePath, dir);
                            if (Directory.Exists(dir))
                            {
                                dir = Path.GetFullPath(dir);
                            }
                        }
                        resolver.Directories.Add(dir);
                    }
                }

                // Import the referenced libraries
                foreach (XmlElement libElem in node.SelectNodes("import/widget-library"))
                {
                    string libname = libElem.GetAttribute("name");
                    if (libname.EndsWith(".dll") || libname.EndsWith(".exe"))
                    {
                        if (basePath != null && !Path.IsPathRooted(libname))
                        {
                            libname = Path.Combine(basePath, libname);
                            if (File.Exists(libname))
                            {
                                libname = Path.GetFullPath(libname);
                            }
                        }
                    }
                    widgetLibraries.Add(libname);
                    if (libElem.GetAttribute("internal") == "true")
                    {
                        internalLibs.Add(libname);
                    }
                }

                app.LoadLibraries(resolver, widgetLibraries);

                ObjectReader reader = new ObjectReader(this, FileFormat.Native);

                if (ownedGlobalActionGroups)
                {
                    foreach (XmlElement groupElem in node.SelectNodes("action-group"))
                    {
                        Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup();
                        actionGroup.Read(reader, groupElem);
                        actionGroups.Add(actionGroup);
                    }
                }

                XmlElement iconsElem = node.SelectSingleNode("icon-factory") as XmlElement;
                if (iconsElem != null)
                {
                    iconFactory.Read(this, iconsElem);
                }

                foreach (XmlElement toplevel in node.SelectNodes("widget"))
                {
                    topLevels.Add(new WidgetData(toplevel.GetAttribute("id"), toplevel, null));
                }
            } finally {
                loading = false;
            }
        }
예제 #4
0
		void Read (XmlDocument doc)
		{
			loading = true;
			string basePath = fileName != null ? Path.GetDirectoryName (fileName) : null;
			
			try {
				string fn = fileName;
				Close ();
				fileName = fn;
				
				XmlNode node = doc.SelectSingleNode ("/stetic-interface");
				if (node == null)
					throw new ApplicationException (Catalog.GetString ("Not a Stetic file according to node name."));
				
				// Load configuration options
				foreach (XmlNode configNode in node.SelectNodes ("configuration/*")) {
					XmlElement config = configNode as XmlElement;
					if (config == null) continue;
					
					if (config.LocalName == "images-root-path")
						imagesRootPath = config.InnerText;
					else if (config.LocalName == "target-gtk-version")
						targetGtkVersion = config.InnerText;
				}
				
				// Load the assembly directories
				resolver = new AssemblyResolver (app);
				foreach (XmlElement libElem in node.SelectNodes ("import/assembly-directory")) {
					string dir = libElem.GetAttribute ("path");
					if (dir.Length > 0) {
						if (basePath != null && !Path.IsPathRooted (dir)) {
							dir = FromOSAgnosticRelPath (Path.Combine (basePath, dir));
							if (Directory.Exists (dir))
								dir = Path.GetFullPath (dir);
						}
						resolver.Directories.Add (dir);
					}
				}
				
				// Import the referenced libraries
				foreach (XmlElement libElem in node.SelectNodes ("import/widget-library")) {
					string libname = libElem.GetAttribute ("name");
					if (libname.EndsWith (".dll") || libname.EndsWith (".exe")) {
						if (basePath != null && !Path.IsPathRooted (libname)) {
							libname = FromOSAgnosticRelPath (Path.Combine (basePath, libname));
							if (File.Exists (libname))
								libname = Path.GetFullPath (libname);
						}
					}
					widgetLibraries.Add (libname);
					if (libElem.GetAttribute ("internal") == "true")
						internalLibs.Add (libname);
				}
				
				app.LoadLibraries (resolver, widgetLibraries);
				
				ObjectReader reader = new ObjectReader (this, FileFormat.Native);
				
				if (ownedGlobalActionGroups) {
					foreach (XmlElement groupElem in node.SelectNodes ("action-group")) {
						Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup ();
						actionGroup.Read (reader, groupElem);
						actionGroups.Add (actionGroup);
					}
				}
				
				XmlElement iconsElem = node.SelectSingleNode ("icon-factory") as XmlElement;
				if (iconsElem != null)
					iconFactory.Read (this, iconsElem);
				
				foreach (XmlElement toplevel in node.SelectNodes ("widget")) {
					topLevels.Add (new WidgetData (toplevel.GetAttribute ("id"), toplevel, null));
				}
			} finally {
				loading = false;
			}
		}
		protected void ReadActionGroups (ObjectReader reader, XmlElement elem)
		{
			if (reader.Format == FileFormat.Native) {
				if (actionGroups == null) {
					actionGroups = new ActionGroupCollection ();
					actionGroups.SetOwner (this);
					actionGroups.ActionGroupAdded += OnGroupAdded;
					actionGroups.ActionGroupRemoved += OnGroupRemoved;
					actionGroups.ActionGroupChanged += OnGroupChanged;
				} else
					actionGroups.Clear ();
				foreach (XmlElement groupElem in elem.SelectNodes ("action-group")) {
					ActionGroup actionGroup = new ActionGroup ();
					actionGroup.Read (reader, groupElem);
					actionGroups.Add (actionGroup); 
				}
			}
		}
예제 #6
0
		public object DeserializeChild (XmlElement data)
		{
			ObjectReader or = new ObjectReader (project, FileFormat.Native);
			if (data.LocalName == "action") {
				Wrapper.Action ac = new Wrapper.Action ();
				ac.Read (or, data);
				return ac;
			} else if (data.LocalName == "action-group") {
				ActionGroup ac = new ActionGroup ();
				ac.Read (or, data);
				return ac;
			}
			throw new NotImplementedException ();
		}
예제 #7
0
		void AddActionGroup (XmlElement groupElem)
		{
			ObjectReader reader = new ObjectReader (this, FileFormat.Native);
			
			Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup ();
			actionGroup.Read (reader, groupElem);
			actionGroups.Add (actionGroup);
		}