示例#1
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (gridStudio.Children.Count < 1)
     {
         PrintClientConfig printClientConfig = XmlHelper.GetClientConfig(AppDomain.CurrentDomain.BaseDirectory + "ClientConfig.xml");
         if (printClientConfig != null)
         {
             PrintItemControl             p = null;
             List <PrintItemControlModel> printItemControls = printClientConfig.PrintItemControls;
             if (printItemControls != null)
             {
                 foreach (PrintItemControlModel item in printItemControls)
                 {
                     p = new PrintItemControl()
                     {
                         Name = item.Name, Caption = item.Caption, Value = item.Value
                     };
                     p.OnRemoveClick += new RoutedEventHandler(p_OnRemoveClick);
                     gridStudio.Children.Add(p);
                 }
             }
             txtPrintX.Text            = printClientConfig.X.ToString();
             txtPrintY.Text            = printClientConfig.Y.ToString();
             cbPrintType.SelectedIndex = printClientConfig.PrintTypeIndex;
             cbPrintName.SelectedIndex = printClientConfig.PrintNameIndex;
         }
     }
 }
示例#2
0
        /// <summary>
        /// 右键菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contentMenuShow_MenuItemClicked(object sender, RoutedEventArgs e)
        {
            MenuItem mi   = sender as MenuItem;
            int      flag = (int)mi.Tag;

            if (flag == 1000)
            {
                AddPrintItemControl a = new AddPrintItemControl();
                a.Owner = App.Current.MainWindow;
                a.ShowDialog();
                if (a.DialogResult == true)
                {
                    PrintItemControl p = a.UserPrintItem;
                    p.OnRemoveClick += new RoutedEventHandler(p_OnRemoveClick);
                    foreach (UIElement item in gridStudio.Children)
                    {
                        if (item is PrintItemControl)
                        {
                            if ((item as PrintItemControl).Name == p.Name)
                            {
                                MessageBox.Show(string.Format("已存在名称为:{0}的输入控件.", p.Name));
                                return;
                            }
                        }
                    }
                    gridStudio.Children.Add(p);
                }
            }
        }
示例#3
0
        /// <summary>
        /// 客户端配置界面保存
        /// </summary>
        public void SaveInterface()
        {
            PrintClientConfig            printClientConfig = new PrintClientConfig();
            List <PrintItemControlModel> printItemControls = new List <PrintItemControlModel>();

            foreach (UIElement item in gridStudio.Children)
            {
                if (item is PrintItemControl)
                {
                    PrintItemControl temp = item as PrintItemControl;
                    printItemControls.Add(new PrintItemControlModel()
                    {
                        Caption = temp.Caption,
                        Name    = temp.Name,
                        Value   = temp.Value
                    });
                }
            }
            printClientConfig.X = int.Parse(txtPrintX.Text);
            printClientConfig.Y = int.Parse(txtPrintY.Text);
            printClientConfig.PrintTypeIndex    = cbPrintType.SelectedIndex;
            printClientConfig.PrintNameIndex    = cbPrintName.SelectedIndex;
            printClientConfig.PrintItemControls = printItemControls;
            XmlHelper.SaveClientConfig(printClientConfig, AppDomain.CurrentDomain.BaseDirectory + "ClientConfig.xml");
        }
示例#4
0
 private void btnSure_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tbName.Text))
     {
         MessageBox.Show("请填写Name.");
         return;
     }
     if (string.IsNullOrWhiteSpace(tbCaption.Text))
     {
         MessageBox.Show("请填写Caption.");
         return;
     }
     UserPrintItem = new PrintItemControl()
     {
         Name = tbName.Text, Caption = tbCaption.Text
     };
     this.DialogResult = true;
 }