protected override void OnStartDemo(SampleViewport viewport) { var box1 = new LayoutFarm.CustomWidgets.SimpleBox(50, 50); box1.BackColor = Color.Red; box1.SetLocation(10, 10); //box1.dbugTag = 1; SetupActiveBoxProperties(box1); viewport.AddContent(box1); var box2 = new LayoutFarm.CustomWidgets.SimpleBox(30, 30); box2.SetLocation(50, 50); //box2.dbugTag = 2; SetupActiveBoxProperties(box2); viewport.AddContent(box2); controllerBox1 = new UIControllerBox(40, 40); Color c = KnownColors.FromKnownColor(KnownColor.Yellow); controllerBox1.BackColor = new Color(100, c.R, c.G, c.B); controllerBox1.SetLocation(200, 200); //controllerBox1.dbugTag = 3; controllerBox1.Visible = false; SetupControllerBoxProperties(controllerBox1); viewport.AddContent(controllerBox1); }
protected override void OnStart(AppHost host) { var box1 = new LayoutFarm.CustomWidgets.Box(50, 50); box1.BackColor = Color.Red; box1.SetLocation(10, 10); //box1.dbugTag = 1; SetupActiveBoxProperties(box1); host.AddChild(box1); var box2 = new LayoutFarm.CustomWidgets.Box(30, 30); box2.SetLocation(50, 50); //box2.dbugTag = 2; SetupActiveBoxProperties(box2); host.AddChild(box2); _controllerBox1 = new UIControllerBox(40, 40); Color c = KnownColors.FromKnownColor(KnownColor.Yellow); _controllerBox1.BackColor = new Color(100, c.R, c.G, c.B); _controllerBox1.SetLocation(200, 200); //controllerBox1.dbugTag = 3; _controllerBox1.Visible = false; SetupControllerBoxProperties(_controllerBox1); host.AddChild(_controllerBox1); }
void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; //-------------------------------------------- //move controller here controllerBox1.SetBounds(box.Left - 5, box.Top - 5, box.Width + 10, box.Height + 10); controllerBox1.Visible = true; controllerBox1.TargetBox = box; e.SetMouseCapture(controllerBox1); }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = Color.LightGray; controllerBox1.Visible = false; controllerBox1.TargetBox = null; }; }
void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.Box box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; //-------------------------------------------- //move controller here _controllerBox1.TargetBox = box; _controllerBox1.SetLocation(box.Left - 5, box.Top - 5); _controllerBox1.SetSize(box.Width + 10, box.Height + 10); _controllerBox1.Visible = true; //-------------------------------------------- e.CancelBubbling = true; //change mouse capture to another control e.SetMouseCapturedElement(_controllerBox1); }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = KnownColors.LightGray; //hide controller _controllerBox1.Visible = false; _controllerBox1.TargetBox = null; e.CancelBubbling = true; }; }
UIControllerBox GetFreeUserControllerBox() { if (userControllerPool.Count > 0) { var controlBox = userControllerPool.Dequeue(); //------------------------------------------- //register to working box list workingControllerBoxes.Add(controlBox); return(controlBox); } else { //create new one //controller box 1 (red corners) var controllerBox1 = new UIControllerBox(40, 40); Color c = KnownColors.FromKnownColor(KnownColor.Yellow); controllerBox1.BackColor = new Color(100, c.R, c.G, c.B); controllerBox1.SetLocation(200, 200); //controllerBox1.dbugTag = 3; controllerBox1.Visible = false; SetupControllerBoxProperties(controllerBox1); //------------------------------------------- //register to working box list workingControllerBoxes.Add(controllerBox1); return(controllerBox1); } }
public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx) { if (_gridViewRenderE == null) { var myGridBox = new GridViewRenderElement(rootgfx, this.Width, this.Height); myGridBox.HasSpecificSize = true;//*** myGridBox.SetLocation(this.Left, this.Top); myGridBox.SetController(this); myGridBox.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray); this.SetPrimaryRenderElement(myGridBox); this._gridViewRenderE = myGridBox; //create layers int nrows = this.gridTable.RowCount; int ncols = this.gridTable.ColumnCount; //---------------------------------------- myGridBox.BuildGrid(gridTable, this.CellSizeStyle); //add grid content for (int c = 0; c < ncols; ++c) { for (int r = 0; r < nrows; ++r) { var gridCell = gridTable.GetCell(r, c); var content = gridCell.ContentElement as UIElement; if (content != null) { myGridBox.SetContent(r, c, content); } } } } return(_gridViewRenderE); }
protected override void OnStartDemo(SampleViewport viewport) { var box1 = new LayoutFarm.CustomWidgets.SimpleBox(50, 50); box1.BackColor = Color.Red; box1.SetLocation(10, 10); viewport.AddContent(box1); //-------------------------------- var box2 = new LayoutFarm.CustomWidgets.SimpleBox(30, 30); box2.SetLocation(50, 50); viewport.AddContent(box2); //1. mouse down box1.MouseDown += (s, e) => { box1.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); box2.Visible = false; }; box1.MouseUp += (s, e) => { box1.BackColor = Color.Red; box2.Visible = true; }; }
protected override void OnStart(AppHost host) { var listbox = new LayoutFarm.CustomWidgets.ListBox(300, 400); listbox.SetLocation(10, 10); listbox.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray); //add list view to viewport host.AddChild(listbox); //add RequestFont listItemFont = new RequestFont("tahoma", 18); for (int i = 0; i < 10; ++i) { var listItem = new LayoutFarm.CustomWidgets.ListItem(400, 20); if ((i % 2) == 0) { listItem.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed); } else { listItem.BackColor = KnownColors.FromKnownColor(KnownColor.Orange); } listItem.SetFont(listItemFont); listItem.Text = "A" + i; listbox.AddItem(listItem); } }
protected override void OnStartDemo(SampleViewport viewport) { //grid0 { var gridBox = new LayoutFarm.CustomWidgets.GridBox(100, 100); gridBox.SetLocation(50, 50); gridBox.BuildGrid(2, 4, CellSizeStyle.UniformCell); viewport.AddContent(gridBox); } //grid1 { var gridBox = new LayoutFarm.CustomWidgets.GridBox(100, 100); gridBox.SetLocation(200, 50); gridBox.BuildGrid(2, 4, CellSizeStyle.UniformCell); viewport.AddContent(gridBox); var simpleButton = new LayoutFarm.CustomWidgets.SimpleBox(20, 20); simpleButton.BackColor = KnownColors.FromKnownColor(KnownColor.OliveDrab); gridBox.AddUI(simpleButton, 1, 1); } //----- //grid2 { var gridBox = new LayoutFarm.CustomWidgets.GridBox(100, 100); gridBox.SetLocation(350, 50); gridBox.BuildGrid(3, 8, CellSizeStyle.UniformCell); viewport.AddContent(gridBox); } }
void SetupCornerBoxController(PlotBox box) { Color c = KnownColors.FromKnownColor(KnownColor.Orange); box.BackColor = new Color(100, c.R, c.G, c.B); //controllerBox1.dbugTag = 3; box.Visible = true; SetupCornerProperties(box); // _controls.Add(box); }
void SetupHorizontalScrollButtonProperties(RenderElement container) { var scroll_button = new ScrollBarButton(10, this.Height, this); //create with default value scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue); int thumbPosX = CalculateThumbPosition() + minmax_boxHeight; scroll_button.SetLocation(thumbPosX, 0); container.AddChild(scroll_button); this.scrollButton = scroll_button; //---------------------------- EvaluateHorizontalScrollBarProperties(); //---------------------------- //3. drag scroll_button.MouseDrag += (s, e) => { //dragging ... //find x-diff Point pos = scroll_button.Position; //if vscroll bar then move only y axis int newXPos = (int)(pos.X + e.DiffCapturedX); //clamp! if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width)) { newXPos = this.Width - (minmax_boxHeight + scrollButton.Width); } else if (newXPos < minmax_boxHeight) { newXPos = minmax_boxHeight; } //calculate value from position int currentMarkAt = (newXPos - minmax_boxHeight); this.scrollValue = (float)(onePixelFor * currentMarkAt); newXPos = CalculateThumbPosition() + minmax_boxHeight; scroll_button.SetLocation(newXPos, pos.Y); if (this.UserScroll != null) { this.UserScroll(this, EventArgs.Empty); } e.StopPropagation(); }; }
void SetupCornerBoxController(UIControllerBox box) { Color c = KnownColors.FromKnownColor(KnownColor.Orange); box.BackColor = new Color(100, c.R, c.G, c.B); box.SetLocation(200, 200); //controllerBox1.dbugTag = 3; box.Visible = false; SetupControllerBoxProperties2(box); //viewport.AddContent(box); // _controls.Add(box); }
public static Color FindColorMatch(Color c) { uint argb = (uint)c.ToArgb(); for (int i = 0; i < KnownColors.ArgbValues.Length; i++) { if (argb == KnownColors.ArgbValues [i]) { return(KnownColors.FromKnownColor((KnownColor)i)); } } return(Color.Empty); }
void SetupEdge_Controller(UIControllerBox box) { Color c = KnownColors.FromKnownColor(KnownColor.Blue); box.BackColor = c;// new Color(200, c.R, c.G, c.B); box.SetLocation(200, 200); box.Visible = true; switch (box.MoveDirection) { case MoveDirection.XAxis: { box.MouseDrag += (s, e) => { Point pos = box.Position; box.SetLocation(pos.X + e.XDiff, pos.Y); //var targetBox = cornerBox.TargetBox; //if (targetBox != null) //{ // //move target box too // targetBox.SetLocation(newX + 5, newY + 5); //} e.CancelBubbling = true; }; } break; case MoveDirection.YAxis: { box.MouseDrag += (s, e) => { Point pos = box.Position; box.SetLocation(pos.X, pos.Y + e.YDiff); //var targetBox = cornerBox.TargetBox; //if (targetBox != null) //{ // //move target box too // targetBox.SetLocation(newX + 5, newY + 5); //} e.CancelBubbling = true; }; } break; } _controls.Add(box); }
void SetupMinButtonProperties(RenderElement container) { ScrollBarButton min_button; if (this.ScrollBarType == ScrollBarType.Horizontal) { min_button = new ScrollBarButton(minmax_boxHeight, this.Height, this); } else { min_button = new ScrollBarButton(this.Width, minmax_boxHeight, this); } min_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray); min_button.MouseUp += (s, e) => this.StepSmallToMin(); container.AddChild(min_button); this.minButton = min_button; }
void SetupVerticalScrollButtonProperties(RenderElement container) { var scroll_button = new ScrollBarButton(this.Width, 10, this); //create with default value scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue); int thumbPosY = CalculateThumbPosition() + _minmax_boxHeight; scroll_button.SetLocation(0, thumbPosY); container.AddChild(scroll_button); _scrollButton = scroll_button; //---------------------------- EvaluateVerticalScrollBarProperties(); //---------------------------- //3. drag scroll_button.MouseDrag += (s, e) => { //dragging ... Point pos = scroll_button.Position; //if vscroll bar then move only y axis int newYPos = (int)(pos.Y + e.DiffCapturedY); //clamp! if (newYPos >= this.Height - (_minmax_boxHeight + _scrollButton.Height)) { newYPos = this.Height - (_minmax_boxHeight + _scrollButton.Height); } else if (newYPos < _minmax_boxHeight) { newYPos = _minmax_boxHeight; } //calculate value from position int currentMarkAt = (newYPos - _minmax_boxHeight); _scrollValue = (float)(_onePixelFor * currentMarkAt); newYPos = CalculateThumbPosition() + _minmax_boxHeight; scroll_button.SetLocation(pos.X, newYPos); if (this.UserScroll != null) { this.UserScroll(this, EventArgs.Empty); } e.StopPropagation(); }; }
protected override void OnStart(AppHost host) { var box_beh = new UIMouseBehaviour <Box>(); { box_beh.GuestMsg += (s, e) => { }; box_beh.MouseDown += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Pointer; }; box_beh.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; //box.BackColor = Color.LightGray; s.Source.BackColor = Color.FromArgb(50, KnownColors.FromKnownColor(KnownColor.DeepSkyBlue)); }; box_beh.MouseDrag += (s, e) => { Box box = s.Source; box.BackColor = Color.FromArgb(180, KnownColors.FromKnownColor(KnownColor.GreenYellow)); Point pos = box.Position; box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff); e.MouseCursorStyle = MouseCursorStyle.Pointer; e.CancelBubbling = true; }; } //------------- { var box1 = new LayoutFarm.CustomWidgets.Box(50, 50); box1.BackColor = Color.Red; box1.SetLocation(10, 10); box_beh.AttachSharedBehaviorTo(box1); host.AddChild(box1); } //-------------------------------- { var box2 = new LayoutFarm.CustomWidgets.Box(30, 30); box2.SetLocation(50, 50); //box2.dbugTag = 2; box_beh.AttachSharedBehaviorTo(box2); host.AddChild(box2); } }
// FIXME: Linear scan public static Color_ FindColorMatch(Color_ c) { uint argb = (uint)c.ToArgb(); // 1-based const int first_real_color_index = (int)KnownColor.AliceBlue; const int last_real_color_index = (int)KnownColor.YellowGreen; for (int i = first_real_color_index - 1; i < last_real_color_index; i++) { if (argb == KnownColors.ArgbValues [i]) { return(KnownColors.FromKnownColor((KnownColor)i)); } } return(Color_.Empty); }
protected override void OnStartDemo(SampleViewport viewport) { var treeView = new LayoutFarm.CustomWidgets.TreeView(300, 400); treeView.SetLocation(10, 10); treeView.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray); viewport.AddContent(treeView); //prepare node icon ImageBinder nodeOpen = LoadImage("../../Demo/arrow_open.png"); //add for (int i = 0; i < 10; ++i) { var childLevel0 = new LayoutFarm.CustomWidgets.TreeNode(400, 40); childLevel0.BackColor = ((i % 2) == 0) ? KnownColors.FromKnownColor(KnownColor.Blue) : KnownColors.FromKnownColor(KnownColor.Yellow); treeView.AddItem(childLevel0); childLevel0.NodeIconImage = nodeOpen; for (int n = 0; n < 4; ++n) { var childLevel1 = new LayoutFarm.CustomWidgets.TreeNode(400, 20); childLevel1.BackColor = ((n % 2) == 0) ? KnownColors.FromKnownColor(KnownColor.Green) : KnownColors.FromKnownColor(KnownColor.YellowGreen); childLevel0.AddChildNode(childLevel1); childLevel1.NodeIconImage = nodeOpen; for (int m = 0; m < 5; ++m) { var childLevel2 = new LayoutFarm.CustomWidgets.TreeNode(400, 20); childLevel2.BackColor = ((m % 2) == 0) ? KnownColors.FromKnownColor(KnownColor.OrangeRed) : KnownColors.FromKnownColor(KnownColor.Wheat); childLevel2.NodeIconImage = nodeOpen; childLevel1.AddChildNode(childLevel2); } } } }
public void Init() { //------------ _centralBox = new UIControllerBox(40, 40); { Color c = KnownColors.FromKnownColor(KnownColor.Yellow); _centralBox.BackColor = new Color(100, c.R, c.G, c.B); _centralBox.SetLocation(200, 200); //controllerBox1.dbugTag = 3; _centralBox.Visible = false; SetupControllerBoxProperties(_centralBox); //viewport.AddChild(controllerBox1); _controls.Add(_centralBox); } _groundBox.Add(_centralBox); //------------ InitCornerControlBoxes(); InitEdgeControlBoxes(); //------------ }
void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; //-------------------------------------------- e.SetMouseCapture(rectBoxController.ControllerBoxMain); rectBoxController.UpdateControllerBoxes(box); }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = Color.LightGray; //controllerBox1.Visible = false; //controllerBox1.TargetBox = null; }; }
void SetupMaxButtonProperties(RenderElement container) { ScrollBarButton max_button; if (this.ScrollBarType == ScrollBarType.Horizontal) { max_button = new ScrollBarButton(minmax_boxHeight, this.Height, this); max_button.SetLocation(this.Width - minmax_boxHeight, 0); } else { max_button = new ScrollBarButton(this.Width, minmax_boxHeight, this); max_button.SetLocation(0, this.Height - minmax_boxHeight); } max_button.BackColor = KnownColors.FromKnownColor(KnownColor.Yellow); max_button.MouseUp += (s, e) => this.StepSmallToMax(); container.AddChild(max_button); this.maxButton = max_button; }
static LayoutFarm.CustomWidgets.ListView CreateSampleListView() { var listview = new LayoutFarm.CustomWidgets.ListView(300, 400); listview.SetLocation(10, 10); listview.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray); //add for (int i = 0; i < 10; ++i) { var listItem = new LayoutFarm.CustomWidgets.ListItem(400, 20); if ((i % 2) == 0) { listItem.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed); } else { listItem.BackColor = KnownColors.FromKnownColor(KnownColor.Orange); } listview.AddItem(listItem); } return(listview); }
static void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = Color.LightGray; }; box.MouseDrag += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.GreenYellow); Point pos = box.Position; box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff); e.MouseCursorStyle = MouseCursorStyle.Pointer; e.CancelBubbling = true; }; }
protected override void OnStartDemo(SampleViewport viewport) { var listview = new LayoutFarm.CustomWidgets.ListView(300, 400); listview.SetLocation(10, 10); listview.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray); viewport.AddContent(listview); //add for (int i = 0; i < 10; ++i) { var listItem = new LayoutFarm.CustomWidgets.ListItem(400, 20); if ((i % 2) == 0) { listItem.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed); } else { listItem.BackColor = KnownColors.FromKnownColor(KnownColor.Orange); } listview.AddItem(listItem); } }
UIControllerBox GetFreeControllerBox() { //Console.WriteLine("<< ctrl " + userControllerPool.Count); UIControllerBox controlBox = null; if (userControllerPool.Count > 0) { controlBox = userControllerPool.Dequeue(); //------------------------------------------- viewport.AddContent(controlBox); //register to working controller box workingControllerBoxes.Add(controlBox); } else { //create new one //controller box 1 (red corners) controlBox = new UIControllerBox(40, 40); controlBox.DesignBoardModule = this; //var gridBox = new LayoutFarm.CustomWidgets.GridBox(30, 30); //gridBox.SetLocation(5, 5); //gridBox.BuildGrid(3, 3, CellSizeStyle.UniformCell); //controlBox.ContentBox = gridBox; Color c = KnownColors.FromKnownColor(KnownColor.Yellow); controlBox.BackColor = new Color(100, c.R, c.G, c.B); controlBox.SetLocation(200, 200); //controllerBox1.dbugTag = 3; controlBox.Visible = false; viewport.AddContent(controlBox); //------------------------------------------- //register to working controller box workingControllerBoxes.Add(controlBox); } return(controlBox); }
protected override void OnStart(AppHost host) { var box1 = new LayoutFarm.CustomWidgets.Box(50, 50); box1.BackColor = Color.Red; box1.SetLocation(10, 10); host.AddChild(box1); //-------------------------------- var box2 = new LayoutFarm.CustomWidgets.Box(30, 30); box2.SetLocation(50, 50); host.AddChild(box2); //1. mouse down box1.MouseDown += (s, e) => { box1.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); box2.Visible = false; }; box1.MouseUp += (s, e) => { box1.BackColor = Color.Red; box2.Visible = true; }; }
// void SetupCorner_Controller(UIControllerBox box) { Color c = KnownColors.FromKnownColor(KnownColor.Orange); box.BackColor = c;// new Color(200, c.R, c.G, c.B); box.SetLocation(200, 200); box.Visible = true; box.MouseDrag += (s, e) => { Point pos = box.Position; double x1 = pos.X; double y1 = pos.Y; if (firstTime) { _mouseDownX = x1; _mouseDownY = y1; firstTime = false; //find rad of firsttime _firstTimeRad = Math.Atan2(y1, x1); _rotateAngleDiff = 0; } else { double newX = _actualX + e.XDiff; double newY = _actualY + e.YDiff; //find new angle double thisTimeRad = Math.Atan2(newY, newX); _rotateAngleDiff = thisTimeRad - _firstTimeRad; x1 = _mouseDownX; //prevent rounding error y1 = _mouseDownY; //prevent rounding error } //if (firstTime) //{ // _snapX1 = x1; // _snapY1 = y1; // firstTime = false; //} //else //{ // x1 = _snapX1; // y1 = _snapY1; //} //double current_distance = Math.Sqrt(x1 * x1 + y1 * y1); // //double newX = pos.X + e.XDiff; //double newY = pos.Y + e.YDiff; //float diff = 1; //if (e.XDiff > 0) //{ // diff = -1; //} //box.SetLocation((int)newX, (int)newY); PixelFarm.CpuBlit.VertexProcessing.Affine aff = PixelFarm.CpuBlit.VertexProcessing.Affine.New( //PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(-x1, -y1), PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Rotate(_rotateAngleDiff)); //PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(x1, y1)); aff.Transform(ref x1, ref y1); _actualX = x1; _actualY = y1; box.SetLocation((int)Math.Round(x1), (int)Math.Round(y1)); //essential to use double, prevent rounding err *** //var targetBox = box.TargetBox; ////test rotation around some axis ////find box center //if (targetBox != null) //{ // //find box center // float centerX = (float)((targetBox.Width + targetBox.Left) / 2f); // float centerY = (float)((targetBox.Height + targetBox.Top) / 2f); // // // Double angle = Math.Atan2(newY - centerY, newX - centerX); // //rotate // PixelFarm.CpuBlit.VertexProcessing.Affine aff = PixelFarm.CpuBlit.VertexProcessing.Affine.NewMatix( // PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(-targetBox.Width / 2, -targetBox.Height / 2), // PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Rotate(angle), // PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(targetBox.Width / 2, targetBox.Height / 2) // ); // //transform // aff.Transform(ref x1, ref y1); // box.SetLocation((int)x1, (int)y1); //} //if (targetBox != null) //{ // //move target box too // targetBox.SetLocation(newX + 5, newY + 5); //} e.CancelBubbling = true; }; _controls.Add(box); }
/// <summary> /// Get color by given name, including .NET name. /// </summary> /// <returns>true - valid color, false - otherwise</returns> private static bool GetColorByName(string str, int idx, int length, out Color color) { color = KnownColors.FromKnownColor(str.Substring(idx, length)); return(color.A > 0); }
void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; UIControllerBox userControllerBox = null; if (this.controllerBoxMode == ControllerBoxMode.MultipleBoxes) { //multiple box userControllerBox = GetFreeUserControllerBox(); } else { //single box if (singleControllerBox != null) { ReleaseUserControllerBox(singleControllerBox); } //get new one userControllerBox = singleControllerBox = GetFreeUserControllerBox(); } //request user controller for this box userControllerBox.TargetBox = box; viewport.AddContent(userControllerBox); //location relative to global position of target box var globalTargetPos = box.GetGlobalLocation(); userControllerBox.SetLocation(globalTargetPos.X - 5, globalTargetPos.Y - 5); userControllerBox.SetSize(box.Width + 10, box.Height + 10); userControllerBox.Visible = true; //move mouse capture to new controller box //for next drag e.SetMouseCapture(userControllerBox); }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = Color.LightGray; RemoveAllUserControllerBoxes(); }; box.DragOver += (s, e) => { switch (e.UserMsgFlags) { case 1: { //sample only box.BackColor = Color.Green; } break; case 2: { //sample only //leaving box.BackColor = Color.Blue; } break; case 3: { //drop var sender = e.Sender as UIControllerBox; var droppingBox = sender.TargetBox as UIBox; if (droppingBox != null) { //move from original var parentBox = droppingBox.ParentUI as LayoutFarm.CustomWidgets.SimpleBox; if (parentBox != null) { var newParentGlobalLoca = box.GetGlobalLocation(); var droppingGlobalLoca = droppingBox.GetGlobalLocation(); parentBox.RemoveChild(droppingBox); box.AddChild(droppingBox); //TODO: review here , //set location relative to other element droppingBox.SetLocation( droppingGlobalLoca.X - newParentGlobalLoca.X, droppingGlobalLoca.Y - newParentGlobalLoca.Y); } else { } } } break; } }; }