Beispiel #1
0
        private void SetAnimationForIconLeave(PackIcon icon)
        {
            DoubleAnimation animation = new DoubleAnimation();

            animation.From     = 0.5;
            animation.To       = 1;
            animation.Duration = TimeSpan.FromSeconds(0.05);
            icon.BeginAnimation(OpacityProperty, animation);
        }
        private void GenerateXml(A4_Paper paper)
        {
            Grid      outerGrid = new Grid();
            Grid      innerGrid = new Grid();
            Rectangle rectangle = new Rectangle();
            //Border border = new Border();
            //Image image = new Image();
            Button buttonPrint  = new Button();
            Button buttonFolder = new Button();

            outerGrid.Width = 400;

            rectangle.Height            = 200;
            rectangle.VerticalAlignment = VerticalAlignment.Top;
            rectangle.Margin            = new Thickness(10, 10, 10, 10);
            rectangle.RadiusX           = 10;
            rectangle.RadiusY           = 10;
            rectangle.Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255));
            DropShadowEffect effect = new DropShadowEffect();

            effect.BlurRadius    = 15;
            effect.Direction     = 0;
            effect.RenderingBias = RenderingBias.Performance;
            effect.ShadowDepth   = 1;
            effect.Color         = Color.FromRgb(187, 187, 187);
            rectangle.Effect     = effect;

            #region
            //border.Width = 210;
            //border.Height = 150;
            //border.BorderThickness = new Thickness(1, 1, 1, 1);
            //border.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
            //border.VerticalAlignment = VerticalAlignment.Top;
            //border.Margin = new Thickness(0, 30, 0, 0);

            //var bitmap = new BitmapImage(new Uri(filePath));
            //image.Source = bitmap;
            //image.Width = 200;
            //image.Height = 150;
            //image.VerticalAlignment = VerticalAlignment.Top;
            #endregion


            ColumnDefinition gridCol1 = new ColumnDefinition();
            ColumnDefinition gridCol2 = new ColumnDefinition();
            RowDefinition    gridRow1 = new RowDefinition();
            RowDefinition    gridRow2 = new RowDefinition();

            innerGrid.RowDefinitions.Add(gridRow1);
            innerGrid.RowDefinitions.Add(gridRow2);
            innerGrid.ColumnDefinitions.Add(gridCol1);
            innerGrid.ColumnDefinitions.Add(gridCol2);


            innerGrid.Width             = 200;
            innerGrid.Height            = 150;
            innerGrid.VerticalAlignment = VerticalAlignment.Top;
            innerGrid.Margin            = new Thickness(0, 30, 0, 0);;


            for (int i = 0; i < paper.Cards.Length; i++)
            {
                int row    = 0;
                int column = 0;
                switch (i)
                {
                case 0:
                    row    = 0;
                    column = 0;
                    break;

                case 1:
                    row    = 0;
                    column = 1;
                    break;

                case 2:
                    row    = 1;
                    column = 0;
                    break;

                case 3:
                    row    = 1;
                    column = 1;
                    break;
                }
                var grid = AddCardToInnerGrid(paper.Cards[i]);
                innerGrid.Children.Add(grid);
                Grid.SetColumn(grid, column);
                Grid.SetRow(grid, row);
            }


            buttonPrint.Style = Resources["PrintButtonStyle"] as Style;
            var icon = new PackIcon {
                Kind = PackIconKind.Printer
            };
            icon.Width          = 30;
            icon.Height         = 30;
            icon.Foreground     = new SolidColorBrush(Color.FromRgb(255, 255, 255));
            buttonPrint.Content = icon;

            //button.Name = "name";
            buttonPrint.Click += (sender, routeEventArgs) =>
            {
                var btn = sender as Button;

                btn.Style = Resources["PrintButtonStyleDone"] as Style;
                var btnIcon = new PackIcon {
                    Kind = PackIconKind.Done
                };
                btnIcon.Width       = 0;
                btnIcon.Height      = 0;
                btnIcon.Foreground  = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                buttonPrint.Content = btnIcon;

                DoubleAnimation iconWidthAnimation = new DoubleAnimation();
                iconWidthAnimation.From     = 0;
                iconWidthAnimation.To       = 30;
                iconWidthAnimation.Duration = TimeSpan.FromMilliseconds(100);

                DoubleAnimation iconHeightAnimation = new DoubleAnimation(0, 30, TimeSpan.FromMilliseconds(100));

                iconHeightAnimation.Completed += delegate(Object c, EventArgs d)
                {
                    Process objProcess = new Process();
                    objProcess.StartInfo.FileName  = "explorer";
                    objProcess.StartInfo.Arguments = GlobalVariables.tempFolderPrint + paper.PaperName;
                    objProcess.Start();
                };

                btnIcon.BeginAnimation(Image.WidthProperty, iconWidthAnimation);
                btnIcon.BeginAnimation(Image.HeightProperty, iconHeightAnimation);
            };


            buttonFolder.Style = Resources["OpenImageButtonStyle"] as Style;
            var icon_buttonFolder = new PackIcon {
                Kind = PackIconKind.FolderImage
            };
            icon_buttonFolder.Width      = 25;
            icon_buttonFolder.Height     = 25;
            icon_buttonFolder.Foreground = new SolidColorBrush(Color.FromRgb(136, 136, 136));
            buttonFolder.Content         = icon_buttonFolder;

            //button.Name = "name";
            buttonFolder.Click += (a, b) =>
            {
                Process objProcess = new Process();
                objProcess.StartInfo.FileName  = "explorer";
                objProcess.StartInfo.Arguments = GlobalVariables.tempFolderPrint;
                objProcess.Start();
            };

            StackPanel topMarginPanel = new StackPanel();
            topMarginPanel.Height = 10;

            StackPanel buttomMarginPanel = new StackPanel();
            buttomMarginPanel.Height = 30;

            outerGrid.Children.Add(rectangle);

            //border.Child = image;
            //outerGrid.Children.Add(border);
            outerGrid.Children.Add(buttonPrint);
            outerGrid.Children.Add(buttonFolder);
            outerGrid.Children.Add(innerGrid);

            PrintListContainer.Children.Add(topMarginPanel);
            PrintListContainer.Children.Add(outerGrid);
            PrintListContainer.Children.Add(buttomMarginPanel);
        }