コード例 #1
0
        private void Polygons_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (var obj in e.NewItems)
                {
                    AnnotatedPolygon poly = (AnnotatedPolygon)obj;

                    poly.MouseRightButtonUp += Poly_MouseRightButtonUp;
                    poly.PreviewTouchUp     += Poly_PreviewTouchUp;

                    CommonCanvas.Children.Insert(1, poly);
                    Canvas.SetZIndex(poly, 1);
                }
            }

            if (e.OldItems != null)
            {
                foreach (var obj in e.OldItems)
                {
                    AnnotatedPolygon poly = (AnnotatedPolygon)obj;
                    RemovePolygon(poly);
                }
            }
        }
コード例 #2
0
 private void RemovePolygon(AnnotatedPolygon poly)
 {
     poly.MouseRightButtonUp -= Poly_MouseRightButtonUp;
     poly.PreviewTouchUp     -= Poly_PreviewTouchUp;
     CommonCanvas.Children.Remove(poly);
 }
コード例 #3
0
        /// <summary>
        /// Binds the View (e.g. IInfoLayerElements that are on the CoodTranformedCanvas) to the
        /// </summary>
        /// <param name="up">Upper point of the core sample main axis</param>
        /// <param name="bottom">Bottom point of the core sample main axis</param>
        /// <param name="side">Any point that is on the side of the core sampe</param>
        /// <param name="poly">An annotated polygon, that highlights the core sample</param>
        /// <param name="vm">View Model that desribes the region</param>
        private static void BindInfoLayer(PhotoCalibrationMarker up, PhotoCalibrationMarker bottom, PhotoCalibrationMarker side, AnnotatedPolygon poly, CalibratedRegionVM vm)
        {
            vm.Up     = up.CentreLocation;
            vm.Bottom = bottom.CentreLocation;
            vm.Side   = side.CentreLocation;

            var b1 = new Binding(nameof(vm.Up));

            b1.Source = vm;
            b1.Mode   = BindingMode.TwoWay;
            up.SetBinding(PhotoCalibrationMarker.CentreLocationLocationProperty, b1);

            var b2 = new Binding(nameof(vm.Bottom));

            b2.Source = vm;
            b2.Mode   = BindingMode.TwoWay;
            bottom.SetBinding(PhotoCalibrationMarker.CentreLocationLocationProperty, b2);

            var b3 = new Binding(nameof(vm.Side));

            b3.Source = vm;
            b3.Mode   = BindingMode.TwoWay;
            side.SetBinding(PhotoCalibrationMarker.CentreLocationLocationProperty, b3);

            var visConverter = new CollapsedConverter();

            var b4 = new Binding(nameof(vm.AreMarkersVisible));

            b4.Source    = vm;
            b4.Converter = visConverter;
            up.SetBinding(UIElement.VisibilityProperty, b4);

            var b5 = new Binding(nameof(vm.AreMarkersVisible));

            b5.Source    = vm;
            b5.Converter = visConverter;
            bottom.SetBinding(UIElement.VisibilityProperty, b5);

            var b6 = new Binding(nameof(vm.AreMarkersVisible));

            b6.Source    = vm;
            b6.Converter = visConverter;
            side.SetBinding(UIElement.VisibilityProperty, b6);
        }