1 /* 2 * "GEDKeeper", the personal genealogical database editor. 3 * Copyright (C) 2009-2021 by Sergey V. Zhdanovskih. 4 * 5 * This file is part of "GEDKeeper". 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 using System; 22 using BSLib; 23 using BSLib.Design; 24 using BSLib.Design.Graphics; 25 using GKCore.Charts; 26 using GKCore.Interfaces; 27 28 using BSDColors = BSLib.Design.BSDConsts.Colors; 29 30 namespace GKCore.Options 31 { 32 public enum DeepMode 33 { 34 None, Background, Foreground 35 } 36 37 /// <summary> 38 /// 39 /// </summary> 40 public sealed class TreeChartOptions : BaseObject, IOptions 41 { 42 public static readonly int MALE_COLOR = -3750145; // FFC6C6FF 43 public static readonly int FEMALE_COLOR = -14650; // FFFFC6C6 44 public static readonly int UNK_SEX_COLOR = -14593; // FFFFC6FF 45 public static readonly int UN_HUSBAND_COLOR = -2631681; // FFD7D7FF 46 public static readonly int UN_WIFE_COLOR = -10281; // FFFFD7D7 47 48 public bool ChildlessExclude; 49 public bool Decorative; 50 public bool FamilyVisible; 51 public bool NameVisible; 52 public bool PatronymicVisible; 53 public bool NickVisible; 54 public bool DiffLines; 55 public bool BirthDateVisible; 56 public bool DeathDateVisible; 57 public bool OnlyYears; 58 public bool Kinship; 59 public bool PortraitsVisible; 60 public bool DefaultPortraits; 61 public bool SignsVisible; 62 public bool CertaintyIndexVisible; 63 public bool TraceSelected; 64 public bool InvertedTree; 65 public bool MarriagesDates; 66 public bool ShowPlaces; 67 public bool HideUnknownSpouses; 68 public bool DottedLinesOfAdoptedChildren; 69 public bool SeparateDatesAndPlacesLines; 70 public bool BoldNames; 71 72 public bool AutoAlign; // debug option, for future purposes 73 public GfxBorderStyle BorderStyle; 74 public DeepMode DeepMode; 75 76 public IColor MaleColor; 77 public IColor FemaleColor; 78 public IColor UnkSexColor; 79 public IColor UnHusbandColor; 80 public IColor UnWifeColor; 81 82 public string DefFontName; 83 public int DefFontSize; 84 public IColor DefFontColor; 85 public BSDTypes.FontStyle DefFontStyle; 86 87 public int BranchDistance; 88 public int LevelDistance; 89 public int Margins; 90 public int SpouseDistance; 91 92 public bool SeparateDepth { get; set; } 93 public int DepthLimit { get; set; } 94 public int DepthLimitAncestors { get; set; } 95 public int DepthLimitDescendants { get; set; } 96 TreeChartOptions()97 public TreeChartOptions() 98 { 99 FamilyVisible = true; 100 NameVisible = true; 101 PatronymicVisible = true; 102 NickVisible = true; 103 DiffLines = true; 104 105 BirthDateVisible = true; 106 DeathDateVisible = true; 107 OnlyYears = true; 108 109 Kinship = false; 110 PortraitsVisible = true; 111 DefaultPortraits = false; 112 SignsVisible = false; 113 CertaintyIndexVisible = false; 114 TraceSelected = true; 115 ChildlessExclude = false; 116 Decorative = true; 117 InvertedTree = false; 118 MarriagesDates = false; 119 ShowPlaces = false; 120 HideUnknownSpouses = false; 121 DottedLinesOfAdoptedChildren = false; 122 SeparateDatesAndPlacesLines = false; 123 BoldNames = false; 124 SeparateDepth = false; 125 126 AutoAlign = true; 127 BorderStyle = GfxBorderStyle.None; 128 DeepMode = DeepMode.None; 129 130 MaleColor = ChartRenderer.GetColor(MALE_COLOR); 131 FemaleColor = ChartRenderer.GetColor(FEMALE_COLOR); 132 UnkSexColor = ChartRenderer.GetColor(UNK_SEX_COLOR); 133 UnHusbandColor = ChartRenderer.GetColor(UN_HUSBAND_COLOR); 134 UnWifeColor = ChartRenderer.GetColor(UN_WIFE_COLOR); 135 136 DefFontName = AppHost.GfxProvider.GetDefaultFontName(); 137 DefFontSize = 8; 138 DefFontColor = ChartRenderer.GetColor(BSDColors.Black); 139 DefFontStyle = BSDTypes.FontStyle.None; 140 141 BranchDistance = TreeChartModel.DEF_BRANCH_DISTANCE; 142 LevelDistance = TreeChartModel.DEF_LEVEL_DISTANCE; 143 Margins = TreeChartModel.DEF_MARGINS; 144 SpouseDistance = TreeChartModel.DEF_SPOUSE_DISTANCE; 145 } 146 Assign(IOptions source)147 public void Assign(IOptions source) 148 { 149 TreeChartOptions srcOptions = source as TreeChartOptions; 150 if (srcOptions == null) return; 151 152 FamilyVisible = srcOptions.FamilyVisible; 153 NameVisible = srcOptions.NameVisible; 154 PatronymicVisible = srcOptions.PatronymicVisible; 155 NickVisible = srcOptions.NickVisible; 156 DiffLines = srcOptions.DiffLines; 157 BirthDateVisible = srcOptions.BirthDateVisible; 158 DeathDateVisible = srcOptions.DeathDateVisible; 159 OnlyYears = srcOptions.OnlyYears; 160 Kinship = srcOptions.Kinship; 161 PortraitsVisible = srcOptions.PortraitsVisible; 162 DefaultPortraits = srcOptions.DefaultPortraits; 163 SignsVisible = srcOptions.SignsVisible; 164 CertaintyIndexVisible = srcOptions.CertaintyIndexVisible; 165 TraceSelected = srcOptions.TraceSelected; 166 ChildlessExclude = srcOptions.ChildlessExclude; 167 Decorative = srcOptions.Decorative; 168 MaleColor = srcOptions.MaleColor; 169 FemaleColor = srcOptions.FemaleColor; 170 UnkSexColor = srcOptions.UnkSexColor; 171 UnHusbandColor = srcOptions.UnHusbandColor; 172 UnWifeColor = srcOptions.UnWifeColor; 173 DefFontName = srcOptions.DefFontName; 174 DefFontSize = srcOptions.DefFontSize; 175 DefFontColor = srcOptions.DefFontColor; 176 DefFontStyle = srcOptions.DefFontStyle; 177 InvertedTree = srcOptions.InvertedTree; 178 MarriagesDates = srcOptions.MarriagesDates; 179 ShowPlaces = srcOptions.ShowPlaces; 180 HideUnknownSpouses = srcOptions.HideUnknownSpouses; 181 DottedLinesOfAdoptedChildren = srcOptions.DottedLinesOfAdoptedChildren; 182 SeparateDatesAndPlacesLines = srcOptions.SeparateDatesAndPlacesLines; 183 BoldNames = srcOptions.BoldNames; 184 SeparateDepth = srcOptions.SeparateDepth; 185 BorderStyle = srcOptions.BorderStyle; 186 187 BranchDistance = srcOptions.BranchDistance; 188 LevelDistance = srcOptions.LevelDistance; 189 Margins = srcOptions.Margins; 190 SpouseDistance = srcOptions.SpouseDistance; 191 } 192 LoadFromFile(IniFile iniFile)193 public void LoadFromFile(IniFile iniFile) 194 { 195 if (iniFile == null) 196 throw new ArgumentNullException("iniFile"); 197 198 FamilyVisible = iniFile.ReadBool("Chart", "FamilyVisible", true); 199 NameVisible = iniFile.ReadBool("Chart", "NameVisible", true); 200 PatronymicVisible = iniFile.ReadBool("Chart", "PatronymicVisible", true); 201 NickVisible = iniFile.ReadBool("Chart", "NickVisible", true); 202 DiffLines = iniFile.ReadBool("Chart", "DiffLines", true); 203 204 BirthDateVisible = iniFile.ReadBool("Chart", "BirthDateVisible", true); 205 DeathDateVisible = iniFile.ReadBool("Chart", "DeathDateVisible", true); 206 OnlyYears = iniFile.ReadBool("Chart", "OnlyYears", true); 207 208 Kinship = iniFile.ReadBool("Chart", "Kinship", false); 209 SignsVisible = iniFile.ReadBool("Chart", "SignsVisible", false); 210 PortraitsVisible = iniFile.ReadBool("Chart", "PortraitsVisible", true); 211 DefaultPortraits = iniFile.ReadBool("Chart", "DefaultPortraits", false); 212 CertaintyIndexVisible = iniFile.ReadBool("Chart", "CertaintyIndexVisible", false); 213 TraceSelected = iniFile.ReadBool("Chart", "TraceSelected", true); 214 ChildlessExclude = iniFile.ReadBool("Chart", "ChildlessExclude", false); 215 Decorative = iniFile.ReadBool("Chart", "Decorative", true); 216 //DeepMode = (DeepMode)iniFile.ReadInteger("Chart", "DeepMode", 0); 217 InvertedTree = iniFile.ReadBool("Chart", "InvertedTree", false); 218 MarriagesDates = iniFile.ReadBool("Chart", "MarriagesDates", false); 219 ShowPlaces = iniFile.ReadBool("Chart", "ShowPlaces", false); 220 HideUnknownSpouses = iniFile.ReadBool("Chart", "HideUnknownSpouses", false); 221 DottedLinesOfAdoptedChildren = iniFile.ReadBool("Chart", "DottedLinesOfAdoptedChildren", false); 222 SeparateDatesAndPlacesLines = iniFile.ReadBool("Chart", "SeparateDatesAndPlacesLines", false); 223 BoldNames = iniFile.ReadBool("Chart", "BoldNames", false); 224 BorderStyle = (GfxBorderStyle)iniFile.ReadInteger("Chart", "BorderStyle", 0); 225 226 MaleColor = ChartRenderer.GetColor(iniFile.ReadInteger("Chart", "MaleColor", MALE_COLOR)); 227 FemaleColor = ChartRenderer.GetColor(iniFile.ReadInteger("Chart", "FemaleColor", FEMALE_COLOR)); 228 UnkSexColor = ChartRenderer.GetColor(iniFile.ReadInteger("Chart", "UnkSexColor", UNK_SEX_COLOR)); 229 UnHusbandColor = ChartRenderer.GetColor(iniFile.ReadInteger("Chart", "UnHusbandColor", UN_HUSBAND_COLOR)); 230 UnWifeColor = ChartRenderer.GetColor(iniFile.ReadInteger("Chart", "UnWifeColor", UN_WIFE_COLOR)); 231 232 DefFontName = iniFile.ReadString("Chart", "FontName", AppHost.GfxProvider.GetDefaultFontName()); 233 DefFontSize = iniFile.ReadInteger("Chart", "FontSize", 8); 234 DefFontColor = ChartRenderer.GetColor(iniFile.ReadInteger("Chart", "FontColor", BSDColors.Black)); 235 DefFontStyle = (BSDTypes.FontStyle)iniFile.ReadInteger("Chart", "FontStyle", 0); 236 237 BranchDistance = iniFile.ReadInteger("Chart", "BranchDistance", TreeChartModel.DEF_BRANCH_DISTANCE); 238 LevelDistance = iniFile.ReadInteger("Chart", "LevelDistance", TreeChartModel.DEF_LEVEL_DISTANCE); 239 Margins = iniFile.ReadInteger("Chart", "Margins", TreeChartModel.DEF_MARGINS); 240 SpouseDistance = iniFile.ReadInteger("Chart", "SpouseDistance", TreeChartModel.DEF_SPOUSE_DISTANCE); 241 242 SeparateDepth = iniFile.ReadBool("Chart", "SeparateDepth", false); 243 DepthLimit = iniFile.ReadInteger("Chart", "DepthLimit", -1); 244 DepthLimitAncestors = iniFile.ReadInteger("Chart", "DepthLimitAncestors", -1); 245 DepthLimitDescendants = iniFile.ReadInteger("Chart", "DepthLimitDescendants", -1); 246 } 247 SaveToFile(IniFile iniFile)248 public void SaveToFile(IniFile iniFile) 249 { 250 if (iniFile == null) 251 throw new ArgumentNullException("iniFile"); 252 253 iniFile.WriteBool("Chart", "FamilyVisible", FamilyVisible); 254 iniFile.WriteBool("Chart", "NameVisible", NameVisible); 255 iniFile.WriteBool("Chart", "PatronymicVisible", PatronymicVisible); 256 iniFile.WriteBool("Chart", "NickVisible", NickVisible); 257 iniFile.WriteBool("Chart", "DiffLines", DiffLines); 258 259 iniFile.WriteBool("Chart", "BirthDateVisible", BirthDateVisible); 260 iniFile.WriteBool("Chart", "DeathDateVisible", DeathDateVisible); 261 iniFile.WriteBool("Chart", "OnlyYears", OnlyYears); 262 263 iniFile.WriteBool("Chart", "Kinship", Kinship); 264 iniFile.WriteBool("Chart", "SignsVisible", SignsVisible); 265 iniFile.WriteBool("Chart", "PortraitsVisible", PortraitsVisible); 266 iniFile.WriteBool("Chart", "DefaultPortraits", DefaultPortraits); 267 iniFile.WriteBool("Chart", "CertaintyIndexVisible", CertaintyIndexVisible); 268 iniFile.WriteBool("Chart", "TraceSelected", TraceSelected); 269 iniFile.WriteBool("Chart", "ChildlessExclude", ChildlessExclude); 270 iniFile.WriteBool("Chart", "Decorative", Decorative); 271 //iniFile.WriteInteger("Chart", "DeepMode", (int)DeepMode); 272 iniFile.WriteBool("Chart", "InvertedTree", InvertedTree); 273 iniFile.WriteBool("Chart", "MarriagesDates", MarriagesDates); 274 iniFile.WriteBool("Chart", "ShowPlaces", ShowPlaces); 275 iniFile.WriteBool("Chart", "HideUnknownSpouses", HideUnknownSpouses); 276 iniFile.WriteBool("Chart", "DottedLinesOfAdoptedChildren", DottedLinesOfAdoptedChildren); 277 iniFile.WriteBool("Chart", "SeparateDatesAndPlacesLines", SeparateDatesAndPlacesLines); 278 iniFile.WriteBool("Chart", "BoldNames", BoldNames); 279 iniFile.WriteInteger("Chart", "BorderStyle", (int)BorderStyle); 280 281 iniFile.WriteInteger("Chart", "MaleColor", MaleColor.ToArgb()); 282 iniFile.WriteInteger("Chart", "FemaleColor", FemaleColor.ToArgb()); 283 iniFile.WriteInteger("Chart", "UnkSexColor", UnkSexColor.ToArgb()); 284 iniFile.WriteInteger("Chart", "UnHusbandColor", UnHusbandColor.ToArgb()); 285 iniFile.WriteInteger("Chart", "UnWifeColor", UnWifeColor.ToArgb()); 286 287 iniFile.WriteString("Chart", "FontName", DefFontName); 288 iniFile.WriteInteger("Chart", "FontSize", DefFontSize); 289 iniFile.WriteInteger("Chart", "FontColor", DefFontColor.ToArgb()); 290 iniFile.WriteInteger("Chart", "FontStyle", (byte)DefFontStyle); 291 292 iniFile.WriteInteger("Chart", "BranchDistance", BranchDistance); 293 iniFile.WriteInteger("Chart", "LevelDistance", LevelDistance); 294 iniFile.WriteInteger("Chart", "Margins", Margins); 295 iniFile.WriteInteger("Chart", "SpouseDistance", SpouseDistance); 296 297 iniFile.WriteBool("Chart", "SeparateDepth", SeparateDepth); 298 iniFile.WriteInteger("Chart", "DepthLimit", DepthLimit); 299 iniFile.WriteInteger("Chart", "DepthLimitAncestors", DepthLimitAncestors); 300 iniFile.WriteInteger("Chart", "DepthLimitDescendants", DepthLimitDescendants); 301 } 302 } 303 } 304