public DropDownListForm() { Draw = () => { DrawFormSolid(new OpenTK.Vector4(1, 1, 1, 1)); DrawText(CurrentItem, 5, -3); }; MouseDown = (b) => { if (Open) { Open = false; Forms.Clear(); } else { int y = 0; Open = true; foreach (var item in Items) { var ib = new ButtonForm().Set(0, H + y, W, 25, item) as ButtonForm; y = y + 25; Add(ib); ib.Click = (bt) => { CurrentItem = item; Open = false; Forms.Clear(); SelectedItem?.Invoke(item); }; } } }; }
public RequestFileForm(string title = "", string defdir = "") { if (FolderPic == null) { FolderPic = new Texture2D("data/UI/folder1.png", LoadMethod.Single, true); FilePic = new Texture2D("data/UI/file1.png", LoadMethod.Single, true); BackPic = new Texture2D("data/ui/backbut1.png", LoadMethod.Single, true); } LockedSize = true; DirBox = new TextBoxForm().Set(55, 35, 300, 20) as TextBoxForm; FileBox = new TextBoxForm().Set(10, 415, 300, 20) as TextBoxForm; Add(DirBox); Add(FileBox); UIForm cancel = new ButtonForm().Set(10, 450, 120, 20, "Cancel"); UIForm ok = new ButtonForm().Set(180, 450, 120, 20, "Select"); cancel.Click = (b) => { if (UI.CurUI.Top == this) { UI.CurUI.Top = null; } }; void SelectFunc(int b) { Selected?.Invoke(DirBox.Text + "/" + FileBox.Text); } ok.Click = SelectFunc; Add(cancel); Add(ok); if (defdir == "") { defdir = DefDir; // System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (title == "") { title = "Select file"; } Set(VividApp.W / 2 - 200, VividApp.H / 2 - 250, 400, 500, title); Files = new ListForm().Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(defdir); BackFolder = new ButtonForm().Set(2, 30, 54, 22, "").SetImage(BackPic) as ButtonForm; void BackFunc(int b) { if (new DirectoryInfo(CurPath).Parent == null) { return; } string curPath = new DirectoryInfo(CurPath).Parent.FullName; Forms.Remove(Files); Files = new ListForm().Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(curPath); } BackFolder.Click = BackFunc; Add(BackFolder); }
public ScrollBarV() { if (ScrollTex == null) { ScrollTex = new Texture2D("data/nxUI/slider/slider1.png", LoadMethod.Single, true); } if (But == null) { But = new Texture2D("data/UI/Skin/but_normal.png", LoadMethod.Single, true); } ScrollBut = new ButtonForm().Set(0, 0, 10, 10, "/\\") as ButtonForm; ScrollBut.CoreTex = ScrollTex; void DrawFunc() { float DY = (GY + Y); float AY = Cur / Max; DrawFormSolid(new Vector4(0.3f, 0.3f, 0.3f, 0.8f)); } void ChangedFunc() { ScrollBut.X = 0; //ScrollBut.Y = 0; ScrollBut.W = W; ScrollBut.H = 20; } Changed = ChangedFunc; Draw = DrawFunc; Add(ScrollBut); void DragFunc(int x, int y) { if (NotUse) { return; } ScrollBut.Y += y; Console.WriteLine("Y:" + y + " SY:" + ScrollBut.Y); if (ScrollBut.Y < 0) { ScrollBut.Y = 0; } if (ScrollBut.Y > (H - ScrollBut.H)) { ScrollBut.Y = (H - ScrollBut.H); } float xs = (float)ScrollBut.Y / ((float)H - (float)ScrollBut.H); Cur = Max * xs; ValueChange?.Invoke(Cur); } ScrollBut.Drag = DragFunc; }
public WindowForm() { if (Shadow == null) { Shadow = new Texture2D("data/UI/Shadow1.png", LoadMethod.Single, true); TitleImg = new Texture2D("data/nxUI/window/title2.png", LoadMethod.Single, true); BodyImg = new Texture2D("data/nxUI/bg/winBody4.png", LoadMethod.Single, true); BodyNorm = new Texture2D("data/UI/normal/winnorm5.jpg", LoadMethod.Single, false); } title = new ButtonForm().Set(0, 0, W, 20, Text).SetImage(TitleImg); body = new ImageForm().Set(0, 20, W - 100, H - 22, "").SetImage(BodyImg, BodyNorm).SetPeak(true, false); body.Peak = false; body.Refract = false; //body.Blur = 0.1f; // body.RefractV = 0.72f; resize = (ButtonForm) new ButtonForm().Set(W - 14, H - 14, 14, 14, ""); AfterSet = () => { title.Text = Text; }; void ResizeDrag(int x, int y) { if (Docked) { return; } if (LockedSize) { return; } Set(X, Y, W + x, H + y, Text); body.Set(0, 22, W, H - 24, ""); resize.X = W - 14; resize.Y = H - 14; } resize.Drag = ResizeDrag; void DragFunc(int x, int y) { if (LockedPos) { return; } if (Docked) { return; } X = X + x; Y = Y + y; } title.Drag = DragFunc; Add(title); Add(body); // Add(resize); void ChangedFunc() { // title.Text = Text; title.W = W; title.H = 20; body.H = H - 26; body.W = W; resize.X = W - 14; resize.Y = H - 20; SubChanged?.Invoke(); } Changed = ChangedFunc; void DrawFunc() { // DrawFormBlur ( Shadow, 0.1f, new Vector4 ( 0.9f, 0.9f, 0.9f, 0.98f ), 5, 5, W + 30, H + 30 ); //DrawForm(TitleImg, 0, 0, W, 20); } Draw = DrawFunc; }