示例#1
0
        private Button createCategoryButton(Category iCat)
        {
            int random = getrandom.Next(0, 5);
            List<string> colours = new List<string>();
            colours.Add("#D2691E");
            colours.Add("#da542e");
            colours.Add("#92009c");
            colours.Add("#029801");
            colours.Add("#2396A6");
            colours.Add("#593D91");
            // main image contain
            
            StackPanel dock = new StackPanel();
            dock.Orientation = Orientation.Vertical;
            dock.Height = 100;
            dock.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            /// creating image
            Image img = new Image();
            img.Width = 40;
            img.Height = 40;
            img.Source = new BitmapImage(new Uri(@"../Resources/folder.png", UriKind.Relative));
            dock.Children.Add(img);
            
            Label lb = new Label();
            lb.Content = iCat.name.ToString() + "\n" + "Files(" + iCat.getFileCount().ToString() + ")";
            dock.Children.Add(lb);

            var x = new Button();
            //x.Title = iCat.name.ToString();
            x.Content = dock;
            //x.Count = iCat.getFileCount().ToString();
            //x.CountFontSize = 10;

            x.Tag = iCat.id;
            //x.Background = new SolidColorBrush((Color)(ColorConverter.ConvertFromString(colours[random])));
            x.Background = null;
            x.BorderThickness = new Thickness(0);
            x.Click += this.selectCategory;
            x.MouseDoubleClick += this.clickCategory;

            x.Height = 100;
            x.Width = 140;
            //x.TitleFontSize = 13;
            x.FontSize = 11;
            x.Margin = new Thickness(5);
            x.Padding = new Thickness(2);

            return x;
        }