Ejemplo n.º 1
0
        public override void OnEnable(SeanLibManager drawer)
        {
            base.OnEnable(drawer);
            zone_Horizon.Area0Size = 200;
            zone_Horizon.min       = 60;
            zone_Horizon.Max       = 800;
            #region 列表Demo

            // Create some list of data, here simply numbers in interval [1, 1000]
            const int itemCount = 1000;
            var       items     = new List <string>(itemCount);
            for (int i = 1; i <= itemCount; i++)
            {
                items.Add(i.ToString());
            }

            // The "makeItem" function will be called as needed
            // when the ListView needs more items to render
            Func <VisualElement> makeItem = () => new Button();

            // As the user scrolls through the list, the ListView object
            // will recycle elements created by the "makeItem"
            // and invoke the "bindItem" callback to associate
            // the element with the matching data item (specified as an index in the list)
            Action <VisualElement, int> bindItem = (e, i) =>
            {
                var btn = (e as Button);
                btn.text = items[i];
                btn.clickable.clicked += () => Debug.Log(i);
            };
            var listView = window.EditorContent.Q <ListView>();
            listView.makeItem      = makeItem;
            listView.bindItem      = bindItem;
            listView.itemsSource   = items;
            listView.selectionType = SelectionType.Multiple;

            // Callback invoked when the user double clicks an item
            listView.onItemChosen += obj => Debug.Log(obj);

            // Callback invoked when the user changes the selection inside the ListView
            listView.onSelectionChanged += objects => Debug.Log(objects);
            #endregion
            #region button
            // Action to perform when button is pressed.
            // Toggles the text on all buttons in 'container'.
            Action action = () =>
            {
                Debug.Log("Button click");
            };

            // Get a reference to the Button from UXML and assign it its action.
            var uxmlButton = window.EditorContent.Q <Button>("the-uxml-button");
            uxmlButton.clickable.clicked += () => action();
            #endregion
            var DemoIMGUI = window.EditorContent.Q <IMGUIContainer>("IMGUI");
            DemoIMGUI.onGUIHandler = OnGUI;
            gifDrawer.LoadGIF(PathTools.Asset2File(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("gif t:texture")[0])));
            gifDrawer.Play();

            gifDrawer1.LoadGIF(PathTools.Asset2File(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("gif t:texture")[0])));
            gifDrawer1.Play();
        }
Ejemplo n.º 2
0
 public void Load(string RawString, MarkDownDoc doc)
 {
     this.doc = doc;
     if (RawString.IsNullOrEmpty())
     {
         return;
     }
     if (RawString.Replace(Environment.NewLine, "") == "***")
     {
         this.type = KeyType.separator;
     }
     else if (RawString[0] == '*')
     {
         this.type = KeyType.font;
         if (RawString.IndexOf("***") == 0)
         {
             //斜体加粗
             keyValue = "BI";
             Data     = RawString.Substring(3, RawString.Length - 6);
         }
         else if (RawString.IndexOf("**") == 0)
         {
             //加粗
             keyValue = "B";
             Data     = RawString.Substring(2, RawString.Length - 4);
         }
         else if (RawString.IndexOf("*") == 0)
         {
             //斜体
             keyValue = "I";
             Data     = RawString.Substring(1, RawString.Length - 2);
         }
     }
     else if (RawString[0] == '#')
     {
         this.type = KeyType.title;
         if (RawString.IndexOf("###") == 0)
         {
             //1号标题
             keyValue = "1";
             Data     = RawString.Substring(3, RawString.Length - 3);
         }
         else if (RawString.IndexOf("##") == 0)
         {
             //3级标题
             keyValue = "2";
             Data     = RawString.Substring(2, RawString.Length - 2);
         }
         else if (RawString.IndexOf("#") == 0)
         {
             //3级标题
             keyValue = "3";
             Data     = RawString.Substring(1, RawString.Length - 1);
         }
     }
     else if (RawString[0] == '!')
     {
         this.type = KeyType.image;
         int start = RawString.IndexOf("(") + 1;
         int end   = RawString.LastIndexOf(")");
         Data = RawString.Substring(start, RawString.Length - start - (RawString.Length - end));
         var ImgAssetPath = doc.AssetDir + "/" + Data;
         if (Path.GetExtension(ImgAssetPath) == ".gif")
         {
             gifDrawer = new GUIGifDrawer();
             gifDrawer.LoadGIF(PathTools.Asset2File(ImgAssetPath));
             if (EditorUserSettings.GetConfigValue("DocAutoPlayGif") != "true")
             {
                 gifDrawer.Controller = true;
             }
             gifDrawer.Play();
         }
         else
         {
             if (PathTools.IsAssetPath(ImgAssetPath))
             {
                 this.texture = AssetDatabase.LoadAssetAtPath(ImgAssetPath, typeof(Texture2D)) as Texture2D;
             }
             else if (File.Exists(ImgAssetPath))
             {
                 byte[] img = File.ReadAllBytes(ImgAssetPath);
                 this.texture = new Texture2D(1024, 1024);
                 texture.LoadImage(img);
             }
         }
     }
     else if (RawString[0] == '(')
     {
         this.type = KeyType.link;
         int start = RawString.IndexOf("(") + 1;
         int end   = RawString.LastIndexOf(")");
         Data = RawString.Substring(start, RawString.Length - start - (RawString.Length - end));
     }
     else if (RawString.IndexOf(">>") == 0)
     {
         this.type = KeyType.doc;
         Data      = RawString.Remove(0, 2);
     }
     else if (RawString[0] == '>')
     {
         this.type = KeyType.page;
         Data      = RawString.Remove(0, 1);
     }
     else if (RawString[0] == '|')
     {
         this.type = KeyType.table;
         string[] datas = RawString.Split('|');
         for (int i = 1; i < datas.Length; i++)
         {
             if (datas[i] == "--:")
             {
                 this.type = KeyType.separator;
                 break;
             }
             MarkDownData subdata = new MarkDownData();
             subdata.Load(datas[i], this.doc);
             this.subdatas.Add(subdata);
         }
     }
     else if (RawString.IndexOf("```") == 0)
     {
         this.type = KeyType.code;
         keyValue  = RawString.Substring(3, RawString.Length - 3);
     }
     else if (RawString.IndexOf("QA") == 0)
     {
         this.type = KeyType.qa;
         keyValue  = RawString.Substring(2, RawString.Length - 2);
     }
     else if (RawString.IndexOf("/{") == 0)
     {
         this.type = KeyType.foldin;
         keyValue  = RawString.Substring(2, RawString.Length - 2);
     }
     else if (RawString.IndexOf("/}") == 0)
     {
         this.type = KeyType.foldout;
         keyValue  = RawString.Substring(2, RawString.Length - 2);
     }
     else
     {
         Data = RawString;
     }
 }