Ver código fonte

激活

tags/录制修改前
zhangxueyang 4 anos atrás
pai
commit
78a1a82778

+ 94
- 0
XHWK.WKTool/Helpers/ZJClippingBorder.cs Ver arquivo

@@ -0,0 +1,94 @@
1
+using System;
2
+using System.Windows;
3
+using System.Windows.Controls;
4
+using System.Windows.Media;
5
+
6
+namespace XHWK.WKTool.Helpers
7
+{
8
+    public class ZJClippingBorder : Border
9
+    {
10
+        private object _oldClip;
11
+
12
+        protected override void OnRender(DrawingContext dc)
13
+        {
14
+            OnApplyChildClip();
15
+            base.OnRender(dc);
16
+        }
17
+
18
+        public override UIElement Child
19
+        {
20
+            get => base.Child;
21
+            set
22
+            {
23
+                if (Child != value)
24
+                {
25
+                    if (Child != null)
26
+                    {
27
+                        Child.SetValue(ClipProperty, _oldClip);
28
+                    }
29
+
30
+                    if (value != null)
31
+                    {
32
+                        _oldClip = value.ReadLocalValue(ClipProperty);
33
+                    }
34
+                    else
35
+                    {
36
+                        // If we dont set it to null we could leak a Geometry object
37
+                        _oldClip = null;
38
+                    }
39
+
40
+                    base.Child = value;
41
+                }
42
+            }
43
+        }
44
+
45
+        protected virtual void OnApplyChildClip()
46
+        {
47
+            UIElement child = Child;
48
+            if (child != null)
49
+            {
50
+                double top = Math.Max(CornerRadius.TopLeft, CornerRadius.TopRight);
51
+                double bottom = Math.Max(CornerRadius.BottomLeft, CornerRadius.BottomRight);
52
+                double max = Math.Max(top, bottom);
53
+                Size size = RenderSize;
54
+                double width = size.Width - (BorderThickness.Left + BorderThickness.Right);
55
+                double height = size.Height - (BorderThickness.Top + BorderThickness.Bottom);
56
+                Geometry result = new RectangleGeometry(new Rect(0, 0, width, height), max, max);
57
+                double halfWidth = width / 2;
58
+                double halfHeight = height / 2;
59
+
60
+                if (CornerRadius.TopLeft == 0)
61
+                {
62
+                    result = new CombinedGeometry(
63
+                        GeometryCombineMode.Union,
64
+                        result,
65
+                        new RectangleGeometry(new Rect(0, 0, halfWidth, halfHeight))
66
+                    );
67
+                }
68
+
69
+                if (CornerRadius.TopRight == 0)
70
+                {
71
+                    result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry
72
+                (new Rect(halfWidth, 0, halfWidth, halfHeight)));
73
+                }
74
+
75
+                if (CornerRadius.BottomLeft == 0)
76
+                {
77
+                    result = new CombinedGeometry
78
+                  (GeometryCombineMode.Union, result, new RectangleGeometry
79
+                  (new Rect(0, halfHeight, halfWidth, halfHeight)));
80
+                }
81
+                if (CornerRadius.BottomRight == 0)
82
+                {
83
+                    result = new CombinedGeometry
84
+                  (
85
+                GeometryCombineMode.Union,
86
+                result,
87
+                new RectangleGeometry(new Rect(halfWidth, halfHeight, halfWidth, halfHeight))
88
+                );
89
+                }
90
+                child.Clip = result;
91
+            }
92
+        }
93
+    }
94
+}

+ 141
- 0
XHWK.WKTool/KeyVerification.xaml Ver arquivo

@@ -0,0 +1,141 @@
1
+<Window x:Class="XHWK.WKTool.KeyVerification"
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
+         xmlns:Views="clr-namespace:XHWK.WKTool.Helpers"
8
+        mc:Ignorable="d"
9
+        Title="KeyVerification"    Width="300"
10
+    Height="230"
11
+    AllowsTransparency="True"
12
+    Background="Transparent"
13
+    ShowInTaskbar="False"
14
+    WindowStartupLocation="CenterOwner"
15
+    WindowStyle="None"
16
+    mc:Ignorable="d" BorderThickness="7">
17
+    <Window.Effect>
18
+        <DropShadowEffect BlurRadius="10" Color="#bababa" Direction="80" ShadowDepth="0"/>
19
+    </Window.Effect>
20
+    <Window.Resources>
21
+        <Style x:Key="oiliu" TargetType="ListBoxItem">
22
+            <!--  设置控件模板  -->
23
+            <Setter Property="Template">
24
+                <Setter.Value>
25
+                    <ControlTemplate TargetType="ListBoxItem">
26
+                        <Border
27
+                            Margin="4,0,0,0"
28
+                            Padding="0"
29
+                            Background="{TemplateBinding Background}">
30
+                            <ContentPresenter
31
+                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
32
+                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
33
+                                TextBlock.Foreground="{TemplateBinding Foreground}" />
34
+                        </Border>
35
+                    </ControlTemplate>
36
+                </Setter.Value>
37
+            </Setter>
38
+        </Style>
39
+        <DataTemplate x:Key="UserTpl">
40
+            <StackPanel
41
+                Width="70.5"
42
+                Height="auto"
43
+                Background="Transparent">
44
+                <TextBlock
45
+                        Padding="0,12,0,0"
46
+                        HorizontalAlignment="Left"
47
+                        FontSize="20"
48
+                        Foreground="#3C525B"
49
+                        Text="{Binding username}" />
50
+            </StackPanel>
51
+        </DataTemplate>
52
+    </Window.Resources>
53
+    <Views:ZJClippingBorder Background="White" CornerRadius="10,10,10,10">
54
+        <Grid Margin="0,0,0,0">
55
+            <Grid.RowDefinitions>
56
+                <RowDefinition Height="50" />
57
+                <RowDefinition Height="*" />
58
+                <RowDefinition Height="75" />
59
+            </Grid.RowDefinitions>
60
+            <!--  头部  -->
61
+            <Grid
62
+                Grid.Row="0"
63
+                Height="50"
64
+                Background="#4597FF">
65
+                <TextBlock
66
+                    x:Name="title_tb"
67
+                    Grid.Row="0"
68
+                    Margin="15,0,0,0"
69
+                    HorizontalAlignment="Left"
70
+                    VerticalAlignment="Center"
71
+                    FontSize="22"
72
+                    Foreground="White"
73
+                    Text="产品激活" />
74
+                <Button
75
+                    Grid.Column="0"
76
+                    Width="46"
77
+                    Height="46"
78
+                    Margin="0,0,10,0"
79
+                    HorizontalAlignment="Right"
80
+                    VerticalAlignment="Center"
81
+                    Background="White"
82
+                    Click="close_click" Cursor="Hand"
83
+                    Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
84
+                    <Button.Template>
85
+                        <ControlTemplate TargetType="{x:Type Button}">
86
+                            <Border
87
+                                BorderBrush="{TemplateBinding Control.BorderBrush}"
88
+                                BorderThickness="0"
89
+                                CornerRadius="20">
90
+                                <ContentPresenter
91
+                                    HorizontalAlignment="Center"
92
+                                    VerticalAlignment="Center"
93
+                                    Content="{TemplateBinding ContentControl.Content}" />
94
+                            </Border>
95
+                        </ControlTemplate>
96
+                    </Button.Template>
97
+                    <Image
98
+                        Width="40"
99
+                        Height="40"
100
+                        HorizontalAlignment="Center"
101
+                        VerticalAlignment="Center"
102
+                        Source="../Images/RollCall/rollCall_1.png"
103
+                        Stretch="Fill" />
104
+                </Button>
105
+            </Grid>
106
+            <Grid Grid.Row="1" Margin="10,20,0,0">
107
+                <StackPanel Orientation="Horizontal" Height="30">
108
+                    <TextBlock Text="密匙:" FontSize="20"/>
109
+                    <TextBox x:Name="txbKey" Text="" Width="200" Foreground="gray" FontSize="18"/>
110
+                </StackPanel>
111
+            </Grid>
112
+
113
+            <Button Cursor="Hand"
114
+                x:Name="btnEnd"
115
+                Grid.Row="2"
116
+                Width="163.5"
117
+                Height="37.2"
118
+                Margin="0,0,0,0"
119
+                Click="btnEnd_Click"
120
+                Content="验证"
121
+                FontSize="18.75"
122
+                Foreground="White">
123
+                <Button.Template>
124
+                    <ControlTemplate TargetType="{x:Type Button}">
125
+                        <Border
126
+                            BorderBrush="{TemplateBinding Control.BorderBrush}"
127
+                            BorderThickness="0"
128
+                            CornerRadius="20">
129
+                            <Border.Background>#6098FF</Border.Background>
130
+                            <ContentPresenter
131
+                                HorizontalAlignment="Center"
132
+                                VerticalAlignment="Center"
133
+                                Content="{TemplateBinding ContentControl.Content}" />
134
+                        </Border>
135
+                    </ControlTemplate>
136
+                </Button.Template>
137
+            </Button>
138
+        </Grid>
139
+
140
+    </Views:ZJClippingBorder>
141
+</Window>

+ 153
- 0
XHWK.WKTool/KeyVerification.xaml.cs Ver arquivo

@@ -0,0 +1,153 @@
1
+using SchoolClient.Commons;
2
+using SchoolClient.Config;
3
+using SchoolClient.Method;
4
+
5
+using System;
6
+using System.IO;
7
+using System.Management;
8
+using System.Text;
9
+using System.Threading;
10
+using System.Windows;
11
+using System.Windows.Forms;
12
+
13
+namespace XHWK.WKTool
14
+{
15
+    /// <summary>
16
+    /// KeyVerification.xaml 的交互逻辑
17
+    /// </summary>
18
+    /*
19
+     输入code 调认证服务,成功跳登陆 并且调用添加历史接口,失败继续输code
20
+         */
21
+    public partial class KeyVerification : Window
22
+    {
23
+        private readonly RegisterController registerController = new RegisterController();
24
+        private int serverReturnCode = 0;
25
+
26
+        public KeyVerification()
27
+        {
28
+            InitializeComponent();
29
+            WindowStartupLocation = WindowStartupLocation.CenterScreen;
30
+        }
31
+
32
+
33
+        private void btnEnd_Click(object sender, RoutedEventArgs e)
34
+        {
35
+            if (string.IsNullOrWhiteSpace(txbKey.Text))
36
+            {
37
+                MessageWindow.Show("密匙未输入");
38
+                return;
39
+            }
40
+            projectcode = txbKey.Text;
41
+            Shared.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddServering, InvokeActivationAddServerCompate);
42
+        }
43
+
44
+        private string projectcode = string.Empty;
45
+        /// <summary>
46
+        /// 认证服务-调用
47
+        /// </summary>
48
+        /// <returns></returns>
49
+        private object InvokeActivationAddServering()
50
+        {
51
+            string device = "pc";
52
+            string mac = GetMacAddress();
53
+            serverReturnCode = registerController.ActivationAdd(mac, device, projectcode);
54
+            return Shared.ServerMsg;
55
+        }
56
+
57
+        /// <summary>
58
+        /// 认证服务-返回结果
59
+        /// </summary>
60
+        /// <returns></returns>
61
+        public void InvokeActivationAddServerCompate(object obj)
62
+        {
63
+            if (serverReturnCode == Shared.ServerScuessCode)
64
+            {
65
+                MessageWindow.Show("产品激活成功");
66
+                Shared.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddHistoryServering, InvokeActivationAddHistoryServerCompate);
67
+                Dispatcher.Invoke(new Action(() =>
68
+                {
69
+                    LoginWindow win = new LoginWindow();
70
+                    //win.Topmost = true;
71
+                    win.Show();
72
+
73
+                    Hide();
74
+                    Thread.Sleep(200);
75
+                    Close();
76
+                }));
77
+            }
78
+            else
79
+            {
80
+                System.Windows.Forms.MessageBox.Show(Shared.ServerMsg, "激活结果:", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
81
+            }
82
+        }
83
+        /// <summary>
84
+        /// 激活信息--添加激活历史-调用
85
+        /// </summary>
86
+        /// <returns></returns>
87
+        private object InvokeActivationAddHistoryServering()
88
+        {
89
+            serverReturnCode = registerController.ActivationAddHistory(ref Shared.TeachingData);
90
+            return Shared.ServerMsg;
91
+        }
92
+
93
+        /// <summary>
94
+        /// 激活信息--添加激活历史-返回结果
95
+        /// </summary>
96
+        /// <returns></returns>
97
+        public void InvokeActivationAddHistoryServerCompate(object obj)
98
+        {
99
+            if (!Directory.Exists(APP.dataPath))
100
+            {
101
+                Directory.CreateDirectory(APP.dataPath);
102
+            }
103
+            string ApplicationData = APP.dataPath + "signatureTime.txt";
104
+            string currentTime = DateTime.Now.ToLongDateString().ToString();//当前时间
105
+            System.IO.File.WriteAllText(ApplicationData, currentTime, Encoding.Default);//存放签名验证日期
106
+
107
+
108
+        }
109
+        /// <summary>  
110
+        /// 获取本机MAC地址  
111
+        /// </summary>  
112
+        /// <returns>本机MAC地址</returns>  
113
+        public static string GetMacAddress()
114
+        {
115
+            try
116
+            {
117
+                string strMac = string.Empty;
118
+                ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
119
+                ManagementObjectCollection moc = mc.GetInstances();
120
+                foreach (ManagementObject mo in moc)
121
+                {
122
+                    if ((bool)mo["IPEnabled"] == true)
123
+                    {
124
+                        strMac = mo["MacAddress"].ToString();
125
+                    }
126
+                }
127
+                moc = null;
128
+                mc = null;
129
+                return strMac;
130
+            }
131
+            catch
132
+            {
133
+                return "unknown";
134
+            }
135
+        }
136
+
137
+        private void close_click(object sender, RoutedEventArgs e)
138
+        {
139
+            closeAction();
140
+        }
141
+        private void closeAction()
142
+        {
143
+            APP.myloading.Show();
144
+            new Thread(o =>
145
+            {
146
+                Dispatcher.Invoke(new Action(() =>
147
+                {
148
+                    System.Environment.Exit(0);
149
+                }));
150
+            }).Start();
151
+        }
152
+    }
153
+}

+ 1
- 1
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Ver arquivo

@@ -1587,7 +1587,7 @@ namespace XHWK.WKTool
1587 1587
                                 }
1588 1588
                                 catch (Exception ex)
1589 1589
                                 {
1590
-                                    System.Windows.MessageBox.Show("无法删除视频!" + ex.Message);
1590
+                                    MessageWindow.Show("无法删除视频!" + ex.Message);
1591 1591
                                     return;
1592 1592
                                 }
1593 1593
                             }

+ 9
- 0
XHWK.WKTool/XHWK.WKTool.csproj Ver arquivo

@@ -89,6 +89,7 @@
89 89
     <Reference Include="System.Configuration" />
90 90
     <Reference Include="System.Data" />
91 91
     <Reference Include="System.Drawing" />
92
+    <Reference Include="System.Management" />
92 93
     <Reference Include="System.Windows.Forms" />
93 94
     <Reference Include="System.Xml" />
94 95
     <Reference Include="Microsoft.CSharp" />
@@ -141,10 +142,14 @@
141 142
     </Compile>
142 143
     <Compile Include="Helpers\ScreenHelper.cs" />
143 144
     <Compile Include="Helpers\WpfHelper.cs" />
145
+    <Compile Include="Helpers\ZJClippingBorder.cs" />
144 146
     <Compile Include="Helpers\ZJDownloadUtil.cs" />
145 147
     <Compile Include="JieTuWindow.xaml.cs">
146 148
       <DependentUpon>JieTuWindow.xaml</DependentUpon>
147 149
     </Compile>
150
+    <Compile Include="KeyVerification.xaml.cs">
151
+      <DependentUpon>KeyVerification.xaml</DependentUpon>
152
+    </Compile>
148 153
     <Compile Include="LoadDialog.xaml.cs">
149 154
       <DependentUpon>LoadDialog.xaml</DependentUpon>
150 155
     </Compile>
@@ -199,6 +204,10 @@
199 204
       <SubType>Designer</SubType>
200 205
       <Generator>MSBuild:Compile</Generator>
201 206
     </Page>
207
+    <Page Include="KeyVerification.xaml">
208
+      <SubType>Designer</SubType>
209
+      <Generator>MSBuild:Compile</Generator>
210
+    </Page>
202 211
     <Page Include="LoadDialog.xaml">
203 212
       <SubType>Designer</SubType>
204 213
       <Generator>MSBuild:Compile</Generator>

+ 1
- 0
XHWK.WKTool/packages.config Ver arquivo

@@ -9,5 +9,6 @@
9 9
   <package id="Aspose.PDF" version="19.1.0" targetFramework="net452" />
10 10
   <package id="Aspose.Slides.NET" version="19.10.0" targetFramework="net452" />
11 11
   <package id="iTextSharp" version="5.5.13.1" targetFramework="net452" />
12
+  <package id="System.Management" version="4.7.0" targetFramework="net452" />
12 13
   <package id="WpfAnimatedGif" version="2.0.0" targetFramework="net452" />
13 14
 </packages>

Carregando…
Cancelar
Salvar