static UIElement CloneImageBox(DesignBox dzBox) { UIHolderBox holderBox = dzBox as UIHolderBox; var originalImgBox = holderBox.TargetBox as LayoutFarm.CustomWidgets.ImageBox; var newClone = new UIHolderBox(holderBox.Width, holderBox.Height); newClone.BackColor = Color.White; var imgbox = new LayoutFarm.CustomWidgets.ImageBox(newClone.Width - 10, newClone.Height - 10); imgbox.ImageBinder = originalImgBox.ImageBinder; //clone content of text box newClone.SetCloneDelegate(CloneImageBox); newClone.SetSerializeDelegate(SerializeDzImageBox); newClone.AddChild(imgbox); newClone.TargetBox = imgbox; return(newClone); }
public UIHolderBox AddNewImageBox(int x, int y, int w, int h, ImageBinder imgBinder) { //add new user box var box1 = new UIHolderBox(w, h); box1.BackColor = Color.White; box1.SetLocation(x, y); var imgBox = new LayoutFarm.CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height); imgBox.ImageBinder = imgBinder; box1.AddChild(imgBox); imgBox.SetLocation(10, 10); box1.TargetBox = imgBox; box1.SetSize(imgBinder.ImageWidth + 20, imgBinder.ImageHeight + 20); SetupActiveBoxProperties(box1); viewport.AddContent(box1); userBoxes.Add(box1); return(box1); }
void AddScrollView2(AppHost host, int x, int y) { var panel = new LayoutFarm.CustomWidgets.Box(800, 600); panel.HasSpecificWidthAndHeight = true; panel.NeedClipArea = true; panel.SetLocation(x + 10, y + 30); panel.BackColor = Color.LightGray; panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack; host.AddChild(panel); //------------------------- //load images... //check folder before load string[] fileNames = new string[0]; if (System.IO.Directory.Exists("../Data/imgs")) { fileNames = System.IO.Directory.GetFiles("../Data/imgs", "0*.jpg"); } //select only int lastY = 0; int imgNo = 0; for (int i = 0; i < fileNames.Length * 4; ++i) //5 imgs { var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 36); imgbox.BackColor = Color.OrangeRed; imgbox.SetLocation(0, lastY); imgbox.MouseUp += (s, e) => { if (e.Button == UIMouseButtons.Right) { //test remove this imgbox on right mouse click panel.RemoveChild(imgbox); } }; ImageBinder imgBinder = host.CreateImageBinder(fileNames[imgNo]); imgbox.SetSize(imgBinder.Width, imgBinder.Height); imgbox.ImageBinder = imgBinder; lastY += imgbox.Height; panel.AddChild(imgbox); imgNo++; if (imgNo == fileNames.Length) //last img { imgNo = 0; //reset } } //-------------------------- //panel may need more panel.SetViewport(0, 0); //------------------------- { //vertical scrollbar var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200); vscbar.SetLocation(x + 10, y + 10); vscbar.MinValue = 0; vscbar.MaxValue = lastY; vscbar.SmallChange = 20; host.AddChild(vscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, panel); } //------------------------- { //horizontal scrollbar var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15); hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal; hscbar.SetLocation(x + 30, y + 10); hscbar.MinValue = 0; hscbar.MaxValue = panel.Width;//just init hscbar.SmallChange = 20; host.AddChild(hscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, panel); } }
void AddScrollView2(SampleViewport viewport, int x, int y) { var panel = new LayoutFarm.CustomWidgets.SimpleBox(800, 1000); panel.NeedClipArea = true; panel.SetLocation(x + 10, y + 30); panel.BackColor = Color.LightGray; panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack; viewport.AddContent(panel); //------------------------- //load images... //check folder before load string[] fileNames = new string[0]; if (System.IO.Directory.Exists("../../Data/imgs")) { fileNames = System.IO.Directory.GetFiles("../../Data/imgs", "0*.jpg"); } //select only int lastY = 0; ImageBinder binder = viewport.GetImageBinder(fileNames[2]); for (int i = 0; i < fileNames.Length * 4; ++i) //5 imgs { var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 400); imgbox.ImageBinder = binder; imgbox.BackColor = Color.OrangeRed; imgbox.SetLocation(0, lastY); imgbox.MouseUp += (s, e) => { if (e.Button == UIMouseButtons.Right) { //test remove this imgbox on right mouse click panel.RemoveChild(imgbox); } }; lastY += imgbox.Height + 5; panel.AddChild(imgbox); } //-------------------------- //panel may need more panel.SetViewport(0, 0); //------------------------- { //vertical scrollbar var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200); vscbar.SetLocation(x + 10, y + 10); vscbar.MinValue = 0; vscbar.MaxValue = lastY; vscbar.SmallChange = 20; viewport.AddContent(vscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar.SliderBox, panel); } //------------------------- { //horizontal scrollbar var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15); hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal; hscbar.SetLocation(x + 30, y + 10); hscbar.MinValue = 0; hscbar.MaxValue = 170; hscbar.SmallChange = 20; viewport.AddContent(hscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar.SliderBox, panel); } panel.PerformContentLayout(); }
public UIHolderBox AddNewImageBox(int x, int y, int w, int h, ImageBinder imgBinder) { //add new user box var box1 = new UIHolderBox(w, h); box1.BackColor = Color.White; box1.SetLocation(x, y); var imgBox = new LayoutFarm.CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height); imgBox.ImageBinder = imgBinder; box1.AddChild(imgBox); imgBox.SetLocation(10, 10); box1.TargetBox = imgBox; box1.SetSize(imgBinder.ImageWidth + 20, imgBinder.ImageHeight + 20); SetupActiveBoxProperties(box1); viewport.AddContent(box1); userBoxes.Add(box1); return box1; }
void AddScrollView2(SampleViewport viewport, int x, int y) { var panel = new LayoutFarm.CustomWidgets.SimpleBox(800, 600); panel.SetLocation(x + 30, y + 30); panel.BackColor = Color.LightGray; panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack; viewport.AddContent(panel); //------------------------- //load images... int lastY = 0; for (int i = 0; i < 5; ++i) { var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 400); //if (!System.IO.File.Exists("../../images/0" + (i + 1) + ".jpg")) //{ //} ClientImageBinder binder = new ClientImageBinder("../../images/0" + (i + 1) + ".jpg"); binder.SetOwner(imgbox); binder.SetLazyFunc(LazyImageLoad); //if use lazy img load func imageContentMan.AddRequestImage(binder); imgbox.ImageBinder = binder; imgbox.BackColor = Color.OrangeRed; imgbox.SetLocation(0, lastY); imgbox.MouseUp += (s, e) => { if (e.Button == UIMouseButtons.Right) { //test remove this imgbox on right mouse click panel.RemoveChild(imgbox); } }; lastY += imgbox.Height + 5; panel.AddChild(imgbox); } //-------------------------- //panel may need more panel.SetViewport(0, 0); //------------------------- { //vertical scrollbar var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200); vscbar.SetLocation(x + 10, y + 10); vscbar.MinValue = 0; vscbar.MaxValue = lastY; vscbar.SmallChange = 20; viewport.AddContent(vscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar, panel); } //------------------------- { //horizontal scrollbar var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(150, 15); hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal; hscbar.SetLocation(x + 30, y + 10); hscbar.MinValue = 0; hscbar.MaxValue = 170; hscbar.SmallChange = 20; viewport.AddContent(hscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar, panel); } panel.PerformContentLayout(); }
static UIElement CloneImageBox(DesignBox dzBox) { UIHolderBox holderBox = dzBox as UIHolderBox; var originalImgBox = holderBox.TargetBox as LayoutFarm.CustomWidgets.ImageBox; var newClone = new UIHolderBox(holderBox.Width, holderBox.Height); newClone.BackColor = Color.White; var imgbox = new LayoutFarm.CustomWidgets.ImageBox(newClone.Width - 10, newClone.Height - 10); imgbox.ImageBinder = originalImgBox.ImageBinder; //clone content of text box newClone.SetCloneDelegate(CloneImageBox); newClone.SetSerializeDelegate(SerializeDzImageBox); newClone.AddChild(imgbox); newClone.TargetBox = imgbox; return newClone; }
void AddScrollView2(SampleViewport viewport, int x, int y) { var panel = new LayoutFarm.CustomWidgets.SimpleBox(400, 300); panel.SetLocation(x + 30, y + 30); panel.BackColor = Color.LightGray; panel.ContentLayoutKind = CustomWidgets.BoxContentLayoutKind.VerticalStack; viewport.AddContent(panel); //------------------------- //load images... int lastY = 0; for (int i = 0; i < 5; ++i) { var imgbox = new LayoutFarm.CustomWidgets.ImageBox(36, 400); //if (!System.IO.File.Exists("../../images/0" + (i + 1) + ".jpg")) //{ //} ClientImageBinder binder = new ClientImageBinder("../../images/0" + (i + 1) + ".jpg"); binder.SetOwner(imgbox); binder.SetLazyFunc(LazyImageLoad); //if use lazy img load func imageContentMan.AddRequestImage(binder); imgbox.ImageBinder = binder; imgbox.BackColor = Color.OrangeRed; imgbox.SetLocation(0, lastY); imgbox.MouseUp += (s, e) => { if (e.Button == UIMouseButtons.Right) { //test remove this imgbox on right mouse click panel.RemoveChild(imgbox); } }; lastY += imgbox.Height + 5; panel.AddChild(imgbox); } //-------------------------- //panel may need more panel.SetViewport(0, 0); //------------------------- { //vertical scrollbar var vscbar = new LayoutFarm.CustomWidgets.ScrollBar(15, 200); vscbar.SetLocation(x + 10, y + 10); vscbar.MinValue = 0; vscbar.MaxValue = lastY; vscbar.SmallChange = 20; viewport.AddContent(vscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(vscbar, panel); } //------------------------- { //horizontal scrollbar var hscbar = new LayoutFarm.CustomWidgets.ScrollBar(300, 15); hscbar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal; hscbar.SetLocation(x + 30, y + 10); hscbar.MinValue = 0; hscbar.MaxValue = 170; hscbar.SmallChange = 20; viewport.AddContent(hscbar); //add relation between viewpanel and scroll bar var scRelation = new LayoutFarm.CustomWidgets.ScrollingRelation(hscbar, panel); } panel.PerformContentLayout(); }