private void ExpandBottom(AppWidget widget) { int miny = m_page.SavedHeight; foreach (var w in m_page.Widgets) { if (w == widget) { continue; } if (w.Top < widget.Bottom) { continue; } if (w.HInterval.Intersection(widget.HInterval).IsEmpty) { continue; } if (w.Top < miny) { miny = w.Top; } } widget.Height = miny - widget.Top; }
private void ExpandRight(AppWidget widget) { int minx = m_page.SavedWidth; foreach (var w in m_page.Widgets) { if (w == widget) { continue; } if (w.Left < widget.Right) { continue; } if (w.VInterval.Intersection(widget.VInterval).IsEmpty) { continue; } if (w.Left < minx) { minx = w.Left; } } widget.Width = minx - widget.Left; }
private void ExpandTop(AppWidget widget) { int maxy = 0; foreach (var w in m_page.Widgets) { if (w == widget) { continue; } if (w.Bottom > widget.Top) { continue; } if (w.HInterval.Intersection(widget.HInterval).IsEmpty) { continue; } if (w.Bottom > maxy) { maxy = w.Bottom; } } widget.Top = maxy; }
private void ExpandLeft(AppWidget widget) { int maxx = 0; foreach (var w in m_page.Widgets) { if (w == widget) { continue; } if (w.Right > widget.Left) { continue; } if (w.VInterval.Intersection(widget.VInterval).IsEmpty) { continue; } if (w.Right > maxx) { maxx = w.Right; } } widget.Left = maxx; }
private void NegateAnchor(AppWidget widget, AnchorStyles anchor) { if ((widget.Anchor & anchor) != 0) { widget.Anchor = widget.Anchor & (~anchor); } else { widget.Anchor = widget.Anchor | anchor; } }
public void ChangedWidget(AppWidget widget) { panel1.Invalidate(); }
private void panel1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { bool processed = false; if (m_selectedWidget != null) { var ht = m_selectedWidget.HitTest(e.Location); processed = true; switch (ht) { case HitTestResult.LeftAnchor: NegateAnchor(m_selectedWidget, AnchorStyles.Left); break; case HitTestResult.RightAnchor: NegateAnchor(m_selectedWidget, AnchorStyles.Right); break; case HitTestResult.TopAnchor: NegateAnchor(m_selectedWidget, AnchorStyles.Top); break; case HitTestResult.BottomAnchor: NegateAnchor(m_selectedWidget, AnchorStyles.Bottom); break; case HitTestResult.LeftMover: ExpandLeft(m_selectedWidget); break; case HitTestResult.RightMover: ExpandRight(m_selectedWidget); break; case HitTestResult.TopMover: ExpandTop(m_selectedWidget); break; case HitTestResult.BottomMover: ExpandBottom(m_selectedWidget); break; case HitTestResult.LeftSizer: m_moveOrig = e.Location; m_horMove = MoveMode.Near; m_verMove = MoveMode.None; break; case HitTestResult.TopSizer: m_moveOrig = e.Location; m_horMove = MoveMode.None; m_verMove = MoveMode.Near; break; case HitTestResult.RightSizer: m_moveOrig = e.Location; m_horMove = MoveMode.Far; m_verMove = MoveMode.None; break; case HitTestResult.BottomSizer: m_moveOrig = e.Location; m_horMove = MoveMode.None; m_verMove = MoveMode.Far; break; case HitTestResult.LTSizer: m_moveOrig = e.Location; m_horMove = MoveMode.Near; m_verMove = MoveMode.Near; break; case HitTestResult.RTSizer: m_moveOrig = e.Location; m_horMove = MoveMode.Far; m_verMove = MoveMode.Near; break; case HitTestResult.LBSizer: m_moveOrig = e.Location; m_horMove = MoveMode.Near; m_verMove = MoveMode.Far; break; case HitTestResult.RBSizer: m_moveOrig = e.Location; m_horMove = MoveMode.Far; m_verMove = MoveMode.Far; break; case HitTestResult.In: m_moveOrig = e.Location; m_horMove = MoveMode.Move; m_verMove = MoveMode.Move; break; default: processed = false; break; } } if (!processed) { AppWidget newsel = null; foreach (var widget in m_page.Widgets) { var ht = widget.HitTest(e.Location); if (ht != HitTestResult.Out) { newsel = widget; break; } } SelectedWidget = newsel; } } OnClick(EventArgs.Empty); panel1.Invalidate(); }