├── 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 |