Ejemplo n.º 1
0
        internal static XamlUI ConvertXamlToUI(byte[] fileBuffer, string suffix)
        {
            MemoryStream     input  = new MemoryStream(fileBuffer);
            ValidationResult result = ValidateXaml(XmlReader.Create(input));
            FrameworkElement ele    = XamlReader.Load(result.OutputXmlReader) as FrameworkElement;

            result.OutputXmlReader.Close();
            string[] id = new string[0];
            if (ele != null)
            {
                id = HandleBindingInformation(ele, result.BindingInfo, suffix);
            }
            if (ele is Window)
            {
                Window window = ele as Window;
                ele           = window.Content as FrameworkElement;
                ele.Resources = window.Resources;
                NameScope.SetNameScope(ele, NameScope.GetNameScope(window));
                window.Close();
            }
            XamlUI lui = new XamlUI(ele, id);

            if (result.BindingInfo != null)
            {
                lui.BindingInfo = result.BindingInfo.ToArray();
            }
            return(lui);
        }
Ejemplo n.º 2
0
        internal static XamlUI ConvertXamlToUI(string uri)
        {
            ValidationResult result = ValidateXaml(XmlReader.Create(uri, XmlReaderSetting));
            FrameworkElement ele    = XamlReader.Load(result.OutputXmlReader) as FrameworkElement;

            result.OutputXmlReader.Close();
            string[] id = new string[0];
            if (ele != null)
            {
                id = HandleBindingInformation(ele, result.BindingInfo);
            }
            if (ele is Window)
            {
                Window window = ele as Window;
                ele           = window.Content as FrameworkElement;
                ele.Resources = window.Resources;
                NameScope.SetNameScope(ele, NameScope.GetNameScope(window));
                window.Close();
            }
            XamlUI lui = new XamlUI(ele, id);

            if (result.BindingInfo != null)
            {
                lui.BindingInfo = result.BindingInfo.ToArray();
            }
            return(lui);
        }
Ejemplo n.º 3
0
        internal static XamlUI ConvertXmlToUI(byte[] fileBuffer, string suffix)
        {
            DisplayFile      file = SerializeHelper.LoadXmlFile(new MemoryStream(fileBuffer));
            FrameworkElement ele  = SerializeHelper.ConvertStringToLayer(file.Content);

            string[] id = HandleBindingInformation(ele, file.BindingInfo, suffix);
            ele.Width  = file.Width;
            ele.Height = file.Height;
            XamlUI lui = new XamlUI(ele, id);

            if (file.BindingInfo != null)
            {
                lui.BindingInfo = file.BindingInfo.ToArray();
            }
            return(lui);
        }
Ejemplo n.º 4
0
        internal static XamlUI ConvertXmlToUI(string xamlURI)
        {
            DisplayFile      file = SerializeHelper.LoadXmlFile(xamlURI);
            FrameworkElement ele  = SerializeHelper.ConvertStringToLayer(file.Content);

            string[] id = HandleBindingInformation(ele, file.BindingInfo);
            ele.Width  = file.Width;
            ele.Height = file.Height;
            XamlUI lui = new XamlUI(ele, id);

            if (file.BindingInfo != null)
            {
                lui.BindingInfo = file.BindingInfo.ToArray();
            }
            return(lui);
        }
Ejemplo n.º 5
0
        internal static XamlUI ConvertDLLToUI(string xamlURI, string suffix)
        {
            FileInfo info  = new FileInfo(xamlURI);
            Match    match = new Regex(@"(?<name>.*)\.[dD][lL][lL]").Match(info.FullName);

            if (match.Success)
            {
                string path = match.Result("${name}") + ".xaml";
                if (System.IO.File.Exists(path))
                {
                    ValidationResult result = ValidateXaml(XmlReader.Create(path, XmlReaderSetting));
                    foreach (Type type in Assembly.LoadFile(info.FullName).GetTypes())
                    {
                        if (type.IsSubclassOf(typeof(Page)) || type.IsSubclassOf(typeof(Control)))
                        {
                            FrameworkElement ele = Activator.CreateInstance(type) as FrameworkElement;
                            string[]         id  = new string[0];
                            if (ele != null)
                            {
                                id = HandleBindingInformation(ele, result.BindingInfo, suffix);
                            }
                            if (ele is Window)
                            {
                                Window window = ele as Window;
                                ele           = window.Content as FrameworkElement;
                                ele.Resources = window.Resources;
                                NameScope.SetNameScope(ele, NameScope.GetNameScope(window));
                                window.Close();
                            }
                            XamlUI lui = new XamlUI(ele, id);
                            if (result.BindingInfo != null)
                            {
                                lui.BindingInfo = result.BindingInfo.ToArray();
                            }
                            return(lui);
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
 public XamlUI Load(string xamlURI, string suffix)
 {
     if (string.IsNullOrEmpty(suffix))
     {
         return(this.Load(xamlURI));
     }
     try
     {
         if (string.IsNullOrEmpty(xamlURI))
         {
             throw new ArgumentNullException("xamlURI");
         }
         string key = xamlURI + string.Format("({0})", suffix);
         if (!this.UIDictionary.ContainsKey(key))
         {
             if (xamlURI.EndsWith(".xaml", true, null))
             {
                 XamlUI lui = XamlHelper.ConvertXamlToUI(xamlURI, suffix);
                 this.UIDictionary.Add(key, lui);
             }
             else if (xamlURI.EndsWith(".dll", true, null))
             {
                 XamlUI lui2 = XamlHelper.ConvertDLLToUI(xamlURI, suffix);
                 this.UIDictionary.Add(key, lui2);
             }
             else
             {
                 XamlUI lui3 = XamlHelper.ConvertXmlToUI(xamlURI, suffix);
                 this.UIDictionary.Add(key, lui3);
             }
         }
         return(this.UIDictionary[key]);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         return(null);
     }
 }
Ejemplo n.º 7
0
 public XamlUI Load(string xamlURI)
 {
     try
     {
         if (this.expired)
         {
             throw new Exception("Invalid License Information!");
         }
         if (string.IsNullOrEmpty(xamlURI))
         {
             throw new ArgumentNullException("xamlURI");
         }
         if (!this.UIDictionary.ContainsKey(xamlURI))
         {
             if (xamlURI.EndsWith(".xaml", true, null))
             {
                 XamlUI lui = XamlHelper.ConvertXamlToUI(xamlURI);
                 this.UIDictionary.Add(xamlURI, lui);
             }
             else if (xamlURI.EndsWith(".dll", true, null))
             {
                 XamlUI lui2 = XamlHelper.ConvertDLLToUI(xamlURI);
                 this.UIDictionary.Add(xamlURI, lui2);
             }
             else
             {
                 XamlUI lui3 = XamlHelper.ConvertXmlToUI(xamlURI);
                 this.UIDictionary.Add(xamlURI, lui3);
             }
         }
         return(this.UIDictionary[xamlURI]);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         return(null);
     }
 }
Ejemplo n.º 8
0
 public XamlUI Load(byte[] fileBuffer, string name, string suffix)
 {
     if (string.IsNullOrEmpty(suffix))
     {
         return(this.Load(fileBuffer, name));
     }
     try
     {
         if (string.IsNullOrEmpty(name))
         {
             throw new ArgumentNullException("name");
         }
         string key = name + string.Format("({0})", suffix);
         if (!this.UIDictionary.ContainsKey(key))
         {
             if (!name.EndsWith(".xaml", true, CultureInfo.CurrentCulture))
             {
                 if (!name.EndsWith(".xml", true, CultureInfo.CurrentCulture))
                 {
                     throw new Exception("不支持的文件类型!");
                 }
                 XamlUI lui2 = XamlHelper.ConvertXmlToUI(fileBuffer, suffix);
                 this.UIDictionary.Add(key, lui2);
             }
             else
             {
                 XamlUI lui = XamlHelper.ConvertXamlToUI(fileBuffer, suffix);
                 this.UIDictionary.Add(key, lui);
             }
         }
         return(this.UIDictionary[key]);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         return(null);
     }
 }
Ejemplo n.º 9
0
 public XamlUI Load(byte[] fileBuffer, string name)
 {
     try
     {
         if (this.expired)
         {
             throw new LicenseException(typeof(UIManager), instance, "Invalid License Information!");
         }
         if (string.IsNullOrEmpty(name))
         {
             throw new ArgumentNullException("name");
         }
         if (!this.UIDictionary.ContainsKey(name))
         {
             if (!name.EndsWith(".xaml", true, CultureInfo.CurrentCulture))
             {
                 if (!name.EndsWith(".xml", true, CultureInfo.CurrentCulture))
                 {
                     throw new Exception("不支持的文件类型!");
                 }
                 XamlUI lui2 = XamlHelper.ConvertXmlToUI(fileBuffer);
                 this.UIDictionary.Add(name, lui2);
             }
             else
             {
                 XamlUI lui = XamlHelper.ConvertXamlToUI(fileBuffer);
                 this.UIDictionary.Add(name, lui);
             }
         }
         return(this.UIDictionary[name]);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         return(null);
     }
 }