Browse Source

打印

tags/录制修改前
zhangxueyang 4 years ago
parent
commit
d6d7b769b4

+ 57
- 1
Common/system/BlackboardNew.cs View File

327
                 if(stroke!=null&&stroke.StylusPoints.Count > 1)
327
                 if(stroke!=null&&stroke.StylusPoints.Count > 1)
328
                 {
328
                 {
329
                     m_canvas.Strokes.Add(stroke);
329
                     m_canvas.Strokes.Add(stroke);
330
-                   
331
                 }
330
                 }
332
             
331
             
333
                 stylusPoints = new StylusPointCollection();
332
                 stylusPoints = new StylusPointCollection();
354
 
353
 
355
 
354
 
356
 
355
 
356
+        }
357
+        //声明一个 DrawingAttributes 类型的变量  
358
+        DrawingAttributes drawingAttributes;
359
+        public void changepaget(double _x, double _y, bool _new,InkCanvas canvas) 
360
+        {
361
+            if (_new)
362
+            {
363
+                if (stroke != null && stroke.StylusPoints.Count > 1)
364
+                {
365
+                    //m_canvas.Strokes.Add(stroke);
366
+                    DrawingAttributes drawingAttributes = new DrawingAttributes();
367
+                    canvas.DefaultDrawingAttributes = drawingAttributes;
368
+                    drawingAttributes.Width = pensize;
369
+                    drawingAttributes.Height = pensize;
370
+                    drawingAttributes.Color = Colors.Red;
371
+                    drawingAttributes.FitToCurve = true;
372
+                    drawingAttributes.IgnorePressure = false;
373
+                
374
+                    canvas.Strokes.Add(stroke);
375
+                    canvas.DefaultDrawingAttributes = drawingAttributes;
376
+                    ZBBPage page = strokes_page_all[pagenum];
377
+                    if (page != null)
378
+                    {
379
+                        step.lines_curr.Add(m_canvas.Strokes);
380
+                        page.lines.Add(step);
381
+                        step = null;
382
+                    }
383
+                }
384
+
385
+                stylusPoints = new StylusPointCollection();
386
+                stylusPoint = new StylusPoint();
387
+                //stroke = new Stroke(stylusPoints);
388
+                stroke = null;
389
+            }
390
+            else
391
+            {
392
+                //stylusPoints = new StylusPointCollection();
393
+                //stylusPoint = new StylusPoint();
394
+                stylusPoint.X = _x;
395
+                stylusPoint.Y = _y;
396
+                stylusPoints.Add(stylusPoint);
397
+                stroke = new Stroke(stylusPoints);
398
+                //m_canvas.
399
+
400
+                //page.lines.Last().lines_curr
401
+               
402
+            }
403
+
404
+
405
+            //page.lines.Last().lines_curr.Add();
406
+            //if (stroke.StylusPoints.Count > 20)
407
+            //{
408
+
409
+
410
+
411
+
412
+
357
         }
413
         }
358
     }
414
     }
359
 }
415
 }

+ 52
- 20
XHWK.WKTool/PracticeWindow.xaml.cs View File

31
         /// </summary>
31
         /// </summary>
32
         private int flg = 0;
32
         private int flg = 0;
33
         /// <summary>
33
         /// <summary>
34
-        /// 
34
+        /// 当前画笔颜色
35
         /// </summary>
35
         /// </summary>
36
         Color Colour=Colors.Black;
36
         Color Colour=Colors.Black;
37
+        /// <summary>
38
+        /// 当前画笔宽
39
+        /// </summary>
40
+        private int Wit = 2;
41
+        /// <summary>
42
+        /// 当前画笔高
43
+        /// </summary>
44
+        private int Hei = 2;
37
         public PracticeWindow()
45
         public PracticeWindow()
38
         {
46
         {
39
             InitializeComponent();
47
             InitializeComponent();
50
             }
58
             }
51
 
59
 
52
 
60
 
53
-        
54
-
55
-
56
 
61
 
57
 
62
 
58
-            ////创建 DrawingAttributes 类的一个实例  
59
-            //drawingAttributes = new DrawingAttributes();
63
+            //创建 DrawingAttributes 类的一个实例  
64
+            drawingAttributes = new DrawingAttributes();
60
 
65
 
61
             //drawingAttributes.StylusTip = StylusTip.Rectangle;
66
             //drawingAttributes.StylusTip = StylusTip.Rectangle;
62
             //drawingAttributes.IsHighlighter = false;
67
             //drawingAttributes.IsHighlighter = false;
66
 
71
 
67
             ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
72
             ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
68
             ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型  
73
             ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型  
69
-            //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
70
-            //Pen();
74
+            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
75
+            Pen();
71
             //blackboard_canvas.Cursor = Cursors.Pen;
76
             //blackboard_canvas.Cursor = Cursors.Pen;
72
 
77
 
73
 
78
 
89
         /// <param name="e"></param>
94
         /// <param name="e"></param>
90
         public void White()
95
         public void White()
91
         {
96
         {
92
-            flg = 0;
97
+            //flg = 0;
93
             drawingAttributes.Color = Colors.White;
98
             drawingAttributes.Color = Colors.White;
99
+            Colour= Colors.White; 
94
         }
100
         }
95
         /// <summary>
101
         /// <summary>
96
         /// 画笔颜色事件 红色
102
         /// 画笔颜色事件 红色
99
         /// <param name="e"></param>
105
         /// <param name="e"></param>
100
         public void Red()
106
         public void Red()
101
         {
107
         {
102
-            flg = 0;
108
+            //flg = 0;
103
             //设置 DrawingAttributes 的 Color 属性设置颜色  
109
             //设置 DrawingAttributes 的 Color 属性设置颜色  
104
             drawingAttributes.Color = Colors.Red;
110
             drawingAttributes.Color = Colors.Red;
111
+            Colour = Colors.Red;
105
         }
112
         }
106
         /// <summary>
113
         /// <summary>
107
         /// 画笔颜色事件 灰色
114
         /// 画笔颜色事件 灰色
110
         /// <param name="e"></param>
117
         /// <param name="e"></param>
111
         public void Gray()
118
         public void Gray()
112
         {
119
         {
113
-            flg = 0;
120
+            //flg = 0;
114
             drawingAttributes.Color = Colors.Gray;
121
             drawingAttributes.Color = Colors.Gray;
122
+            Colour = Colors.Gray;
115
         }
123
         }
116
         /// <summary>
124
         /// <summary>
117
         /// 画笔颜色事件 青色
125
         /// 画笔颜色事件 青色
120
         /// <param name="e"></param>
128
         /// <param name="e"></param>
121
         public void CyanBlue()
129
         public void CyanBlue()
122
         {
130
         {
123
-            flg = 0;
131
+            //flg = 0;
124
             drawingAttributes.Color = Colors.LimeGreen;
132
             drawingAttributes.Color = Colors.LimeGreen;
133
+            Colour = Colors.LimeGreen;
125
         }
134
         }
126
         /// <summary>
135
         /// <summary>
127
         /// 画笔颜色事件 黄色
136
         /// 画笔颜色事件 黄色
130
         /// <param name="e"></param>
139
         /// <param name="e"></param>
131
         public void Yellow()
140
         public void Yellow()
132
         {
141
         {
133
-            flg = 0;
142
+            //flg = 0;
134
             drawingAttributes.Color = Colors.Gold;
143
             drawingAttributes.Color = Colors.Gold;
144
+            Colour = Colors.Gold;
135
         }
145
         }
136
         /// <summary>
146
         /// <summary>
137
         /// 画笔颜色事件 蓝色
147
         /// 画笔颜色事件 蓝色
140
         /// <param name="e"></param>
150
         /// <param name="e"></param>
141
         public void Blue()
151
         public void Blue()
142
         {
152
         {
143
-            flg = 0;
153
+            //flg = 0;
144
             drawingAttributes.Color = Colors.DeepSkyBlue;
154
             drawingAttributes.Color = Colors.DeepSkyBlue;
155
+            Colour = Colors.DeepSkyBlue;
145
         }
156
         }
146
         /// <summary>
157
         /// <summary>
147
         /// 画笔粗细事件 细
158
         /// 画笔粗细事件 细
150
         /// <param name="e"></param>
161
         /// <param name="e"></param>
151
         public void Fine()
162
         public void Fine()
152
         {
163
         {
153
-            flg = 0;
164
+            //flg = 0;
154
             drawingAttributes.Width = 1;
165
             drawingAttributes.Width = 1;
155
             drawingAttributes.Height = 1;
166
             drawingAttributes.Height = 1;
167
+            Wit = 1;
168
+            Hei = 1;
156
         }
169
         }
157
         /// <summary>
170
         /// <summary>
158
         /// 画笔粗细事件 中
171
         /// 画笔粗细事件 中
161
         /// <param name="e"></param>
174
         /// <param name="e"></param>
162
         public void In()
175
         public void In()
163
         {
176
         {
164
-            flg = 0;
177
+            //flg = 0;
165
             drawingAttributes.Width = 3;
178
             drawingAttributes.Width = 3;
166
             drawingAttributes.Height = 3;
179
             drawingAttributes.Height = 3;
180
+            Wit = 3;
181
+            Hei = 3;
182
+
167
         }
183
         }
168
         /// <summary>
184
         /// <summary>
169
         /// 画笔粗细事件 粗
185
         /// 画笔粗细事件 粗
172
         /// <param name="e"></param>
188
         /// <param name="e"></param>
173
         public void Crude()
189
         public void Crude()
174
         {
190
         {
175
-            flg = 0;
191
+            //flg = 0;
176
             drawingAttributes.Width = 5;
192
             drawingAttributes.Width = 5;
177
             drawingAttributes.Height = 5;
193
             drawingAttributes.Height = 5;
194
+            Wit = 5;
195
+            Hei = 5;
178
         }
196
         }
179
         /// <summary>
197
         /// <summary>
180
         /// 橡皮
198
         /// 橡皮
208
             flg = 2;
226
             flg = 2;
209
             drawingAttributes = new DrawingAttributes
227
             drawingAttributes = new DrawingAttributes
210
             {
228
             {
211
-                Color = Colors.Red,
212
-                Width = 2,
213
-                Height = 2,
229
+                Color = Colour,
230
+                Width = Wit,
231
+                Height = Hei,
214
                 StylusTip = StylusTip.Rectangle,
232
                 StylusTip = StylusTip.Rectangle,
215
                 //FitToCurve = true,
233
                 //FitToCurve = true,
216
                 IsHighlighter = false,
234
                 IsHighlighter = false,
219
             };
237
             };
220
             blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
238
             blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
221
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
239
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
240
+            blackboard_canvas.Cursor = Cursors.Cross;
222
         }
241
         }
223
         /// <summary>
242
         /// <summary>
224
         /// 矩形
243
         /// 矩形
226
         public void Rectangle()
245
         public void Rectangle()
227
         {
246
         {
228
             flg = 1;
247
             flg = 1;
248
+            drawingAttributes = new DrawingAttributes
249
+            {
250
+                Color = Colour,
251
+                Width = Wit,
252
+                Height = Hei,
253
+                StylusTip = StylusTip.Rectangle,
254
+                //FitToCurve = true,
255
+                IsHighlighter = false,
256
+                IgnorePressure = true,
257
+
258
+            };
259
+            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
229
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
260
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
261
+            blackboard_canvas.Cursor = Cursors.Cross;
230
         }
262
         }
231
         private System.Windows.Point iniP;
263
         private System.Windows.Point iniP;
232
         private void blackboard_canvas_MouseDown(object sender, MouseButtonEventArgs e)
264
         private void blackboard_canvas_MouseDown(object sender, MouseButtonEventArgs e)

+ 82
- 0
XHWK.WKTool/PrintWindow.xaml View File

1
+<Window x:Class="XHWK.WKTool.PrintWindow"
2
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
+        xmlns:local="clr-namespace:XHWK.WKTool"
7
+        mc:Ignorable="d"
8
+        Title="PrintWindow" Height="729" Width="1028" AllowsTransparency="True"
9
+    ShowInTaskbar="False"
10
+    WindowStartupLocation="CenterOwner"
11
+    WindowStyle="None">
12
+    <Grid>
13
+        <Grid.RowDefinitions>
14
+            <RowDefinition Height="102"/>
15
+            <RowDefinition Height="*"/>
16
+            <RowDefinition Height="80"/>
17
+        </Grid.RowDefinitions>
18
+        <Grid Grid.Row="0" Background="#E6EAF0">
19
+            <Grid.RowDefinitions>
20
+                <RowDefinition Height="auto"/>
21
+                <RowDefinition Height="auto"/>
22
+                <RowDefinition Height="auto"/>
23
+            </Grid.RowDefinitions>
24
+            <TextBlock Grid.Row="0" Text="打印预览" Background="#2E8CF0" Foreground="#FFFFFF" Width="50" HorizontalAlignment="Left" Margin="10,5,0,0"/>
25
+            <StackPanel Grid.Row="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="10,10,0,0">
26
+                <TextBlock  Text="打印机:" Width="210" FontSize="20"/>
27
+                <TextBlock Text="份数:" FontSize="20" Margin="120,0,0,0"/>
28
+                <TextBox Width="100"/>
29
+            </StackPanel>
30
+            <Button Grid.Row="1" Background="#CC4848" Foreground="#FFFFFF" Content="×" FontSize="20" Width="30" Height="30" HorizontalAlignment="Right" Margin="0,0,20,0">
31
+
32
+            </Button>
33
+            <StackPanel Grid.Row="2" HorizontalAlignment="Left" Orientation="Horizontal" Margin="10,10,0,0">
34
+                <ComboBox Cursor="Hand" Width="210"
35
+                                x:Name="cmbClass"
36
+                                Padding="10,0,10,0"
37
+                                VerticalContentAlignment="Center"
38
+                                BorderThickness="0"
39
+                                DisplayMemberPath="Value"
40
+                                FontSize="14"
41
+                                ItemsSource="{Binding bookList}"
42
+                                SelectedValuePath="Key"
43
+                                SelectionChanged="cmbClass_SelectionChanged" />
44
+                <TextBlock Text="点型:" FontSize="20"  Margin="120,0,0,0"/>
45
+                <RadioButton Content="方点" FontSize="16" IsChecked="True" Margin="0,5,0,0"/>
46
+                <RadioButton Content="圆点" FontSize="16" IsChecked="True" Margin="0,5,0,0"/>
47
+            </StackPanel>
48
+            <TextBlock Grid.Row="2" Text="关闭" HorizontalAlignment="Right" Margin="0,10,20,0"  Width="30" Height="30"/>
49
+        </Grid>
50
+        <Grid Grid.Row="1">
51
+            <Image x:Name="imgPri"/>
52
+        </Grid>
53
+
54
+        <Button
55
+                    x:Name="btnPrint"
56
+                    Grid.Row="8"
57
+                    Width="115"
58
+                    Height="46"
59
+                    Click="BtnPrint_Click"
60
+                    Content="打印"
61
+            Foreground="White"
62
+                    FontSize="17"
63
+                    IsDefault="True"
64
+                    Cursor="Hand"
65
+                    Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
66
+            <Button.Template>
67
+                <ControlTemplate TargetType="{x:Type Button}">
68
+                    <Border
69
+                                BorderBrush="{TemplateBinding Control.BorderBrush}"
70
+                                BorderThickness="1"
71
+                                CornerRadius="7">
72
+                        <Border.Background>#2E8CF0</Border.Background>
73
+                        <ContentPresenter
74
+                                    HorizontalAlignment="Center"
75
+                                    VerticalAlignment="Center"
76
+                                    Content="{TemplateBinding ContentControl.Content}" />
77
+                    </Border>
78
+                </ControlTemplate>
79
+            </Button.Template>
80
+        </Button>
81
+    </Grid>
82
+</Window>

+ 89
- 0
XHWK.WKTool/PrintWindow.xaml.cs View File

1
+using Common.system;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Data;
5
+using System.Linq;
6
+using System.Text;
7
+using System.Threading.Tasks;
8
+using System.Windows;
9
+using System.Windows.Controls;
10
+using System.Windows.Data;
11
+using System.Windows.Documents;
12
+using System.Windows.Input;
13
+using System.Windows.Media;
14
+using System.Windows.Media.Imaging;
15
+using System.Windows.Shapes;
16
+
17
+namespace XHWK.WKTool
18
+{
19
+    /// <summary>
20
+    /// 打印
21
+    /// </summary>
22
+    public partial class PrintWindow : Window
23
+    {
24
+        /// <summary>
25
+        /// 下拉框数据源
26
+        /// </summary>
27
+        public DataTable data = new DataTable();
28
+        public PrintWindow()
29
+        {
30
+            InitializeComponent();
31
+            string defa = string.Empty;
32
+            List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
33
+            if(defaList.Count>0)
34
+            {
35
+                data.Columns.Add("Value");
36
+                data.Columns.Add("Key");
37
+                for (int i = 0; i < defaList.Count; i++)
38
+                {
39
+                    //创建一行
40
+                    DataRow row = data.NewRow();
41
+                    //将此行添加到table中
42
+                    data.Rows.Add(row);
43
+                    data.Rows[i]["Value"] = defaList[i];
44
+                    data.Rows[i]["Key"] = i.ToString();
45
+                }
46
+                //dtComponentsUniqueNo = data.DefaultView.ToTable();
47
+                //cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
48
+                cmbClass.SelectedIndex = 0;
49
+            }
50
+        }
51
+        public void Initialize(string _imgPath)
52
+        {
53
+         
54
+        }
55
+        /// <summary>
56
+        /// 打印机下拉框改变事件
57
+        /// </summary>
58
+        /// <param name="sender"></param>
59
+        /// <param name="e"></param>
60
+        private void cmbClass_SelectionChanged(object sender, SelectionChangedEventArgs e)
61
+        {
62
+
63
+        }
64
+        /// <summary>
65
+        /// 打印
66
+        /// </summary>
67
+        /// <param name="sender"></param>
68
+        /// <param name="e"></param>
69
+        private void BtnPrint_Click(object sender, RoutedEventArgs e)
70
+        {
71
+            int pr = 1;
72
+            string msg = string.Empty;
73
+            string outPut = string.Empty;
74
+            LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF", out pr, out msg, out outPut);
75
+            if (pr == 0)
76
+            {
77
+                outPut = outPut.Replace("[", "").Replace("]", "").Replace("\"", "").Trim();
78
+                APP.OutPut = outPut.Split(',');
79
+                string defa = string.Empty;
80
+                List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
81
+
82
+                int printResult = 1;
83
+                string standardError = string.Empty;
84
+                string standardOutput = string.Empty;
85
+                LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF", 1, /*defa*/"导出为WPS PDF", out printResult, out standardError, out standardOutput);
86
+            }
87
+        }
88
+    }
89
+}

+ 4
- 2
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

1476
             }
1476
             }
1477
             Dispatcher.Invoke(new Action(() =>
1477
             Dispatcher.Invoke(new Action(() =>
1478
             {
1478
             {
1479
-                myblackboard.changepages(0, 0, true);
1479
+                //myblackboard.changepages(0, 0, true);
1480
+                myblackboard.changepaget(0, 0, true, blackboard_canvas);
1480
             }));
1481
             }));
1481
           
1482
           
1482
         }
1483
         }
1613
 
1614
 
1614
                 Dispatcher.Invoke(new Action(() =>
1615
                 Dispatcher.Invoke(new Action(() =>
1615
                 {
1616
                 {
1616
-                    myblackboard.changepages(testX, testY,false);
1617
+                    //myblackboard.changepages(testX, testY,false);
1618
+                    myblackboard.changepaget(testX, testY, false, blackboard_canvas);
1617
                 }));
1619
                 }));
1618
 
1620
 
1619
              
1621
              

Loading…
Cancel
Save