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); }
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; }