public VirtualSchemaContainer() { // InitializeComponent(); scroller = new ScrollViewer(); scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; scroller.CanContentScroll = true; Child = scroller; grid = new VirtualCanvas(); scroller.Content = grid; grid.SmallScrollIncrement = new Size(_tileWidth + _tileMargin, _tileHeight + _tileMargin); //Scroller.Content = grid; object v = scroller.GetValue(ScrollViewer.CanContentScrollProperty); Canvas target = grid.ContentCanvas; zoom = new MapZoom(target); pan = new Pan(target, zoom); rectZoom = new RectangleSelectionGesture(target, zoom, System.Windows.Input.ModifierKeys.Control); rectZoom.ZoomSelection = true; autoScroll = new AutoScroll(target, zoom); zoom.ZoomChanged += new EventHandler(OnZoomChanged); grid.VisualsChanged += new EventHandler <VisualChangeEventArgs>(OnVisualsChanged); //ZoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(OnZoomSliderValueChanged); grid.Scale.Changed += new EventHandler(OnScaleChanged); grid.Translate.Changed += new EventHandler(OnScaleChanged); grid.Background = new SolidColorBrush(Color.FromRgb(0xd0, 0xd0, 0xd0)); grid.ContentCanvas.Background = Brushes.White; }
public UIElement CreateVisual(VirtualCanvas parent) { if (_visual == null) { _visual = _el; Func <DependencyProperty, bool> f = p => { Binding b = BindingOperations.GetBinding(_visual, p); if (b.Source is ChannelDataProvider) { (b.Source as ChannelDataProvider).StopUpdate = false; Debug.WriteLine((b.Source as ChannelDataProvider).ChannelName + "Created"); (b.Source as ChannelDataProvider).Refresh(); } return(true); }; /* * foreach (DependencyProperty p in dict.Keys) * { * BindingOperations.SetBinding(_visual, p, dict[p]); * }*/ EnumerateBindings(_visual, f); } return(_visual); }
public Size MeasureText(VirtualCanvas parent, string label) { if (_parent != parent) { FontFamily fontFamily = (FontFamily)parent.GetValue(TextBlock.FontFamilyProperty); FontStyle fontStyle = (FontStyle)parent.GetValue(TextBlock.FontStyleProperty); FontWeight fontWeight = (FontWeight)parent.GetValue(TextBlock.FontWeightProperty); FontStretch fontStretch = (FontStretch)parent.GetValue(TextBlock.FontStretchProperty); _fontSize = (double)parent.GetValue(TextBlock.FontSizeProperty); _typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); _parent = parent; } FormattedText ft = new FormattedText(label, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, _typeface, _fontSize, Brushes.Black); return(new Size(ft.Width, ft.Height)); }
public FrameworkElement CreateVisual(VirtualCanvas parent) { if (_visual == null) { _visual = _el; Func <DependencyProperty, bool> f = p => { Binding b = BindingOperations.GetBinding(_visual, p); if (b != null && b.Source is ChannelDataProvider) { (b.Source as ChannelDataProvider).StopUpdate = false; (b.Source as ChannelDataProvider).Refresh(); } return(true); }; EnumerateBindings(_visual, f); } return(_visual); }