示例#1
0
        private void ImageBrowser_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog
            {
                Filter      = "Image files (*.jpg, *.jpeg, *.jpe, *.png) | *.jpg; *.jpeg; *.jpe; *.png",
                Title       = "Open Image",
                Multiselect = false
            };

            if (dialog.ShowDialog() == true)
            {
                var url    = dialog.FileName;
                var image  = new BitmapImage(new Uri(url));
                var height = image.Height;
                var width  = image.Width;

                DESIGN_FixedPage.Width  = DESIGN_Image.Width = DESIGN_Canvas.Width = width;
                DESIGN_FixedPage.Height = DESIGN_Image.Height = DESIGN_Canvas.Height = height;
                dragDropHandler.RemoveEventHandlers();
                dragDropHandler = new BasicDesignControlDragDropHandler(DESIGN_Canvas)
                {
                    ConstraintArea     = new Point(width, height),
                    ConstraintToBounds = true
                };
                DESIGN_Image.Source = image;
                DESIGN_Canvas.Children.Clear();
            }
        }
示例#2
0
        public void LoadSavedDesign()
        {
            /// TODO: Defined XAML for this designer is as same as the one in
            /// <see cref="Dashboard.UI.Assets.PrintAssets.PrintResource"/>. Make them a
            /// Single one to handle it better. See Bookmarks with tag #XAML_DESIGN_DUP for more info

            var  conf           = App.CurrentApp.AppConfiguration.DesignModel;
            bool isDefaultImage = string.IsNullOrEmpty(conf.ImageBackgroundSource);
            var  imgUri         = isDefaultImage ?
                                  "pack://application:,,,/Dashboard;component/Resources/Images/ReportDefault - NO.png" : conf.ImageBackgroundSource;
            var image  = new BitmapImage(new Uri(imgUri));
            var height = image.Height;
            var width  = image.Width;

            DESIGN_FixedPage.Width  = DESIGN_Image.Width = DESIGN_Canvas.Width = width;
            DESIGN_FixedPage.Height = DESIGN_Image.Height = DESIGN_Canvas.Height = height;

            DESIGN_Image.Source = image;
            dragDropHandler     = new BasicDesignControlDragDropHandler(DESIGN_Canvas)
            {
                ConstraintToBounds = true,
                ConstraintArea     = new Point(DESIGN_Image.Width, DESIGN_Image.Height)
            };

            foreach (var item in conf.Textboxes)
            {
                var textblock = new BindableTextBlock(item.Type)
                {
                    Width          = item.Width,
                    Height         = item.Height,
                    Tag            = (item.IsBound) ? $"BINDTO:{item.BindingTag}" : "",
                    Text           = item.Text,
                    TextFontWeight = item.Type == BindableTextType.Normal ? FontWeights.Bold : FontWeights.Normal,
                    Designing      = true
                };
                if (item.IsBound)
                {
                    SetBinding(BindableTextBlock.TextProperty, item.BindingTag);
                }
                DESIGN_Canvas.Children.Add(textblock);
                Canvas.SetLeft(textblock, item.CanvasLeft);
                Canvas.SetTop(textblock, item.CanvasTop);
            }

            if (isDefaultImage)
            {
                Slider.Value = 60;
            }
        }