public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx) { if (!this.HasReadyRenderElement) { //first time RenderElement baseRenderElement = base.GetPrimaryRenderElement(rootgfx); imageBox = new ImageBox(16, 16); if (this.isChecked) { imageBox.ImageBinder = ResImageList.GetImageBinder(ImageName.CheckBoxChecked); } else { imageBox.ImageBinder = ResImageList.GetImageBinder(ImageName.CheckBoxUnChecked); } imageBox.MouseDown += (s, e) => { //toggle checked/unchecked this.Checked = !this.Checked; }; this.AddChild(imageBox); return baseRenderElement; } else { return base.GetPrimaryRenderElement(rootgfx); } }
LayoutFarm.CustomWidgets.MenuItem CreateMenuItem(int x, int y) { var mnuItem = new CustomWidgets.MenuItem(150, 20); mnuItem.SetLocation(x, y); //-------------------- //1. create landing part var landPart = new LayoutFarm.CustomWidgets.Box(150, 20); landPart.BackColor = Color.OrangeRed; mnuItem.LandPart = landPart; //-------------------------------------- //add small px to land part //image //load bitmap with gdi+ if (_arrowBmp == null) { _arrowBmp = _appHost.LoadImageAndBind("../Data/imgs/arrow_open.png"); } LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(_arrowBmp.Width, _arrowBmp.Height); imgBox.ImageBinder = _arrowBmp; landPart.AddChild(imgBox); //-------------------------------------- //if click on this image then imgBox.MouseDown += (s, e) => { e.CancelBubbling = true; //1. maintenace parent menu*** mnuItem.MaintenanceParentOpenState(); //----------------------------------------------- if (mnuItem.IsOpened) { mnuItem.Close(); } else { mnuItem.Open(); } }; imgBox.MouseUp += (s, e) => { mnuItem.UnmaintenanceParentOpenState(); }; imgBox.LostMouseFocus += (s, e) => { if (!mnuItem.MaintenceOpenState) { mnuItem.CloseRecursiveUp(); } }; //-------------------------------------- //2. float part var floatPart = new LayoutFarm.CustomWidgets.MenuBox(400, 100); floatPart.BackColor = Color.Gray; mnuItem.FloatPart = floatPart; return(mnuItem); }
protected override void OnStartDemo(SampleViewport viewport) { SetupImageList(); for (int i = 1; i < 5; ++i) { var textbox = new LayoutFarm.CustomWidgets.SimpleBox(30, 30); textbox.SetLocation(i * 40, i * 40); viewport.AddContent(textbox); } //-------------------- //image box //load bitmap with gdi+ ImageBinder imgBinder = new ClientImageBinder(null); imgBinder.SetImage(LoadBitmap("../../Demo/favorites32.png")); var imgBox = new CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height); imgBox.ImageBinder = imgBinder; viewport.AddContent(imgBox); //-------------------- //checked box int boxHeight = 20; int boxY = 50; //multiple select for (int i = 0; i < 4; ++i) { var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight); statedBox.SetLocation(10, boxY); boxY += boxHeight + 5; viewport.AddContent(statedBox); } //------------------------------------------------------------------------- //single select boxY += 50; for (int i = 0; i < 4; ++i) { var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight); statedBox.SetLocation(10, boxY); boxY += boxHeight + 5; viewport.AddContent(statedBox); statedBox.WhenChecked += (s, e) => { var selectedBox = (LayoutFarm.CustomWidgets.CheckBox)s; if (selectedBox != currentSingleCheckedBox) { if (currentSingleCheckedBox != null) { currentSingleCheckedBox.Checked = false; } currentSingleCheckedBox = selectedBox; } }; } //------------------------------------------------------------------- //test canvas var canvasBox = new MyDrawingCanvas(300, 300); canvasBox.SetLocation(400, 150); viewport.AddContent(canvasBox); //------------------------------------------------------------------- }
LayoutFarm.CustomWidgets.ComboBox CreateComboBox(int x, int y) { var comboBox = new CustomWidgets.ComboBox(400, 20); comboBox.SetLocation(x, y); //-------------------- //1. create landing part var landPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 20); landPart.BackColor = Color.Green; comboBox.LandPart = landPart; //-------------------------------------- //add small px to land part //image //load bitmap with gdi+ if (arrowBmp == null) { arrowBmp = LoadImage("../../Demo/arrow_open.png"); } LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.Image.Width, arrowBmp.Image.Height); imgBox.ImageBinder = arrowBmp; //-------------------------------------- //2. float part var floatPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 100); floatPart.BackColor = Color.Blue; comboBox.FloatPart = floatPart; //-------------------------------------- //if click on this image then imgBox.MouseDown += (s, e) => { e.CancelBubbling = true; if (comboBox.IsOpen) { comboBox.CloseHinge(); } else { comboBox.OpenHinge(); } }; imgBox.LostMouseFocus += (s, e) => { if (comboBox.IsOpen) { comboBox.CloseHinge(); } }; landPart.AddChild(imgBox); return(comboBox); }
protected override void OnStart(AppHost host) { PixelFarm.Drawing.ImageBinder imgBinder = host.LoadImageAndBind("../Data/imgs/favorites32.png"); for (int i = 0; i < 100; ++i) { //share 1 img binder with multiple img boxes var imgBox = new CustomWidgets.ImageBox(imgBinder.Width, imgBinder.Height); imgBox.ImageBinder = imgBinder; imgBox.SetLocation(i * 10, i * 10); host.AddChild(imgBox); } }
public CheckBox(int w, int h) : base(w, h) { _imageBox = new ImageBox(); _imageBox.ImageBinder = _isChecked ? s_checkedImg : s_uncheckedImg; _imageBox.MouseDown += (s, e) => { //toggle checked/unchecked this.Checked = !this.Checked; }; AddChild(_imageBox); }
protected override void OnStartDemo(SampleViewport viewport) { ImageBinder imgBinder = viewport.GetImageBinder2("../../Data/imgs/favorites32.png"); for (int i = 0; i < 100; ++i) { //share 1 img binder with multiple img boxes var imgBox = new CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height); imgBox.ImageBinder = imgBinder; imgBox.SetLocation(i * 10, i * 10); viewport.AddContent(imgBox); } }
//------------------------------------------------ void SetupNodeIconBehaviour(ImageBox uiNodeIcon) { uiNodeIcon.MouseDown += (s, e) => { if (this.IsOpen) { //then close this.Collapse(); } else { this.Expand(); } }; }
LayoutFarm.CustomWidgets.ComboBox CreateComboBox(int x, int y) { var comboBox = new CustomWidgets.ComboBox(400, 20); comboBox.SetLocation(x, y); //-------------------- //1. create landing part var landPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 20); landPart.BackColor = Color.Green; comboBox.LandPart = landPart; //-------------------------------------- //add small px to land part //image //load bitmap with gdi+ if (arrowBmp == null) { arrowBmp = LoadImageBinder("../../Demo/arrow_open.png"); } LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.Image.Width, arrowBmp.Image.Height); imgBox.ImageBinder = arrowBmp; //-------------------------------------- //2. float part var floatPart = new LayoutFarm.CustomWidgets.SimpleBox(400, 100); floatPart.BackColor = Color.Blue; comboBox.FloatPart = floatPart; //-------------------------------------- //if click on this image then imgBox.MouseDown += (s, e) => { e.CancelBubbling = true; if (comboBox.IsOpen) { comboBox.CloseHinge(); } else { comboBox.OpenHinge(); } }; imgBox.LostMouseFocus += (s, e) => { if (comboBox.IsOpen) { comboBox.CloseHinge(); } }; landPart.AddChild(imgBox); return comboBox; }
void SetupNodeIconBehaviour(ImageBox uiNodeIcon) { uiNodeIcon.MouseDown += (s, e) => { if (this.IsOpen) { //then close this.Collapse(); } else { this.Expand(); } }; }
protected override void OnStartDemo(SampleViewport viewport) { SetupImageList(viewport); for (int i = 1; i < 5; ++i) { var textbox = new LayoutFarm.CustomWidgets.SimpleBox(30, 30); textbox.SetLocation(i * 40, i * 40); viewport.AddContent(textbox); } //-------------------- //image box //load bitmap with gdi+ ImageBinder imgBinder = viewport.GetImageBinder2("../../Data/imgs/favorites32.png"); var imgBox = new CustomWidgets.ImageBox(imgBinder.Image.Width, imgBinder.Image.Height); imgBox.ImageBinder = imgBinder; viewport.AddContent(imgBox); //-------------------- //checked box int boxHeight = 20; int boxY = 50; //multiple select for (int i = 0; i < 4; ++i) { var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight); statedBox.SetLocation(10, boxY); boxY += boxHeight + 5; viewport.AddContent(statedBox); } //------------------------------------------------------------------------- //single select boxY += 50; for (int i = 0; i < 4; ++i) { var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight); statedBox.SetLocation(10, boxY); boxY += boxHeight + 5; viewport.AddContent(statedBox); statedBox.WhenChecked += (s, e) => { var selectedBox = (LayoutFarm.CustomWidgets.CheckBox)s; if (selectedBox != currentSingleCheckedBox) { if (currentSingleCheckedBox != null) { currentSingleCheckedBox.Checked = false; } currentSingleCheckedBox = selectedBox; } }; } //------------------------------------------------------------------- //test canvas var canvasBox = new MyDrawingCanvas(300, 300); canvasBox.SetLocation(400, 150); viewport.AddContent(canvasBox); //------------------------------------------------------------------- }
LayoutFarm.CustomWidgets.MenuItem CreateMenuItem(int x, int y) { var mnuItem = new CustomWidgets.MenuItem(150, 20); mnuItem.SetLocation(x, y); //-------------------- //1. create landing part var landPart = new LayoutFarm.CustomWidgets.SimpleBox(150, 20); landPart.BackColor = Color.OrangeRed; mnuItem.LandPart = landPart; //-------------------------------------- //add small px to land part //image //load bitmap with gdi+ if (arrowBmp == null) { arrowBmp = LoadImageBinder("../../Demo/arrow_open.png"); } LayoutFarm.CustomWidgets.ImageBox imgBox = new CustomWidgets.ImageBox(arrowBmp.ImageWidth, arrowBmp.ImageHeight); imgBox.ImageBinder = arrowBmp; landPart.AddChild(imgBox); //-------------------------------------- //if click on this image then imgBox.MouseDown += (s, e) => { e.CancelBubbling = true; //1. maintenace parent menu*** mnuItem.MaintenanceParentOpenState(); //----------------------------------------------- if (mnuItem.IsOpened) { mnuItem.Close(); } else { mnuItem.Open(); } }; imgBox.MouseUp += (s, e) => { mnuItem.UnmaintenanceParentOpenState(); }; imgBox.LostMouseFocus += (s, e) => { if (!mnuItem.MaintenceOpenState) { mnuItem.CloseRecursiveUp(); } }; //-------------------------------------- //2. float part var floatPart = new LayoutFarm.CustomWidgets.MenuBox(400, 100); floatPart.BackColor = Color.Gray; mnuItem.FloatPart = floatPart; return mnuItem; }
protected override void OnStart(AppHost host) { //SetupImageList(host); for (int i = 1; i < 5; ++i) { var textbox = new LayoutFarm.CustomWidgets.Box(30, 30); textbox.SetLocation(i * 40, i * 40); host.AddChild(textbox); } //-------------------- //image box //load bitmap with gdi+ ImageBinder imgBinder = host.LoadImageAndBind("../Data/imgs/favorites32.png"); var imgBox = new CustomWidgets.ImageBox(imgBinder.Width, imgBinder.Height); imgBox.ImageBinder = imgBinder; host.AddChild(imgBox); //-------------------- //checked box int boxHeight = 20; int boxY = 50; //multiple select for (int i = 0; i < 4; ++i) { var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight); statedBox.SetLocation(10, boxY); boxY += boxHeight + 5; host.AddChild(statedBox); } //------------------------------------------------------------------------- //single select boxY += 50; for (int i = 0; i < 4; ++i) { var statedBox = new LayoutFarm.CustomWidgets.CheckBox(20, boxHeight); statedBox.SetLocation(10, boxY); boxY += boxHeight + 5; host.AddChild(statedBox); statedBox.CheckChanged += (s, e) => { var selectedBox = (LayoutFarm.CustomWidgets.CheckBox)s; if (selectedBox != _currentSingleCheckedBox) { if (_currentSingleCheckedBox != null) { _currentSingleCheckedBox.Checked = false; } _currentSingleCheckedBox = selectedBox; } }; } //------------------------------------------------------------------- //test canvas var canvasBox = new MyDrawingCanvas(300, 300); canvasBox.SetLocation(400, 150); host.AddChild(canvasBox); //------------------------------------------------------------------- }
public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx) { if (primElement == null) { //first time var element = new CustomRenderBox(rootgfx, this.Width, this.Height); element.SetLocation(this.Left, this.Top); element.BackColor = this.backColor; element.HasSpecificSize = true; //----------------------------- // create default layer for node content //----------------------------- uiNodeIcon = new ImageBox(16, 16);//create with default size SetupNodeIconBehaviour(uiNodeIcon); element.AddChild(uiNodeIcon); //----------------------------- myTextRun = new CustomTextRun(rootgfx, 10, 17); myTextRun.SetLocation(16, 0); myTextRun.Text = "Test01"; element.AddChild(myTextRun); //----------------------------- this.primElement = element; } return primElement; }