├── PicEditor.sln
├── PicEditor
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── PicEditor.csproj
├── PicEditor.csproj.user
├── PicEditor.ico
├── Properties
│ └── PublishProfiles
│ │ ├── FolderProfile.pubxml
│ │ └── FolderProfile.pubxml.user
├── controller
│ ├── ColorWindowControl.cs
│ ├── ListBoxControl.cs
│ ├── PCSControl.cs
│ ├── PaintControl.cs
│ ├── PicBACControl.cs
│ ├── PicChannelMixerControl.cs
│ ├── PicControl.cs
│ ├── PicCurveControl.cs
│ ├── PicHSControl.cs
│ ├── PicMeanFilterControl.cs
│ ├── PicPixelatedControl.cs
│ ├── PicSharpenControl.cs
│ ├── PicTSControl.cs
│ ├── SliderControl.cs
│ └── TextControl.cs
├── core
│ └── PicProcess.cs
├── style
│ ├── Button.xaml
│ ├── CheckBox.xaml
│ ├── ListBox.xaml
│ ├── Menu.xaml
│ ├── RadioButton.xaml
│ ├── Rectangle.xaml
│ ├── ScrollViewer.xaml
│ ├── Slider.xaml
│ ├── TabControl.xaml
│ └── Window.xaml
└── window
│ ├── AboutWindow.xaml
│ ├── AboutWindow.xaml.cs
│ ├── ColorWindow.xaml
│ ├── ColorWindow.xaml.cs
│ ├── CreatePictureWindow.xaml
│ ├── CreatePictureWindow.xaml.cs
│ ├── HelpWindow.xaml
│ ├── HelpWindow.xaml.cs
│ ├── MsgWindow.xaml
│ ├── MsgWindow.xaml.cs
│ ├── OpenPictureWindow.xaml
│ ├── OpenPictureWindow.xaml.cs
│ ├── PicBACWindow.xaml
│ ├── PicBACWindow.xaml.cs
│ ├── PicChannelMixerWindow.xaml
│ ├── PicChannelMixerWindow.xaml.cs
│ ├── PicColorScaleWindow.xaml
│ ├── PicColorScaleWindow.xaml.cs
│ ├── PicCurveWindow.xaml
│ ├── PicCurveWindow.xaml.cs
│ ├── PicHSWindow.xaml
│ ├── PicHSWindow.xaml.cs
│ ├── PicMeanFilterWindow.xaml
│ ├── PicMeanFilterWindow.xaml.cs
│ ├── PicPixelatedWindow.xaml
│ ├── PicPixelatedWindow.xaml.cs
│ ├── PicResizeWindow.xaml
│ ├── PicResizeWindow.xaml.cs
│ ├── PicSharpenWindow.xaml
│ ├── PicSharpenWindow.xaml.cs
│ ├── PicTSWindow.xaml
│ ├── PicTSWindow.xaml.cs
│ ├── SettingWindow.xaml
│ └── SettingWindow.xaml.cs
├── README.md
└── images
├── 软件窗口图1.PNG
└── 软件窗口图2.PNG
/PicEditor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29709.97
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PicEditor", "PicEditor\PicEditor.csproj", "{38C2E221-7085-4C7B-9827-8591C0155C01}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {38C2E221-7085-4C7B-9827-8591C0155C01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {38C2E221-7085-4C7B-9827-8591C0155C01}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {38C2E221-7085-4C7B-9827-8591C0155C01}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {38C2E221-7085-4C7B-9827-8591C0155C01}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {071D3313-A288-4837-82E2-8475D9D87482}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/PicEditor/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/PicEditor/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace PicEditor
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | protected override void OnStartup(StartupEventArgs e)
17 | {
18 | MainWindow mainWindow = new MainWindow
19 | {
20 | StartupArgs = e.Args.Length == 0 ? null : e.Args[0],
21 | };
22 | mainWindow.ShowDialog();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/PicEditor/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using System.Windows;
3 |
4 | [assembly: ThemeInfo(
5 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
6 | //(used if a resource is not found in the page,
7 | // or application resource dictionaries)
8 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
9 | //(used if a resource is not found in the page,
10 | // app, or any theme specific resource dictionaries)
11 | )]
12 | [assembly: SuppressIldasm()]
13 |
--------------------------------------------------------------------------------
/PicEditor/PicEditor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 | true
8 | PicEditor.ico
9 | 2.1.2
10 | 2.1.2.0
11 | 2.1.2.0
12 | ZZH
13 | 图片编辑器 (https://github.com/zou-z/PicEditor/releases)
14 | © 2020 ZZH
15 | PicEditor.ico
16 |
17 |
18 |
19 |
20 | x64
21 |
22 |
23 |
24 |
25 |
26 | True
27 |
28 |
29 |
30 |
31 |
32 |
33 | f935dc20-1cf0-11d0-adb9-00c04fd58a0b
34 | 1
35 | 0
36 | tlbimp
37 | 0
38 | false
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/PicEditor/PicEditor.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <_LastSelectedProfileId>D:\Project\WPF\PicEditor\PicEditor\Properties\PublishProfiles\FolderProfile.pubxml
5 |
6 |
7 |
8 | Designer
9 |
10 |
11 |
12 |
13 | Code
14 |
15 |
16 | Code
17 |
18 |
19 | Code
20 |
21 |
22 | Code
23 |
24 |
25 | Code
26 |
27 |
28 | Code
29 |
30 |
31 | Code
32 |
33 |
34 | Code
35 |
36 |
37 | Code
38 |
39 |
40 | Code
41 |
42 |
43 | Code
44 |
45 |
46 | Code
47 |
48 |
49 | Code
50 |
51 |
52 | Code
53 |
54 |
55 | Code
56 |
57 |
58 | Code
59 |
60 |
61 | Code
62 |
63 |
64 |
65 |
66 | Designer
67 |
68 |
69 | Designer
70 |
71 |
72 | Designer
73 |
74 |
75 | Designer
76 |
77 |
78 | Designer
79 |
80 |
81 | Designer
82 |
83 |
84 | Designer
85 |
86 |
87 | Designer
88 |
89 |
90 | Designer
91 |
92 |
93 | Designer
94 |
95 |
96 | Designer
97 |
98 |
99 | Designer
100 |
101 |
102 | Designer
103 |
104 |
105 | Designer
106 |
107 |
108 | Designer
109 |
110 |
111 | Designer
112 |
113 |
114 | Designer
115 |
116 |
117 | Designer
118 |
119 |
120 | Designer
121 |
122 |
123 | Designer
124 |
125 |
126 | Designer
127 |
128 |
129 | Designer
130 |
131 |
132 | Designer
133 |
134 |
135 | Designer
136 |
137 |
138 | Designer
139 |
140 |
141 | Designer
142 |
143 |
144 | Designer
145 |
146 |
147 | Designer
148 |
149 |
150 |
--------------------------------------------------------------------------------
/PicEditor/PicEditor.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zou-z/PicEditor/bacf4b04c764cfa278db06bd70503ca0d3420fad/PicEditor/PicEditor.ico
--------------------------------------------------------------------------------
/PicEditor/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | FileSystem
8 | Release
9 | Any CPU
10 | netcoreapp3.1
11 | D:\software\PicEditor
12 | true
13 | win-x64
14 | False
15 | False
16 | False
17 |
18 |
--------------------------------------------------------------------------------
/PicEditor/Properties/PublishProfiles/FolderProfile.pubxml.user:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/PicEditor/controller/ListBoxControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.ComponentModel;
5 | using System.Text;
6 | using System.Windows.Media;
7 | using System.Windows.Media.Imaging;
8 |
9 | namespace PicEditor.controller
10 | {
11 | class ListBoxControl : INotifyPropertyChanged
12 | {
13 | public event PropertyChangedEventHandler PropertyChanged;
14 | private ObservableCollection hr=new ObservableCollection();
15 | private int index;
16 |
17 | public ObservableCollection History
18 | {
19 | get { return hr; }
20 | set
21 | {
22 | hr = value;
23 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("History"));
24 | }
25 | }
26 | public int Index
27 | {
28 | get { return index; }
29 | set
30 | {
31 | index = value;
32 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Index"));
33 | }
34 | }
35 |
36 | public ListBoxControl()
37 | {
38 | Index = -1;
39 | }
40 | //需要控制数据集的大小
41 | public bool AddHistory(BitmapSource bs,string history_name,string name,string path)
42 | {
43 | if (bs == null)
44 | return false;
45 | for (int i = hr.Count - 1; i > index; i--)
46 | hr.Remove(hr[i]);
47 | hr.Add(new HistoryRecord(bs, history_name,name,path));
48 | Index++;
49 | return true;
50 | }
51 | }
52 | public class HistoryRecord
53 | {
54 | public BitmapSource HistoryPic { get; set; }
55 | public string HistoryName { get; set; }
56 | public string Name;
57 | public string Path;
58 | public HistoryRecord(BitmapSource HistoryPic, string HistoryName, string Name, string Path)
59 | {
60 | this.HistoryPic = HistoryPic;
61 | this.HistoryName = HistoryName;
62 | this.Name = Name;
63 | this.Path = Path;
64 | }
65 | ///
66 | /// 将三通道图片转化成四通道图片(在Pic控件上显示图片时使用)
67 | ///
68 | /// BitmapSource
69 | public BitmapSource Pic()
70 | {
71 | if (HistoryPic.Format == PixelFormats.Bgra32)
72 | return HistoryPic;
73 | FormatConvertedBitmap fcb = new FormatConvertedBitmap();
74 | fcb.BeginInit();
75 | fcb.Source = HistoryPic;
76 | fcb.DestinationFormat = PixelFormats.Bgra32;
77 | fcb.EndInit();
78 | return fcb;
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/PicEditor/controller/PCSControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PCSControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double ib = 0, ig = 150, iw = 300, ob = 0, ow = 300;
12 | private int ibt = 0, iwt = 255, obt = 0, owt = 255;
13 | private double igt = 1.0;
14 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
15 |
16 | public double IB
17 | {
18 | get { return ib; }
19 | set
20 | {
21 | ib = value < 0 ? 0 : (value > iw ? iw : value);
22 | ibt = (int)(255 * ib / 300);
23 | if (igt >= 1)
24 | ig = ib + (10 - igt) / 18 * (iw - ib);
25 | else
26 | ig = ib + (1.9 - igt) / 1.8 * (iw - ib);
27 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IB"));
28 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IBT"));
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
30 | }
31 | }
32 | public double IG
33 | {
34 | get { return ig; }
35 | set
36 | {
37 | ig = value < ib ? ib : (value > iw ? iw : value);
38 | igt = (ig - ib) / (iw - ib);
39 | if (igt < 0.5)
40 | igt = Math.Round(10 - 18 * igt, 2);
41 | else
42 | igt = Math.Round(1.9 - 1.8 * igt, 2);
43 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
44 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IGT"));
45 | }
46 | }
47 | public double IW
48 | {
49 | get { return iw; }
50 | set
51 | {
52 | iw = value > 300 ? 300 : (value < ib ? ib : value);
53 | iwt = (int)(255 * iw / 300);
54 | if (igt >= 1)
55 | ig = ib + (10 - igt) / 18 * (iw - ib);
56 | else
57 | ig = ib + (1.9 - igt) / 1.8 * (iw - ib);
58 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IW"));
59 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IWT"));
60 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
61 | }
62 | }
63 | public double OB
64 | {
65 | get { return ob; }
66 | set
67 | {
68 | ob = value < 0 ? 0 : (value > ow ? ow : value);
69 | obt = (int)(255 * ob / 300);
70 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OB"));
71 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OBT"));
72 | }
73 | }
74 | public double OW
75 | {
76 | get { return ow; }
77 | set
78 | {
79 | ow = value > 300 ? 300 : (value < ob ? ob : value);
80 | owt = (int)(255 * ow / 300);
81 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OW"));
82 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OWT"));
83 | }
84 | }
85 |
86 | public int IBT
87 | {
88 | get { return ibt; }
89 | set
90 | {
91 | ibt = value < 0 ? 0 : (value > iwt ? iwt : value);
92 | ib = 300.0 * ibt / 255;
93 | if (igt >= 1)
94 | ig = ib + (10 - igt) / 18 * (iw - ib);
95 | else
96 | ig = ib + (1.9 - igt) / 1.8 * (iw - ib);
97 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IBT"));
98 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IB"));
99 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
100 | }
101 | }
102 | public int IWT
103 | {
104 | get { return iwt; }
105 | set
106 | {
107 | iwt = value > 255 ? 255 : (value < ibt ? ibt : value);
108 | iw = 300.0 * iwt / 255;
109 | if (igt >= 1)
110 | ig = ib + (10 - igt) / 18 * (iw - ib);
111 | else
112 | ig = ib + (1.9 - igt) / 1.8 * (iw - ib);
113 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IWT"));
114 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IW"));
115 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
116 | }
117 | }
118 | public int OBT
119 | {
120 | get { return obt; }
121 | set
122 | {
123 | obt = value < 0 ? 0 : (value > owt ? owt : value);
124 | ob = 300.0 * obt / 255;
125 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OBT"));
126 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OB"));
127 | }
128 | }
129 | public int OWT
130 | {
131 | get { return owt; }
132 | set
133 | {
134 | owt = value > 255 ? 255 : (value < obt ? obt : value);
135 | ow = 300.0 * owt / 255;
136 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OWT"));
137 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OW"));
138 | }
139 | }
140 | public double IGT
141 | {
142 | get { return igt; }
143 | set
144 | {
145 | igt = value < 0.1 ? 0.1 : (value > 10 ? 10 : value);
146 | if (igt >= 1)
147 | ig = ib + (10 - igt) / 18 * (iw - ib);
148 | else
149 | ig = ib + (1.9 - igt) / 1.8 * (iw - ib);
150 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IGT"));
151 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
152 | }
153 | }
154 | public System.Windows.Visibility Visi
155 | {
156 | get { return visi; }
157 | set
158 | {
159 | visi = value;
160 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
161 | }
162 | }
163 | public void GetData(double[] data)
164 | {
165 | data[0] = ibt;
166 | data[1] = igt;
167 | data[2] = iwt;
168 | data[3] = obt;
169 | data[4] = owt;
170 | }
171 | public void Reset()
172 | {
173 | ib = 0; ig = 150; iw = 300; ob = 0; ow = 300;
174 | ibt = 0; iwt = 255; obt = 0; owt = 255; igt = 1.0;
175 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IB"));
176 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IG"));
177 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IW"));
178 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OB"));
179 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OW"));
180 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IBT"));
181 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IGT"));
182 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IWT"));
183 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OBT"));
184 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OWT"));
185 | }
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/PicEditor/controller/PaintControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PaintControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private System.Windows.Ink.DrawingAttributes da;
12 | private int size;
13 | public bool Delete = false;
14 |
15 | public System.Windows.Ink.DrawingAttributes DA
16 | {
17 | get { return da; }
18 | set
19 | {
20 | da = value;
21 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DA"));
22 | }
23 | }
24 | public int Size
25 | {
26 | get { return size; }
27 | set
28 | {
29 | size = value;
30 | DA.Width = DA.Height = size;
31 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Size"));
32 | }
33 | }
34 |
35 | public PaintControl()
36 | {
37 | DA = new System.Windows.Ink.DrawingAttributes
38 | {
39 | Color = System.Windows.Media.Colors.Black
40 | };
41 | Size = 5;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicBACControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicBACControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double b;
12 | private double c;
13 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
14 |
15 | public double B
16 | {
17 | get { return (int)b; }
18 | set
19 | {
20 | b = value < -127 ? -127 : (value > 127 ? 127 : value);
21 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("B"));
22 | }
23 | }
24 | public double C
25 | {
26 | get { return (int)c; }
27 | set
28 | {
29 | c = value < -127 ? -127 : (value > 127 ? 127 : value);
30 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("C"));
31 | }
32 | }
33 | public System.Windows.Visibility Visi
34 | {
35 | get { return visi; }
36 | set
37 | {
38 | visi = value;
39 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
40 | }
41 | }
42 | public void Reset()
43 | {
44 | b = c = 0;
45 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("B"));
46 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("C"));
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicChannelMixerControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicChannelMixerControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double r, rg, rb, gr, g, gb, br, bg, b;
12 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
13 |
14 | public double R
15 | {
16 | get { return Math.Round(r,2); }
17 | set
18 | {
19 | r = value < -2 ? -2 : (value > 2? 2: value);
20 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("R"));
21 | }
22 | }
23 | public double Rg
24 | {
25 | get { return Math.Round(rg, 2); }
26 | set
27 | {
28 | rg = value < -2 ? -2 : (value > 2 ? 2 : value);
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Rg"));
30 | }
31 | }
32 | public double Rb
33 | {
34 | get { return Math.Round(rb, 2); }
35 | set
36 | {
37 | rb = value < -2 ? -2 : (value > 2 ? 2 : value);
38 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Rb"));
39 | }
40 | }
41 | public double Gr
42 | {
43 | get { return Math.Round(gr, 2); }
44 | set
45 | {
46 | gr = value < -2 ? -2 : (value > 2 ? 2 : value);
47 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Gr"));
48 | }
49 | }
50 | public double G
51 | {
52 | get { return Math.Round(g, 2); }
53 | set
54 | {
55 | g = value < -2 ? -2 : (value > 2 ? 2 : value);
56 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("G"));
57 | }
58 | }
59 | public double Gb
60 | {
61 | get { return Math.Round(gb, 2); }
62 | set
63 | {
64 | gb = value < -2 ? -2 : (value > 2 ? 2 : value);
65 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Gb"));
66 | }
67 | }
68 | public double Br
69 | {
70 | get { return Math.Round(br, 2); }
71 | set
72 | {
73 | br = value < -2 ? -2 : (value > 2 ? 2 : value);
74 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Br"));
75 | }
76 | }
77 | public double Bg
78 | {
79 | get { return Math.Round(bg, 2); }
80 | set
81 | {
82 | bg = value < -2 ? -2 : (value > 2 ? 2 : value);
83 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Bg"));
84 | }
85 | }
86 | public double B
87 | {
88 | get { return Math.Round(b, 2); }
89 | set
90 | {
91 | b = value < -2 ? -2 : (value > 2 ? 2 : value);
92 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("B"));
93 | }
94 | }
95 | public System.Windows.Visibility Visi
96 | {
97 | get { return visi; }
98 | set
99 | {
100 | visi = value;
101 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
102 | }
103 | }
104 | public PicChannelMixerControl()
105 | {
106 | Reset();
107 | }
108 | public void Reset()
109 | {
110 | R = G = B = 1;
111 | Rg = Rb = Gr = Gb = Br = Bg = 0;
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicHSControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicHSControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double h = 0, s = 0, v = 0;
12 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
13 |
14 | public double H
15 | {
16 | get { return (int)h; }
17 | set
18 | {
19 | h = value < -180 ? -180 : (value > 180 ? 180 : value);
20 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("H"));
21 | }
22 | }
23 | public double S
24 | {
25 | get { return (int)s; }
26 | set
27 | {
28 | s = value < -100 ? -100 : (value > 100 ? 100 : value);
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("S"));
30 | }
31 | }
32 | public double V
33 | {
34 | get { return (int)v; }
35 | set
36 | {
37 | v = value < -100 ? -100 : (value > 100 ? 100 : value);
38 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("V"));
39 | }
40 | }
41 | public System.Windows.Visibility Visi
42 | {
43 | get { return visi; }
44 | set
45 | {
46 | visi = value;
47 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
48 | }
49 | }
50 | public void Reset()
51 | {
52 | h = s = v = 0;
53 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("H"));
54 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("S"));
55 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("V"));
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicMeanFilterControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicMeanFilterControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double radius = 0;
12 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
13 |
14 | public double Radius
15 | {
16 | get { return (int)radius; }
17 | set
18 | {
19 | radius = value < 0 ? 0 : (value > 30 ? 30 : value);
20 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Radius"));
21 | }
22 | }
23 | public System.Windows.Visibility Visi
24 | {
25 | get { return visi; }
26 | set
27 | {
28 | visi = value;
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicPixelatedControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicPixelatedControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double size = 1;
12 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
13 |
14 | public double Size
15 | {
16 | get { return (int)size; }
17 | set
18 | {
19 | size = value < 0 ? 0 : (value > 500 ? 500 : value);
20 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Size"));
21 | }
22 | }
23 | public System.Windows.Visibility Visi
24 | {
25 | get { return visi; }
26 | set
27 | {
28 | visi = value;
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicSharpenControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicSharpenControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double sharpen = 0;
12 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
13 |
14 | public double Sharpen
15 | {
16 | get { return (int)sharpen; }
17 | set
18 | {
19 | sharpen = value < 0 ? 0 : (value > 100 ? 100 : value);
20 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Sharpen"));
21 | }
22 | }
23 | public System.Windows.Visibility Visi
24 | {
25 | get { return visi; }
26 | set
27 | {
28 | visi = value;
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/PicEditor/controller/PicTSControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class PicTSControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private double num = 256;
12 | private System.Windows.Visibility visi = System.Windows.Visibility.Collapsed;
13 |
14 | public double Num
15 | {
16 | get { return (int)num; }
17 | set
18 | {
19 | num = value < 2 ? 2 : (value > 256 ? 256 : value);
20 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Num"));
21 | }
22 | }
23 | public System.Windows.Visibility Visi
24 | {
25 | get { return visi; }
26 | set
27 | {
28 | visi = value;
29 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visi"));
30 | }
31 | }
32 | public void Reset()
33 | {
34 | num = 256;
35 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Num"));
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/PicEditor/controller/SliderControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace PicEditor.controller
7 | {
8 | class SliderControl : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 | private readonly System.Windows.Controls.ScrollViewer SViewer;
12 | private readonly int PicPadding;
13 | private bool IsWheel = false;
14 | private const double a= 0.093577; //函数y=ln(x-a)的系数a
15 | private readonly PicControl picControl;
16 |
17 | private double sliderValue; //存放Slider值
18 | private string picSliderText;
19 | public double SliderValue
20 | {
21 | get { return sliderValue; }
22 | set
23 | {
24 | //通过鼠标滚轮缩放图片,value为图片缩放倍数
25 | if (IsWheel)
26 | {
27 | sliderValue = Math.Log(value - a);
28 | picControl.Scale = value;
29 | PicSliderText = (value * 100).ToString() + "%";
30 | //因为定点缩放需要获取鼠标位置,因此不在此处设置SViewer的offset
31 | IsWheel = false;
32 | }
33 | //通过拖动Slider缩放图片,value为Slider值
34 | else
35 | {
36 | sliderValue = value;
37 | double scale = picControl.Scale, offset_h = SViewer.HorizontalOffset, offset_v = SViewer.VerticalOffset;
38 | picControl.Scale = Math.Pow(Math.E, value) + a;
39 | PicSliderText = ((int)(picControl.Scale * 100)).ToString() + "%";
40 | //以目前窗口内图像中心为缩放中心
41 | if ((scale * picControl.Width + 2 * PicPadding <= SViewer.ActualWidth) && (picControl.Scale * picControl.Width + 2 * PicPadding > SViewer.ActualWidth))
42 | {
43 | //图像中心点像素横坐标:(offset1-padding+sv.width/2)*scale2/scale1 (纵坐标相同),应用定点缩放x1*s-x2+padding即可计算出offset2
44 | SViewer.ScrollToHorizontalOffset((picControl.Scale * picControl.Width - SViewer.ActualWidth) / 2 + PicPadding);
45 | }
46 | else
47 | {
48 | SViewer.ScrollToHorizontalOffset((offset_h - PicPadding + SViewer.ActualWidth / 2) * picControl.Scale / scale - SViewer.ActualWidth / 2 + PicPadding);
49 | }
50 | if ((scale * picControl.Height + 2 * PicPadding <= SViewer.ActualHeight) && (picControl.Scale * picControl.Height + 2 * PicPadding > SViewer.ActualHeight))
51 | {
52 | SViewer.ScrollToVerticalOffset((picControl.Scale * picControl.Height - SViewer.ActualHeight) / 2 + PicPadding);
53 | }
54 | else
55 | {
56 | SViewer.ScrollToVerticalOffset((offset_v - PicPadding + SViewer.ActualHeight / 2) * picControl.Scale / scale - SViewer.ActualHeight / 2 + PicPadding);
57 | }
58 | }
59 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SliderValue"));
60 | }
61 | }
62 | public string PicSliderText
63 | {
64 | get { return picSliderText; }
65 | set
66 | {
67 | picSliderText = value;
68 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PicSliderText"));
69 | }
70 | }
71 |
72 | public SliderControl(PicControl picControl,System.Windows.Controls.ScrollViewer SViewer, int PicPadding)
73 | {
74 | this.picControl = picControl;
75 | this.SViewer = SViewer;
76 | this.PicPadding = PicPadding;
77 | SliderValue = -0.098249;
78 | }
79 | public double GetScaleValue(bool increase)
80 | {
81 | double[] v = new double[] { 0.1, 0.25, 0.33, 0.5, 0.66, 0.75, 1, 1.25, 1.5, 2, 3, 4, 6, 8, 16, 32, 64, 128 };
82 | //标记为是用鼠标滚轮缩放图片
83 | IsWheel = true;
84 | for (int i = 0; i < v.Length; i++)
85 | {
86 | //if (picControl.Scale == v[i])
87 | if (Math.Abs(picControl.Scale - v[i]) < 0.01)
88 | {
89 | if (increase)
90 | return (i + 1 == v.Length) ? v[i] : v[i + 1];
91 | else
92 | return i == 0 ? v[0] : v[i - 1];
93 | }
94 | //找到第一个比scale大的数
95 | else if (v[i] > picControl.Scale)
96 | {
97 | if (increase)
98 | return v[i];
99 | else
100 | return v[i - 1];
101 | }
102 | }
103 | return picControl.Scale;
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/PicEditor/controller/TextControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 | using System.Windows.Markup;
6 | using System.Windows.Media;
7 |
8 | namespace PicEditor.controller
9 | {
10 | class TextControl : INotifyPropertyChanged
11 | {
12 | public event PropertyChangedEventHandler PropertyChanged;
13 | private int left;
14 | private int top;
15 |
16 | public int Left
17 | {
18 | get { return left; }
19 | set
20 | {
21 | left = value;
22 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Left"));
23 | }
24 | }
25 | public int Top
26 | {
27 | get { return top; }
28 | set
29 | {
30 | top = value;
31 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Top"));
32 | }
33 | }
34 | public List AllFontFamily { get; } = new List();
35 | public List AllFontSize
36 | {
37 | get
38 | {
39 | int[] fontSize = new int[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72, 94, 130 };
40 | List list = new List();
41 | for(int i = 0; i < fontSize.Length; i++)
42 | {
43 | list.Add(new FontSizeClass(fontSize[i]));
44 | }
45 | return list;
46 | }
47 | }
48 |
49 | public TextControl()
50 | {
51 | List ZhFontFamily = new List();
52 | foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
53 | {
54 | LanguageSpecificStringDictionary fontdics = fontfamily.FamilyNames;
55 | string fontfamilyname;
56 | //添加英文字体
57 | if (fontdics.ContainsKey(XmlLanguage.GetLanguage("en-us")))
58 | {
59 | if (fontdics.TryGetValue(XmlLanguage.GetLanguage("en-us"), out fontfamilyname))
60 | {
61 | AllFontFamily.Add(new FontFamilyClass(fontfamilyname));
62 | }
63 | }
64 | //添加中文字体
65 | if (fontdics.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
66 | {
67 | if (fontdics.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out fontfamilyname))
68 | {
69 | ZhFontFamily.Add(new FontFamilyClass(fontfamilyname));
70 | }
71 | }
72 | }
73 | AllFontFamily.AddRange(ZhFontFamily);
74 | }
75 | }
76 | public class FontFamilyClass
77 | {
78 | public string FontFamily { get; set; }
79 | public FontFamilyClass(string FontFamily)
80 | {
81 | this.FontFamily = FontFamily;
82 | }
83 | }
84 | public class FontSizeClass
85 | {
86 | public int FontSize { get; set; }
87 | public FontSizeClass(int FontSize)
88 | {
89 | this.FontSize = FontSize;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/PicEditor/style/Button.xaml:
--------------------------------------------------------------------------------
1 |
3 |
24 |
45 |
61 |
77 |
--------------------------------------------------------------------------------
/PicEditor/style/CheckBox.xaml:
--------------------------------------------------------------------------------
1 |
3 |
22 |
--------------------------------------------------------------------------------
/PicEditor/style/ListBox.xaml:
--------------------------------------------------------------------------------
1 |
3 |
77 |
--------------------------------------------------------------------------------
/PicEditor/style/Menu.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
28 |
29 |
61 |
--------------------------------------------------------------------------------
/PicEditor/style/RadioButton.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
34 |
63 |
--------------------------------------------------------------------------------
/PicEditor/style/Rectangle.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/PicEditor/style/ScrollViewer.xaml:
--------------------------------------------------------------------------------
1 |
3 |
19 |
32 |
45 |
78 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/PicEditor/style/Slider.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
18 |
34 |
59 |
--------------------------------------------------------------------------------
/PicEditor/style/TabControl.xaml:
--------------------------------------------------------------------------------
1 |
3 |
22 |
53 |
--------------------------------------------------------------------------------
/PicEditor/style/Window.xaml:
--------------------------------------------------------------------------------
1 |
3 |
27 |
103 |
--------------------------------------------------------------------------------
/PicEditor/window/AboutWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/PicEditor/window/AboutWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 | using System.Windows.Threading;
13 |
14 | namespace PicEditor.window
15 | {
16 | ///
17 | /// AboutWindow.xaml 的交互逻辑
18 | ///
19 | public partial class AboutWindow : Window
20 | {
21 | public AboutWindow()
22 | {
23 | InitializeComponent();
24 | }
25 | private void Window_Loaded(object sender, RoutedEventArgs e)
26 | {
27 | PicEditorVersion.Text = "v " + Application.ResourceAssembly.GetName().Version.ToString();
28 | OSInfo.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() =>
29 | {
30 | try
31 | {
32 | System.Diagnostics.Process process = new System.Diagnostics.Process();
33 | process.StartInfo.FileName = "cmd";
34 | process.StartInfo.Arguments = "/c ver";
35 | process.StartInfo.UseShellExecute = false;
36 | process.StartInfo.RedirectStandardOutput = true;
37 | process.StartInfo.CreateNoWindow = true;
38 | process.Start();
39 | string res = process.StandardOutput.ReadToEnd();
40 | process.WaitForExit();
41 | process.Close();
42 | OSInfo.Text = "OS : Windows " + res.Substring(res.LastIndexOf(' ') + 1, res.LastIndexOf(']') - res.LastIndexOf(' ') - 1);
43 | }
44 | catch (Exception)
45 | {
46 | OSInfo.Text = "OS : 获取失败";
47 | }
48 | }));
49 | }
50 | private void Window_KeyDown(object sender, KeyEventArgs e)
51 | {
52 | if (e.Key == Key.Escape)
53 | this.Close();
54 | }
55 | private void Close(object sender, RoutedEventArgs e)
56 | {
57 | this.Close();
58 | }
59 | private void Path_MouseMove(object sender, MouseEventArgs e)
60 | {
61 | if (e.LeftButton == MouseButtonState.Pressed)
62 | this.DragMove();
63 | }
64 | private void GoToHomePage(object sender, MouseButtonEventArgs e)
65 | {
66 | System.Diagnostics.Process.Start("explorer.exe", (sender as TextBox).Text);
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/PicEditor/window/ColorWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
35 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/PicEditor/window/ColorWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 | using PicEditor.controller;
13 |
14 | namespace PicEditor.window
15 | {
16 | ///
17 | /// ColorWindow.xaml 的交互逻辑
18 | ///
19 | public partial class ColorWindow : Window
20 | {
21 | private readonly string title;
22 | private string pressed_sign = "NULL";
23 | private string target;
24 | private readonly ColorWindowControl colorWindowControl = new ColorWindowControl();
25 |
26 | public ColorWindow(string title, Brush origin_color,string target)
27 | {
28 | InitializeComponent();
29 | this.title = title;
30 | colorWindowControl.NewColor = OldColor.Fill = origin_color;
31 | this.target = target;
32 | }
33 |
34 | private void Window_Loaded(object sender, RoutedEventArgs e)
35 | {
36 | Title = ColorWinTitle.Text = title;
37 | WindowContent.DataContext = colorWindowControl;
38 | colorWindowControl.Init(OldColor.Fill.ToString().Substring(1, 8));
39 | }
40 |
41 | private void Grid_MouseMove(object sender, MouseEventArgs e)
42 | {
43 | if (e.LeftButton == MouseButtonState.Pressed && pressed_sign == "NULL")
44 | this.DragMove();
45 | }
46 |
47 | private void Close(object sender, RoutedEventArgs e)
48 | {
49 | this.Close();
50 | }
51 |
52 | private void ColorBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
53 | {
54 | Point p = e.GetPosition(ColorBar);
55 | colorWindowControl.Top = (int)(p.Y - 0.5);
56 | if (pressed_sign == "NULL")
57 | pressed_sign = "ColorBar";
58 | }
59 |
60 | private void ColorRect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
61 | {
62 | Point p = e.GetPosition(ColorRect);
63 | colorWindowControl.X = (int)p.X;
64 | colorWindowControl.Y = (int)p.Y;
65 | if (pressed_sign == "NULL")
66 | pressed_sign = "ColorRect";
67 | }
68 |
69 | private void WindowContent_MouseMove(object sender, MouseEventArgs e)
70 | {
71 | if (e.LeftButton == MouseButtonState.Pressed)
72 | {
73 | if (pressed_sign == "ColorBar")
74 | {
75 | Point p = e.GetPosition(ColorBar);
76 | colorWindowControl.Top = (int)(p.Y - 0.5);
77 | }
78 | else if (pressed_sign == "ColorRect")
79 | {
80 | Point p = e.GetPosition(ColorRect);
81 | colorWindowControl.X = (int)p.X;
82 | colorWindowControl.Y = (int)p.Y;
83 | }
84 | }
85 | else if (e.LeftButton == MouseButtonState.Released && pressed_sign != "NULL")
86 | {
87 | pressed_sign = "NULL";
88 | }
89 | }
90 |
91 | private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
92 | {
93 | Rectangle rect = sender as Rectangle;
94 | colorWindowControl.HEX = rect.Fill.ToString().Substring(1, 8);
95 | }
96 |
97 | private void Confirm(object sender, RoutedEventArgs e)
98 | {
99 | this.Close();
100 | MainWindow mainWindow = this.Owner as MainWindow;
101 | Color color = Color.FromArgb((byte)colorWindowControl.A, (byte)colorWindowControl.R, (byte)colorWindowControl.G, (byte)colorWindowControl.B);
102 | if (target == "FgColor")
103 | {
104 | mainWindow.SetFgColor(color);
105 | }
106 | else if (target == "TextBgColor")
107 | {
108 | mainWindow.SetTextBgColor(color);
109 | }
110 | else if(target== "PicSynFillColor")
111 | {
112 | mainWindow.SetPicSynFillColor(color);
113 | }
114 | }
115 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
116 | {
117 | if (e.Key == Key.Enter)
118 | {
119 | colorWindowControl.UpdateHex((sender as TextBox).Text);
120 | }
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/PicEditor/window/CreatePictureWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/PicEditor/window/CreatePictureWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 |
13 | namespace PicEditor.window
14 | {
15 | ///
16 | /// CreatePictureWindow.xaml 的交互逻辑
17 | ///
18 | public partial class CreatePictureWindow : Window
19 | {
20 | public CreatePictureWindow()
21 | {
22 | InitializeComponent();
23 | }
24 |
25 | private void Window_KeyDown(object sender, KeyEventArgs e)
26 | {
27 | if (e.Key == Key.Enter)
28 | {
29 | Confirm();
30 | }
31 | else if (e.Key == Key.Escape)
32 | {
33 | this.Close();
34 | }
35 | }
36 |
37 | private void Close(object sender, RoutedEventArgs e)
38 | {
39 | this.Close();
40 | }
41 |
42 | private void Grid_MouseMove(object sender, MouseEventArgs e)
43 | {
44 | if (e.LeftButton == MouseButtonState.Pressed)
45 | this.DragMove();
46 | }
47 |
48 | private void Confirm(object sender, RoutedEventArgs e)
49 | {
50 | Confirm();
51 | }
52 | private void Confirm()
53 | {
54 | if (W.Tag.ToString() == "" && H.Tag.ToString() == "" && DpiX.Tag.ToString() == "" && DpiY.Tag.ToString() == "")
55 | {
56 | this.Close();
57 | MainWindow mainWindow = this.Owner as MainWindow;
58 | mainWindow.CreatePicture(int.Parse(W.Text), int.Parse(H.Text), double.Parse(DpiX.Text), double.Parse(DpiY.Text), WhiteBg.IsChecked == true ? true : false);
59 | }
60 | }
61 |
62 | private void ToInt(object sender, TextChangedEventArgs e)
63 | {
64 | TextBox tb = sender as TextBox;
65 | try
66 | {
67 | tb.Background = new SolidColorBrush(Color.FromRgb(48, 48, 48));
68 | int i = int.Parse(tb.Text);
69 | if (i <= 0)
70 | {
71 | tb.Background = new SolidColorBrush(Colors.Red);
72 | tb.Tag = "Error";
73 | return;
74 | }
75 | tb.Tag = "";
76 | }
77 | catch (Exception)
78 | {
79 | tb.Background = new SolidColorBrush(Colors.Red);
80 | tb.Tag = "Error";
81 | }
82 | }
83 |
84 | private void ToDouble(object sender, TextChangedEventArgs e)
85 | {
86 | TextBox tb = sender as TextBox;
87 | try
88 | {
89 | tb.Background = new SolidColorBrush(Color.FromRgb(48, 48, 48));
90 | double i = double.Parse(tb.Text);
91 | if (i <= 0)
92 | {
93 | tb.Background = new SolidColorBrush(Colors.Red);
94 | tb.Tag = "Error";
95 | return;
96 | }
97 | tb.Tag = "";
98 | }
99 | catch (Exception)
100 | {
101 | tb.Background = new SolidColorBrush(Colors.Red);
102 | tb.Tag = "Error";
103 | }
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/PicEditor/window/HelpWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/PicEditor/window/HelpWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 |
13 | namespace PicEditor.window
14 | {
15 | ///
16 | /// HelpWindow.xaml 的交互逻辑
17 | ///
18 | public partial class HelpWindow : Window
19 | {
20 | public HelpWindow()
21 | {
22 | InitializeComponent();
23 | }
24 |
25 | private void Window_Loaded(object sender, RoutedEventArgs e)
26 | {
27 | test1.Text = "(1) BlackWhite:用于显示黑白两种色值的像素格式(非黑即白)。\r\n" +
28 | "(2) Gray2:2BPP(Bits Per Pixel,位 / 像素)的灰色通道。允许四种灰阶。\r\n" +
29 | "(3) Gray4:4BPP的灰度通道,允许16种灰阶值表示灰色。\r\n" +
30 | "(4) Gray8:显示8BPP的灰度通道,允许256种灰阶值表示灰色。\r\n" +
31 | "(5) Gray16:16BPP的灰色通道,最多允许65536种灰阶值表示灰色。这种格式的Gamma是1.0。\r\n" +
32 | "(6) Gray32Float:32BPP的灰度通道,允许超过40亿灰阶。此格式的Gamma值是1.0。\r\n" +
33 | "(7) Indexed1:指定2种颜色作为调色板的像素格式。\r\n" +
34 | "(8) Indexed2:指定4种颜色作为调色板的像素格式。\r\n" +
35 | "(9) Indexed4:指定16种颜色作为调色板的像素格式。\r\n" +
36 | "(10) Indexed8:指定256种颜色作为调色板的像素格式。\r\n" +
37 | "(11) Bgr24:Bgr24像素格式是一种采用24BPP的sRGB格式。每个颜色通道(蓝色blue, 绿色green, 红色red)各占8BPP(位 / 像素)。\r\n" +
38 | "(12) Bgra32:Bgra32像素格式是一种32BPP的sRGB格式。每个颜色通道(蓝色blue, 绿色green, 红色red)各占8BPP(位 / 像素),与Bgr24不同的是,它还有用于表现不透明度的alpha通道(8BPP)。\r\n" +
39 | "(13) Bgr101010:Bgr101010像素格式是一种采用32BPP(位 / 像素)的sRGB格式。每个颜色通道(蓝色blue, 绿色green, 红色red)各占10BPP(位 / 像素)。\r\n" +
40 | "(14) Bgr32:Bgr32像素格式是一种采用32BPP(位 / 像素)的sRGB格式。与Bgr101010格式不同的是,它的每个颜色通道(蓝色blue, 绿色green, 红色red)各占8BPP(位 / 像素)。\r\n" +
41 | "(15) Bgr555:Bgr555也是一种sRGB格式,它采用16BPP(位 / 像素). 它的每个颜色通道(蓝色blue, 绿色green, 红色red)各占5BPP(位 / 像素)。\r\n" +
42 | "(16) Bgr565:Bgr565像素格式是一种16BPP(位 / 像素)的sRGB格式。它的每个颜色通道(蓝色blue, 绿色green, 红色red)分别占5BPP,6BPP,5BPP(位 / 像素)。\r\n" +
43 | "(17) Pbgra32:采用32BPP的一种基于sRGB的像素格式。每个颜色通道(蓝色blue, 绿色green, 红色red,Alpha通道)各占8BPP(位 / 像素)。每种颜色通道是经过与Alpha值预处理之后的。\r\n" +
44 | "(18) Prgba64:是一种基于sRGB格式,采用64BPP。每个颜色通道(蓝色blue, 绿色green, 红色red,Alpha通道)各占32BPP(位 / 像素)。每种颜色通道是经过与Alpha值预处理之后的。这种格式的Gamma是1.0。\r\n" +
45 | "(19) Rgb24:是一种基于sRGB格式,采用24BPP。每个颜色通道(蓝色blue, 绿色green, 红色red)各占8BPP(位 / 像素)。\r\n" +
46 | "(20) Rgb48:是一种基于sRGB格式,采用48BPP。每个颜色通道(蓝色blue, 绿色green, 红色red)各占16BPP(位 / 像素)。这种格式的Gamma是1.0。\r\n" +
47 | "(21) Rgba64:是一种基于sRGB格式,采用64BPP。每个颜色通道(蓝色blue, 绿色green, 红色red,Alpha通道)各占16BPP(位 / 像素)。这种格式的Gamma是1.0。\r\n" +
48 | "(22) Rgb128Float:是一种基于ScRGB格式,采用128BPP。每个颜色通道各占32BPP(位 / 像素)。这种格式的Gamma是1.0。\r\n" +
49 | "(23) Rgba128Float:是一种基于ScRGB格式,采用128BPP。每个颜色通道(蓝色blue, 绿色green, 红色red,Alpha通道)各占32BPP(位 / 像素)。这种格式的Gamma是1.0。\r\n" +
50 | "(24) Prgba128Float:是一种基于ScRGB格式,采用128BPP。每个颜色通道(蓝色blue, 绿色green, 红色red,Alpha通道)各占32BPP(位 / 像素)。每种颜色通道是经过与Alpha值预处理之后的。这种格式的Gamma是1.0。\r\n" +
51 | "(25) Cmyk32:用于表现印刷色格式,采用32BPP,共四个颜色通道即C、M、Y、K(青色Cyan, 品红Magenta, 黄色Yellow和黑色blacK),各占8PP。";
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/PicEditor/window/MsgWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/PicEditor/window/MsgWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 |
13 | namespace PicEditor.window
14 | {
15 | ///
16 | /// MsgWindow.xaml 的交互逻辑
17 | ///
18 | public partial class MsgWindow : Window
19 | {
20 | private readonly string title;
21 | private readonly string message;
22 | private readonly string button;
23 | public MsgWindow(string title,string message,string button)
24 | {
25 | InitializeComponent();
26 | this.title = title;
27 | this.message = message;
28 | this.button = button;
29 | }
30 |
31 | private void Window_Loaded(object sender, RoutedEventArgs e)
32 | {
33 | Title = MsgTitle.Text = title;
34 | Msg.Text = message;
35 | if (button == "Confirm")
36 | {
37 | Cancel.Visibility = Visibility.Collapsed;
38 | }
39 | }
40 |
41 | private void Close(object sender, RoutedEventArgs e)
42 | {
43 | this.Close();
44 | }
45 |
46 | private void Grid_MouseMove(object sender, MouseEventArgs e)
47 | {
48 | if (e.LeftButton == MouseButtonState.Pressed)
49 | this.DragMove();
50 | }
51 |
52 | private void MsgConfirm(object sender, RoutedEventArgs e)
53 | {
54 | this.DialogResult = true;
55 | this.Close();
56 | }
57 |
58 | private void MsgCancel(object sender, RoutedEventArgs e)
59 | {
60 | this.DialogResult = false;
61 | this.Close();
62 | }
63 |
64 | private void Window_KeyDown(object sender, KeyEventArgs e)
65 | {
66 | if (e.Key == Key.Enter)
67 | {
68 | this.DialogResult = true;
69 | this.Close();
70 | }
71 | else if (e.Key == Key.Escape)
72 | {
73 | this.DialogResult = false;
74 | this.Close();
75 | }
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/PicEditor/window/OpenPictureWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/PicEditor/window/OpenPictureWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 |
13 | namespace PicEditor.window
14 | {
15 | ///
16 | /// OpenPictureWindow.xaml 的交互逻辑
17 | ///
18 | public partial class OpenPictureWindow : Window
19 | {
20 | private string target = null;
21 | public OpenPictureWindow(string target)
22 | {
23 | InitializeComponent();
24 | this.target = target;
25 | }
26 | private void Window_Loaded(object sender, RoutedEventArgs e)
27 | {
28 | URL.Focus();
29 | URL.Select(URL.Text.Length, 0);
30 | }
31 | public void SetValue(String url)
32 | {
33 | URL.Text = url;
34 | Tip.Text = "打开失败!此链接不是图片链接";
35 | }
36 | private void OpenPicture()
37 | {
38 | if (URL.Text == null || URL.Text == "")
39 | {
40 | Tip.Text = "链接不能为空!";
41 | return;
42 | }
43 | this.Close();
44 | MainWindow mainWindow = this.Owner as MainWindow;
45 | if (target == "OpenPictureByURL")
46 | mainWindow.OpenPictureByURL(URL.Text);
47 | else if(target== "AddSecPicByURL")
48 | mainWindow.AddSecPicByURL(URL.Text);
49 | }
50 | private void Button_Click(object sender, RoutedEventArgs e)
51 | {
52 | OpenPicture();
53 | }
54 | private void URL_KeyDown(object sender, KeyEventArgs e)
55 | {
56 | if (e.Key == Key.Enter)
57 | OpenPicture();
58 | else if (e.Key == Key.Escape)
59 | this.Close();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/PicEditor/window/PicBACWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/PicEditor/window/PicBACWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 | using PicEditor.controller;
13 | using PicEditor.core;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// BACWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicBACWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicBACControl picBACControl = new PicBACControl();
24 |
25 | public PicBACWindow(BitmapSource bs)
26 | {
27 | InitializeComponent();
28 | this.bs = bs;
29 | Content.DataContext = picBACControl;
30 | Brightness.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
31 | Contrast.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
32 | }
33 |
34 | private void Close(object sender, RoutedEventArgs e)
35 | {
36 | Cancel();
37 | }
38 |
39 | private void Grid_MouseMove(object sender, MouseEventArgs e)
40 | {
41 | if (e.LeftButton == MouseButtonState.Pressed)
42 | this.DragMove();
43 | }
44 | private void Confirm(object sender, RoutedEventArgs e)
45 | {
46 | MainWindow mainWindow = this.Owner as MainWindow;
47 | mainWindow.PicColorCallback(null, "亮度/对比度");
48 | this.Close();
49 | }
50 | private void Cancel(object sender, RoutedEventArgs e)
51 | {
52 | Cancel();
53 | }
54 | private void Cancel()
55 | {
56 | MainWindow mainWindow = this.Owner as MainWindow;
57 | mainWindow.PicColorCallback();
58 | this.Close();
59 | }
60 |
61 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
62 | {
63 | Start();
64 | }
65 |
66 | private void Reset(object sender, RoutedEventArgs e)
67 | {
68 | picBACControl.Reset();
69 | MainWindow mainWindow = this.Owner as MainWindow;
70 | mainWindow.PicColorCallback();
71 | }
72 |
73 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
74 | {
75 | if(e.Key==Key.Enter)
76 | Start();
77 | }
78 |
79 | private void Start()
80 | {
81 | MainWindow mainWindow = this.Owner as MainWindow;
82 | picBACControl.Visi = Visibility.Visible;
83 | mainWindow.PicBAC(bs, this, picBACControl.B, picBACControl.C);
84 | }
85 |
86 | public void Back()
87 | {
88 | picBACControl.Visi = Visibility.Collapsed;
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/PicEditor/window/PicChannelMixerWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using PicEditor.core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// PicChannelMixerWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicChannelMixerWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicChannelMixerControl picChannelMixerControl = new PicChannelMixerControl();
24 | public PicChannelMixerWindow(BitmapSource bs)
25 | {
26 | InitializeComponent();
27 | this.bs = bs;
28 | Content.DataContext = picChannelMixerControl;
29 | R.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
30 | Rg.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
31 | Rb.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
32 | Gr.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
33 | G.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
34 | Gb.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
35 | Br.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
36 | Bg.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
37 | B.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
38 | }
39 |
40 | private void Grid_MouseMove(object sender, MouseEventArgs e)
41 | {
42 | if (e.LeftButton == MouseButtonState.Pressed)
43 | this.DragMove();
44 | }
45 |
46 | private void Close(object sender, RoutedEventArgs e)
47 | {
48 | Cancel();
49 | }
50 |
51 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
52 | {
53 | if (e.Key == Key.Enter)
54 | Start();
55 | }
56 |
57 | private void Confirm(object sender, RoutedEventArgs e)
58 | {
59 | MainWindow mainWindow = this.Owner as MainWindow;
60 | mainWindow.PicColorCallback(null, "通道混合器");
61 | this.Close();
62 | }
63 |
64 | private void Cancel(object sender, RoutedEventArgs e)
65 | {
66 | Cancel();
67 | }
68 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
69 | {
70 | Start();
71 | }
72 | private void Cancel()
73 | {
74 | MainWindow mainWindow = this.Owner as MainWindow;
75 | mainWindow.PicColorCallback();
76 | this.Close();
77 | }
78 | private void Reset(object sender, RoutedEventArgs e)
79 | {
80 | picChannelMixerControl.Reset();
81 | MainWindow mainWindow = this.Owner as MainWindow;
82 | mainWindow.PicColorCallback();
83 | }
84 | private void Start()
85 | {
86 | MainWindow mainWindow = this.Owner as MainWindow;
87 | double[] red = new double[] { picChannelMixerControl.R, picChannelMixerControl.Rg, picChannelMixerControl.Rb };
88 | double[] green = new double[] { picChannelMixerControl.Gr, picChannelMixerControl.G, picChannelMixerControl.Gb };
89 | double[] blue = new double[] { picChannelMixerControl.Br, picChannelMixerControl.Bg, picChannelMixerControl.B };
90 | picChannelMixerControl.Visi = Visibility.Visible;
91 | mainWindow.PicChannelMixer(bs, this, red, green, blue);
92 | }
93 | public void Back()
94 | {
95 | picChannelMixerControl.Visi = Visibility.Collapsed;
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/PicEditor/window/PicColorScaleWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/PicEditor/window/PicColorScaleWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Shapes;
13 |
14 | namespace PicEditor.window
15 | {
16 | ///
17 | /// PicColorScaleWindow.xaml 的交互逻辑
18 | ///
19 | public partial class PicColorScaleWindow : Window
20 | {
21 | private readonly BitmapSource bs;
22 | private string pressed = "NULL";
23 | private readonly int[][] data = new int[4][];
24 | private readonly int[] max = new int[4];
25 | private readonly PCSControl pCSControl = new PCSControl();
26 |
27 | public PicColorScaleWindow(BitmapSource bs)
28 | {
29 | InitializeComponent();
30 | this.bs = bs;
31 | for (int i = 0; i < 4; i++)
32 | data[i] = new int[256];
33 | Content.DataContext = pCSControl;
34 |
35 | }
36 |
37 | private void Window_Loaded(object sender, RoutedEventArgs e)
38 | {
39 | ChartPath.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, (Action)(() =>
40 | {
41 | core.PicProcess picProcess = new core.PicProcess();
42 | picProcess.GetPixelCount(bs, data[1], data[2], data[3]);
43 | for (int i = 0; i < 256; i++)
44 | {
45 | data[0][i] = data[1][i] + data[2][i] + data[3][i];
46 | max[0] = data[0][i] > max[0] ? data[0][i] : max[0];
47 | max[1] = data[1][i] > max[1] ? data[1][i] : max[1];
48 | max[2] = data[2][i] > max[2] ? data[2][i] : max[2];
49 | max[3] = data[3][i] > max[3] ? data[3][i] : max[3];
50 | }
51 | Channel.SelectedIndex = 0;
52 | }));
53 | }
54 |
55 | private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
56 | {
57 | ChartPath.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, (Action)(() =>
58 | {
59 | int ChartWidth = 300;
60 | int ChartHeight = 100;
61 | string paths = "M 0," + ChartHeight + " ";
62 | double WidthOffset = (double)ChartWidth / 256;
63 | for (int i = 0; i < 256; i++)
64 | {
65 | int y = ChartHeight - ChartHeight * data[Channel.SelectedIndex][i] / max[Channel.SelectedIndex];
66 | paths += (i * WidthOffset).ToString() + "," + y.ToString() + " ";
67 | }
68 | paths += ChartWidth + "," + ChartHeight + " Z";
69 | var converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Geometry));
70 | ChartPath.Data = (Geometry)converter.ConvertFrom(paths);
71 | if (Channel.SelectedIndex == 0)
72 | RightColor.Color = Colors.White;
73 | else if (Channel.SelectedIndex == 1)
74 | RightColor.Color = Color.FromRgb(255, 0, 0);
75 | else if (Channel.SelectedIndex == 2)
76 | RightColor.Color = Color.FromRgb(0, 255, 0);
77 | else if (Channel.SelectedIndex == 3)
78 | RightColor.Color = Color.FromRgb(0, 0, 255);
79 | }));
80 | }
81 |
82 | private void Grid_MouseMove(object sender, MouseEventArgs e)
83 | {
84 | if (e.LeftButton == MouseButtonState.Pressed && pressed == "NULL")
85 | this.DragMove();
86 | }
87 |
88 | private void Close(object sender, RoutedEventArgs e)
89 | {
90 | Cancel();
91 | }
92 |
93 | private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
94 | {
95 | pressed = (sender as Path).Name;
96 | }
97 |
98 | private void StackPanel_MouseMove(object sender, MouseEventArgs e)
99 | {
100 | if (e.LeftButton == MouseButtonState.Pressed)
101 | {
102 | Point p = e.GetPosition(Chart);
103 | if (pressed == "IB")
104 | pCSControl.IB = p.X;
105 | else if (pressed == "IG")
106 | pCSControl.IG = p.X;
107 | else if (pressed == "IW")
108 | pCSControl.IW = p.X;
109 | else if (pressed == "OB")
110 | pCSControl.OB = p.X;
111 | else if (pressed == "OW")
112 | pCSControl.OW = p.X;
113 | }
114 | else if (e.LeftButton == MouseButtonState.Released)
115 | {
116 | if (pressed != "NULL")
117 | {
118 | pressed = "NULL";
119 | Start();
120 | }
121 | }
122 | }
123 | private void Cancel()
124 | {
125 | MainWindow mainWindow = this.Owner as MainWindow;
126 | mainWindow.PicColorCallback();
127 | this.Close();
128 | }
129 |
130 | private void Confirm(object sender, RoutedEventArgs e)
131 | {
132 | MainWindow mainWindow = this.Owner as MainWindow;
133 | mainWindow.PicColorCallback(null, "色阶");
134 | this.Close();
135 | }
136 |
137 | private void Cancel(object sender, RoutedEventArgs e)
138 | {
139 | Cancel();
140 | }
141 |
142 | private void Reset(object sender, RoutedEventArgs e)
143 | {
144 | pCSControl.Reset();
145 | MainWindow mainWindow = this.Owner as MainWindow;
146 | mainWindow.PicColorCallback();
147 | }
148 |
149 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
150 | {
151 | if (e.Key == Key.Enter)
152 | Start();
153 | }
154 |
155 | private void Start()
156 | {
157 | MainWindow mainWindow = this.Owner as MainWindow;
158 | pCSControl.Visi = Visibility.Visible;
159 | double[] data = new double[5];
160 | pCSControl.GetData(data);
161 | mainWindow.PicColorScale(bs, this, Channel.SelectedIndex, data[0], data[1], data[2], data[3], data[4]);
162 | }
163 | public void Back()
164 | {
165 | pCSControl.Visi = Visibility.Collapsed;
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/PicEditor/window/PicCurveWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/PicEditor/window/PicCurveWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using PicEditor.core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// PicCurveWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicCurveWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicCurveControl picCurveControl = new PicCurveControl();
24 | private string elli = "NULL";
25 | private readonly int[][] data = new int[4][];
26 | private readonly int[] max = new int[4];
27 | public PicCurveWindow(BitmapSource bs)
28 | {
29 | InitializeComponent();
30 | this.bs = bs;
31 | for (int i = 0; i < 4; i++)
32 | data[i] = new int[256];
33 | Content.DataContext = picCurveControl;
34 | }
35 | private void Window_Loaded(object sender, RoutedEventArgs e)
36 | {
37 | ChartPath.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, (Action)(() =>
38 | {
39 | core.PicProcess picProcess = new core.PicProcess();
40 | picProcess.GetPixelCount(bs, data[1], data[2], data[3]);
41 | for (int i = 0; i < 256; i++)
42 | {
43 | data[0][i] = data[1][i] + data[2][i] + data[3][i];
44 | max[0] = data[0][i] > max[0] ? data[0][i] : max[0];
45 | max[1] = data[1][i] > max[1] ? data[1][i] : max[1];
46 | max[2] = data[2][i] > max[2] ? data[2][i] : max[2];
47 | max[3] = data[3][i] > max[3] ? data[3][i] : max[3];
48 | }
49 | Channel.SelectedIndex = 0;
50 | }));
51 | }
52 | private void Grid_MouseMove(object sender, MouseEventArgs e)
53 | {
54 | if (e.LeftButton == MouseButtonState.Pressed && elli == "NULL")
55 | this.DragMove();
56 | }
57 |
58 | private void Close(object sender, RoutedEventArgs e)
59 | {
60 | Cancel();
61 | }
62 |
63 | private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
64 | {
65 | ChartPath.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, (Action)(() =>
66 | {
67 | int ChartWidth = 255;
68 | int ChartHeight = 255;
69 | string paths = "M 0," + ChartHeight + " ";
70 | double WidthOffset = (double)ChartWidth / 256;
71 | for (int i = 0; i < 256; i++)
72 | {
73 | int y = ChartHeight - ChartHeight * data[Channel.SelectedIndex][i] / max[Channel.SelectedIndex];
74 | paths += (i * WidthOffset).ToString() + "," + y.ToString() + " ";
75 | }
76 | paths += ChartWidth + "," + ChartHeight + " Z";
77 | var converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Geometry));
78 | ChartPath.Data = (Geometry)converter.ConvertFrom(paths);
79 | if (Channel.SelectedIndex == 0)
80 | TopColor.Color = Colors.White;
81 | else if (Channel.SelectedIndex == 1)
82 | TopColor.Color = Color.FromRgb(255, 0, 0);
83 | else if (Channel.SelectedIndex == 2)
84 | TopColor.Color = Color.FromRgb(0, 255, 0);
85 | else if (Channel.SelectedIndex == 3)
86 | TopColor.Color = Color.FromRgb(0, 0, 255);
87 | picCurveControl.ChangeChannel(Channel.SelectedIndex);
88 | }));
89 | }
90 |
91 | private void Confirm(object sender, RoutedEventArgs e)
92 | {
93 | MainWindow mainWindow = this.Owner as MainWindow;
94 | mainWindow.PicColorCallback(null, "曲线");
95 | this.Close();
96 | }
97 |
98 | private void Cancel(object sender, RoutedEventArgs e)
99 | {
100 | Cancel();
101 | }
102 | private void Cancel()
103 | {
104 | MainWindow mainWindow = this.Owner as MainWindow;
105 | mainWindow.PicColorCallback();
106 | this.Close();
107 | }
108 | private void Reset(object sender, RoutedEventArgs e)
109 | {
110 | picCurveControl.Reset();
111 | MainWindow mainWindow = this.Owner as MainWindow;
112 | mainWindow.PicColorCallback();
113 | }
114 |
115 | private void ResetChannel(object sender, RoutedEventArgs e)
116 | {
117 | int[][] path_data = picCurveControl.ResetChannel(Channel.SelectedIndex);
118 | PicProcess picProcess = new PicProcess();
119 | MainWindow mainWindow = this.Owner as MainWindow;
120 | picCurveControl.Visi = Visibility.Visible;
121 | Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)(() =>
122 | {
123 | mainWindow.PicColorCallback(picProcess.PicCurve(bs, path_data));
124 | picCurveControl.Visi = Visibility.Collapsed;
125 | }));
126 | }
127 | private void StackPanel_MouseMove(object sender, MouseEventArgs e)
128 | {
129 | if (e.LeftButton == MouseButtonState.Pressed)
130 | {
131 | if (elli == "NULL")
132 | return;
133 | Point p = e.GetPosition(Chart);
134 | switch (elli)
135 | {
136 | case "Y1":
137 | picCurveControl.Y1 = p.Y; break;
138 | case "Y2":
139 | picCurveControl.Y2 = p.Y; break;
140 | case "Y3":
141 | picCurveControl.Y3 = p.Y; break;
142 | case "Y4":
143 | picCurveControl.Y4 = p.Y; break;
144 | case "Y5":
145 | picCurveControl.Y5 = p.Y; break;
146 | case "Y6":
147 | picCurveControl.Y6 = p.Y; break;
148 | case "Y7":
149 | picCurveControl.Y7 = p.Y; break;
150 | case "Y8":
151 | picCurveControl.Y8 = p.Y; break;
152 | case "Y9":
153 | picCurveControl.Y9 = p.Y; break;
154 | }
155 | picCurveControl.UpdatePath(Channel.SelectedIndex);
156 | }
157 | else if (e.LeftButton == MouseButtonState.Released)
158 | {
159 | if (elli != "NULL")
160 | {
161 | elli = "NULL";
162 | Start();
163 | }
164 | }
165 | }
166 |
167 | private void Elli_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
168 | {
169 | elli = (sender as Ellipse).Name;
170 | }
171 |
172 | private void Start()
173 | {
174 | MainWindow mainWindow = this.Owner as MainWindow;
175 | picCurveControl.Visi = Visibility.Visible;
176 | int[][] path_data = picCurveControl.GetPathData();
177 | mainWindow.PicCurve(bs, this, path_data);
178 | }
179 | public void Back()
180 | {
181 | picCurveControl.Visi = Visibility.Collapsed;
182 | }
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/PicEditor/window/PicHSWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/PicEditor/window/PicHSWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Shapes;
13 |
14 | namespace PicEditor.window
15 | {
16 | ///
17 | /// PicHSWindow.xaml 的交互逻辑
18 | ///
19 | public partial class PicHSWindow : Window
20 | {
21 | private readonly BitmapSource bs;
22 | private readonly PicHSControl picHSControl = new PicHSControl();
23 |
24 | public PicHSWindow(BitmapSource bs)
25 | {
26 | InitializeComponent();
27 | this.bs = bs;
28 | Content.DataContext = picHSControl;
29 | Hue.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
30 | Saturation.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
31 | Value.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
32 | }
33 |
34 | private void Window_Loaded(object sender, RoutedEventArgs e)
35 | {
36 | Mode.SelectedIndex = 0;
37 | }
38 |
39 | private void Grid_MouseMove(object sender, MouseEventArgs e)
40 | {
41 | if (e.LeftButton == MouseButtonState.Pressed)
42 | this.DragMove();
43 | }
44 |
45 | private void Close(object sender, RoutedEventArgs e)
46 | {
47 | Cancel();
48 | }
49 |
50 | private void Confirm(object sender, RoutedEventArgs e)
51 | {
52 | MainWindow mainWindow = this.Owner as MainWindow;
53 | mainWindow.PicColorCallback(null, "色相/饱和度");
54 | this.Close();
55 | }
56 |
57 | private void Cancel(object sender, RoutedEventArgs e)
58 | {
59 | Cancel();
60 | }
61 |
62 | private void Reset(object sender, RoutedEventArgs e)
63 | {
64 | picHSControl.Reset();
65 | MainWindow mainWindow = this.Owner as MainWindow;
66 | mainWindow.PicColorCallback();
67 | }
68 | private void Cancel()
69 | {
70 | MainWindow mainWindow = this.Owner as MainWindow;
71 | mainWindow.PicColorCallback();
72 | this.Close();
73 | }
74 | private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
75 | {
76 | VName.Text = Mode.SelectedIndex == 0 ? "明度" : "亮度";
77 | }
78 |
79 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
80 | {
81 | Start();
82 | }
83 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
84 | {
85 | if (e.Key == Key.Enter)
86 | Start();
87 | }
88 |
89 | private void Start()
90 | {
91 | MainWindow mainWindow = this.Owner as MainWindow;
92 | picHSControl.Visi = Visibility.Visible;
93 | mainWindow.PicHS(bs, this, Mode.SelectedIndex, picHSControl.H, picHSControl.S / 100, picHSControl.V / 100);
94 | }
95 | public void Back()
96 | {
97 | picHSControl.Visi = Visibility.Collapsed;
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/PicEditor/window/PicMeanFilterWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/PicEditor/window/PicMeanFilterWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using PicEditor.core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// PicMeanFilterWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicMeanFilterWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicMeanFilterControl picMeanFilterControl = new PicMeanFilterControl();
24 | public PicMeanFilterWindow(BitmapSource bs)
25 | {
26 | InitializeComponent();
27 | this.bs = bs;
28 | Content.DataContext = picMeanFilterControl;
29 | Radius.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
30 | }
31 |
32 | private void Grid_MouseMove(object sender, MouseEventArgs e)
33 | {
34 | if (e.LeftButton == MouseButtonState.Pressed)
35 | this.DragMove();
36 | }
37 |
38 | private void Close(object sender, RoutedEventArgs e)
39 | {
40 | Cancel();
41 | }
42 |
43 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
44 | {
45 | if (e.Key == Key.Enter)
46 | Start();
47 | }
48 |
49 | private void Confirm(object sender, RoutedEventArgs e)
50 | {
51 | MainWindow mainWindow = this.Owner as MainWindow;
52 | mainWindow.PicColorCallback(null, "模糊");
53 | this.Close();
54 | }
55 |
56 | private void Cancel(object sender, RoutedEventArgs e)
57 | {
58 | Cancel();
59 | }
60 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
61 | {
62 | Start();
63 | }
64 | private void Cancel()
65 | {
66 | MainWindow mainWindow = this.Owner as MainWindow;
67 | mainWindow.PicColorCallback();
68 | this.Close();
69 | }
70 | private void Start()
71 | {
72 | MainWindow mainWindow = this.Owner as MainWindow;
73 | picMeanFilterControl.Visi = Visibility.Visible;
74 | mainWindow.PicMeanFilter(bs,this, (int)picMeanFilterControl.Radius);
75 | }
76 | public void Back()
77 | {
78 | picMeanFilterControl.Visi = Visibility.Collapsed;
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/PicEditor/window/PicPixelatedWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/PicEditor/window/PicPixelatedWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using PicEditor.core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// PicPixelatedWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicPixelatedWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicPixelatedControl picPixelatedControl = new PicPixelatedControl();
24 | public PicPixelatedWindow(BitmapSource bs)
25 | {
26 | InitializeComponent();
27 | this.bs = bs;
28 | Content.DataContext = picPixelatedControl;
29 | Size.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
30 | }
31 |
32 | private void Grid_MouseMove(object sender, MouseEventArgs e)
33 | {
34 | if (e.LeftButton == MouseButtonState.Pressed)
35 | this.DragMove();
36 | }
37 |
38 | private void Close(object sender, RoutedEventArgs e)
39 | {
40 | Cancel();
41 | }
42 |
43 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
44 | {
45 | if (e.Key == Key.Enter)
46 | Start();
47 | }
48 |
49 | private void Confirm(object sender, RoutedEventArgs e)
50 | {
51 | MainWindow mainWindow = this.Owner as MainWindow;
52 | mainWindow.PicColorCallback(null, "像素化");
53 | this.Close();
54 | }
55 |
56 | private void Cancel(object sender, RoutedEventArgs e)
57 | {
58 | Cancel();
59 | }
60 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
61 | {
62 | Start();
63 | }
64 | private void Cancel()
65 | {
66 | MainWindow mainWindow = this.Owner as MainWindow;
67 | mainWindow.PicColorCallback();
68 | this.Close();
69 | }
70 | private void Start()
71 | {
72 | MainWindow mainWindow = this.Owner as MainWindow;
73 | if (picPixelatedControl.Size == 1)
74 | {
75 | mainWindow.PicColorCallback(bs);
76 | return;
77 | }
78 | picPixelatedControl.Visi = Visibility.Visible;
79 | mainWindow.PicPixelated(bs, this, (int)picPixelatedControl.Size);
80 | }
81 | public void Back()
82 | {
83 | picPixelatedControl.Visi = Visibility.Collapsed;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/PicEditor/window/PicResizeWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/PicEditor/window/PicResizeWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 |
13 | namespace PicEditor.window
14 | {
15 | ///
16 | /// PicResizeWindow.xaml 的交互逻辑
17 | ///
18 | public partial class PicResizeWindow : Window
19 | {
20 | private int width;
21 | private int height;
22 | public PicResizeWindow(int width,int height)
23 | {
24 | InitializeComponent();
25 | this.width = width;
26 | this.height = height;
27 | W.Text = width.ToString();
28 | H.Text = height.ToString();
29 | }
30 | private void Window_KeyDown(object sender, KeyEventArgs e)
31 | {
32 | if (e.Key == Key.Enter)
33 | {
34 | Confirm();
35 | }
36 | else if (e.Key == Key.Escape)
37 | {
38 | this.Close();
39 | }
40 | }
41 |
42 | private void Close(object sender, RoutedEventArgs e)
43 | {
44 | this.Close();
45 | }
46 |
47 | private void Confirm(object sender, RoutedEventArgs e)
48 | {
49 | Confirm();
50 | }
51 | private void Confirm()
52 | {
53 | if (W.Tag.ToString() == "" && H.Tag.ToString() == "")
54 | {
55 | this.Close();
56 | MainWindow mainWindow = this.Owner as MainWindow;
57 | mainWindow.PicResize(int.Parse(W.Text), int.Parse(H.Text));
58 | }
59 | }
60 | private void Grid_MouseMove(object sender, MouseEventArgs e)
61 | {
62 | if (e.LeftButton == MouseButtonState.Pressed)
63 | this.DragMove();
64 | }
65 | private void ToInt(object sender, TextChangedEventArgs e)
66 | {
67 | TextBox tb = sender as TextBox;
68 | try
69 | {
70 | tb.Background = new SolidColorBrush(Color.FromRgb(48, 48, 48));
71 | int i = int.Parse(tb.Text);
72 | if (i <= 0)
73 | {
74 | tb.Background = new SolidColorBrush(Colors.Red);
75 | tb.Tag = "Error";
76 | return;
77 | }
78 | tb.Tag = "";
79 | }
80 | catch (Exception)
81 | {
82 | tb.Background = new SolidColorBrush(Colors.Red);
83 | tb.Tag = "Error";
84 | }
85 | }
86 | private void CalcProportion(object sender, RoutedEventArgs e)
87 | {
88 | TextBox tb = sender as TextBox;
89 | if (tb.Tag.ToString() == "" && KeepProportion.IsChecked == true)
90 | {
91 | int i = int.Parse(tb.Text);
92 | if (tb.Name == "W")
93 | H.Text = (i * height / width).ToString();
94 | else if (tb.Name == "H")
95 | W.Text = (i * width / height).ToString();
96 | }
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/PicEditor/window/PicSharpenWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/PicEditor/window/PicSharpenWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using PicEditor.core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// PicSharpenWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicSharpenWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicSharpenControl picSharpenControl = new PicSharpenControl();
24 |
25 | public PicSharpenWindow(BitmapSource bs)
26 | {
27 | InitializeComponent();
28 | this.bs = bs;
29 | Content.DataContext = picSharpenControl;
30 | Sharpen.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
31 | }
32 |
33 | private void Grid_MouseMove(object sender, MouseEventArgs e)
34 | {
35 | if (e.LeftButton == MouseButtonState.Pressed)
36 | this.DragMove();
37 | }
38 |
39 | private void Close(object sender, RoutedEventArgs e)
40 | {
41 | Cancel();
42 | }
43 |
44 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
45 | {
46 | if (e.Key == Key.Enter)
47 | Start();
48 | }
49 |
50 | private void Confirm(object sender, RoutedEventArgs e)
51 | {
52 | MainWindow mainWindow = this.Owner as MainWindow;
53 | mainWindow.PicColorCallback(null, "锐化");
54 | this.Close();
55 | }
56 |
57 | private void Cancel(object sender, RoutedEventArgs e)
58 | {
59 | Cancel();
60 | }
61 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
62 | {
63 | Start();
64 | }
65 | private void Cancel()
66 | {
67 | MainWindow mainWindow = this.Owner as MainWindow;
68 | mainWindow.PicColorCallback();
69 | this.Close();
70 | }
71 | private void Start()
72 | {
73 | MainWindow mainWindow = this.Owner as MainWindow;
74 | picSharpenControl.Visi = Visibility.Visible;
75 | mainWindow.PicSharpen(bs, this, picSharpenControl.Sharpen / 100.0);
76 | }
77 | public void Back()
78 | {
79 | picSharpenControl.Visi = Visibility.Collapsed;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/PicEditor/window/PicTSWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/PicEditor/window/PicTSWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PicEditor.controller;
2 | using PicEditor.core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// TSWindow.xaml 的交互逻辑
19 | ///
20 | public partial class PicTSWindow : Window
21 | {
22 | private readonly BitmapSource bs;
23 | private readonly PicTSControl picTSControl = new PicTSControl();
24 | public PicTSWindow(BitmapSource bs)
25 | {
26 | InitializeComponent();
27 | this.bs = bs;
28 | Content.DataContext = picTSControl;
29 | TNum.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
30 | }
31 |
32 | private void Grid_MouseMove(object sender, MouseEventArgs e)
33 | {
34 | if (e.LeftButton == MouseButtonState.Pressed)
35 | this.DragMove();
36 | }
37 |
38 | private void Close(object sender, RoutedEventArgs e)
39 | {
40 | Cancel();
41 | }
42 |
43 | private void Confirm(object sender, RoutedEventArgs e)
44 | {
45 | MainWindow mainWindow = this.Owner as MainWindow;
46 | mainWindow.PicColorCallback(null, "色调分离");
47 | this.Close();
48 | }
49 |
50 | private void Cancel(object sender, RoutedEventArgs e)
51 | {
52 | Cancel();
53 | }
54 |
55 | private void Reset(object sender, RoutedEventArgs e)
56 | {
57 | picTSControl.Reset();
58 | MainWindow mainWindow = this.Owner as MainWindow;
59 | mainWindow.PicColorCallback();
60 | }
61 |
62 | private void TextBox_KeyDown(object sender, KeyEventArgs e)
63 | {
64 | if (e.Key == Key.Enter)
65 | Start();
66 | }
67 | private void Slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
68 | {
69 | Start();
70 | }
71 | private void Cancel()
72 | {
73 | MainWindow mainWindow = this.Owner as MainWindow;
74 | mainWindow.PicColorCallback();
75 | this.Close();
76 | }
77 | private void Start()
78 | {
79 | MainWindow mainWindow = this.Owner as MainWindow;
80 | if (picTSControl.Num == 256)
81 | {
82 | mainWindow.PicColorCallback(bs);
83 | return;
84 | }
85 | picTSControl.Visi = Visibility.Visible;
86 | mainWindow.PicTS(bs, this, (int)picTSControl.Num);
87 | }
88 | public void Back()
89 | {
90 | picTSControl.Visi = Visibility.Collapsed;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/PicEditor/window/SettingWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/PicEditor/window/SettingWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Shapes;
13 | using System.Xml;
14 |
15 | namespace PicEditor.window
16 | {
17 | ///
18 | /// SettingWindow.xaml 的交互逻辑
19 | ///
20 | public partial class SettingWindow : Window
21 | {
22 | private readonly Setting setting;
23 | public SettingWindow(Setting setting)
24 | {
25 | InitializeComponent();
26 | this.setting = setting;
27 | }
28 | private void Window_Loaded(object sender, RoutedEventArgs e)
29 | {
30 | for (int i = 0; i < 19; i++)
31 | {
32 | comboBox.Items.Add(i + 2);
33 | if (i + 2 == setting.Precision)
34 | comboBox.SelectedIndex = i;
35 | }
36 | HideSidePanel.IsChecked = setting.HideSidePanel;
37 | FitPicSize.IsChecked = setting.FitPicSize;
38 | }
39 | private void Window_KeyDown(object sender, KeyEventArgs e)
40 | {
41 | if (e.Key == Key.Enter)
42 | {
43 | Confirm();
44 | }
45 | else if (e.Key == Key.Escape)
46 | {
47 | this.Close();
48 | }
49 | }
50 |
51 | private void Grid_MouseMove(object sender, MouseEventArgs e)
52 | {
53 | if (e.LeftButton == MouseButtonState.Pressed)
54 | this.DragMove();
55 | }
56 |
57 | private void Close(object sender, RoutedEventArgs e)
58 | {
59 | this.Close();
60 | }
61 |
62 | private void DefaultSetting(object sender, RoutedEventArgs e)
63 | {
64 | comboBox.SelectedIndex = 14;
65 | HideSidePanel.IsChecked = false;
66 | FitPicSize.IsChecked = false;
67 | }
68 |
69 | private void Confirm(object sender, RoutedEventArgs e)
70 | {
71 | Confirm();
72 | }
73 | public void Confirm()
74 | {
75 | int precision = comboBox.SelectedIndex + 2;
76 | bool hideSidePanel = HideSidePanel.IsChecked == true ? true : false;
77 | bool fitPicSize = FitPicSize.IsChecked == true ? true : false;
78 | this.Close();
79 | if (precision == setting.Precision && hideSidePanel == setting.HideSidePanel && fitPicSize == setting.FitPicSize)
80 | return;
81 | setting.Precision = precision;
82 | setting.HideSidePanel = hideSidePanel;
83 | setting.FitPicSize = fitPicSize;
84 | setting.Alter();
85 | }
86 | }
87 | public class Setting
88 | {
89 | public int Precision;
90 | public bool HideSidePanel;
91 | public bool FitPicSize;
92 | private readonly string file_name;
93 | public Setting()
94 | {
95 | Precision = 16;
96 | HideSidePanel = FitPicSize = false;
97 | file_name = AppDomain.CurrentDomain.BaseDirectory + "setting.xml";
98 | }
99 | public void Get()
100 | {
101 | if (!File.Exists(file_name))
102 | {
103 | Create();
104 | return;
105 | }
106 | XmlDocument xml = new XmlDocument();
107 | xml.Load(file_name);
108 | XmlNode root = xml.SelectSingleNode("Setting");
109 | XmlNodeList nodes = root.ChildNodes;
110 | for (int i = 0; i < 3 && i < nodes.Count; i++)
111 | {
112 | if (nodes[i].Name == "Precision")
113 | {
114 | try
115 | {
116 | Precision = int.Parse(nodes[i].InnerText);
117 | }
118 | catch (Exception)
119 | {
120 | Precision = 16;
121 | }
122 | }
123 | else if (nodes[i].Name == "HideSidePanel")
124 | {
125 | HideSidePanel = nodes[i].InnerText == "True" ? true : false;
126 | }
127 | else if (nodes[i].Name == "FitPicSize")
128 | {
129 | FitPicSize = nodes[i].InnerText == "True" ? true : false;
130 | }
131 | }
132 | }
133 | public void Create()
134 | {
135 | XmlDocument xml = new XmlDocument();
136 | XmlElement root = xml.CreateElement("Setting");
137 | xml.AppendChild(root);
138 | XmlElement node = xml.CreateElement("Precision");
139 | node.InnerText = Precision.ToString();
140 | root.AppendChild(node);
141 | node = xml.CreateElement("HideSidePanel");
142 | node.InnerText = HideSidePanel.ToString();
143 | root.AppendChild(node);
144 | node = xml.CreateElement("FitPicSize");
145 | node.InnerText = FitPicSize.ToString();
146 | root.AppendChild(node);
147 | xml.Save(file_name);
148 | }
149 | public void Alter()
150 | {
151 | if (!File.Exists(file_name))
152 | {
153 | Create();
154 | return;
155 | }
156 | XmlDocument xml = new XmlDocument();
157 | xml.Load(file_name);
158 | XmlNode root = xml.SelectSingleNode("Setting");
159 | XmlNodeList nodes = root.ChildNodes;
160 | for (int i = 0; i < 3 && i < nodes.Count; i++)
161 | {
162 | if (nodes[i].Name == "Precision")
163 | {
164 | nodes[i].InnerText = Precision.ToString();
165 | }
166 | else if (nodes[i].Name == "HideSidePanel")
167 | {
168 | nodes[i].InnerText = HideSidePanel.ToString();
169 | }
170 | else if (nodes[i].Name == "FitPicSize")
171 | {
172 | nodes[i].InnerText = FitPicSize.ToString();
173 | }
174 | }
175 | xml.Save(file_name);
176 | }
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PicEditor
2 | 图片编辑器(WPF)
3 | ## 软件截图
4 | 
5 | 
6 | ## 下载地址
7 | https://github.com/zou-z/PicEditor/releases
8 | ## 使用方法
9 | 下载并解压zip文件,运行exe文件
10 | ## 注意事项
11 | Windows10以下系统缺少Segoe MDL2 Assets字体,将导致软件图标无法显示。
12 |
--------------------------------------------------------------------------------
/images/软件窗口图1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zou-z/PicEditor/bacf4b04c764cfa278db06bd70503ca0d3420fad/images/软件窗口图1.PNG
--------------------------------------------------------------------------------
/images/软件窗口图2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zou-z/PicEditor/bacf4b04c764cfa278db06bd70503ca0d3420fad/images/软件窗口图2.PNG
--------------------------------------------------------------------------------