public RequestFileForm(string title = "", string defdir = "") { 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"); void SelectFunc(int b) { Selected?.Invoke(DirBox.Text + "/" + FileBox.Text); } ok.Click = SelectFunc; Add(cancel); Add(ok); if (defdir == "") { defdir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (title == "") { title = "Select file"; } Set(FusionApp.W / 2 - 200, FusionApp.H / 2 - 250, 400, 500, title); Files = new ListForm( ).Set(10, 60, 370, 350, "") as ListForm; Add(Files); Scan(defdir); BackFolder = new ButtonForm( ).Set(0, 25, 64, 32, "").SetImage(new Texture2D("data/UI/backfolder1.png", LoadMethod.Single, true)) 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( ) { But = new Texture2D("data/UI/Skin/but_normal.png", LoadMethod.Single, true); ScrollBut = new ButtonForm( ).Set(0, 0, W, 10) as ButtonForm; 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) { 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; } Cur = (ScrollBut.Y / Max); } ScrollBut.Drag = DragFunc; }
public WindowForm( ) { Shadow = new Texture2D("data/UI/Shadow1.png", LoadMethod.Single, true); TitleImg = new Texture2D("data/UI/Skin/wintitle.png", LoadMethod.Single, true); BodyImg = new Texture2D("data/UI/Skin/windowsbg7.jpg", LoadMethod.Single, true); BodyNorm = new Texture2D("data/UI/normal/winnorm5.jpg", LoadMethod.Single, false); UIForm title = new ButtonForm().Set(0, 0, W, 20, "").SetImage(TitleImg); body = new ImageForm().Set(0, 20, W, H - 22, "").SetImage(BodyImg, BodyNorm).SetPeak(true, false); body.Blur = 0.1f; body.RefractV = 0.72f; body.Click = (b) => { Root.Forms.Remove(this); Root.Forms.Add(this); }; resize = (ButtonForm) new ButtonForm( ).Set(W - 14, H - 14, 14, 14, ""); void ResizeDrag(int x, int y) { 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; } 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), 15, 15, W + 50, H + 50); //DrawForm(TitleImg, 0, 0, W, 20); } Draw = DrawFunc; }