Beispiel #1
0
        void ContentMenuShow_MenuItemClicked(object sender, RoutedEventArgs e)
        {
            MenuItem mi   = sender as MenuItem;
            int      flag = (int)mi.Tag;

            if (flag == 1002)
            {
                canvasSpace.Children.Clear();
                OnPrintControlPropertyEvent(null, null);
                return;
            }
            else if (flag == 1003)
            {
                AddPrintCanvas a = new AddPrintCanvas(PrintLable);
                a.Owner = App.Current.MainWindow;
                a.ShowDialog();
                if (a.DialogResult == true)
                {
                    PrintLable = a.PrintLable;
                    AddOrUpdatePrintLable(PrintLable, false);
                }
            }
            if (OnCanvasContentMenuEvent != null)
            {
                OnCanvasContentMenuEvent(sender, null);
            }
        }
Beispiel #2
0
 public AddPrintCanvas(PrintLableModel printLable)
 {
     InitializeComponent();
     if (printLable != null)
     {
         tbWidth.Text  = ((printLable.Width * 127 / 1500.0)).ToString();
         tbHeight.Text = ((printLable.Height * 127 / 1500.0)).ToString();
     }
 }
Beispiel #3
0
        private void btnSure_Click(object sender, RoutedEventArgs e)
        {
            double result = 0;

            PrintLable = new PrintLableModel();
            if (string.IsNullOrWhiteSpace(tbWidth.Text))
            {
                MessageBox.Show("请填写Caption.");
                return;
            }
            else
            {
                if (double.TryParse(tbWidth.Text, out result))
                {
                    //300打印机 1dot=25.4/300mm
                    //203打印机 1dot=25.4/203mm
                    //将实际标签尺寸转成以打印机dot为单位的尺寸,即y=x*300/25.4
                    //这里生成的是y dot,但PrintLable.Width是WPF单位,实际界面呈现时会等比例放大或缩小z.
                    //幸运的是,并不影响使用,因为条码控件本身就是WPF类型控件,其界面呈现时与打印机单位相比也会等比例放大或缩小z.
                    //如果是200点的打印机,那么在这里更改缩放比例即可.即result * 203 / 25.4.
                    //就是说通过调整界面呈现大小,来适应不同打印设备.
                    PrintLable.Width = ((result * 1500 / 127.0));
                }
                else
                {
                    MessageBox.Show("请正确填写标签Width.");
                    return;
                }
            }
            if (string.IsNullOrWhiteSpace(tbHeight.Text))
            {
                MessageBox.Show("请填写Caption.");
                return;
            }
            else
            {
                if (double.TryParse(tbHeight.Text, out result))
                {
                    PrintLable.Height = ((result * 1500 / 127.0));
                }
                else
                {
                    MessageBox.Show("请正确填写标签Height.");
                    return;
                }
            }
            this.DialogResult = true;
        }
Beispiel #4
0
 private void AddOrUpdatePrintLable(PrintLableModel printLable, bool isAdd)
 {
     if (printLable != null)
     {
         if (isAdd)
         {
             canvasSpace.Children.Clear();
             borderWork.Width  = printLable.Width;
             borderWork.Height = printLable.Height;
         }
         else
         {
             borderWork.Width  = printLable.Width;
             borderWork.Height = printLable.Height;
         }
         ZoomableCanvasScale = 4;
         tbScale.Text        = string.Format("{0}*", ScaleList[ZoomableCanvasScale]);
     }
 }
Beispiel #5
0
 private void btnNew_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (canvasSpace.Children.Count > 0 || xmlPath != string.Empty)
         {
             if (System.Windows.MessageBox.Show(string.Format("是否保存当前打印信息?"), "警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 if (string.IsNullOrWhiteSpace(xmlPath))
                 {
                     My.SaveFileDialog saveFileDialog = new My.SaveFileDialog();
                     saveFileDialog.Filter = "All(*.xml)|*.xml";
                     if (saveFileDialog.ShowDialog() == My.DialogResult.OK)
                     {
                         xmlPath = saveFileDialog.FileName;
                     }
                     else
                     {
                         return;
                     }
                 }
                 SaveInterfaceToXML(xmlPath);
             }
         }
         xmlPath = string.Empty;
         AddPrintCanvas a = new AddPrintCanvas(null);
         a.Owner = App.Current.MainWindow;
         a.ShowDialog();
         if (a.DialogResult == true)
         {
             PrintLable = a.PrintLable;
             AddOrUpdatePrintLable(PrintLable, true);
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(string.Format("新建异常:{0}", ex.Message));
     }
 }