├── FileFormat.xls
├── Source
├── HexComparer
│ ├── Hc.ico
│ ├── Resources
│ │ ├── arrow.png
│ │ └── arrow-180.png
│ ├── app.config
│ ├── Properties
│ │ ├── Settings.settings
│ │ ├── Settings.Designer.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── HexComparer.sln
│ ├── Program.cs
│ ├── RegSizePrompt.cs
│ ├── UCViewData.cs
│ ├── UCHexViewer.Designer.cs
│ ├── UCHexViewer.cs
│ ├── FMain.cs
│ ├── RegSizePrompt.resx
│ ├── UCHexViewer.resx
│ ├── UCViewData.resx
│ ├── HexComparer.csproj
│ ├── HexViewerControl.cs
│ └── RegSizePrompt.Designer.cs
├── SamsungChanelEditor
│ ├── TV.ico
│ ├── Samsung
│ │ ├── Definitions
│ │ │ ├── FileFormat.cs
│ │ │ ├── FileFormatSerieC.cs
│ │ │ ├── ChannelFormat292.cs
│ │ │ └── ChannelFormat.cs
│ │ ├── StateChannel.cs
│ │ ├── SatDataBaseFile.cs
│ │ ├── AstraHDChannel.cs
│ │ ├── CloneInfoFile.cs
│ │ ├── OtherFile.cs
│ │ ├── MapChannelAnalog.cs
│ │ ├── MapChannel.cs
│ │ └── SCMFile.cs
│ ├── packages.config
│ ├── Common
│ │ ├── EditableAttribute.cs
│ │ ├── IChannelFile.cs
│ │ ├── IChannel.cs
│ │ └── ChannelList.cs
│ ├── Properties
│ │ ├── Settings.settings
│ │ ├── Settings.Designer.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── App.config
│ ├── Program.cs
│ ├── Utils
│ │ ├── FileUtils.cs
│ │ ├── StringUtils.cs
│ │ ├── DataMapping.cs
│ │ └── MyZipFile.cs
│ └── UI
│ │ ├── FInputBox.cs
│ │ ├── FAboutBox.cs
│ │ ├── FInputBox.designer.cs
│ │ ├── FAboutBox.resx
│ │ ├── FInputBox.resx
│ │ ├── UCSingleEdit.resx
│ │ └── ListViewDragAndDrop.cs
├── SamsChannelEditor.sln
└── SamsungFileTests
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── DataMappingTests.cs
│ └── SamsungFileTests.csproj
├── web
└── img
│ ├── logos
│ ├── opensource-logo.png
│ └── sourceforge-logo.png
│ └── screenshots
│ └── mainscreen.PNG
├── .gitattributes
├── README.md
└── .gitignore
/FileFormat.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/FileFormat.xls
--------------------------------------------------------------------------------
/Source/HexComparer/Hc.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/Source/HexComparer/Hc.ico
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/TV.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/Source/SamsungChanelEditor/TV.ico
--------------------------------------------------------------------------------
/web/img/logos/opensource-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/web/img/logos/opensource-logo.png
--------------------------------------------------------------------------------
/web/img/logos/sourceforge-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/web/img/logos/sourceforge-logo.png
--------------------------------------------------------------------------------
/web/img/screenshots/mainscreen.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/web/img/screenshots/mainscreen.PNG
--------------------------------------------------------------------------------
/Source/HexComparer/Resources/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/Source/HexComparer/Resources/arrow.png
--------------------------------------------------------------------------------
/Source/HexComparer/Resources/arrow-180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/Source/HexComparer/Resources/arrow-180.png
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/Definitions/FileFormat.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imasm/samschanneledit/HEAD/Source/SamsungChanelEditor/Samsung/Definitions/FileFormat.cs
--------------------------------------------------------------------------------
/Source/HexComparer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Common/EditableAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SamsChannelEditor.Common
4 | {
5 | [AttributeUsage(AttributeTargets.Property)]
6 | internal class EditableAttribute : Attribute
7 | {
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/Source/HexComparer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/HexComparer/HexComparer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexComparer", "HexComparer.csproj", "{BC87FE82-6E26-473F-BD27-36568BB6F691}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Common/IChannelFile.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace SamsChannelEditor.Common
21 | {
22 | internal interface IChannelFile
23 | {
24 | string FileName { get; set; }
25 | bool ReadFrom(string directory);
26 | bool SaveTo(string directory);
27 |
28 | ChannelList Channels { get; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/Definitions/FileFormatSerieC.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace SamsChannelEditor.Samsung.Definitions
21 | {
22 | internal class FileFormatSerieC : FileFormat
23 | {
24 | public FileFormatSerieC() : base("Serie-C")
25 | {
26 | Favorites = 4;
27 | MapAirD = new ChannelFormat292();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/HexComparer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Este código fue generado por una herramienta.
4 | // Versión de runtime:4.0.30319.42000
5 | //
6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
7 | // se vuelve a generar el código.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace HexComparer.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/HexComparer/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Windows.Forms;
22 |
23 | namespace HexComparer
24 | {
25 | static class Program
26 | {
27 | [STAThread]
28 | static void Main()
29 | {
30 | Application.EnableVisualStyles();
31 | Application.SetCompatibleTextRenderingDefault(false);
32 | Application.Run(new FMain());
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Este código fue generado por una herramienta.
4 | // Versión de runtime:4.0.30319.42000
5 | //
6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
7 | // se vuelve a generar el código.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SamsChannelEditor.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/App.config:
--------------------------------------------------------------------------------
1 |
2 |
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 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Windows.Forms;
22 | using System.IO;
23 | using SamsChannelEditor.UI;
24 |
25 | namespace SamsChannelEditor
26 | {
27 | static class Program
28 | {
29 | [STAThread]
30 | static void Main()
31 | {
32 | InitLogging();
33 |
34 | Application.EnableVisualStyles();
35 | Application.SetCompatibleTextRenderingDefault(false);
36 | Application.Run(new FMain());
37 | }
38 |
39 | private static void InitLogging()
40 | {
41 | // Logs de depuració
42 | var fi = new FileInfo("SamsChannelEditor.exe.Config");
43 | log4net.Config.XmlConfigurator.Configure(fi);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Utils/FileUtils.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.IO;
21 |
22 | namespace SamsChannelEditor.Utils
23 | {
24 | internal class FileUtils
25 | {
26 | public static long GetFileSize(string filename)
27 | {
28 | var fi = new FileInfo(filename);
29 | return fi.Length;
30 | }
31 |
32 | public static string GetTempDirectory()
33 | {
34 | var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
35 | while (Directory.Exists(path))
36 | path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
37 |
38 | Directory.CreateDirectory(path);
39 | return path;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/StateChannel.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Text;
21 |
22 | namespace SamsChannelEditor.Samsung
23 | {
24 | internal class StateChannel : MapChannel
25 | {
26 | public StateChannel(int pos, byte[] buffer)
27 | : base(pos, buffer)
28 | {
29 | }
30 |
31 | public override string Name
32 | {
33 | get { return Encoding.Unicode.GetString(Data, 0x25, 100); }
34 | }
35 |
36 | public override string ChannelType
37 | {
38 | get { return ((MapChannelType)Data[0x0E]).ToString(); }
39 | }
40 |
41 | public override bool IsEncrypted
42 | {
43 | get { return false; } // return (data[24] == 1); }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Common/IChannel.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace SamsChannelEditor.Common
21 | {
22 | internal interface IChannel
23 | {
24 | bool IsOk();
25 | int FilePosition { get; }
26 | byte[] Data { get; }
27 |
28 | short Number { get; set; }
29 | string Name { get; set; }
30 | string ChannelType { get; }
31 | bool IsEncrypted { get; }
32 | long Frequency { get; }
33 | ushort ServiceID { get; }
34 | ushort Multiplex_TSID { get; }
35 | ushort Multiplex_ONID { get; }
36 | ushort Network { get; }
37 | bool Deleted { get; set; }
38 | bool Active { get; set; }
39 |
40 | bool FavoriteList1 { get; set; }
41 | bool FavoriteList2 { get; set; }
42 | bool FavoriteList3 { get; set; }
43 | bool FavoriteList4 { get; set; }
44 |
45 | bool Locked { get; set; }
46 |
47 | byte CalcChecksum(bool save);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Utils/StringUtils.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 |
22 | namespace SamsChannelEditor.Utils
23 | {
24 | internal static class StringUtils
25 | {
26 | public static string Reverse(string s)
27 | {
28 | var arr = s.ToCharArray();
29 | Array.Reverse(arr);
30 | return new string(arr);
31 | }
32 |
33 | public static string RemoveNulls(string s)
34 | {
35 | var pos = s.IndexOf('\0');
36 | return pos > 0 ? s.Substring(0, pos) : s;
37 | }
38 |
39 | public static string Copy(string s, int start, int count)
40 | {
41 | if (start < 0)
42 | start = 0;
43 |
44 | if (start >= s.Length)
45 | return "";
46 |
47 | return (start + count) > s.Length ? s.Substring(start) : s.Substring(start, count);
48 | }
49 |
50 | internal static int TryToInt32(string s, int defaultnum)
51 | {
52 | int nout;
53 | return Int32.TryParse(s, out nout) ? nout : defaultnum;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Source/HexComparer/RegSizePrompt.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.IO;
22 | using System.Windows.Forms;
23 |
24 | namespace HexComparer
25 | {
26 | public partial class RegSizePrompt : Form
27 | {
28 | public string Filename { get; set; }
29 | public int RegSize { get; private set; }
30 |
31 | public RegSizePrompt()
32 | {
33 | InitializeComponent();
34 | RegSize = 0;
35 | }
36 |
37 | private void RegSizePrompt_Load(object sender, EventArgs e)
38 | {
39 | var fi = new FileInfo(Filename);
40 | lblFileName.Text = Path.GetFileName(Filename);
41 | lblFileSize.Text = fi.Length + " bytes";
42 |
43 | if (fi.Length >= 1000)
44 | nudRegSize.Value = (decimal)fi.Length / 1000;
45 | else
46 | nudRegSize.Value = fi.Length;
47 | }
48 |
49 | private void btnCancel_Click(object sender, EventArgs e)
50 | {
51 | DialogResult = DialogResult.Cancel;
52 | }
53 |
54 | private void btnOk_Click(object sender, EventArgs e)
55 | {
56 | RegSize = (int)nudRegSize.Value;
57 | DialogResult = DialogResult.OK;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/SatDataBaseFile.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Data;
22 | using System.IO;
23 | using System.Text;
24 |
25 | namespace SamsChannelEditor.Samsung
26 | {
27 | internal class SatDataBaseFile : OtherFile
28 | {
29 | readonly byte[] _regtmp;
30 |
31 | public SatDataBaseFile(string filename)
32 | : base(filename, SCMFileContentType.satDataBase)
33 | {
34 | _regtmp = new byte[145];
35 | }
36 |
37 | public override DataTable CreateDataTable()
38 | {
39 | var dt = new DataTable();
40 | dt.Columns.Add("#", typeof(int));
41 | dt.Columns.Add("Satellite", typeof(String));
42 | return dt;
43 | }
44 |
45 | public override bool ReadFile(string fullPathFileName)
46 | {
47 | var idx = 0;
48 | using (var fs = File.Open(fullPathFileName, FileMode.Open))
49 | {
50 | while (fs.Read(_regtmp, 0, _regtmp.Length) == _regtmp.Length)
51 | {
52 | idx++;
53 | var dr = DataTable.NewRow();
54 | dr[0] = idx;
55 | dr[1] = Encoding.Unicode.GetString(_regtmp, 0x0D, 50);
56 | DataTable.Rows.Add(dr);
57 | }
58 | }
59 | return true;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/AstraHDChannel.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Text;
22 |
23 | namespace SamsChannelEditor.Samsung
24 | {
25 | internal class AstraHDChannel : MapChannel
26 | {
27 | public AstraHDChannel(int pos, byte[] buffer)
28 | : base(pos, buffer)
29 | {
30 | }
31 |
32 | public override string Name
33 | {
34 | get
35 | {
36 | return Encoding.Unicode.GetString(Data, 0x31, 100);
37 | }
38 | }
39 |
40 | public override string ChannelType
41 | {
42 | get
43 | {
44 | return ((MapChannelType)Data[14]).ToString();
45 | }
46 | }
47 |
48 | public override ushort Multiplex_ONID
49 | {
50 | get { return BitConverter.ToUInt16(Data, 32); }
51 | }
52 |
53 | public override ushort Multiplex_TSID
54 | {
55 | get { return BitConverter.ToUInt16(Data, 36); }
56 | }
57 |
58 | public override ushort Network
59 | {
60 | get { return 0; }
61 | }
62 |
63 | public override ushort ServiceID
64 | {
65 | get { return BitConverter.ToUInt16(Data, 16); }
66 | }
67 |
68 | //TODO: Discover
69 | public override bool IsEncrypted
70 | {
71 | get { return (Data[180] == 1); }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/Definitions/ChannelFormat292.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace SamsChannelEditor.Samsung.Definitions
21 | {
22 | internal class ChannelFormat292 : ChannelFormat
23 | {
24 | public ChannelFormat292() : base()
25 | {
26 | Length = 292;
27 | ProgramNumberOffset = 0;
28 | VideoPidOffset = 2;
29 | PcrPidOffset = 4;
30 | ServiceIdOffset = 6;
31 | DeletedOffset = 8;
32 | DeletedMask = 0x01;
33 | SignalSourceOffset = 10;
34 | QamOffset = 12;
35 | BandwidthOffset = 14;
36 | ServiceTypeOffset = 15;
37 | CodecOffset = 16;
38 | HResOffset = 20;
39 | VResOffset = 22;
40 | EncryptedOffset = 24;
41 | EncryptedMask = 0x01;
42 | FrameRateOffset = 25;
43 | SymbolRateOffset = 28;
44 | LockOffset = 31;
45 | LockMask = 0x01;
46 | OriginalNetworkIdOffset = 32;
47 | NetworkIdOffset = 34;
48 | ServiceProviderIdOffset = 40;
49 | ChannelTransponderOffset = 42;
50 | LogicalProgramNrOffset = 44;
51 | TransportStreamIdOffset = 48;
52 | NameOffset = 64;
53 | NameLength = 100;
54 | ShortNameOffset = 264;
55 | ShortNameLength = 18;
56 | VideoFormatOffset = 282;
57 | FavoritesOffset = 290;
58 | ChecksumOffset = 291;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/CloneInfoFile.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Data;
22 | using System.IO;
23 | using System.Text;
24 | using SamsChannelEditor.Utils;
25 |
26 | namespace SamsChannelEditor.Samsung
27 | {
28 | internal class CloneInfoFile : OtherFile
29 | {
30 | readonly byte[] _regtmp = new byte[68];
31 |
32 | public CloneInfoFile(string filename, SCMFileContentType maptype)
33 | : base(filename, maptype)
34 | {
35 | }
36 |
37 | public override DataTable CreateDataTable()
38 | {
39 | var dt = new DataTable();
40 | dt.Columns.Add("Country ID", typeof(String));
41 | dt.Columns.Add("TV Model", typeof(String));
42 | return dt;
43 | }
44 |
45 | public override bool ReadFile(string fullPathFileName)
46 | {
47 | using (var fs = File.Open(fullPathFileName, FileMode.Open))
48 | {
49 | int readed = fs.Read(_regtmp, 0, _regtmp.Length);
50 | if (readed > 0)
51 | {
52 | var pais = StringUtils.Reverse(Encoding.ASCII.GetString(_regtmp, 0x00, 3));
53 | var model = Encoding.ASCII.GetString(_regtmp, 0x04, 15);
54 |
55 | DataRow dr = DataTable.NewRow();
56 | dr[0] = pais;
57 | dr[1] = model;
58 | DataTable.Rows.Add(dr);
59 | }
60 | }
61 | return true;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Source/HexComparer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("HexComparer")]
28 | [assembly: AssemblyDescription("")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("Microsoft")]
31 | [assembly: AssemblyProduct("HexComparer")]
32 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 |
36 | // Setting ComVisible to false makes the types in this assembly not visible
37 | // to COM components. If you need to access a type in this assembly from
38 | // COM, set the ComVisible attribute to true on that type.
39 | [assembly: ComVisible(false)]
40 |
41 | // The following GUID is for the ID of the typelib if this project is exposed to COM
42 | [assembly: Guid("e28a81aa-38e2-4786-b178-42ad7963e999")]
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/Source/SamsChannelEditor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsChannelEditor", "SamsungChanelEditor\SamsChannelEditor.csproj", "{18DCEEBD-0C76-4A9E-A188-96E3B8C274E8}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexComparer", "HexComparer\HexComparer.csproj", "{BC87FE82-6E26-473F-BD27-36568BB6F691}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsungFileTests", "SamsungFileTests\SamsungFileTests.csproj", "{503B0248-C841-45C8-AB19-E385653FF3D9}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {18DCEEBD-0C76-4A9E-A188-96E3B8C274E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {18DCEEBD-0C76-4A9E-A188-96E3B8C274E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {18DCEEBD-0C76-4A9E-A188-96E3B8C274E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {18DCEEBD-0C76-4A9E-A188-96E3B8C274E8}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {BC87FE82-6E26-473F-BD27-36568BB6F691}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {503B0248-C841-45C8-AB19-E385653FF3D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {503B0248-C841-45C8-AB19-E385653FF3D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {503B0248-C841-45C8-AB19-E385653FF3D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {503B0248-C841-45C8-AB19-E385653FF3D9}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | BuildVersion_AssemblyInfoFilename =
36 | BuildVersion_UpdateFileVersion = False
37 | BuildVersion_UpdateAssemblyVersion = False
38 | BuildVersion_StartDate = 1975/10/21
39 | BuildVersion_BuildVersioningStyle = None.None.None.None
40 | BuildVersion_UseGlobalSettings = False
41 | EndGlobalSection
42 | EndGlobal
43 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("SamsungChanelEditor")]
28 | [assembly: AssemblyDescription("Channel editor for Samsung TV's")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("Ivan Masmitja")]
31 | [assembly: AssemblyProduct("Samsung Channel Editor")]
32 | [assembly: AssemblyCopyright("Copyright © Ivan Masmitja 2011 - 2018 (GPL3)")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 |
36 | // Setting ComVisible to false makes the types in this assembly not visible
37 | // to COM components. If you need to access a type in this assembly from
38 | // COM, set the ComVisible attribute to true on that type.
39 | [assembly: ComVisible(false)]
40 |
41 | // The following GUID is for the ID of the typelib if this project is exposed to COM
42 | [assembly: Guid("42c45be2-527d-4d6d-a46a-431836e6ace7")]
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("0.13.0.0")]
55 | [assembly: AssemblyFileVersion("0.13.0.0")]
56 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/OtherFile.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Data;
21 | using System.IO;
22 | using log4net;
23 |
24 | namespace SamsChannelEditor.Samsung
25 | {
26 | internal abstract class OtherFile
27 | {
28 | static readonly ILog LOG = LogManager.GetLogger("OtherFile");
29 |
30 | public string FileName { get; set; }
31 | public SCMFileContentType MapType { get; private set; }
32 | public bool Changed { get; set; }
33 |
34 | public DataTable DataTable { get; private set; }
35 |
36 | protected OtherFile(string filename, SCMFileContentType maptype)
37 | {
38 | MapType = maptype;
39 | Changed = false;
40 | FileName = filename;
41 | DataTable = CreateDataTable();
42 | }
43 |
44 | #region Abstract Methods
45 | public abstract bool ReadFile(string fullPathFileName);
46 | public abstract DataTable CreateDataTable();
47 | #endregion
48 |
49 | public void Clear()
50 | {
51 | DataTable.Rows.Clear();
52 | }
53 |
54 | public bool ReadFrom(string directory)
55 | {
56 | Changed = false;
57 | Clear();
58 |
59 | string fullPathFileName = Path.Combine(directory, FileName);
60 |
61 | if (LOG.IsDebugEnabled)
62 | LOG.Debug("Read MapFile " + fullPathFileName);
63 |
64 | if (!File.Exists(fullPathFileName))
65 | throw new FileLoadException(string.Format("File {0} not found", fullPathFileName), "Open file error");
66 |
67 | return ReadFile(fullPathFileName);
68 | }
69 |
70 |
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Source/SamsungFileTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // La información general de un ensamblado se controla mediante el siguiente
25 | // conjunto de atributos. Cambie estos valores de atributo para modificar la información
26 | // asociada con un ensamblado.
27 | [assembly: AssemblyTitle("SamsungFileTests")]
28 | [assembly: AssemblyDescription("")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("Esteban Espuña")]
31 | [assembly: AssemblyProduct("SamsungFileTests")]
32 | [assembly: AssemblyCopyright("Copyright © Esteban Espuña 2017")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 |
36 | // Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles
37 | // para los componentes COM. Si es necesario obtener acceso a un tipo en este ensamblado desde
38 | // COM, establezca el atributo ComVisible en true en este tipo.
39 | [assembly: ComVisible(false)]
40 |
41 | // El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM.
42 | [assembly: Guid("503b0248-c841-45c8-ab19-e385653ff3d9")]
43 |
44 | // La información de versión de un ensamblado consta de los cuatro valores siguientes:
45 | //
46 | // Versión principal
47 | // Versión secundaria
48 | // Número de compilación
49 | // Revisión
50 | //
51 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
52 | // mediante el carácter '*', como se muestra a continuación:
53 | //[assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/Source/HexComparer/UCViewData.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.ComponentModel;
22 | using System.Windows.Forms;
23 |
24 | namespace HexComparer
25 | {
26 | public partial class UCViewData : UserControl
27 | {
28 | bool _showInHexadecimal;
29 | byte[] _lastData;
30 | int _lastIdx;
31 |
32 | [Browsable(true)]
33 | public override string Text
34 | {
35 | get { return groupBox1.Text; }
36 | set { groupBox1.Text = value; }
37 | }
38 |
39 | [Browsable(true), DefaultValue(false)]
40 | public bool ShowInHexadecimal
41 | {
42 | get { return _showInHexadecimal; }
43 | set
44 | {
45 | _showInHexadecimal = value;
46 | if (_lastData != null)
47 | ShowValues(_lastData, _lastIdx);
48 | }
49 | }
50 |
51 | public UCViewData()
52 | {
53 | ShowInHexadecimal = false;
54 | InitializeComponent();
55 | }
56 |
57 | public void ShowValues(byte[] data, int idx)
58 | {
59 | _lastData = data;
60 | _lastIdx = idx;
61 |
62 | var format = ShowInHexadecimal ? "X2" : "d";
63 |
64 | txtIndex.Text = idx.ToString(format);
65 |
66 | txtByte.Text = idx < data.Length ? data[idx].ToString(format) : "";
67 | txtInt16.Text = idx <= data.Length - 2 ? BitConverter.ToUInt16(data, idx).ToString(format) : "";
68 | txtInt32.Text = idx <= data.Length - 4 ? BitConverter.ToUInt32(data, idx).ToString(format) : "";
69 | txtInt64.Text = idx <= data.Length - 8 ? BitConverter.ToUInt64(data, idx).ToString(format) : "";
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Utils/DataMapping.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Text;
22 |
23 | namespace SamsChannelEditor.Utils
24 | {
25 | public class DataMapping
26 | {
27 | private Encoding DefaultEncoding { get; set; }
28 |
29 | private byte[] data;
30 | public byte[] Data
31 | {
32 | get { return data; }
33 | set { data = value; }
34 | }
35 |
36 | public int BaseOffset { get; set; }
37 |
38 | public DataMapping()
39 | {
40 | DefaultEncoding = Encoding.BigEndianUnicode;
41 | BaseOffset = 0;
42 | }
43 |
44 | #region Byte
45 | public byte GetByte(int offset)
46 | {
47 | return data[BaseOffset + offset];
48 | }
49 |
50 | public void SetByte(int offset, byte value)
51 | {
52 | data[BaseOffset + offset] = value;
53 | }
54 |
55 | #endregion
56 |
57 | #region Word
58 | public ushort GetWord(int offset)
59 | {
60 | return BitConverter.ToUInt16(this.data, BaseOffset + offset);
61 | }
62 |
63 | public void SetWord(int offset, ushort value)
64 | {
65 | byte[] b = BitConverter.GetBytes(value);
66 | this.data[BaseOffset + offset + 0] = b[0];
67 | this.data[BaseOffset + offset + 1] = b[1];
68 | }
69 |
70 | #endregion
71 |
72 | #region String()
73 | public string GetString(int offset, int length)
74 | {
75 | var encoding = this.DefaultEncoding;
76 | return encoding.GetString(this.data, BaseOffset + offset, length).TrimEnd('\0');
77 | }
78 |
79 | public int SetString(int offset, int length, string text)
80 | {
81 | var bytes = this.DefaultEncoding.GetBytes(text);
82 | int len = Math.Min(bytes.Length, length);
83 | Array.Clear(Data, offset, len);
84 | Array.Copy(bytes, 0, this.data, BaseOffset + offset, len);
85 | return len;
86 | }
87 | #endregion
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Source/SamsungFileTests/DataMappingTests.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using Microsoft.VisualStudio.TestTools.UnitTesting;
22 | using SamsChannelEditor.Utils;
23 |
24 | namespace SamsungFileTests
25 | {
26 | [TestClass]
27 | public class DataMappingTests
28 | {
29 | [TestMethod]
30 | public void TestByte()
31 | {
32 | DataMapping mapping = new DataMapping();
33 | byte[] data = new byte[12];
34 | for (byte i = byte.MinValue; i < byte.MaxValue; i++)
35 | {
36 | Array.Clear(data, 0, 12);
37 | mapping.Data = data;
38 | mapping.SetByte(0, i);
39 | Assert.AreEqual(i, mapping.GetByte(0));
40 | }
41 |
42 | Array.Clear(data, 0, 12);
43 | mapping.Data = data;
44 | mapping.SetByte(0, byte.MaxValue);
45 | Assert.AreEqual(byte.MaxValue, mapping.GetByte(0));
46 | }
47 |
48 | [TestMethod]
49 | public void TestWord()
50 | {
51 | DataMapping mapping = new DataMapping();
52 | byte[] data = new byte[12];
53 | for (ushort i = ushort.MinValue; i < ushort.MaxValue; i++)
54 | {
55 | Array.Clear(data, 0, 12);
56 | mapping.Data = data;
57 | mapping.SetWord(0, i);
58 | Assert.AreEqual(i, mapping.GetWord(0));
59 | }
60 |
61 | Array.Clear(data, 0, 12);
62 | mapping.Data = data;
63 | mapping.SetWord(0, ushort.MaxValue);
64 | Assert.AreEqual(ushort.MaxValue, mapping.GetWord(0));
65 | }
66 |
67 | [TestMethod]
68 | public void TestString()
69 | {
70 | string[] samples = new string[] { "test 1", "čšýáířřží", "پاکستان", "is our country" };
71 |
72 | DataMapping mapping = new DataMapping();
73 | byte[] data = new byte[200];
74 |
75 | foreach (var str in samples)
76 | {
77 | Array.Clear(data, 0, 200);
78 | mapping.Data = data;
79 | mapping.SetString(0, 200, str);
80 | Assert.AreEqual(str, mapping.GetString(0, 200));
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Source/HexComparer/UCHexViewer.Designer.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace HexComparer
21 | {
22 | partial class UCHexViewer
23 | {
24 | ///
25 | /// Required designer variable.
26 | ///
27 | private System.ComponentModel.IContainer components = null;
28 |
29 | ///
30 | /// Clean up any resources being used.
31 | ///
32 | /// true if managed resources should be disposed; otherwise, false.
33 | protected override void Dispose(bool disposing)
34 | {
35 | if (disposing && (components != null))
36 | {
37 | components.Dispose();
38 | }
39 | base.Dispose(disposing);
40 | }
41 |
42 | #region Component Designer generated code
43 |
44 | ///
45 | /// Required method for Designer support - do not modify
46 | /// the contents of this method with the code editor.
47 | ///
48 | private void InitializeComponent()
49 | {
50 | this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
51 | this.SuspendLayout();
52 | //
53 | // vScrollBar1
54 | //
55 | this.vScrollBar1.Dock = System.Windows.Forms.DockStyle.Right;
56 | this.vScrollBar1.Location = new System.Drawing.Point(299, 0);
57 | this.vScrollBar1.Name = "vScrollBar1";
58 | this.vScrollBar1.Size = new System.Drawing.Size(17, 348);
59 | this.vScrollBar1.TabIndex = 0;
60 | this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);
61 | //
62 | // UCHexViewer
63 | //
64 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
65 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
66 | this.Controls.Add(this.vScrollBar1);
67 | this.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
68 | this.Name = "UCHexViewer";
69 | this.Size = new System.Drawing.Size(316, 348);
70 | this.ResumeLayout(false);
71 |
72 | }
73 |
74 | #endregion
75 |
76 | private System.Windows.Forms.VScrollBar vScrollBar1;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Source/HexComparer/UCHexViewer.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Windows.Forms;
22 |
23 | namespace HexComparer
24 | {
25 | public partial class UCHexViewer : UserControl
26 | {
27 | readonly HexViewerControl _hexctrl;
28 |
29 | public event HexViewerItemChangedEventHandler SelectedItemChanged;
30 |
31 | public byte[] Data1 { get { return _hexctrl.Data1; } }
32 | public byte[] Data2 { get { return _hexctrl.Data2; } }
33 |
34 | public int CurrentOffset
35 | {
36 | get { return _hexctrl.Offset; }
37 | set { _hexctrl.Offset = value; }
38 | }
39 |
40 | public UCHexViewer()
41 | {
42 | InitializeComponent();
43 |
44 | _hexctrl = new HexViewerControl();
45 | _hexctrl.SelectedItemChanged += hexctrl_SelectedItemChanged;
46 | _hexctrl.Dock = DockStyle.Fill;
47 | Controls.Add(_hexctrl);
48 | _hexctrl.BringToFront();
49 | }
50 |
51 | void hexctrl_SelectedItemChanged(object sender, HexViewerItemChangedEventArgs e)
52 | {
53 | if (SelectedItemChanged != null)
54 | SelectedItemChanged(sender, e);
55 | }
56 |
57 | public int SelectedIndex
58 | {
59 | get { return _hexctrl.SelectedIndex; }
60 | set
61 | {
62 | _hexctrl.SelectedIndex = value;
63 |
64 | if (_hexctrl.SelectedIndex < _hexctrl.Offset)
65 | vScrollBar1.Value = Math.Max(_hexctrl.SelectedIndex, 0);
66 | else if (_hexctrl.SelectedIndex >= _hexctrl.Offset + _hexctrl.RecordsPerPage)
67 | vScrollBar1.Value = Math.Max(_hexctrl.SelectedIndex - (_hexctrl.RecordsPerPage - 1), 0);
68 | }
69 | }
70 |
71 | public void SetData(byte[] d1, byte[] d2)
72 | {
73 | _hexctrl.SetData(d1, d2);
74 |
75 | if (_hexctrl.RecordsPerPage < _hexctrl.MaxLen)
76 | {
77 | vScrollBar1.Minimum = 0;
78 | vScrollBar1.Maximum = _hexctrl.MaxLen;// -hexctrl.RecordsPerPage;
79 | vScrollBar1.SmallChange = 1;
80 | vScrollBar1.LargeChange = _hexctrl.RecordsPerPage;
81 | vScrollBar1.Visible = true;
82 | }
83 | else
84 | {
85 | vScrollBar1.Visible = false;
86 | }
87 | }
88 |
89 | private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
90 | {
91 | _hexctrl.Offset = e.NewValue;
92 | }
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/FInputBox.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Windows.Forms;
22 |
23 | namespace SamsChannelEditor.UI
24 | {
25 | public partial class FInputBox : Form
26 | {
27 | public string Value
28 | {
29 | get { return txtValor.Text; }
30 | set { txtValor.Text = value; }
31 | }
32 |
33 | public char PasswordChar
34 | {
35 | get { return txtValor.PasswordChar; }
36 | set { txtValor.PasswordChar = value; }
37 | }
38 |
39 | public FInputBox()
40 | {
41 | InitializeComponent();
42 | Value = "";
43 | }
44 |
45 | public DialogResult Demana(string caption, string missatge, string defaulttext)
46 | {
47 | Text = caption;
48 | label1.Text = missatge;
49 | Value = defaulttext;
50 |
51 | return ShowDialog();
52 | }
53 |
54 | private void FInputBox_KeyDown(object sender, KeyEventArgs e)
55 | {
56 | if (e.KeyCode == Keys.Return)
57 | {
58 | Accept();
59 | }
60 | else
61 | if (e.KeyCode == Keys.Escape)
62 | {
63 | Cancel();
64 | }
65 | }
66 |
67 | private void Accept()
68 | {
69 | DialogResult = DialogResult.OK;
70 | Close();
71 | }
72 |
73 | private void Cancel()
74 | {
75 | DialogResult = DialogResult.Cancel;
76 | Close();
77 | }
78 |
79 | private void button2_Click(object sender, EventArgs e)
80 | {
81 | Cancel();
82 | }
83 |
84 | private void button1_Click(object sender, EventArgs e)
85 | {
86 | Accept();
87 | }
88 |
89 | private void FInputBox_Load(object sender, EventArgs e)
90 | {
91 | txtValor.Focus();
92 | }
93 |
94 | private void FInputBox_Activated(object sender, EventArgs e)
95 | {
96 | txtValor.Focus();
97 | }
98 |
99 | /*
100 | public DialogResult DemanaDecimal()
101 | {
102 |
103 | return ShowDialog();
104 | }*/
105 |
106 | /*
107 | #region Validacions
108 | private bool ValidarDecimal(object sender, InputBoxValidateEventArgs e)
109 | {
110 | bool bret = true;
111 |
112 | try
113 | {
114 | e.Valor = decimal.Parse(e.UserText);
115 | }
116 | catch
117 | {
118 | bret = false;
119 | }
120 | return bret;
121 | }
122 | #endregion
123 | * */
124 | }
125 | }
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Este código fue generado por una herramienta.
4 | // Versión de runtime:4.0.30319.42000
5 | //
6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
7 | // se vuelve a generar el código.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SamsChannelEditor.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc.
17 | ///
18 | // StronglyTypedResourceBuilder generó automáticamente esta clase
19 | // a través de una herramienta como ResGen o Visual Studio.
20 | // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen
21 | // con la opción /str o recompile su proyecto de VS.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SamsChannelEditor.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las
51 | /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Busca una cadena traducida similar a Error.
65 | ///
66 | internal static string ERROR_CAPTION {
67 | get {
68 | return ResourceManager.GetString("ERROR_CAPTION", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Busca una cadena traducida similar a This is readonly field. You can not edit it..
74 | ///
75 | internal static string READONLYFIELD_EXCEPTION {
76 | get {
77 | return ResourceManager.GetString("READONLYFIELD_EXCEPTION", resourceCulture);
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Source/HexComparer/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Este código fue generado por una herramienta.
4 | // Versión de runtime:4.0.30319.42000
5 | //
6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
7 | // se vuelve a generar el código.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace HexComparer.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc.
17 | ///
18 | // StronglyTypedResourceBuilder generó automáticamente esta clase
19 | // a través de una herramienta como ResGen o Visual Studio.
20 | // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen
21 | // con la opción /str o recompile su proyecto de VS.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HexComparer.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las
51 | /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Busca un recurso adaptado de tipo System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap arrow {
67 | get {
68 | object obj = ResourceManager.GetObject("arrow", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Busca un recurso adaptado de tipo System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap arrow_180 {
77 | get {
78 | object obj = ResourceManager.GetObject("arrow-180", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/Definitions/ChannelFormat.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Text;
22 |
23 | namespace SamsChannelEditor.Samsung.Definitions
24 | {
25 | internal class ChannelFormat
26 | {
27 | private byte[] data;
28 |
29 | public int Length { get; set; }
30 | public int ProgramNumberOffset { get; set; }
31 | public int VideoPidOffset { get; set; }
32 | public int PcrPidOffset { get; set; }
33 | public int ServiceIdOffset { get; set; }
34 | public int DeletedOffset { get; set; }
35 | public int DeletedMask { get; set; }
36 | public int SignalSourceOffset { get; set; }
37 | public int QamOffset { get; set; }
38 | public int BandwidthOffset { get; set; }
39 | public int ServiceTypeOffset { get; set; }
40 | public int CodecOffset { get; set; }
41 | public int HResOffset { get; set; }
42 | public int VResOffset { get; set; }
43 | public int EncryptedOffset { get; set; }
44 | public int EncryptedMask { get; set; }
45 | public int FrameRateOffset { get; set; }
46 | public int SymbolRateOffset { get; set; }
47 | public int LockOffset { get; set; }
48 | public int LockMask { get; set; }
49 | public int OriginalNetworkIdOffset { get; set; }
50 | public int NetworkIdOffset { get; set; }
51 | public int ServiceProviderIdOffset { get; set; }
52 | public int ChannelTransponderOffset { get; set; }
53 | public int LogicalProgramNrOffset { get; set; }
54 | public int TransportStreamIdOffset { get; set; }
55 | public int NameOffset { get; set; }
56 | public int NameLength { get; set; }
57 | public int ShortNameOffset { get; set; }
58 | public int ShortNameLength { get; set; }
59 | public int VideoFormatOffset { get; set; }
60 | public int FavoritesOffset { get; set; }
61 | public int ChecksumOffset { get; set; }
62 |
63 |
64 | protected ChannelFormat()
65 | {
66 |
67 |
68 | Length = -1;
69 | ProgramNumberOffset = -1;
70 | VideoPidOffset = -1;
71 | PcrPidOffset = -1;
72 | ServiceIdOffset = -1;
73 | DeletedOffset = -1;
74 | DeletedMask = 0x01;
75 | SignalSourceOffset = -1;
76 | QamOffset = -1;
77 | BandwidthOffset = -1;
78 | ServiceTypeOffset = -1;
79 | CodecOffset = -1;
80 | HResOffset = -1;
81 | VResOffset = -1;
82 | EncryptedOffset = -1;
83 | EncryptedMask = 0x01;
84 | FrameRateOffset = -1;
85 | SymbolRateOffset = -1;
86 | LockOffset = -1;
87 | LockMask = 0x01;
88 | OriginalNetworkIdOffset = -1;
89 | NetworkIdOffset = -1;
90 | ServiceProviderIdOffset = -1;
91 | ChannelTransponderOffset = -1;
92 | LogicalProgramNrOffset = -1;
93 | TransportStreamIdOffset = -1;
94 | NameOffset = -1;
95 | NameLength = -1;
96 | ShortNameOffset = -1;
97 | ShortNameLength = -1;
98 | VideoFormatOffset = -1;
99 | FavoritesOffset = -1;
100 | ChecksumOffset = -1;
101 | }
102 |
103 |
104 |
105 | }
106 | }
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/MapChannelAnalog.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Text;
22 | using SamsChannelEditor.Common;
23 |
24 | namespace SamsChannelEditor.Samsung
25 | {
26 | internal class MapChannelAnalog : IChannel
27 | {
28 | bool _isDeleted;
29 |
30 | public int FilePosition { get; set; }
31 | public bool Deleted { get { return _isDeleted; } set { _isDeleted = value; } }
32 | public bool Active { get { return !_isDeleted; } set { _isDeleted = !value; } }
33 |
34 | public byte[] Data { get; private set; }
35 |
36 | public MapChannelAnalog(int pos, byte[] buffer)
37 | {
38 | _isDeleted = false;
39 | Number = (short)pos;
40 | FilePosition = pos;
41 | Data = (byte[])buffer.Clone();
42 | }
43 |
44 | public short Number { get; set; }
45 |
46 | [Editable]
47 | public virtual string Name
48 | {
49 | get
50 | {
51 | return Encoding.BigEndianUnicode.GetString(Data, 20, 10);
52 | }
53 | set
54 | {
55 | byte[] newName = Encoding.BigEndianUnicode.GetBytes(value);
56 | newName.CopyTo(Data, 20);
57 | }
58 | }
59 |
60 | public virtual string ChannelType
61 | {
62 | get
63 | {
64 | return MapChannelType.TV.ToString();
65 | }
66 | }
67 |
68 | public virtual bool IsEncrypted
69 | {
70 | get { return false; }
71 | }
72 |
73 | public virtual long Frequency
74 | {
75 | //TODO: Search Freq. field
76 | get { return 0; }
77 | }
78 |
79 | public virtual ushort Network
80 | {
81 | get { return 0; }
82 | }
83 |
84 | public virtual ushort ServiceID
85 | {
86 | get { return 0; }
87 | }
88 |
89 | public virtual ushort Multiplex_TSID
90 | {
91 | get { return 0; }
92 | }
93 |
94 | public virtual ushort Multiplex_ONID
95 | {
96 | get { return 0; }
97 | }
98 |
99 | public virtual bool FavoriteList1
100 | {
101 | get { return false; }
102 | set {; }
103 | }
104 |
105 | public virtual bool FavoriteList2
106 | {
107 | get { return false; }
108 | set {; }
109 | }
110 |
111 | public virtual bool FavoriteList3
112 | {
113 | get { return false; }
114 | set {; }
115 | }
116 |
117 | public virtual bool FavoriteList4
118 | {
119 | get { return false; }
120 | set {; }
121 | }
122 |
123 | public virtual bool Locked
124 | {
125 | get { return false; }
126 | set {; }
127 | }
128 |
129 | public virtual bool IsOk()
130 | {
131 | return (BitConverter.ToInt16(Data, 0) > 0);
132 | }
133 |
134 | public byte CalcChecksum()
135 | {
136 | return CalcChecksum(false);
137 | }
138 |
139 | public virtual byte CalcChecksum(bool saveindata)
140 | {
141 | byte ck = 0;
142 | for (var i = 0; i < Data.Length - 1; i++)
143 | ck += Data[i];
144 |
145 | if (saveindata)
146 | Data[Data.Length - 1] = ck;
147 |
148 | return ck;
149 | }
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/Source/SamsungFileTests/SamsungFileTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {503B0248-C841-45C8-AB19-E385653FF3D9}
7 | Library
8 | Properties
9 | SamsungFileTests
10 | SamsungFileTests
11 | v4.8
12 | 512
13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 10.0
15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
17 | False
18 | UnitTest
19 |
20 |
21 |
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | {18dceebd-0c76-4a9e-a188-96e3b8c274e8}
60 | SamsChannelEditor
61 |
62 |
63 |
64 |
65 |
66 |
67 | False
68 |
69 |
70 | False
71 |
72 |
73 | False
74 |
75 |
76 | False
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/FAboutBox.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Diagnostics;
22 | using System.Reflection;
23 | using System.Windows.Forms;
24 |
25 | namespace SamsChannelEditor.UI
26 | {
27 | sealed partial class FAboutBox : Form
28 | {
29 | public FAboutBox()
30 | {
31 | InitializeComponent();
32 | Text = String.Format("About {0}", AssemblyTitle);
33 | labelProductName.Text = AssemblyProduct;
34 | labelVersion.Text = AssemblyVersion;
35 | labelCopyright.Text = AssemblyCopyright;
36 | labelCompanyName.Text = AssemblyCompany;
37 | textBoxDescription.Text = AssemblyDescription;
38 |
39 | //linkLabelWebsite.Text = @"http://samschanneledit.sourceforge.net/";
40 | linkLabelWebsite.Text = @"https://github.com/imasm/samschanneledit";
41 | }
42 |
43 | #region Assembly Attribute Accessors
44 |
45 | public string AssemblyTitle
46 | {
47 | get
48 | {
49 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
50 | if (attributes.Length > 0)
51 | {
52 | var titleAttribute = (AssemblyTitleAttribute)attributes[0];
53 | if (titleAttribute.Title != "")
54 | {
55 | return titleAttribute.Title;
56 | }
57 | }
58 | return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
59 | }
60 | }
61 |
62 | public string AssemblyVersion
63 | {
64 | get
65 | {
66 | return Assembly.GetExecutingAssembly().GetName().Version.ToString();
67 | }
68 | }
69 |
70 | public string AssemblyDescription
71 | {
72 | get
73 | {
74 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
75 | if (attributes.Length == 0)
76 | {
77 | return "";
78 | }
79 | return ((AssemblyDescriptionAttribute)attributes[0]).Description;
80 | }
81 | }
82 |
83 | public string AssemblyProduct
84 | {
85 | get
86 | {
87 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
88 | if (attributes.Length == 0)
89 | {
90 | return "";
91 | }
92 | return ((AssemblyProductAttribute)attributes[0]).Product;
93 | }
94 | }
95 |
96 | public string AssemblyCopyright
97 | {
98 | get
99 | {
100 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
101 | if (attributes.Length == 0)
102 | {
103 | return "";
104 | }
105 | return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
106 | }
107 | }
108 |
109 | public string AssemblyCompany
110 | {
111 | get
112 | {
113 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
114 | if (attributes.Length == 0)
115 | {
116 | return "";
117 | }
118 | return ((AssemblyCompanyAttribute)attributes[0]).Company;
119 | }
120 | }
121 | #endregion
122 |
123 | public new static DialogResult Show()
124 | {
125 | var f = new FAboutBox();
126 | return f.ShowDialog();
127 | }
128 |
129 | private void linkLabelWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
130 | {
131 | var sInfo = new ProcessStartInfo(linkLabelWebsite.Text);
132 | Process.Start(sInfo);
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## NO LONGER MAINTAINED
2 | THIS PROJECT IS NO LONGER MAINTAINED.
3 |
4 | > At this moment, I no longer have access to Samsung TVs, and I cannot test their latest models. For this reason, this project cannot provide further updates.
5 | > Fortunately, there are currently better options, such as [ChanSort](https://github.com/PredatH0r/ChanSort).
6 |
7 | # SamsChannelEditor
8 |
9 |
10 | SamsChannelEditor is a desktop application for editing a channel list from your Samsung TV. Now sorting channels should be much easier.
11 |
12 |
13 | * Support Samsung C and D Series.
14 | * Works with scm files directly.
15 | * Support for multiple channels configurations:
16 | * map-AirD
17 | * map-AirA
18 | * map-CableD
19 | * map-CableA
20 | * map-SateD
21 | * map-CDTVVD
22 | * AstraHDPlusD
23 | * Support for configuration files (read-only)
24 | * CloneInfo
25 | * SatDataBase
26 | * Easy to use: Just drag & drop channels.
27 |
28 | ! USE AT YOUR OWN RISK !
29 | --------------------------
30 | This software was written without support from TV manufacturers or access to any official documentation about the file formats
31 | and is suppliedded "as is" without warranty of any kind, either express or implied. Use at your own risk.
32 |
33 | Installation
34 | ------------
35 | There's no setup package, just download the zip file from [SamsChannelEditor](http://sourceforge.net/projects/samschanneledit/files),
36 | extract all in a folder and execute ''samschanneleditor.exe''.
37 |
38 | This application is written in C# so you need the .Net framework 4.0 (or newer) to be installed on your computer.
39 |
40 | Source Code
41 | ------------
42 | Source code is aviable from [GitHub](https://github.com/imasm/samschanneledit)
43 |
44 | __Build instructions:__
45 | *Requieres .NET Framework 4.8 Sdk*
46 | ```bash
47 | projectPath\source> nuget.exe restore
48 | projectPath\source> msbuild SamsChannelEditor.sln /property:Configuration=Release
49 | ```
50 |
51 | Bad file size error
52 | -------------------
53 | Since version 0.9 you can define new sizes in SamsChannelEditor.exe.config. Just open with a text editor like notepad and add a new size for your file in section.
54 |
55 | key: starts with "fs_" and after comes the channel file name (without "-" after map) value: is a number list separated by commas. Each number specifies a possible record size.
56 |
57 | To calculate your record size:
58 |
59 | * change extension .scm to .zip
60 | * Extract all files.
61 | * Select file you are opening and look the size in file properties.
62 | * record size is a 1000 multiple (divide your size by 1000 or 2000)
63 |
64 | ### Example: ###
65 |
66 | ```xml
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | ```
75 |
76 | Libraries & Resources used
77 | --------------------------
78 | * [\#ziplib](http://www.icsharpcode.net/opensource/sharpziplib)
79 | * [log4net](http://logging.apache.org/log4net)
80 | * [Free Icons by Axialis Software](http://www.axialis.com/free/icons)
81 |
82 | Developers and Collaborators
83 | -----------------------------
84 | * Ivan Masmitja(https://github.com/imasm)
85 | * Andrey(https://github.com/andrew097)
86 | * Hinni(https://github.com/Hinni)
87 |
88 | License
89 | -------
90 | Copyright (C) 2011 Ivan Masmitjà Dagas
91 |
92 | This program is free software: you can redistribute it and/or modify
93 | it under the terms of the GNU General Public License as published by
94 | the Free Software Foundation, either version 3 of the License, or
95 | (at your option) any later version.
96 |
97 | This program is distributed in the hope that it will be useful,
98 | but WITHOUT ANY WARRANTY; without even the implied warranty of
99 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100 | GNU General Public License for more details.
101 |
102 | You should have received a copy of the GNU General Public License
103 | along with this program. If not, see .
104 |
105 | Last changelog
106 | --------------
107 | ### Version 0.13 ###
108 |
109 | * Fix removing encrypted channels.
110 |
111 | ### Version 0.12 ###
112 |
113 | * Fix Drag&Drop. Channel still enabled.
114 | * Fix rename. Short names will appear correctly.
115 |
116 | ### Version 0.11 ###
117 |
118 | * Fixed channel names output. Names in Russian output correctly. Other languages must do so
119 | * Channel data edit feature realized. You can edit channel name and favourites.
120 |
121 | ### Version 0.10 ###
122 |
123 | * Applied a patch created by Andreas Winter to save sort order to file and restore after.
124 | * Applied a patch created by Andreas Mayer to remove encrypted channels.
125 |
126 | ### Version 0.9 ###
127 |
128 | * Moved record sizes to SamsChannelEditor.exe.config. Now are easy to add new record sizes for new models.
129 |
130 | ### Version 0.8 ###
131 |
132 | * BUG [3468470] : Open map-SateD 144bytes length (LE37C670)
133 | * MoveTo problems detected when out of range number is introduced.
134 |
135 | ### Version 0.7 ###
136 |
137 | * Works on D Series
138 | * Drag and Drop with auto scroll
139 | * Added support for analog channels map-AirA and map-CableA
140 | * Context menu: MoveTo
141 | * Context menu: Renumber All
142 |
--------------------------------------------------------------------------------
/Source/HexComparer/FMain.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Collections.Generic;
22 | using System.Globalization;
23 | using System.Windows.Forms;
24 | using System.IO;
25 |
26 | namespace HexComparer
27 | {
28 | public partial class FMain : Form
29 | {
30 | public FMain()
31 | {
32 | InitializeComponent();
33 | }
34 |
35 | private void loadToolStripMenuItem_Click(object sender, EventArgs e)
36 | {
37 | var ofd = new OpenFileDialog { CheckFileExists = true, Filter = "*.*|*.*", FilterIndex = 0 };
38 |
39 | if (ofd.ShowDialog() != DialogResult.OK) return;
40 |
41 | var r = new RegSizePrompt { Filename = ofd.FileName };
42 | if (r.ShowDialog() == DialogResult.OK)
43 | {
44 | OpenFile(r.Filename, r.RegSize);
45 | }
46 | }
47 |
48 | List _allregs = new List();
49 | private void OpenFile(string filename, int regsize)
50 | {
51 | using (FileStream fs = File.Open(filename, FileMode.Open))
52 | {
53 | _allregs.Clear();
54 | byte[] tmp = new byte[regsize];
55 | int readed = fs.Read(tmp, 0, tmp.Length);
56 | while (readed > 0)
57 | {
58 | _allregs.Add(tmp);
59 |
60 | tmp = new byte[regsize];
61 | readed = fs.Read(tmp, 0, tmp.Length);
62 | }
63 | fs.Close();
64 | }
65 |
66 | _idx1 = 0;
67 | _idx2 = 1;
68 |
69 | if (_idx2 >= _allregs.Count)
70 | _idx2 = _allregs.Count - 1;
71 |
72 | lblIdx1.Text = _idx1.ToString(CultureInfo.InvariantCulture);
73 | lblIdx2.Text = _idx2.ToString(CultureInfo.InvariantCulture);
74 |
75 | ucHexViewer1.SetData(_allregs[_idx1], _allregs[_idx2]);
76 | }
77 |
78 | int _idx1;
79 | int _idx2;
80 |
81 | private void btnAnt1_Click(object sender, EventArgs e)
82 | {
83 | int prex1 = _idx1;
84 | int prex2 = _idx2;
85 |
86 | if (sender == btnAnt1)
87 | {
88 | if (_idx1 > 0)
89 | _idx1--;
90 | }
91 | else if (sender == btnAnt2)
92 | {
93 | if (_idx2 > 0)
94 | _idx2--;
95 | }
96 | else if (sender == btnPost1)
97 | {
98 | if (_idx1 < _allregs.Count - 1)
99 | _idx1++;
100 | }
101 | else if (sender == btnPost2)
102 | {
103 | if (_idx2 < _allregs.Count - 1)
104 | _idx2++;
105 | }
106 |
107 | lblIdx1.Text = _idx1.ToString(CultureInfo.InvariantCulture);
108 | lblIdx2.Text = _idx2.ToString(CultureInfo.InvariantCulture);
109 |
110 | if ((_idx1 != prex1) || (_idx2 != prex2))
111 | {
112 | var offset = ucHexViewer1.CurrentOffset;
113 | ucHexViewer1.SetData(_allregs[_idx1], _allregs[_idx2]);
114 | ucHexViewer1.CurrentOffset = offset;
115 | }
116 | }
117 |
118 | private void ucHexViewer1_SelectedItemChanged(object sender, HexViewerItemChangedEventArgs e)
119 | {
120 | if (ucHexViewer1.Data1 != null)
121 | ucViewData1.ShowValues(ucHexViewer1.Data1, e.Index);
122 |
123 | if (ucHexViewer1.Data2 != null)
124 | ucViewData2.ShowValues(ucHexViewer1.Data2, e.Index);
125 | }
126 |
127 |
128 | private void btnDecimal_Click(object sender, EventArgs e)
129 | {
130 | ucViewData1.ShowInHexadecimal = ucViewData2.ShowInHexadecimal = false;
131 | btnDecimal.Checked = true;
132 | btnHexadecimal.Checked = false;
133 | }
134 |
135 | private void btnHexadecimal_Click(object sender, EventArgs e)
136 | {
137 | ucViewData1.ShowInHexadecimal = ucViewData2.ShowInHexadecimal = true;
138 | btnDecimal.Checked = false;
139 | btnHexadecimal.Checked = true;
140 | }
141 |
142 | private void FMain_KeyDown(object sender, KeyEventArgs e)
143 | {
144 | switch (e.KeyCode)
145 | {
146 | case Keys.Down:
147 | ucHexViewer1.SelectedIndex++;
148 | break;
149 | case Keys.Up:
150 | ucHexViewer1.SelectedIndex--;
151 | break;
152 | }
153 | e.Handled = true;
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Common/ChannelList.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Collections.Generic;
21 | using System.Globalization;
22 | using System.IO;
23 | using System.Text;
24 | using SamsChannelEditor.Utils;
25 |
26 | namespace SamsChannelEditor.Common
27 | {
28 | internal class ChannelList : List
29 | {
30 | private static bool ChannelIsOk(IChannel ch)
31 | {
32 | return (ch != null) && (ch.IsOk());
33 | }
34 |
35 | private static int CompareChanelByNumber(IChannel x, IChannel y)
36 | {
37 | if ((ChannelIsOk(x)) && (ChannelIsOk(y)))
38 | return x.Number.CompareTo(y.Number);
39 |
40 | if (ChannelIsOk(x))
41 | return -1;
42 |
43 | if (ChannelIsOk(y))
44 | return 1;
45 |
46 | return 0;
47 | }
48 |
49 | private static int CompareChanelByFilePos(IChannel x, IChannel y)
50 | {
51 | if ((ChannelIsOk(x)) && (ChannelIsOk(y)))
52 | return x.FilePosition.CompareTo(y.FilePosition);
53 |
54 | if (ChannelIsOk(x))
55 | return -1;
56 |
57 | if (ChannelIsOk(y))
58 | return 1;
59 |
60 | return 0;
61 | }
62 |
63 | private static int CompareChanelByName(IChannel x, IChannel y)
64 | {
65 | if ((ChannelIsOk(x)) && (ChannelIsOk(y)))
66 | return System.String.Compare(x.Name, y.Name, System.StringComparison.Ordinal);
67 |
68 | if (ChannelIsOk(x))
69 | return -1;
70 |
71 | if (ChannelIsOk(y))
72 | return 1;
73 |
74 | return 0;
75 | }
76 |
77 | public void SortByChanelNum()
78 | {
79 | Sort(CompareChanelByNumber);
80 | }
81 |
82 | public void SortByFilePosition()
83 | {
84 | Sort(CompareChanelByFilePos);
85 | }
86 |
87 | public void SortByName()
88 | {
89 | Sort(CompareChanelByName);
90 | }
91 |
92 | public void SwapChannels(int idx1, int idx2)
93 | {
94 | IChannel ch1 = this[idx1];
95 | this[idx1] = this[idx2];
96 | this[idx2] = ch1;
97 | }
98 |
99 | internal void SaveOrderTo(string filename)
100 | {
101 | using (var sw = new StreamWriter(filename, false, Encoding.Unicode))
102 | {
103 | sw.Write("Number".PadRight(10));
104 | sw.Write("Name".PadRight(100));
105 | sw.Write("TSID ");
106 | sw.Write("ONID ");
107 | sw.WriteLine();
108 |
109 | SortByChanelNum();
110 | foreach (IChannel ch in this)
111 | {
112 | if (ch.IsOk() && (!ch.Deleted))
113 | {
114 | sw.Write(ch.Number.ToString(CultureInfo.InvariantCulture).PadRight(10));
115 | sw.Write(ch.Name.PadRight(100));
116 | sw.Write(ch.Multiplex_TSID.ToString("X4") + " ");
117 | sw.Write(ch.Multiplex_ONID.ToString("X4") + " ");
118 | sw.WriteLine();
119 | }
120 | }
121 |
122 | sw.Flush();
123 | sw.Close();
124 | }
125 | }
126 |
127 | internal int SetOrderFrom(string filename)
128 | {
129 | const short notusedix = 16383;
130 | short curix = notusedix;
131 | foreach (IChannel ch in this)
132 | ch.Number = curix++;
133 |
134 | curix = 0;
135 |
136 | char[] charsToTrim = { ' ', '\t', ',', ';' };
137 |
138 | using (var sr = new StreamReader(filename, Encoding.Unicode))
139 | {
140 | if (sr.ReadLine() != null) // ignore first line
141 | {
142 | string linia;
143 | while ((linia = sr.ReadLine()) != null)
144 | {
145 | var nom = StringUtils.Copy(linia, 10, 100);
146 | nom = nom.Trim(charsToTrim);
147 |
148 | foreach (IChannel ch in this)
149 | if (ch.Number >= notusedix && ch.Name.Equals(nom))
150 | {
151 | ch.Number = curix++;
152 | break;
153 | }
154 | }
155 | }
156 | sr.Close();
157 | }
158 | SortByChanelNum();
159 | return curix;
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/FInputBox.designer.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace SamsChannelEditor.UI
21 | {
22 | partial class FInputBox
23 | {
24 | ///
25 | /// Required designer variable.
26 | ///
27 | private System.ComponentModel.IContainer components = null;
28 |
29 | ///
30 | /// Clean up any resources being used.
31 | ///
32 | /// true if managed resources should be disposed; otherwise, false.
33 | protected override void Dispose(bool disposing)
34 | {
35 | if (disposing && (components != null))
36 | {
37 | components.Dispose();
38 | }
39 | base.Dispose(disposing);
40 | }
41 |
42 | #region Windows Form Designer generated code
43 |
44 | ///
45 | /// Required method for Designer support - do not modify
46 | /// the contents of this method with the code editor.
47 | ///
48 | private void InitializeComponent()
49 | {
50 | this.label1 = new System.Windows.Forms.Label();
51 | this.btnOk = new System.Windows.Forms.Button();
52 | this.btnCancel = new System.Windows.Forms.Button();
53 | this.txtValor = new System.Windows.Forms.TextBox();
54 | this.SuspendLayout();
55 | //
56 | // label1
57 | //
58 | this.label1.AutoSize = true;
59 | this.label1.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
60 | this.label1.Location = new System.Drawing.Point(13, 20);
61 | this.label1.Name = "label1";
62 | this.label1.Size = new System.Drawing.Size(75, 16);
63 | this.label1.TabIndex = 2;
64 | this.label1.Text = "InputBox";
65 | //
66 | // btnOk
67 | //
68 | this.btnOk.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
69 | this.btnOk.Location = new System.Drawing.Point(16, 79);
70 | this.btnOk.Name = "btnOk";
71 | this.btnOk.Size = new System.Drawing.Size(118, 26);
72 | this.btnOk.TabIndex = 1;
73 | this.btnOk.Text = "OK";
74 | this.btnOk.UseVisualStyleBackColor = true;
75 | this.btnOk.Click += new System.EventHandler(this.button1_Click);
76 | //
77 | // btnCancel
78 | //
79 | this.btnCancel.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
80 | this.btnCancel.Location = new System.Drawing.Point(154, 79);
81 | this.btnCancel.Name = "btnCancel";
82 | this.btnCancel.Size = new System.Drawing.Size(118, 26);
83 | this.btnCancel.TabIndex = 2;
84 | this.btnCancel.Text = "CANCEL";
85 | this.btnCancel.UseVisualStyleBackColor = true;
86 | this.btnCancel.Click += new System.EventHandler(this.button2_Click);
87 | //
88 | // txtValor
89 | //
90 | this.txtValor.Location = new System.Drawing.Point(16, 39);
91 | this.txtValor.Name = "txtValor";
92 | this.txtValor.Size = new System.Drawing.Size(256, 22);
93 | this.txtValor.TabIndex = 3;
94 | //
95 | // FInputBox
96 | //
97 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 14F);
98 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
99 | this.ClientSize = new System.Drawing.Size(284, 114);
100 | this.Controls.Add(this.txtValor);
101 | this.Controls.Add(this.btnCancel);
102 | this.Controls.Add(this.btnOk);
103 | this.Controls.Add(this.label1);
104 | this.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
105 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
106 | this.KeyPreview = true;
107 | this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
108 | this.Name = "FInputBox";
109 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
110 | this.Text = "InputBox";
111 | this.Load += new System.EventHandler(this.FInputBox_Load);
112 | this.Activated += new System.EventHandler(this.FInputBox_Activated);
113 | this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FInputBox_KeyDown);
114 | this.ResumeLayout(false);
115 | this.PerformLayout();
116 |
117 | }
118 |
119 | #endregion
120 |
121 | private System.Windows.Forms.Label label1;
122 | private System.Windows.Forms.Button btnOk;
123 | private System.Windows.Forms.Button btnCancel;
124 | private System.Windows.Forms.TextBox txtValor;
125 |
126 | }
127 | }
--------------------------------------------------------------------------------
/Source/HexComparer/RegSizePrompt.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Source/HexComparer/UCHexViewer.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Source/HexComparer/UCViewData.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/FAboutBox.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/FInputBox.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/UCSingleEdit.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Error
122 | Error
123 |
124 |
125 | This is readonly field. You can not edit it.
126 | You are trying to edit readonly field.
127 |
128 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Utils/MyZipFile.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Collections.Generic;
22 | using System.IO;
23 | using ICSharpCode.SharpZipLib.Core;
24 | using ICSharpCode.SharpZipLib.Zip;
25 | using log4net;
26 |
27 | namespace SamsChannelEditor.Utils
28 | {
29 | internal class MyZipFile
30 | {
31 | static readonly ILog LOG = LogManager.GetLogger("MyZipFile");
32 |
33 | string _zipfilename = "";
34 | ZipFile _zipfile;
35 |
36 | public string FileName
37 | {
38 | get { return _zipfilename; }
39 | set { _zipfilename = value; }
40 | }
41 |
42 | public MyZipFile(string filename)
43 | {
44 | FileName = filename;
45 | _zipfile = new ZipFile(filename);
46 | }
47 |
48 | public void Close()
49 | {
50 | if (_zipfile != null)
51 | {
52 | _zipfile.Close();
53 | _zipfile = null;
54 | }
55 | _zipfilename = "";
56 | }
57 |
58 | public string ExtractFile(string fileinzip)
59 | {
60 | string fout = "";
61 |
62 | if (LOG.IsDebugEnabled)
63 | LOG.Debug("Extract file " + fileinzip + " from " + FileName);
64 |
65 | var zentry = _zipfile.GetEntry(fileinzip);
66 | if (zentry == null)
67 | return "";
68 |
69 | var directoryName = Path.GetDirectoryName(zentry.Name);
70 | var fileName = Path.GetFileName(zentry.Name);
71 | var temppath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
72 |
73 | // create directory
74 | if (string.IsNullOrEmpty(directoryName))
75 | directoryName = temppath;
76 | else
77 | directoryName = Path.Combine(temppath, directoryName);
78 |
79 | if (directoryName != "" && (!Directory.Exists(directoryName)))
80 | Directory.CreateDirectory(directoryName);
81 |
82 | if (!string.IsNullOrEmpty(fileName))
83 | {
84 | fout = Path.Combine(directoryName, fileName);
85 | var buffer = new byte[4096];
86 | var zipStream = _zipfile.GetInputStream(zentry);
87 | using (var streamWriter = File.Create(fout))
88 | {
89 | StreamUtils.Copy(zipStream, streamWriter, buffer);
90 | }
91 |
92 | if (LOG.IsDebugEnabled)
93 | LOG.Debug("File extracted: " + fout);
94 | }
95 |
96 | return fout;
97 | }
98 |
99 | public string ExtractFiles()
100 | {
101 | //string temppath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
102 | var temppath = FileUtils.GetTempDirectory();
103 |
104 | if (LOG.IsDebugEnabled)
105 | LOG.Debug("Extract files from " + FileName);
106 |
107 | foreach (ZipEntry zentry in _zipfile)
108 | {
109 | if (zentry == null)
110 | return "";
111 |
112 | var directoryName = Path.GetDirectoryName(zentry.Name);
113 | var fileName = Path.GetFileName(zentry.Name);
114 |
115 | // create directory
116 | if (string.IsNullOrEmpty(directoryName))
117 | directoryName = temppath;
118 | else
119 | directoryName = Path.Combine(temppath, directoryName);
120 |
121 | if (directoryName != "" && (!Directory.Exists(directoryName)))
122 | Directory.CreateDirectory(directoryName);
123 |
124 | if (!string.IsNullOrEmpty(fileName))
125 | {
126 | var fout = Path.Combine(directoryName, fileName);
127 | var buffer = new byte[4096];
128 |
129 | var zipStream = _zipfile.GetInputStream(zentry);
130 | using (var streamWriter = File.Create(fout))
131 | {
132 | StreamUtils.Copy(zipStream, streamWriter, buffer);
133 | }
134 |
135 | if (LOG.IsDebugEnabled)
136 | LOG.Debug("File extracted: " + fout);
137 | }
138 | }
139 |
140 | return temppath;
141 | }
142 |
143 | public void AddFile(string fileinzip)
144 | {
145 | //ZipFile zipFile = new ZipFile(_zipfilename);
146 |
147 | // Must call BeginUpdate to start, and CommitUpdate at the end.
148 | _zipfile.BeginUpdate();
149 | // The "Add()" method will add or overwrite as necessary.
150 | // When the optional entryName parameter is omitted, the entry will be named
151 | // with the full folder path and without the drive e.g. "temp/folder/test1.txt".
152 | _zipfile.Add(fileinzip, Path.GetFileName(fileinzip));
153 |
154 | // Both CommitUpdate and Close must be called.
155 | _zipfile.CommitUpdate();
156 |
157 | if (LOG.IsDebugEnabled)
158 | LOG.Debug(fileinzip + " added to " + FileName);
159 | }
160 |
161 | public List ListAllFiles()
162 | {
163 | var zf = new ZipFile(_zipfilename);
164 | var list = new List();
165 | foreach (ZipEntry z in zf)
166 | {
167 | if (z.IsFile)
168 | list.Add(z.Name);
169 | }
170 | zf.Close();
171 | return list;
172 | }
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/Source/HexComparer/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\arrow.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\arrow-180.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
--------------------------------------------------------------------------------
/Source/HexComparer/HexComparer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {BC87FE82-6E26-473F-BD27-36568BB6F691}
9 | WinExe
10 | Properties
11 | HexComparer
12 | HexComparer
13 | v4.8
14 | 512
15 | false
16 | Hc.ico
17 |
18 |
19 | 3.5
20 |
21 | publish\
22 | true
23 | Disk
24 | false
25 | Foreground
26 | 7
27 | Days
28 | false
29 | false
30 | true
31 | 0
32 | 1.0.0.%2a
33 | false
34 | true
35 |
36 |
37 |
38 | true
39 | full
40 | false
41 | bin\Debug\
42 | DEBUG;TRACE
43 | prompt
44 | 4
45 | false
46 |
47 |
48 | pdbonly
49 | true
50 | bin\Release\
51 | TRACE
52 | prompt
53 | 4
54 | false
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | Form
67 |
68 |
69 | FMain.cs
70 |
71 |
72 |
73 |
74 |
75 | FMain.cs
76 |
77 |
78 | ResXFileCodeGenerator
79 | Resources.Designer.cs
80 | Designer
81 |
82 |
83 | RegSizePrompt.cs
84 |
85 |
86 | UCHexViewer.cs
87 |
88 |
89 | UCViewData.cs
90 |
91 |
92 | True
93 | Resources.resx
94 | True
95 |
96 |
97 | SettingsSingleFileGenerator
98 | Settings.Designer.cs
99 |
100 |
101 | True
102 | Settings.settings
103 | True
104 |
105 |
106 | Form
107 |
108 |
109 | RegSizePrompt.cs
110 |
111 |
112 | UserControl
113 |
114 |
115 | UCHexViewer.cs
116 |
117 |
118 | UserControl
119 |
120 |
121 | UCViewData.cs
122 |
123 |
124 |
125 |
126 | False
127 | .NET Framework 3.5 SP1 Client Profile
128 | false
129 |
130 |
131 | False
132 | .NET Framework 2.0 %28x86%29
133 | false
134 |
135 |
136 | False
137 | .NET Framework 3.0 %28x86%29
138 | false
139 |
140 |
141 | False
142 | .NET Framework 3.5
143 | false
144 |
145 |
146 | False
147 | .NET Framework 3.5 SP1
148 | true
149 |
150 |
151 | False
152 | Windows Installer 3.1
153 | true
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
174 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/MapChannel.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Text;
22 | using SamsChannelEditor.Common;
23 | using SamsChannelEditor.Utils;
24 |
25 | namespace SamsChannelEditor.Samsung
26 | {
27 | internal enum MapChannelType : byte
28 | {
29 | None = 0x00,
30 | TV = 0x01,
31 | Radio = 0x02,
32 | Data = 0x0C,
33 | HD = 0x19,
34 | Other = 0xFF, // wildcard for new models not supported
35 | }
36 |
37 | internal class MapChannel : IChannel
38 | {
39 | private bool _isDeleted;
40 |
41 | public int FilePosition { get; set; }
42 |
43 | public bool Deleted
44 | {
45 | get { return _isDeleted; }
46 | set { _isDeleted = value; }
47 | }
48 |
49 | public bool Active
50 | {
51 | get { return !_isDeleted; }
52 | set { _isDeleted = !value; }
53 | }
54 |
55 | public byte[] Data { get; private set; }
56 |
57 | public MapChannel(int pos, byte[] buffer)
58 | {
59 | _isDeleted = false;
60 | FilePosition = pos;
61 | Data = (byte[])buffer.Clone();
62 | }
63 |
64 | public short Number
65 | {
66 | get { return BitConverter.ToInt16(Data, 0); }
67 |
68 | set
69 | {
70 | Int16 sh = value;
71 | byte[] b = BitConverter.GetBytes(sh);
72 |
73 | Data[0] = b[0];
74 | Data[1] = b[1];
75 | }
76 | }
77 |
78 | [Editable]
79 | public virtual string Name
80 | {
81 | get { return StringUtils.RemoveNulls(Encoding.BigEndianUnicode.GetString(Data, 64, 100)); }
82 | set
83 | {
84 | byte[] newName = Encoding.BigEndianUnicode.GetBytes(value);
85 | Array.Clear(Data, 64, 100);
86 | newName.CopyTo(Data, 64);
87 | }
88 | }
89 |
90 |
91 | public virtual string ChannelType
92 | {
93 | get
94 | {
95 | MapChannelType ct = GetMapChannelType(Data[15]);
96 | return ct != MapChannelType.Other ? ct.ToString() : "";
97 | }
98 | }
99 |
100 | public virtual bool IsEncrypted
101 | {
102 | get { return (Data[24] == 1); }
103 | }
104 |
105 | public virtual long Frequency
106 | {
107 | //TODO: Search Freq. field
108 | get { return 0; }
109 | }
110 |
111 | public virtual ushort Network
112 | {
113 | get { return BitConverter.ToUInt16(Data, 34); }
114 | }
115 |
116 | public virtual ushort ServiceID
117 | {
118 | get { return BitConverter.ToUInt16(Data, 6); }
119 | }
120 |
121 | public virtual ushort Multiplex_TSID
122 | {
123 | get { return BitConverter.ToUInt16(Data, 48); }
124 | }
125 |
126 | public virtual ushort Multiplex_ONID
127 | {
128 | get { return BitConverter.ToUInt16(Data, 32); }
129 | }
130 |
131 | [Editable]
132 | public virtual bool FavoriteList1
133 | {
134 | get
135 | {
136 | if (Data.Length > 290)
137 | return ((Data[290] & 0x01) > 0);
138 | return false;
139 | }
140 | set
141 | {
142 | if (Data.Length <= 290)
143 | return;
144 |
145 | if (value)
146 | {
147 | Data[290] |= 0x01;
148 | }
149 | else
150 | {
151 | Data[290] &= 0xFE;
152 | }
153 | }
154 | }
155 |
156 | [Editable]
157 | public virtual bool FavoriteList2
158 | {
159 | get
160 | {
161 | if (Data.Length > 290)
162 | return ((Data[290] & 0x02) > 0);
163 | return false;
164 | }
165 | set
166 | {
167 | if (Data.Length <= 290)
168 | return;
169 |
170 | if (value)
171 | {
172 | Data[290] |= 0x02;
173 | }
174 | else
175 | {
176 | Data[290] &= 0xFD;
177 | }
178 | }
179 | }
180 |
181 | [Editable]
182 | public virtual bool FavoriteList3
183 | {
184 | get
185 | {
186 | if (Data.Length > 290)
187 | return ((Data[290] & 0x04) > 0);
188 | return false;
189 | }
190 | set
191 | {
192 | if (Data.Length <= 290)
193 | return;
194 |
195 | if (value)
196 | {
197 | Data[290] |= 0x04;
198 | }
199 | else
200 | {
201 | Data[290] &= 0xFB;
202 | }
203 | }
204 | }
205 |
206 | [Editable]
207 | public virtual bool FavoriteList4
208 | {
209 | get
210 | {
211 | if (Data.Length > 290)
212 | return ((Data[290] & 0x08) > 0);
213 | return false;
214 | }
215 | set
216 | {
217 | if (Data.Length <= 290)
218 | return;
219 |
220 | if (value)
221 | {
222 | Data[290] |= 0x08;
223 | }
224 | else
225 | {
226 | Data[290] &= 0xF7;
227 | }
228 | }
229 | }
230 |
231 | [Editable]
232 | public virtual bool Locked
233 | {
234 | get { return Data[31] == 0x01; }
235 | set
236 | {
237 | if (value)
238 | {
239 | Data[31] = 0x01;
240 | }
241 | else
242 | {
243 | Data[31] = 0x00;
244 | }
245 | }
246 | }
247 |
248 | public virtual bool IsOk()
249 | {
250 | return (BitConverter.ToInt16(Data, 0) > 0);
251 | }
252 |
253 | public byte CalcChecksum()
254 | {
255 | return CalcChecksum(false);
256 | }
257 |
258 | public virtual byte CalcChecksum(bool saveindata)
259 | {
260 | byte ck = 0;
261 | for (int i = 0; i < Data.Length - 1; i++)
262 | ck += Data[i];
263 |
264 | if (saveindata)
265 | Data[Data.Length - 1] = ck;
266 |
267 | return ck;
268 | }
269 |
270 | protected MapChannelType GetMapChannelType(byte b)
271 | {
272 | try
273 | {
274 | return (MapChannelType)b;
275 | }
276 | catch
277 | {
278 | return MapChannelType.Other;
279 | }
280 | }
281 | }
282 | }
283 |
--------------------------------------------------------------------------------
/Source/HexComparer/HexViewerControl.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Globalization;
22 | using System.Text;
23 | using System.Windows.Forms;
24 | using System.Drawing;
25 |
26 | namespace HexComparer
27 | {
28 | public class HexViewerItemChangedEventArgs : EventArgs
29 | {
30 | public int Index { get; private set; }
31 | public byte Byte1 { get; private set; }
32 | public byte Byte2 { get; private set; }
33 |
34 | public HexViewerItemChangedEventArgs(int idx, byte byte1, byte byte2)
35 | {
36 | Index = idx;
37 | Byte1 = byte1;
38 | Byte2 = byte2;
39 | }
40 | }
41 |
42 | public delegate void HexViewerItemChangedEventHandler(object sender, HexViewerItemChangedEventArgs e);
43 |
44 | internal sealed class HexViewerControl : Control
45 | {
46 | char[] _chars1;
47 | char[] _chars2;
48 |
49 | int _offset;
50 |
51 | int _recordHeight;
52 | int _selectedIndex = -1;
53 |
54 | public event HexViewerItemChangedEventHandler SelectedItemChanged;
55 |
56 | public int Offset
57 | {
58 | get { return _offset; }
59 | set
60 | {
61 | _offset = value;
62 | if (_offset < 0)
63 | _offset = 0;
64 |
65 | if (_offset > MaxLen)
66 | _offset = MaxLen;
67 |
68 | Invalidate();
69 | }
70 | }
71 |
72 | public int RecordsPerPage { get; private set; }
73 | public int MaxLen { get; private set; }
74 |
75 | public HexViewerControl()
76 | {
77 | TabStop = true;
78 | DoubleBuffered = true;
79 | }
80 |
81 | public int SelectedIndex
82 | {
83 | get { return _selectedIndex; }
84 | set { SetSelectIndex(value); }
85 | }
86 |
87 | public byte[] Data1 { get; private set; }
88 | public byte[] Data2 { get; private set; }
89 |
90 | public void SetData(byte[] d1, byte[] d2)
91 | {
92 | MaxLen = (d1.Length > d2.Length ? d1.Length : d2.Length);
93 | Data1 = d1;
94 | Data2 = d2;
95 | _offset = 0;
96 |
97 | _chars1 = Encoding.ASCII.GetChars(Data1);
98 | _chars2 = Encoding.ASCII.GetChars(Data2);
99 |
100 | _recordHeight = (int)(Font.GetHeight() * 1.3);
101 | RecordsPerPage = Height / _recordHeight;
102 |
103 | Invalidate();
104 | }
105 |
106 | protected override void OnResize(EventArgs e)
107 | {
108 | _recordHeight = (int)(Font.GetHeight() * 1.3);
109 | RecordsPerPage = Height / _recordHeight;
110 | //base.OnResize(e);
111 | Invalidate();
112 | }
113 |
114 | protected override void OnPaintBackground(PaintEventArgs e)
115 | {
116 | e.Graphics.Clear(BackColor);
117 | using (var p = new Pen(new SolidBrush(Color.Black), 1))
118 | {
119 | var middle = Width / 2;
120 | var separator = Width / 6;
121 |
122 | e.Graphics.FillRectangle(Brushes.DarkGray, 0, 0, separator, Height);
123 | e.Graphics.FillRectangle(Brushes.DarkGray, middle, 0, separator, Height);
124 |
125 | e.Graphics.DrawLine(p, new Point(middle, 0), new Point(middle, Height));
126 |
127 | p.DashPattern = new float[] { 1, 1 };
128 |
129 | e.Graphics.DrawLine(p, new Point(separator, 0), new Point(separator, Height));
130 | e.Graphics.DrawLine(p, new Point(separator * 2, 0), new Point(separator * 2, Height));
131 | e.Graphics.DrawLine(p, new Point(middle + separator, 0), new Point(middle + separator, Height));
132 | e.Graphics.DrawLine(p, new Point(middle + separator * 2, 0), new Point(middle + separator * 2, Height));
133 | }
134 | }
135 |
136 | protected override void OnPaint(PaintEventArgs e)
137 | {
138 | var gr = e.Graphics;
139 |
140 | var middle = Width / 2;
141 | var separator = Width / 6;
142 |
143 | using (Brush normalbrush = new SolidBrush(ForeColor), selbrus = new SolidBrush(Color.LightSkyBlue))
144 | {
145 | using (var p = new Pen(ForeColor, 1))
146 | {
147 | for (var i = 0; i < RecordsPerPage; i++)
148 | {
149 | var current = _offset + i;
150 | var currstr = string.Format("{0} ({0:X2})", current);
151 |
152 | var brush = normalbrush;
153 |
154 | if (current == _selectedIndex)
155 | gr.FillRectangle(selbrus, 0, _recordHeight * i, Width, _recordHeight);
156 |
157 | int posy;
158 | if ((Data1 != null) && (current < Data1.Length))
159 | {
160 | posy = _recordHeight * i + (int)(_recordHeight * 0.3);
161 | gr.DrawString(currstr, Font, brush, 4, posy);
162 | gr.DrawString(Data1[current].ToString("X2"), Font, brush, separator + 4, posy);
163 | gr.DrawString(GetChar(_chars1, current).ToString(CultureInfo.InvariantCulture),
164 | Font, brush, separator * 2 + 4, posy);
165 | }
166 |
167 | if ((Data2 != null) && (current < Data2.Length))
168 | {
169 | posy = _recordHeight * i + (int)(_recordHeight * 0.3);
170 | gr.DrawString(currstr, Font, brush, middle + 4, posy);
171 | gr.DrawString(Data2[current].ToString("X2"), Font, brush, middle + separator + 4, posy);
172 | gr.DrawString(GetChar(_chars2, current).ToString(CultureInfo.InvariantCulture),
173 | Font, brush, middle + (separator * 2) + 4, posy);
174 | }
175 |
176 | gr.DrawLine(p, new Point(0, _recordHeight * (i + 1)), new Point(Width, _recordHeight * (i + 1)));
177 | }
178 | }
179 | }
180 | base.OnPaint(e);
181 | }
182 |
183 | private static char GetChar(char[] chars, int idx)
184 | {
185 | return (chars[idx] >= 32) && (chars[idx] < 254) ? chars[idx] : ' ';
186 | }
187 |
188 | protected override void OnMouseDown(MouseEventArgs e)
189 | {
190 | var record = e.Y / _recordHeight;
191 | SetSelectIndex(_offset + record);
192 | base.OnMouseDown(e);
193 | }
194 |
195 | private void SetSelectIndex(int i)
196 | {
197 | if (i < 0) i = 0;
198 | if (i >= MaxLen) i = MaxLen - 1;
199 |
200 | _selectedIndex = i;
201 |
202 | if (SelectedItemChanged != null)
203 | {
204 | byte b1 = 0;
205 | byte b2 = 0;
206 |
207 | if ((Data1 != null) && (Data1.Length > _selectedIndex))
208 | b1 = Data1[_selectedIndex];
209 |
210 | if ((Data2 != null) && (Data2.Length > _selectedIndex))
211 | b2 = Data2[_selectedIndex];
212 |
213 | SelectedItemChanged(this, new HexViewerItemChangedEventArgs(_selectedIndex, b1, b2));
214 | }
215 |
216 | Invalidate();
217 | }
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/Source/HexComparer/RegSizePrompt.Designer.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | namespace HexComparer
21 | {
22 | partial class RegSizePrompt
23 | {
24 | ///
25 | /// Required designer variable.
26 | ///
27 | private System.ComponentModel.IContainer components = null;
28 |
29 | ///
30 | /// Clean up any resources being used.
31 | ///
32 | /// true if managed resources should be disposed; otherwise, false.
33 | protected override void Dispose(bool disposing)
34 | {
35 | if (disposing && (components != null))
36 | {
37 | components.Dispose();
38 | }
39 | base.Dispose(disposing);
40 | }
41 |
42 | #region Windows Form Designer generated code
43 |
44 | ///
45 | /// Required method for Designer support - do not modify
46 | /// the contents of this method with the code editor.
47 | ///
48 | private void InitializeComponent()
49 | {
50 | this.btnOk = new System.Windows.Forms.Button();
51 | this.btnCancel = new System.Windows.Forms.Button();
52 | this.label1 = new System.Windows.Forms.Label();
53 | this.lblFileName = new System.Windows.Forms.Label();
54 | this.label3 = new System.Windows.Forms.Label();
55 | this.lblFileSize = new System.Windows.Forms.Label();
56 | this.label5 = new System.Windows.Forms.Label();
57 | this.nudRegSize = new System.Windows.Forms.NumericUpDown();
58 | this.label2 = new System.Windows.Forms.Label();
59 | ((System.ComponentModel.ISupportInitialize)(this.nudRegSize)).BeginInit();
60 | this.SuspendLayout();
61 | //
62 | // btnOk
63 | //
64 | this.btnOk.Location = new System.Drawing.Point(15, 130);
65 | this.btnOk.Name = "btnOk";
66 | this.btnOk.Size = new System.Drawing.Size(87, 23);
67 | this.btnOk.TabIndex = 0;
68 | this.btnOk.Text = "Ok";
69 | this.btnOk.UseVisualStyleBackColor = true;
70 | this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
71 | //
72 | // btnCancel
73 | //
74 | this.btnCancel.Location = new System.Drawing.Point(113, 130);
75 | this.btnCancel.Name = "btnCancel";
76 | this.btnCancel.Size = new System.Drawing.Size(87, 23);
77 | this.btnCancel.TabIndex = 1;
78 | this.btnCancel.Text = "Cancel";
79 | this.btnCancel.UseVisualStyleBackColor = true;
80 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
81 | //
82 | // label1
83 | //
84 | this.label1.AutoSize = true;
85 | this.label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
86 | this.label1.Location = new System.Drawing.Point(12, 19);
87 | this.label1.Name = "label1";
88 | this.label1.Size = new System.Drawing.Size(35, 13);
89 | this.label1.TabIndex = 2;
90 | this.label1.Text = "File:";
91 | //
92 | // lblFileName
93 | //
94 | this.lblFileName.AutoSize = true;
95 | this.lblFileName.Location = new System.Drawing.Point(56, 19);
96 | this.lblFileName.Name = "lblFileName";
97 | this.lblFileName.Size = new System.Drawing.Size(58, 13);
98 | this.lblFileName.TabIndex = 3;
99 | this.lblFileName.Text = "Filename";
100 | //
101 | // label3
102 | //
103 | this.label3.AutoSize = true;
104 | this.label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
105 | this.label3.Location = new System.Drawing.Point(12, 46);
106 | this.label3.Name = "label3";
107 | this.label3.Size = new System.Drawing.Size(38, 13);
108 | this.label3.TabIndex = 4;
109 | this.label3.Text = "Size:";
110 | //
111 | // lblFileSize
112 | //
113 | this.lblFileSize.AutoSize = true;
114 | this.lblFileSize.Location = new System.Drawing.Point(56, 46);
115 | this.lblFileSize.Name = "lblFileSize";
116 | this.lblFileSize.Size = new System.Drawing.Size(48, 13);
117 | this.lblFileSize.TabIndex = 5;
118 | this.lblFileSize.Text = "Filesize";
119 | //
120 | // label5
121 | //
122 | this.label5.AutoSize = true;
123 | this.label5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
124 | this.label5.Location = new System.Drawing.Point(12, 77);
125 | this.label5.Name = "label5";
126 | this.label5.Size = new System.Drawing.Size(62, 13);
127 | this.label5.TabIndex = 6;
128 | this.label5.Text = "RegSize:";
129 | //
130 | // nudRegSize
131 | //
132 | this.nudRegSize.Location = new System.Drawing.Point(80, 75);
133 | this.nudRegSize.Maximum = new decimal(new int[] {
134 | 10000,
135 | 0,
136 | 0,
137 | 0});
138 | this.nudRegSize.Name = "nudRegSize";
139 | this.nudRegSize.Size = new System.Drawing.Size(75, 21);
140 | this.nudRegSize.TabIndex = 7;
141 | //
142 | // label2
143 | //
144 | this.label2.AutoSize = true;
145 | this.label2.Location = new System.Drawing.Point(161, 77);
146 | this.label2.Name = "label2";
147 | this.label2.Size = new System.Drawing.Size(38, 13);
148 | this.label2.TabIndex = 8;
149 | this.label2.Text = "bytes";
150 | //
151 | // RegSizePrompt
152 | //
153 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);
154 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
155 | this.ClientSize = new System.Drawing.Size(217, 170);
156 | this.ControlBox = false;
157 | this.Controls.Add(this.label2);
158 | this.Controls.Add(this.nudRegSize);
159 | this.Controls.Add(this.label5);
160 | this.Controls.Add(this.lblFileSize);
161 | this.Controls.Add(this.label3);
162 | this.Controls.Add(this.lblFileName);
163 | this.Controls.Add(this.label1);
164 | this.Controls.Add(this.btnCancel);
165 | this.Controls.Add(this.btnOk);
166 | this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
167 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
168 | this.Name = "RegSizePrompt";
169 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
170 | this.Text = "RegSizePrompt";
171 | this.Load += new System.EventHandler(this.RegSizePrompt_Load);
172 | ((System.ComponentModel.ISupportInitialize)(this.nudRegSize)).EndInit();
173 | this.ResumeLayout(false);
174 | this.PerformLayout();
175 |
176 | }
177 |
178 | #endregion
179 |
180 | private System.Windows.Forms.Button btnOk;
181 | private System.Windows.Forms.Button btnCancel;
182 | private System.Windows.Forms.Label label1;
183 | private System.Windows.Forms.Label lblFileName;
184 | private System.Windows.Forms.Label label3;
185 | private System.Windows.Forms.Label lblFileSize;
186 | private System.Windows.Forms.Label label5;
187 | private System.Windows.Forms.NumericUpDown nudRegSize;
188 | private System.Windows.Forms.Label label2;
189 | }
190 | }
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/Samsung/SCMFile.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using log4net;
23 | using SamsChannelEditor.Utils;
24 |
25 | namespace SamsChannelEditor.Samsung
26 | {
27 | public enum SCMFileContentType
28 | {
29 | unknown = -1,
30 | mapAirA,
31 | mapAirD,
32 | mapCableA,
33 | mapCableD,
34 | mapCDTVVD,
35 | mapSateD,
36 | mapAstraHDPlusD,
37 | cloneInfo,
38 | satDataBase,
39 | }
40 |
41 | internal class SCMFileContentInfo
42 | {
43 | public string Filename { get; private set; }
44 | public SCMFileContentType ContentType { get; private set; }
45 | public bool IsChannelListFile { get; private set; }
46 |
47 | public SCMFileContentInfo(string filename, SCMFileContentType contenttype, bool ischannellist)
48 | {
49 | Filename = filename;
50 | ContentType = contenttype;
51 | IsChannelListFile = ischannellist;
52 | }
53 | }
54 |
55 | internal class SCMFile
56 | {
57 | static readonly ILog LOG = LogManager.GetLogger("SCMFile");
58 |
59 | #region Static methods
60 | static readonly Dictionary SUPPORTED_FILES = new Dictionary
61 | {
62 | {"cloneinfo", new SCMFileContentInfo("cloneinfo", SCMFileContentType.cloneInfo, false) },
63 | {"map-aird", new SCMFileContentInfo("map-aird", SCMFileContentType.mapAirD, true) },
64 | {"map-aira", new SCMFileContentInfo("map-aira", SCMFileContentType.mapAirA, true) },
65 | {"map-cablea", new SCMFileContentInfo("map-cablea", SCMFileContentType.mapCableA, true) },
66 | {"map-cabled", new SCMFileContentInfo("map-cabled", SCMFileContentType.mapCableD, true) },
67 | {"map-cdtvvd", new SCMFileContentInfo("map-cdtvvd", SCMFileContentType.mapCDTVVD, true) },
68 | {"map-sated", new SCMFileContentInfo("map-sated", SCMFileContentType.mapSateD, true) },
69 | {"map-astrahdplusd", new SCMFileContentInfo("map-astrahdplusd", SCMFileContentType.mapAstraHDPlusD, true) },
70 | {"satdatabase.dat", new SCMFileContentInfo("satdatabase.dat", SCMFileContentType.satDataBase, false) },
71 | };
72 |
73 | internal static bool IsChannelMapFile(string filename)
74 | {
75 | if (string.IsNullOrEmpty(filename))
76 | return false;
77 |
78 | filename = Path.GetFileName(filename);
79 | if (string.IsNullOrEmpty(filename))
80 | return false;
81 |
82 | var f = filename.ToLower();
83 |
84 | return SUPPORTED_FILES.ContainsKey(f) &&
85 | SUPPORTED_FILES[f].IsChannelListFile;
86 | }
87 |
88 | public static bool IsSupportedFile(string filename)
89 | {
90 | return (GetFileType(filename) != SCMFileContentType.unknown);
91 | }
92 |
93 | public static SCMFileContentType GetFileType(string filename)
94 | {
95 | if (string.IsNullOrEmpty(filename))
96 | return SCMFileContentType.unknown;
97 |
98 | filename = Path.GetFileName(filename);
99 | if (string.IsNullOrEmpty(filename))
100 | return SCMFileContentType.unknown;
101 |
102 | var f = filename.ToLower();
103 |
104 | return SUPPORTED_FILES.ContainsKey(f) ? SUPPORTED_FILES[f].ContentType : SCMFileContentType.unknown;
105 | }
106 |
107 | public static bool IsSCMFile(string filename)
108 | {
109 | if (string.IsNullOrEmpty(filename))
110 | return false;
111 |
112 | var extension = Path.GetExtension(filename);
113 | if (string.IsNullOrEmpty(extension))
114 | return false;
115 |
116 | return (extension.ToLower() == ".scm");
117 | }
118 | #endregion
119 |
120 | string _tempDirectory;
121 | readonly MyZipFile _zipfile;
122 | readonly string[] _filesInside;
123 |
124 | readonly Dictionary _mapfiles;
125 | readonly Dictionary _otherfiles;
126 |
127 | public string FileName { get; private set; }
128 |
129 | public SCMFile(string filename)
130 | {
131 | if (LOG.IsDebugEnabled)
132 | LOG.Debug("Open SCM File " + filename);
133 |
134 | FileName = filename;
135 | _zipfile = new MyZipFile(filename);
136 | _tempDirectory = _zipfile.ExtractFiles();
137 | _filesInside = GetContentFiles();
138 | _mapfiles = new Dictionary();
139 | _otherfiles = new Dictionary();
140 | }
141 |
142 | private string[] GetContentFiles()
143 | {
144 | var files = Directory.GetFiles(_tempDirectory);
145 | for (var i = 0; i < files.Length; i++)
146 | files[i] = Path.GetFileName(files[i]);
147 |
148 | return files;
149 | }
150 |
151 | public void Close()
152 | {
153 | FileName = "";
154 | _tempDirectory = "";
155 | _zipfile.Close();
156 | }
157 |
158 | public string[] GetAllFiles()
159 | {
160 | return (string[])_filesInside.Clone();
161 | }
162 |
163 | public string[] GetSupportedFiles()
164 | {
165 | var l = new List();
166 | foreach (var f in _filesInside)
167 | {
168 | if (IsSupportedFile(f))
169 | l.Add(f);
170 | }
171 |
172 | return l.ToArray();
173 | }
174 |
175 | public MapFile GetMapFile(string filename)
176 | {
177 | MapFile mapFile = null;
178 |
179 | var filetype = GetFileType(filename);
180 |
181 | if (LOG.IsInfoEnabled)
182 | LOG.Debug("Get MapFile " + filetype);
183 |
184 | if (_mapfiles.ContainsKey(filetype))
185 | mapFile = _mapfiles[filetype];
186 | else
187 | {
188 | if (filetype != SCMFileContentType.unknown)
189 | mapFile = new MapFile(filename, filetype);
190 |
191 | if (mapFile != null)
192 | {
193 | mapFile.ReadFrom(_tempDirectory);
194 | _mapfiles.Add(filetype, mapFile);
195 | }
196 | }
197 |
198 | return mapFile;
199 | }
200 |
201 | internal OtherFile GetOtherFile(string filename)
202 | {
203 | OtherFile otherFile = null;
204 |
205 | var filetype = GetFileType(filename);
206 |
207 | if (LOG.IsInfoEnabled)
208 | LOG.Debug("Get Other File " + filetype);
209 |
210 | if (_otherfiles.ContainsKey(filetype))
211 | otherFile = _otherfiles[filetype];
212 | else
213 | {
214 | switch (filetype)
215 | {
216 | case SCMFileContentType.cloneInfo:
217 | otherFile = new CloneInfoFile(filename, filetype);
218 | break;
219 | case SCMFileContentType.satDataBase:
220 | otherFile = new SatDataBaseFile(filename);
221 | break;
222 | }
223 |
224 | if (otherFile != null)
225 | {
226 | otherFile.ReadFrom(_tempDirectory);
227 | _otherfiles.Add(filetype, otherFile);
228 | }
229 | }
230 |
231 | return otherFile;
232 | }
233 |
234 | public void Save()
235 | {
236 | if (LOG.IsInfoEnabled)
237 | LOG.Info("Saving scm file");
238 |
239 | foreach (var kvp in _mapfiles)
240 | {
241 | if (kvp.Value.Changed)
242 | {
243 | kvp.Value.SaveTo(_tempDirectory);
244 | _zipfile.AddFile(Path.Combine(_tempDirectory, kvp.Value.FileName));
245 | }
246 | }
247 | }
248 |
249 |
250 | }
251 | }
252 |
--------------------------------------------------------------------------------
/Source/SamsungChanelEditor/UI/ListViewDragAndDrop.cs:
--------------------------------------------------------------------------------
1 | #region Copyright (C) 2011-2017 Ivan Masmitjà
2 |
3 | // Copyright (C) 2011-2017 Ivan Masmitjà
4 | //
5 | // SamsChannelEditor is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // SamsChannelEditor is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with SamsChannelEditor. If not, see .
17 |
18 | #endregion
19 |
20 | using System;
21 | using System.Drawing;
22 | using System.Runtime.InteropServices;
23 | using System.Windows.Forms;
24 |
25 | namespace SamsChannelEditor.UI
26 | {
27 | internal sealed class ListViewDragAndDrop : ListView
28 | {
29 | public class AfterDragAndDropEventArgs : EventArgs
30 | {
31 | public int MinIndex;
32 | public int MaxIndex;
33 |
34 | public AfterDragAndDropEventArgs(int minidx, int maxidx)
35 | {
36 | MinIndex = minidx;
37 | MaxIndex = maxidx;
38 | }
39 | }
40 |
41 | public class AfterDragAndDropItemEventArgs : EventArgs
42 | {
43 | public int OldItemIndex;
44 | public int NewItemIndex;
45 | public ListViewItem Item;
46 |
47 | public AfterDragAndDropItemEventArgs(ListViewItem item, int oldidx, int newidx)
48 | {
49 | OldItemIndex = oldidx;
50 | NewItemIndex = newidx;
51 | Item = item;
52 | }
53 | }
54 |
55 | public bool DragAndDropEnabled { get; set; }
56 |
57 | public delegate void AfterDragAndDropItemEventHandler(object sender, AfterDragAndDropItemEventArgs e);
58 |
59 | public delegate void AfterDragAndDropEventHandler(object sender, AfterDragAndDropEventArgs e);
60 |
61 | public event AfterDragAndDropItemEventHandler AfterDragAndDropItem;
62 | public event AfterDragAndDropEventHandler AfterDragAndDrop;
63 |
64 | public bool IsUpdating { get; private set; }
65 |
66 | private int _scrollDirection;
67 |
68 | private readonly Timer _tmrLvScroll;
69 |
70 | public ListViewDragAndDrop()
71 | {
72 | DragAndDropEnabled = true;
73 | IsUpdating = false;
74 | DoubleBuffered = true;
75 | OwnerDraw = true;
76 | DragOver += new DragEventHandler(ListViewDragAndDrop_DragOver);
77 | _tmrLvScroll = new Timer();
78 | _tmrLvScroll.Tick += new EventHandler(tmrLVScroll_Tick);
79 | }
80 |
81 | public new void BeginUpdate()
82 | {
83 | IsUpdating = true;
84 | base.BeginUpdate();
85 | }
86 |
87 | public new void EndUpdate()
88 | {
89 | IsUpdating = false;
90 | base.EndUpdate();
91 | }
92 |
93 | protected override void OnItemDrag(ItemDragEventArgs e)
94 | {
95 | base.OnItemDrag(e);
96 |
97 | if (DragAndDropEnabled)
98 | {
99 | IsUpdating = true;
100 | DoDragDrop(SelectedItems, DragDropEffects.Move);
101 | IsUpdating = false;
102 | }
103 | }
104 |
105 | protected override void OnDragEnter(DragEventArgs drgevent)
106 | {
107 | base.OnDragEnter(drgevent);
108 |
109 | if (DragAndDropEnabled)
110 | {
111 | int len = drgevent.Data.GetFormats().Length - 1;
112 | int i;
113 | for (i = 0; i <= len; i++)
114 | if (drgevent.Data.GetFormats()[i].Equals("System.Windows.Forms.ListView+SelectedListViewItemCollection"))
115 | drgevent.Effect = DragDropEffects.Move;
116 | }
117 | }
118 |
119 | protected override void OnDragDrop(DragEventArgs drgevent)
120 | {
121 | base.OnDragDrop(drgevent);
122 |
123 | if (!DragAndDropEnabled)
124 | return;
125 |
126 | if (SelectedItems.Count == 0)
127 | return;
128 |
129 | var cp = PointToClient(new Point(drgevent.X, drgevent.Y));
130 |
131 | var dragToItem = GetItemAt(cp.X, cp.Y);
132 | if (dragToItem == null)
133 | return;
134 |
135 | int dragIndex = dragToItem.Index;
136 |
137 | ListViewItem[] sel = new ListViewItem[SelectedItems.Count];
138 | for (var i = 0; i <= SelectedItems.Count - 1; i++)
139 | sel[i] = SelectedItems[i];
140 |
141 | int min = -1;
142 | int max = -1;
143 |
144 | for (var i = 0; i < sel.GetLength(0); i++)
145 | {
146 | ListViewItem dragItem = sel[i];
147 |
148 | dragItem.Selected = false;
149 | int itemIndex = dragIndex;
150 |
151 | if (itemIndex == dragItem.Index)
152 | return;
153 |
154 | if (dragItem.Index < itemIndex)
155 | itemIndex++;
156 | else
157 | itemIndex = dragIndex + i;
158 |
159 | var insertItem = (ListViewItem)dragItem.Clone();
160 | insertItem.Selected = true;
161 |
162 | int oldidx = dragItem.Index;
163 | int newidx = itemIndex;
164 |
165 | insertItem = Items.Insert(itemIndex, insertItem);
166 | Items.Remove(dragItem);
167 |
168 | if ((min == -1) || (Math.Min(oldidx, newidx) < min))
169 | min = Math.Min(oldidx, newidx);
170 |
171 | if ((max == -1) || (Math.Max(oldidx, newidx) > max))
172 | max = Math.Max(oldidx, newidx);
173 |
174 | if (AfterDragAndDropItem != null)
175 | AfterDragAndDropItem(this, new AfterDragAndDropItemEventArgs(insertItem, oldidx, newidx));
176 | }
177 |
178 | if (AfterDragAndDrop != null)
179 | AfterDragAndDrop(this, new AfterDragAndDropEventArgs(min, max));
180 | }
181 |
182 | private void ListViewDragAndDrop_DragOver(object sender, DragEventArgs e)
183 | {
184 | var position = new Point(e.X, e.Y);
185 | position = PointToClient(position);
186 |
187 | if (position.Y <= Font.Height / 2)
188 | {
189 | // getting close to top, ensure previous item is visible
190 | _scrollDirection = 0;
191 | _tmrLvScroll.Enabled = true;
192 | }
193 | else if (position.Y >= ClientSize.Height - Font.Height / 2)
194 | {
195 | // getting close to bottom, ensure next item is visible
196 | _scrollDirection = 1;
197 | _tmrLvScroll.Enabled = true;
198 | }
199 | else
200 | {
201 | _tmrLvScroll.Enabled = false;
202 | }
203 |
204 | e.Effect = DragDropEffects.Move;
205 |
206 | position.X = e.X;
207 | position.Y = e.Y;
208 | }
209 |
210 | protected override void OnDrawItem(DrawListViewItemEventArgs e)
211 | {
212 | e.DrawDefault = true;
213 | e.Item.BackColor = e.Item.Index % 2 == 0 ? Color.White : Color.FromArgb(240, 240, 240);
214 | base.OnDrawItem(e);
215 | }
216 |
217 | protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
218 | {
219 | e.DrawDefault = true;
220 | base.OnDrawColumnHeader(e);
221 | }
222 |
223 | protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
224 | {
225 | e.SubItem.BackColor = e.Item.Index % 2 == 0 ? Color.White : Color.FromArgb(240, 240, 240);
226 | e.DrawDefault = true;
227 | base.OnDrawSubItem(e);
228 | }
229 |
230 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
231 | private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
232 |
233 |
234 | private void tmrLVScroll_Tick(object sender, EventArgs e)
235 | {
236 | ScrollControl(this, ref _scrollDirection);
237 | }
238 |
239 | private static void ScrollControl(Control objControl, ref int intDirection)
240 | {
241 | // This function enables a control (e.g. TreeView or ListView) to scroll
242 | // during a drag-and-drop operation.
243 | // For lngDirection, a value of 0 scrolls up; a value of 1 scrolls down.
244 |
245 | const UInt32 WM_SCROLL = 0x0115;
246 | SendMessage(objControl.Handle, WM_SCROLL, new IntPtr(intDirection), IntPtr.Zero);
247 | }
248 | }
249 | }
250 |
251 |
252 |
--------------------------------------------------------------------------------