当前位置: 首页>>代码示例>>C#>>正文


C# Editor.Layout方法代码示例

本文整理汇总了C#中Editor.Layout方法的典型用法代码示例。如果您正苦于以下问题:C# Editor.Layout方法的具体用法?C# Editor.Layout怎么用?C# Editor.Layout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Editor的用法示例。


在下文中一共展示了Editor.Layout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FetchForm

        public static void FetchForm(AbsoluteLayout Parent, System.Xml.Linq.XNode Nodes)
        {
            int cIndex = 0;
            int TabIndexes = ((System.Xml.Linq.XElement) Nodes).Elements().Count();
            foreach(XElement C in ((System.Xml.Linq.XElement) Nodes).Elements()) {
                if (C.Name == "Object") {
                    cIndex++;
                    if (true) {
                        if (C.Attribute("type").Value.StartsWith("System.Windows.Forms.PictureBox")) {
                            var CP = new Image();
                            foreach (XElement V in C.Elements()) {
                                if (V.Name == "Property") {
                                    switch (V.Attribute("name").Value) {
                                        case "Location":
                                            CP.ORect = new Rectangle(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)), CP.ORect.Width, CP.ORect.Height);
                                            CP.Layout(new Rectangle(
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY,
                                                CP.Width,
                                                CP.Height));
                                            Point pt = new Point(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY);
                                            break;
                                        case "Size":
                                            CP.ORect = new Rectangle(CP.ORect.Left, CP.ORect.Top, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)));
                                            CP.Layout(new Rectangle(CP.X, CP.Y, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX, Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY));
                                            break;
                                        case "SizeMode":
                                            if (V.Value == "StretchImage") {
                                                CP.Aspect = Aspect.Fill ;
                                            } else if (V.Value == "Zoom") {
                                                CP.Aspect = Aspect.AspectFill;
                                            } else if (V.Value == "Normal") {
                                                CP.Aspect = Aspect.AspectFit;
                                            }
                                            break;
                                        case "Image":
                                            string IMGData = String.Concat(V.Value);
                                            byte[] B = System.Convert.FromBase64String(IMGData);
                                            CP.Source = ImageSource.FromStream(() => new System.IO.MemoryStream(B));
                                            break;
                                        case "BackColor":
                                            CP.BackgroundColor = ColorExtensions.GetXColor(String.Concat(V.Nodes()));
                                            break;
                                        case "Tag":
                                            CP.ClassId = String.Concat(V.Nodes());
                                            break;
                                    }
                                }
                            }
                            CP.Aspect = Aspect.AspectFill;
                            Parent.Children.Add(CP, new Rectangle(CP.X, CP.Y, CP.Width, CP.Height), AbsoluteLayoutFlags.None);
                            Parent.LowerChild(CP);
                        } else if (C.Attribute("type").Value.StartsWith("System.Windows.Forms.Button")) {
                            var CP = new Button ();
                            foreach(XElement V in C.Elements()) {
                                if (V.Name == "Property") {
                                    switch (V.Attribute("name").Value) {
                                        case "Location":
                                            CP.ORect = new Rectangle(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)), CP.ORect.Width, CP.ORect.Height);
                                            CP.Layout(new Rectangle(
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY,
                                                CP.Width,
                                                CP.Height));
                                            Point pt = new Point(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY);
                                            break;
                                        case "Size":
                                            CP.ORect = new Rectangle(CP.ORect.Left, CP.ORect.Top, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)));
                                            CP.Layout(new Rectangle(CP.X, CP.Y, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX, Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY));
                                            break;
                                        case "Image":
                                            string IMGData = String.Concat(V.Value);
                                            byte[] B = System.Convert.FromBase64String(IMGData);
                                            var TempFile = System.IO.Path.GetTempFileName();
                                            System.IO.File.WriteAllBytes(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + System.IO.Path.GetFileName(TempFile), B);
                                            CP.Image = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + System.IO.Path.GetFileName(TempFile);
                                            break;
                                        case "ForeColor":
                                            CP.TextColor = ColorExtensions.GetXColor(String.Concat(V.Nodes()));
                                            break;
                                        case "BackColor":
                                            CP.BackgroundColor = ColorExtensions.GetXColor(String.Concat(V.Nodes()));
                                            break;
                                        case "Caption":
                                        case "Text":
                                            CP.Text = String.Concat(V.Nodes()).Replace("##", "\r\n");
                                            break;
                                        case "Tag":
                                            CP.ClassId = String.Concat(V.Nodes());
                                            break;
                                        case "Font":
                                            string[] UFont = String.Concat(V.Nodes()).Replace("style=", "").Replace("Microsoft Sans Serif", "Helvetica").Split(new[] {
                                                ","
                                            }, StringSplitOptions.RemoveEmptyEntries);
                                            CP.FontFamily = UFont[0];
                                            CP.FontSize = float.Parse(UFont[1].Replace("pt", ""));
                                            if (Array.IndexOf(UFont, " Bold") > -1) {
                                                CP.FontAttributes = CP.FontAttributes | FontAttributes.Bold;
//.........这里部分代码省略.........
开发者ID:MuffPotter,项目名称:XamarinDesigner,代码行数:101,代码来源:Parser.cs


注:本文中的Editor.Layout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。