/// <summary> /// Calculates the screenAreas for the buttons and fields /// </summary> public void CalculateScreenAreas() { //Arrow Left/up double Tx = r_up.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this); double Ty = r_up.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this); double Bx = r_up.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this) + r_up.RenderedGeometry.Bounds.Width; double By = r_up.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this) + r_up.Height; TPoint left = new TPoint((int) Math.Round(Tx), (int) Math.Round(Ty), TPoint.PointCreationType.screen); TPoint right = new TPoint((int)Math.Round(Bx), (int)Math.Round(By), TPoint.PointCreationType.screen); arrowLeft = new GraphicalRegion(left, right); //Arrow right/down Tx = r_down.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this); Ty = r_down.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this); Bx = r_down.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this) + r_down.Width; By = r_down.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this) + r_down.Height; left = new TPoint((int)Math.Round(Tx), (int)Math.Round(Ty), TPoint.PointCreationType.screen); right = new TPoint((int)Math.Round(Bx), (int)Math.Round(By), TPoint.PointCreationType.screen); arrowRight = new GraphicalRegion(left, right); //MenuObject 1 Tx = c1.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this); Ty = c1.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this); Bx = c1.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this) + c1.Width; By = c1.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this) + c1.Height; left = new TPoint((int)Math.Round(Tx), (int)Math.Round(Ty), TPoint.PointCreationType.screen); right = new TPoint((int)Math.Round(Bx), (int)Math.Round(By), TPoint.PointCreationType.screen); MObject1 = new GraphicalRegion(left, right); //MenuObject 2 Tx = c2.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this); Ty = c2.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this); Bx = c2.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this) + c2.Width; By = c2.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this) + c2.Height; left = new TPoint((int)Math.Round(Tx), (int)Math.Round(Ty), TPoint.PointCreationType.screen); right = new TPoint((int)Math.Round(Bx), (int)Math.Round(By), TPoint.PointCreationType.screen); MObject2 = new GraphicalRegion(left, right); //MenuObject 3 Tx = c3.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this); Ty = c3.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this); Bx = c3.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this) + c3.Width; By = c3.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this) + c3.Height; left = new TPoint((int)Math.Round(Tx), (int)Math.Round(Ty), TPoint.PointCreationType.screen); right = new TPoint((int)Math.Round(Bx), (int)Math.Round(By), TPoint.PointCreationType.screen); MObject3 = new GraphicalRegion(left, right); //MenuObject 4 Tx = c4.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this); Ty = c4.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this); Bx = c4.Margin.Left + menugrid.Margin.Left + Canvas.GetLeft(this) + c4.Width; By = c4.Margin.Top + menugrid.Margin.Top + Canvas.GetTop(this) + c4.Height; left = new TPoint((int)Math.Round(Tx), (int)Math.Round(Ty), TPoint.PointCreationType.screen); right = new TPoint((int)Math.Round(Bx), (int)Math.Round(By), TPoint.PointCreationType.screen); MObject4 = new GraphicalRegion(left, right); }
private void GetRegions(out GraphicalRegion b4, out GraphicalRegion b3, out GraphicalRegion b2, out GraphicalRegion b1) { //recalculate screen areas _tableManager.DisplayManager.WorkThreadSafe((Action) (() => _gfxMenu.CalculateScreenAreas()), null); //Check wheter the object is in one of the regions of the menu objects b1 = null; GraphicalRegion b1_ = null; b2 = null; GraphicalRegion b2_ = null; b3 = null; GraphicalRegion b3_ = null; b4 = null; GraphicalRegion b4_ = null; _tableManager.BeamerScreen.Dispatcher.Invoke((Action) (() => { b1_ = (GraphicalRegion) _gfxMenu.MObject1.Clone(); }), null); _tableManager.BeamerScreen.Dispatcher.Invoke((Action)(() => { b2_ = (GraphicalRegion)_gfxMenu.MObject2.Clone(); }), null); _tableManager.BeamerScreen.Dispatcher.Invoke((Action)(() => { b3_ = (GraphicalRegion)_gfxMenu.MObject3.Clone(); }), null); _tableManager.BeamerScreen.Dispatcher.Invoke((Action)(() => { b4_ = (GraphicalRegion)_gfxMenu.MObject4.Clone(); }), null); b1 = b1_; b2 = b2_; b3 = b3_; b4 = b4_; }