Exemple #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.dockPanelRoot.DataContext = imageViewModel;

            horizontalPositionConverter = (ImagePositionConverter)this.Resources["HorizontalPositionConverter"];
            horizontalPositionConverter.GetMaxImagePosition = new Func <int>(
                () => { return(this.imageViewModel.LoadedBitmapWidth); }
                );
            horizontalPositionConverter.GetMaxViewPosition = new Func <double>(
                () => { return(this.imageMain.ActualWidth); }
                );


            verticalPositionConverter = (ImagePositionConverter)this.Resources["VerticalPositionConverter"];
            verticalPositionConverter.GetMaxImagePosition = new Func <int>(
                () => { return(this.imageViewModel.LoadedBitmapHeight); }
                );
            verticalPositionConverter.GetMaxViewPosition = new Func <double>(
                () => { return(this.imageMain.ActualHeight); }
                );


            this.imageViewModel.LoadedBitmap = (BitmapImage)this.Resources["KiritoriMageHelp"];

            ImageAdorner imageAdorner = new ImageAdorner(this.imagePanel)
            {
                ImageViewModel = this.imageViewModel,
                HorizontalPositionConverter = horizontalPositionConverter,
                VerticalPositionConverter   = verticalPositionConverter
            };

            imageAdornerLayer = AdornerLayer.GetAdornerLayer(this.imagePanel);
            imageAdornerLayer.Add(imageAdorner);

            // mainly for generating a new point
            imageViewModel.RangeDataUpdated += new EventHandler((sender1, e1) => {
                imageAdornerLayer.Update();
            });

            this.Width  = Properties.Settings.Default.WindowWidth;
            this.Height = Properties.Settings.Default.WindowHeight;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.dockPanelRoot.DataContext = imageViewModel;

            horizontalPositionConverter = (ImagePositionConverter)this.Resources["HorizontalPositionConverter"];
            horizontalPositionConverter.GetMaxImagePosition = new Func<int>(
                () => { return this.imageViewModel.LoadedBitmapWidth; }
            );
            horizontalPositionConverter.GetMaxViewPosition = new Func<double>(
                () => { return this.imageMain.ActualWidth; }
            );

            verticalPositionConverter = (ImagePositionConverter)this.Resources["VerticalPositionConverter"];
            verticalPositionConverter.GetMaxImagePosition = new Func<int>(
                () => { return this.imageViewModel.LoadedBitmapHeight; }
            );
            verticalPositionConverter.GetMaxViewPosition = new Func<double>(
                () => { return this.imageMain.ActualHeight; }
            );

            this.imageViewModel.LoadedBitmap = (BitmapImage)this.Resources["KiritoriMageHelp"];

            ImageAdorner imageAdorner = new ImageAdorner(this.imagePanel)
            {
                ImageViewModel = this.imageViewModel,
                HorizontalPositionConverter = horizontalPositionConverter,
                VerticalPositionConverter = verticalPositionConverter
            };

            imageAdornerLayer = AdornerLayer.GetAdornerLayer(this.imagePanel);
            imageAdornerLayer.Add(imageAdorner);

            // mainly for generating a new point
            imageViewModel.RangeDataUpdated += new EventHandler((sender1, e1) => {
                imageAdornerLayer.Update();
            });

            this.Width = Properties.Settings.Default.WindowWidth;
            this.Height = Properties.Settings.Default.WindowHeight;
        }