Exemplo n.º 1
0
        public KnowledgeWiki()
        {
            InitializeComponent();
            viewModel   = new KnowledgeWikiViewModel();
            DataContext = viewModel;

            foreach (var knowledge in viewModel.Knowledges)
            {
                Button button = new Button();
                button.Content = $" {knowledge.Knowledge} ";
                //button.Width = 160;
                button.Height = 40;
                button.Margin = new Thickness(10, 5, 10, 5);
                button.Name   = "btn" + knowledge.Id.Replace("-", "");
                button.Tag    = knowledge;
                Binding binding = new Binding()
                {
                    Source = knowledge,
                    Path   = new PropertyPath("Visibility"),
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };
                BindingOperations.SetBinding(button, Button.VisibilityProperty, binding);
                ButtonHelper.SetButtonStyle(button, ButtonStyle.Hollow);
                ButtonHelper.SetClickStyle(button, ClickStyle.Sink);
                ButtonHelper.SetCornerRadius(button, new CornerRadius(4));
                ButtonHelper.SetHoverBrush(button, "#00BCFF".ToColor().ToBrush());
                button.BorderBrush = "#20A0FF".ToColor().ToBrush();
                button.Foreground  = "#20A0FF".ToColor().ToBrush();
                button.Click      += Button_Click;
                this.content.Children.Add(button);
            }
        }
Exemplo n.º 2
0
        private void RdbButtonStyle_CheckChanged(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }
            var rdb = sender as RadioButton;

            ButtonHelper.SetButtonStyle(BtnCustom, (ButtonStyle)Enum.Parse(typeof(ButtonStyle), rdb.Content.ToString()));
            UpdateTemplate();
            UpdateCode();
        }
Exemplo n.º 3
0
 private void ChbExtendControl_CheckChanged(object sender, RoutedEventArgs e)
 {
     if (ChbExtendControl.IsChecked != true)
     {
         GroupBoxHelper.SetExtendControl(GrpCustom, null);
     }
     else
     {
         var button = new Button()
         {
             Content    = "details >",
             Margin     = new Thickness(0, 0, 5, 0),
             Foreground = "#AA57A2E0".ToColor().ToBrush()
         };
         ButtonHelper.SetButtonStyle(button, ButtonStyle.Link);
         ButtonHelper.SetHoverBrush(button, "#57A2E0".ToColor().ToBrush());
         GroupBoxHelper.SetExtendControl(GrpCustom, button);
     }
 }
Exemplo n.º 4
0
        private bool AddColtrols(int addWhat, int[] things, String anothers1)
        {
            /* addWhat - 创建什么, another,anothers - 其他数据
             * 1 - 普通卡片
             * 2 - 普通事件
             */
            if (addWhat == 1)
            {
                Card        card        = new Card();
                StackPanel  stackPanel  = new StackPanel();
                Grid        grid        = new Grid();
                TextBlock   textBlock   = new TextBlock();
                Button      button      = new Button();
                ListView    listView    = new ListView();
                ContextMenu contextMenu = new ContextMenu();
                MenuItem    menuItem1   = new MenuItem();
                MenuItem    menuItem2   = new MenuItem();
                MenuItem    menuItem3   = new MenuItem();

                menuItem1.Name   = "MenuItem1";
                menuItem1.Header = "删除卡片";
                menuItem1.Icon   = "";
                menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(CD_Del);
                contextMenu.Items.Add(menuItem1);

                contextMenu.Width      = 150;
                contextMenu.Background = baseColora.Card;
                contextMenu.Foreground = baseColora.Fg;
                ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color);
                ContextMenuHelper.SetItemHeight(contextMenu, 30);

                textBlock.ContextMenu             = contextMenu;
                card.ContextMenu                  = contextMenu;
                card.PreviewMouseRightButtonDown += WhatFuckOpenMeMe;

                textBlock.Text = things[0] + ". " + anothers1;
                textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                textBlock.TextWrapping        = TextWrapping.Wrap;
                textBlock.Margin     = new Thickness(34, 25, 34, 10);
                textBlock.Foreground = baseColora.Fg;
                textBlock.FontFamily = baseColora.Fonts;
                textBlock.FontSize   = 15;

                button.Foreground          = baseColora.Fg;
                button.Margin              = new Thickness(0, 10, 15, 0);
                button.Name                = "BCDD" + things[0];
                button.Width               = 30;
                button.Click              += DelCard_Click;
                button.HorizontalAlignment = HorizontalAlignment.Right;
                ButtonHelper.SetIcon(button, "");
                IconHelper.SetFontSize(button, 16);
                ButtonHelper.SetButtonStyle(button, ButtonStyle.Link);

                card.Name       = "CDD" + things[0];
                card.Margin     = new Thickness(5, 15, 20, 5);
                card.Width      = 540;
                card.Background = baseColora.Card;

                grid.Children.Add(textBlock);
                grid.Children.Add(button);
                stackPanel.Children.Add(grid);
                card.Content = stackPanel;
                ScrollViewerHelper.SetScrollBarCornerRadius(listView, new CornerRadius(3));
                stackPanel.Children.Add(listView);
                MainIn.Children.Add(card);

                RegisterName("CDD" + things[0], card);
            }
            else if (addWhat == 2)
            {
                Card card = GetChildObjects <Card>(MainIn, "CDD" + things[1].ToString());
                if (card == null)
                {
                    this.RunCard.Visibility = Visibility.Visible;
                    error.ErrorTo("创建控件失败,未找到分类卡片。", Percent, Errorsay);
                    error.logWriter("Tool -7:未找到分类卡片。卡片名称:CDD" + things[1], false);
                    return(false);
                }
                List <StackPanel> lstControl = GetChildObjects <StackPanel>(card, typeof(StackPanel));
                if (lstControl == null)
                {
                    this.RunCard.Visibility = Visibility.Visible;
                    error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件。", Percent, Errorsay);
                    error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件。卡片名称:CDD" + things[1], false);
                    return(false);
                }
                List <ListView> lstControl1 = GetChildObjects <ListView>(lstControl[0], typeof(ListView));
                if (lstControl1 == null)
                {
                    this.RunCard.Visibility = Visibility.Visible;
                    error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件中的列表控件。", Percent, Errorsay);
                    error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件中的列表控件。卡片名称:CDD" + things[1], false);
                    return(false);
                }
                ContextMenu contextMenu = new ContextMenu();
                MenuItem    menuItem1   = new MenuItem();
                MenuItem    menuItem2   = new MenuItem();
                MenuItem    menuItem3   = new MenuItem();

                menuItem1.Name   = "MenuItem1";
                menuItem1.Header = "完成";
                menuItem1.Icon   = "";
                menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Fin);
                contextMenu.Items.Add(menuItem1);
                menuItem2.Name   = "MenuItem2";
                menuItem2.Header = "删除";
                menuItem2.Icon   = "";
                menuItem2.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Del);
                if (things[2] == 0)
                {
                    contextMenu.Items.Add(menuItem2);
                }

                contextMenu.Width      = 150;
                contextMenu.Background = baseColora.Card;
                contextMenu.Foreground = baseColora.Fg;
                ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color);
                ContextMenuHelper.SetItemHeight(contextMenu, 30);

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Name        = "CDD" + things[1] + "IT" + things[0];
                listViewItem.ContextMenu = contextMenu;
                listViewItem.PreviewMouseRightButtonDown += WhatFuckOpenMe;
                TextBlock textBlock = new TextBlock();
                textBlock.Text       = anothers1;
                textBlock.Background = baseColora.Tran;
                textBlock.FontFamily = baseColora.Fonts;
                textBlock.Foreground = baseColora.Font;
                textBlock.FontSize   = 15;
                textBlock.Margin     = new Thickness(38, 5, 38, 5);

                listViewItem.Content = textBlock;
                lstControl1[0].Items.Add(listViewItem);
            }
            return(true);
        }