Beispiel #1
0
        public void Scan(string folder)
        {
            if (new DirectoryInfo(folder).Exists == false)
            {
                return;
            }

            DirBox.Text = new DirectoryInfo(folder).FullName;
            // LastPath.Add(folder);
            CurPath = folder;
            DirectoryInfo di = new DirectoryInfo(folder);

            foreach (DirectoryInfo fold in di.GetDirectories())
            {
                ItemForm ni = Files.AddItem(fold.Name, FolderPic);
                void DoubleClickFunc(int b)
                {
                    Console.WriteLine("Scanning:" + fold.FullName);
                    Forms.Remove(Files);
                    Files = new ListForm().Set(10, 60, 370, 350, "") as ListForm;
                    Add(Files);
                    Scan(fold.FullName);
                    // Files.Changed?.Invoke();
                }

                ni.DoubleClick = DoubleClickFunc;
            }
            if (!Folder)
            {
                foreach (FileInfo file in di.GetFiles())
                {
                    ItemForm newi = Files.AddItem(file.Name, FilePic);
                    void ClickFunc(int b)
                    {
                        FileBox.Text = file.Name;
                    }

                    void DoubleClickFunc(int b)
                    {
                        Selected?.Invoke(DirBox.Text + "/" + newi.Text);
                    }

                    newi.DoubleClick = DoubleClickFunc;
                    newi.Click       = ClickFunc;
                }
                Files.Changed?.Invoke();
            }
            else
            {
                Files.Changed?.Invoke();
            }
        }
Beispiel #2
0
        public ItemForm AddItem(string text, Texture2D pic)
        {
            ItemForm nitem = new ItemForm
            {
                Text = text,
                Pic  = pic,
                W    = W - 20,
                H    = 20
            };

            Items.Add(nitem);
            return(nitem);
            //Changed?.Invoke();
        }
Beispiel #3
0
 public ItemForm AddItem(ItemForm item)
 {
     Items.Add(item);
     return(item);
     //Changed?.Invoke();
 }
Beispiel #4
0
        public ListForm()
        {
            PushArea = true;
            Col      = new Vector4(0.8f, 0.8f, 0.8f, 0.5f);

            void DrawFunc()
            {
                DrawFormSolid(Col);
            }

            void ChangedFunc()
            {
                Scroller.X = W - 10;
                Scroller.Y = 2;
                Scroller.W = 10;
                Scroller.H = H;

                Scroller.Changed?.Invoke();
                foreach (ItemForm item in Items)
                {
                    Forms.Remove(item);
                }

                float sh = (Scroller.H - Scroller.ScrollBut.H);
                float mh = Items.Count * 20;

                float dh = sh / mh;

                if (dh < 0.03f)
                {
                    //Scroller.Max = Scr
                    //    sm1 = (float)Scroller.H * 0.03f;
                }

                Scroller.ScrollBut.H = (int)(dh * Scroller.H);
                if (dh < 0.1f)
                {
                    //Scroller.ScrollBut.H = 6;
                    //Scroller.Max
                    //Scroller.Max = Scroller.Max - 10;
                }

                Scroller.Max = Scroller.H;
                float ly  = Scroller.Cur / Scroller.Max;
                float mh2 = ly * ((Items.Count + 1) * 22);

                if (Scroller.ScrollBut.H > H)
                {
                    Scroller.ScrollBut.H = H;
                }
                //ly = -(ly * H);
                ly = -(mh2);
                //ly = ly - 20;

                foreach (ItemForm item in Items)
                {
                    //var newi = new ItemForm().Set(5, (int)ly, W - 15, 20, item.Text) as ItemForm;
                    ItemForm newi = item;
                    //newi.Pic = item.Pic;
                    if (ly > H - 22 || ly < 0)
                    {
                        newi.Render      = false;
                        newi.CheckBounds = false;
                    }
                    else
                    {
                        newi.CheckBounds = true;
                        newi.Render      = true;
                    }
                    newi.Y = (int)ly;
                    ly     = ly + 22;
                    //  newi.ViewX = 0;
                    //  newi.ViewY = 0;
                    // newi.ViewW = W;
                    // newi.ViewH = H;
                    Add(newi);
                }

                if (Scroller.ScrollBut.H < 5)
                {
                    Scroller.ScrollBut.H = 5;
                }

                //Scroller.ScrollBut.Drag(0, 15);
            }

            Changed = ChangedFunc;

            Draw = DrawFunc;

            Scroller = new ScrollBarV();

            void PostDragFunc(int x, int y)
            {
                //Scroller.Cur = Scroller.ScrollBut.Y / Scroller.H;
                //float my = Scroller.Max / Scroller.H;
                //Scroller.Cur = Scroller.Cur * my;

                Scroller.Cur = Scroller.ScrollBut.Y;
                Changed?.Invoke();
            }

            Scroller.ScrollBut.PostDrag = PostDragFunc;

            Add(Scroller);

            //PostDragFunc(0, 5);
            //Scroller.ScrollBut.Drag(0, -5);
        }