1 /* 2 * Copyright 2009 Alexander Curtis <alex@logicmill.com> 3 * This file is part of GEDmill - A family history website creator 4 * 5 * GEDmill 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 * GEDmill 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 GEDmill. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 using System; 20 using System.Collections.Generic; 21 using System.Drawing; 22 using System.Globalization; 23 using BSLib; 24 using GKCore; 25 using GKCL = GKCore.Logging; 26 27 namespace GEDmill 28 { 29 /// <summary> 30 /// Class that contains all the user configurable settings, and serialises them into IsolatedStorage at program start and exit. 31 /// Note not all settings here are presented through the UI, but most are. Originally there was a distinction her but it has become blurred. 32 /// </summary> 33 public class GMConfig 34 { 35 public const string LOG_FILE = "GEDmill.log"; 36 public const string LOG_LEVEL = "WARN"; 37 38 // The current version of this app, for display purposes. 39 public static string SoftwareVersion = "1.11.0"; 40 41 // The name of the app for display purposes 42 public static string SoftwareName = "GEDmill " + SoftwareVersion; 43 44 // Filename for the online help (as in "on the same system", as opposed to offline e.g. printed manual) 45 public static string HelpFilename = "GEDmill Help.chm"; 46 47 private static readonly GKCL.ILogger fLogger = GKCL.LogManager.GetLogger(GMConfig.LOG_FILE, GMConfig.LOG_LEVEL, typeof(GMConfig).Name); 48 49 // Filename used to store users config 50 public const string ConfigFilename = "GEDmillPlugin.ini"; 51 52 // Name to use where no other name is available 53 public string UnknownName; 54 55 // How to capitalise individuals' names 56 public int NameCapitalisation; 57 58 // File extension for html files 59 public string HtmlExtension; 60 61 // Absolute sFilename of image to use as background 62 public string BackgroundImage; 63 64 // Maximum allowed width of individual image 65 public int MaxImageWidth; 66 67 // Maximum allowed height of individual image 68 public int MaxImageHeight; 69 70 // Age at which defining occupation is chosen 71 public int AgeForOccupation; 72 73 // Maximum allowed width of source image 74 public int MaxSourceImageWidth; 75 76 // Maximum allowed height of source image 77 public int MaxSourceImageHeight; 78 79 // Maximum allowed width of thumbnail image 80 public int MaxThumbnailImageWidth; 81 82 // Maximum allowed height of thumbnail image 83 public int MaxThumbnailImageHeight; 84 85 // Filename of image if any to use on front webpage. 86 public string FrontPageImageFilename; 87 88 // Filename of front webpage. 89 public string FrontPageFilename; 90 91 // Number of spaces between each tab stop, when converting \t characters to html. 92 public int TabSpaces; 93 94 // True if event descriptions to start with capital letter, e.g. "Born" as opposed to "born". 95 public bool CapitaliseEventDescriptions; 96 97 // True if to include text about website statistics on front page. 98 public bool ShowFrontPageStats; 99 100 // Extra text to include on title page. 101 public string CommentaryText; 102 103 // Name of font to render tree diagrams with 104 public string TreeFontName; 105 106 // Size of font to render tree diagrams with 107 public float TreeFontSize; 108 109 // Width to try not to exceed when creating mini tree diagrams 110 public int TargetTreeWidth; 111 112 // True if mini tree diagrams are to be added to pages 113 public bool ShowMiniTrees; 114 115 // User's email address to include on webpages 116 public string UserEmailAddress; 117 118 // Allow multiple multimedia files per individual. Enables m_nMaxNumberMultimediaFiles. 119 public bool AllowMultipleImages; 120 121 // If true will not overwrite existing front page file. 122 public bool PreserveFrontPage; 123 124 // If true will not overwrite existing style sheet css file. 125 public bool PreserveStylesheet; 126 127 // Whether to create autorun.inf and autoplay.exe files 128 public bool CreateCDROMFiles; 129 130 // Whether to include files that aren't pictures as multimedia objects 131 public bool AllowNonPictures; 132 133 // Link to users main website, put at top of each indi page. 134 public string MainWebsiteLink; 135 136 // Name to use for stylesheet css file. 137 public string StylesheetFilename; 138 139 // Name to user for individuals who appear but have their information withheld 140 public string ConcealedName; 141 142 // Word used to prefix locations, e.g. "at" or "in". 143 public string PlaceWord; 144 145 // String to use (in index) for names with no surname 146 public string NoSurname; 147 148 // True if all sources mentioned by a restricted individual should also be restricted (i.e. omitted from website) 149 public bool RestrictAssociatedSources; 150 151 // True if all multimedia files are to be renamed to a standard naming system. Now generally superceded by m_renameOriginalPicture 152 public bool RenameMultimedia; 153 154 // True to generate a separate html page for each letter of names index. Useful if index would otherwise be massive. 155 public bool IndexLetterPerPage; 156 157 // HTML string representing colour to draw connecting lines in mini trees 158 public Color MiniTreeColourBranch; 159 160 // HTML string representing colour to draw outline of individual boxes in mini trees 161 public Color MiniTreeColourIndiBorder; 162 163 // HTML string representing colour to fill normal individual boxes in mini trees 164 public Color MiniTreeColourIndiBackground; 165 166 // HTML string representing colour to fill selected individual boxes in mini trees 167 public Color MiniTreeColourIndiHighlight; 168 169 // HTML string representing colour to fill boxes for individuals marked as concealed in mini trees. 170 public Color MiniTreeColourIndiBgConcealed; 171 172 // HTML string representing colour to write text for individuals marked as concealed in mini trees. 173 public Color MiniTreeColourIndiFgConcealed; 174 175 // HTML string representing colour to fill shaded individual boxes in mini trees 176 public Color MiniTreeColourIndiShade; 177 178 // HTML string representing colour to draw text in individual boxes in mini trees 179 public Color MiniTreeColourIndiText; 180 181 // HTML string representing colour to draw linkable text in individual boxes in mini trees 182 public Color MiniTreeColourIndiLink; 183 184 // HTML string representing colour to fill entire background of mini tree diagrams 185 public Color MiniTreeColourBackground; 186 187 // Whether to restrict records with RESN set to confidential 188 public bool RestrictConfidential; 189 190 // Whether to restrict records with RESN set to privacy 191 public bool RestrictPrivacy; 192 193 // If true, multimedia files are copied into m_imageFolder. 194 public bool CopyMultimedia; 195 196 // Which folder to copy multimedia into. Ends up as subdirectory to m_outputFolder; 197 public string ImageFolder; 198 199 // If true, links to multimedia are altered to be relative to output folder (e.g. ..\..\files\file.zzz). If false, they are left as absolute (e.g. D:\files\file.zzz) 200 public bool RelativiseMultimedia; 201 202 // Maximum number of multimedia files per individual page 203 public int MaxNumberMultimediaFiles; 204 205 // Title to use for index page 206 public string IndexTitle; 207 208 // Folder in which to dump all the html output 209 public string OutputFolder; 210 211 // Which version number of the software this config file is for 212 public string Version; 213 214 // Name of owner used in titles, descriptions of pages. 215 public string OwnersName; 216 217 // Xref of root individual in tree, for link on front page. 218 public string FirstRecordXRef; 219 220 // Title to put on front page of website 221 public string SiteTitle; 222 223 // Filename of gedcom file to parse 224 public string InputFilename; 225 226 // Path to folder containing this application. 227 public string ApplicationPath; 228 229 // Path to application's data 230 public string AppDataPath; 231 232 // String indicating image format to use to store mini tree file 233 public string MiniTreeImageFormat; 234 235 // If true, the background image will be used to fill in the background of mini trees, giving the effect that they are transparent. 236 public bool FakeMiniTreeTransparency; 237 238 // List of Xrefs for individuals to be mentioned on front page. 239 public List<string> KeyIndividuals; 240 241 // Set true if indexes are allowed to span multiple html files 242 public bool MultiPageIndexes; 243 244 // Number of individuals to aim to list per index page. 245 public int IndividualsPerIndexPage; 246 247 // If true, website pages are opened in web browser once app exits with Finish button. 248 public bool OpenWebsiteOnExit; 249 250 // If true, instead of pretending restricted individuals don't exist, they are shown as black boxes. 251 public bool OnlyConceal; 252 253 // If true, clicking the picture will link to the original large picture. 254 public bool LinkOriginalPicture; 255 256 // If true, the original picture will be renamed as it is copied. Now takes on role of m_renameMultimedia. 257 public bool RenameOriginalPicture; 258 259 // Directory in which list of excluded individuals is stored 260 public string ExcludeFileDir; 261 262 // Name of file in which list of excluded individuals is stored 263 public string ExcludeFileName; 264 265 // If true, email addresses won't appear in web pages in harvestable form. 266 public bool ObfuscateEmails; 267 268 // If true, "Last updated <date>" appears on home page. 269 public bool AddHomePageCreateTime; 270 271 // If true, pages get "Valid XHTML" validator link at bottom. 272 public bool IncludeValiditySticker; 273 274 // If true, nickName else otherName appears in brackets in individual's index entry. 275 public bool IncludeNickNamesInIndex; 276 277 // Optional text user can have displayed in each page footer. 278 public string CustomFooter; 279 280 // If true, the user's custom individual reference number will appear in the index. 281 public bool IncludeUserRefInIndex; 282 283 // If true, include the individuals (most appropriate, best) occupation in page header. 284 public bool OccupationHeadline; 285 286 // True indicates that text in Commentary box (settings pane) should not be escaped. (i.e. HTML is preserved) 287 public bool CommentaryIsHtml; 288 289 // True indicates that text in Footer box (settings pane) should not be escaped. (i.e. HTML is preserved) 290 public bool FooterIsHtml; 291 292 // True means when naming html files, to use user record number if present for sFilename. 293 public bool UserRecFilename; 294 295 // If false, doesn't include the navigation bar at the top of each page. 296 public bool IncludeNavbar; 297 298 // If true, withheld records will use the indivdual's name in minitrees, rather than m_concealedName. 299 public bool UseWithheldNames; 300 301 // If true, first names are put on a different line to surnames in minitree individual boxes. 302 public bool ConserveTreeWidth; 303 304 // If true, the mini tree has siblings of the selected individuals ordered as they are in the GEDCOM. False means sort them by date. Significant when some siblings have no recorded birth date 305 public bool KeepSiblingOrder; 306 307 // If false, no multimedia pics, images, files etc. will appear in HTML. 308 public bool AllowMultimedia; 309 310 // If true, the list of "Citations" on source records will not be generated. 311 public bool SupressBackreferences; 312 313 314 private static GMConfig fInstance; 315 316 public static GMConfig Instance 317 { 318 get { 319 if (fInstance == null) { 320 fInstance = new GMConfig(); 321 } 322 return fInstance; 323 } 324 } 325 326 327 // Constructor, sets default values for the config GMConfig()328 private GMConfig() 329 { 330 ApplicationPath = GMHelper.GetAppPath(); 331 AppDataPath = AppHost.GetAppDataPathStatic(); 332 BackgroundImage = ApplicationPath + "\\bg-gedmill.jpg"; 333 FrontPageImageFilename = ApplicationPath + "\\gedmill.jpg"; 334 335 RestrictConfidential = false; 336 RestrictPrivacy = false; 337 OutputFolder = ""; 338 UnknownName = "<unknown>"; // "no name" implied we knew them and they had no name. 339 NameCapitalisation = 1; 340 Version = "1.11.0"; 341 HtmlExtension = "html"; 342 CopyMultimedia = true; 343 ImageFolder = "multimedia"; 344 RelativiseMultimedia = false; 345 MaxImageWidth = 160; 346 MaxImageHeight = 160; 347 MaxNumberMultimediaFiles = 32; 348 AgeForOccupation = 50; 349 NoSurname = "No Surname"; 350 IndexTitle = "Index Of Names"; 351 MaxSourceImageWidth = 800; 352 MaxSourceImageHeight = 800; 353 MaxThumbnailImageWidth = 45; 354 MaxThumbnailImageHeight = 45; 355 FirstRecordXRef = ""; 356 InputFilename = ""; 357 TabSpaces = 8; 358 PlaceWord = "in"; 359 CapitaliseEventDescriptions = true; 360 RestrictAssociatedSources = true; 361 RenameMultimedia = true; 362 IndexLetterPerPage = false; 363 ShowFrontPageStats = true; 364 CommentaryText = ""; 365 366 OwnersName = Environment.UserName; 367 368 SiteTitle = "Family history"; 369 if (!string.IsNullOrEmpty(OwnersName)) 370 SiteTitle += " of " + OwnersName; 371 372 // Reset those settings that can be modified by the user on the config screen. 373 Reset(); 374 } 375 376 // Construct the HTTP URL for the created site's landing page 377 public string FrontPageURL 378 { 379 get { 380 return string.Concat(OutputFolder, "\\", FrontPageFilename, ".", HtmlExtension); 381 } 382 } 383 384 // Construct the HTTP URL for the created site's help page 385 public string HelpPageURL 386 { 387 get { 388 return string.Concat(OutputFolder, "\\", "help.", HtmlExtension); 389 } 390 } 391 392 // Serialise all the config settings Save()393 public void Save() 394 { 395 try { 396 using (var ini = new IniFile(AppDataPath + ConfigFilename)) { 397 ini.WriteString("Common", "Version", Version); 398 ini.WriteBool("Common", "RestrictConfidential", RestrictConfidential); 399 ini.WriteBool("Common", "RestrictPrivacy", RestrictPrivacy); 400 ini.WriteString("Common", "OutputFolder", OutputFolder); 401 ini.WriteString("Common", "UnknownName", UnknownName); 402 ini.WriteInteger("Common", "NameCapitalisation", NameCapitalisation); 403 ini.WriteString("Common", "HtmlExtension", HtmlExtension); 404 ini.WriteBool("Common", "CopyMultimedia", CopyMultimedia); 405 ini.WriteString("Common", "ImageFolder", ImageFolder); 406 ini.WriteBool("Common", "RelativiseMultimedia", RelativiseMultimedia); 407 ini.WriteString("Common", "BackgroundImage", BackgroundImage); 408 ini.WriteInteger("Common", "MaxImageWidth", MaxImageWidth); 409 ini.WriteInteger("Common", "MaxImageHeight", MaxImageHeight); 410 ini.WriteInteger("Common", "MaxNumberMultimediaFiles", MaxNumberMultimediaFiles); 411 ini.WriteInteger("Common", "AgeForOccupation", AgeForOccupation); 412 ini.WriteString("Common", "OwnersName", OwnersName); 413 ini.WriteString("Common", "NoSurname", NoSurname); 414 ini.WriteString("Common", "IndexTitle", IndexTitle); 415 ini.WriteInteger("Common", "MaxSourceImageWidth", MaxSourceImageWidth); 416 ini.WriteInteger("Common", "MaxSourceImageHeight", MaxSourceImageHeight); 417 ini.WriteString("Common", "FirstRecordXRef", FirstRecordXRef); 418 ini.WriteString("Common", "SiteTitle", SiteTitle); 419 ini.WriteString("Common", "InputFilename", InputFilename); 420 ini.WriteString("Common", "ApplicationPath", ApplicationPath); 421 ini.WriteString("Common", "FrontPageImageFilename", FrontPageImageFilename); 422 ini.WriteInteger("Common", "TabSpaces", TabSpaces); 423 ini.WriteString("Common", "PlaceWord", PlaceWord); 424 ini.WriteBool("Common", "CapitaliseEventDescriptions", CapitaliseEventDescriptions); 425 ini.WriteBool("Common", "RestrictAssociatedSources", RestrictAssociatedSources); 426 ini.WriteBool("Common", "RenameMultimedia", RenameMultimedia); 427 ini.WriteBool("Common", "IndexLetterPerPage", IndexLetterPerPage); 428 ini.WriteString("Common", "MiniTreeColourBranch", ConvertColour(MiniTreeColourBranch)); 429 ini.WriteString("Common", "MiniTreeColourIndiBorder", ConvertColour(MiniTreeColourIndiBorder)); 430 ini.WriteString("Common", "MiniTreeColourIndiBackground", ConvertColour(MiniTreeColourIndiBackground)); 431 ini.WriteString("Common", "MiniTreeColourIndiHighlight", ConvertColour(MiniTreeColourIndiHighlight)); 432 ini.WriteString("Common", "MiniTreeColourIndiShade", ConvertColour(MiniTreeColourIndiShade)); 433 ini.WriteBool("Common", "ShowFrontPageStats", ShowFrontPageStats); 434 ini.WriteString("Common", "CommentaryText", CommentaryText); 435 ini.WriteString("Common", "TreeFontName", TreeFontName); 436 ini.WriteFloat("Common", "TreeFontSize", TreeFontSize); 437 ini.WriteInteger("Common", "TargetTreeWidth", TargetTreeWidth); 438 ini.WriteString("Common", "MiniTreeImageFormat", MiniTreeImageFormat); 439 ini.WriteString("Common", "MiniTreeColourIndiText", ConvertColour(MiniTreeColourIndiText)); 440 ini.WriteString("Common", "MiniTreeColourIndiLink", ConvertColour(MiniTreeColourIndiLink)); 441 ini.WriteString("Common", "MiniTreeColourBackground", ConvertColour(MiniTreeColourBackground)); 442 ini.WriteBool("Common", "ShowMiniTrees", ShowMiniTrees); 443 ini.WriteString("Common", "UserEmailAddress", UserEmailAddress); 444 ini.WriteBool("Common", "FakeMiniTreeTransparency", FakeMiniTreeTransparency); 445 446 if (KeyIndividuals != null) { 447 int keyIndividualsCount = KeyIndividuals.Count; 448 ini.WriteInteger("Individuals", "Count", keyIndividualsCount); 449 for (int i = 0; i < keyIndividualsCount; i++) { 450 string keyXref = KeyIndividuals[i]; 451 ini.WriteString("Individuals", "I_" + i, keyXref); 452 } 453 } 454 455 ini.WriteBool("Common", "MultiPageIndexes", MultiPageIndexes); 456 ini.WriteInteger("Common", "IndividualsPerIndexPage", IndividualsPerIndexPage); 457 ini.WriteBool("Common", "OpenWebsiteOnExit", OpenWebsiteOnExit); 458 ini.WriteString("Common", "FrontPageFilename", FrontPageFilename); 459 ini.WriteBool("Common", "CreateCDROMFiles", CreateCDROMFiles); 460 ini.WriteBool("Common", "AllowMultipleImages", AllowMultipleImages); 461 ini.WriteBool("Common", "AllowNonPictures", AllowNonPictures); 462 ini.WriteInteger("Common", "MaxThumbnailImageWidth", MaxThumbnailImageWidth); 463 ini.WriteInteger("Common", "MaxThumbnailImageHeight", MaxThumbnailImageHeight); 464 ini.WriteString("Common", "MainWebsiteLink", MainWebsiteLink); 465 ini.WriteBool("Common", "PreserveFrontPage", PreserveFrontPage); 466 ini.WriteBool("Common", "PreserveStylesheet", PreserveStylesheet); 467 ini.WriteString("Common", "StylesheetFilename", StylesheetFilename); 468 ini.WriteString("Common", "MiniTreeColourIndiBgConcealed", ConvertColour(MiniTreeColourIndiBgConcealed)); 469 ini.WriteBool("Common", "OnlyConceal", OnlyConceal); 470 ini.WriteString("Common", "ConcealedName", ConcealedName); 471 ini.WriteString("Common", "MiniTreeColourIndiFgConcealed", ConvertColour(MiniTreeColourIndiFgConcealed)); 472 ini.WriteBool("Common", "LinkOriginalPicture", LinkOriginalPicture); 473 ini.WriteBool("Common", "RenameOriginalPicture", RenameOriginalPicture); 474 ini.WriteString("Common", "ExcludeFileDir", ExcludeFileDir); 475 ini.WriteString("Common", "ExcludeFileName", ExcludeFileName); 476 ini.WriteBool("Common", "ObfuscateEmails", ObfuscateEmails); 477 ini.WriteBool("Common", "AddHomePageCreateTime", AddHomePageCreateTime); 478 ini.WriteBool("Common", "IncludeValiditySticker", IncludeValiditySticker); 479 ini.WriteBool("Common", "IncludeNickNamesInIndex", IncludeNickNamesInIndex); 480 ini.WriteString("Common", "CustomFooter", CustomFooter); 481 ini.WriteBool("Common", "IncludeUserRefInIndex", IncludeUserRefInIndex); 482 ini.WriteBool("Common", "OccupationHeadline", OccupationHeadline); 483 ini.WriteBool("Common", "CommentaryIsHtml", CommentaryIsHtml); 484 ini.WriteBool("Common", "FooterIsHtml", FooterIsHtml); 485 ini.WriteBool("Common", "UserRecFilename", UserRecFilename); 486 ini.WriteBool("Common", "IncludeNavbar", IncludeNavbar); 487 ini.WriteBool("Common", "UseWithheldNames", UseWithheldNames); 488 ini.WriteBool("Common", "ConserveTreeWidth", ConserveTreeWidth); 489 ini.WriteBool("Common", "AllowMultimedia", AllowMultimedia); 490 ini.WriteBool("Common", "SupressBackreferences", SupressBackreferences); 491 ini.WriteBool("Common", "KeepSiblingOrder", KeepSiblingOrder); 492 493 int versionMajor = 1, versionMinor = 11, versionPatch = 0; 494 ini.WriteInteger("Common", "VersionMajor", versionMajor); 495 ini.WriteInteger("Common", "VersionMinor", versionMinor); 496 ini.WriteInteger("Common", "VersionPatch", versionPatch); 497 } 498 } catch (Exception ex) { 499 fLogger.WriteError("CConfig.StoreSettings()", ex); 500 } 501 } 502 503 // Deserialise all the settings Load()504 public void Load() 505 { 506 int versionMajor = 0, versionMinor = 0, versionPatch = 0; 507 508 try { 509 using (var ini = new IniFile(AppDataPath + ConfigFilename)) { 510 Version = ini.ReadString("Common", "Version", ""); 511 RestrictConfidential = ini.ReadBool("Common", "RestrictConfidential", false); 512 RestrictPrivacy = ini.ReadBool("Common", "RestrictPrivacy", false); 513 OutputFolder = ini.ReadString("Common", "OutputFolder", ""); 514 UnknownName = ini.ReadString("Common", "UnknownName", "<unknown>"); 515 NameCapitalisation = ini.ReadInteger("Common", "NameCapitalisation", 1); 516 HtmlExtension = ini.ReadString("Common", "HtmlExtension", "html"); 517 CopyMultimedia = ini.ReadBool("Common", "CopyMultimedia", true); 518 ImageFolder = ini.ReadString("Common", "ImageFolder", "multimedia"); 519 RelativiseMultimedia = ini.ReadBool("Common", "RelativiseMultimedia", false); 520 BackgroundImage = ini.ReadString("Common", "BackgroundImage", ""); 521 MaxImageWidth = ini.ReadInteger("Common", "MaxImageWidth", 160); 522 MaxImageHeight = ini.ReadInteger("Common", "MaxImageHeight", 160); 523 MaxNumberMultimediaFiles = ini.ReadInteger("Common", "MaxNumberMultimediaFiles", 32); 524 AgeForOccupation = ini.ReadInteger("Common", "AgeForOccupation", 50); 525 OwnersName = ini.ReadString("Common", "OwnersName", ""); 526 NoSurname = ini.ReadString("Common", "NoSurname", "No Surname"); 527 IndexTitle = ini.ReadString("Common", "IndexTitle", "Index Of Names"); 528 MaxSourceImageWidth = ini.ReadInteger("Common", "MaxSourceImageWidth", 800); 529 MaxSourceImageHeight = ini.ReadInteger("Common", "MaxSourceImageHeight", 800); 530 FirstRecordXRef = ini.ReadString("Common", "FirstRecordXRef", ""); 531 SiteTitle = ini.ReadString("Common", "SiteTitle", "Family history"); 532 InputFilename = ini.ReadString("Common", "InputFilename", ""); 533 ApplicationPath = ini.ReadString("Common", "ApplicationPath", ""); 534 FrontPageImageFilename = ini.ReadString("Common", "FrontPageImageFilename", ""); 535 TabSpaces = ini.ReadInteger("Common", "TabSpaces", 8); 536 PlaceWord = ini.ReadString("Common", "PlaceWord", "in"); 537 CapitaliseEventDescriptions = ini.ReadBool("Common", "CapitaliseEventDescriptions", true); 538 RestrictAssociatedSources = ini.ReadBool("Common", "RestrictAssociatedSources", true); 539 RenameMultimedia = ini.ReadBool("Common", "RenameMultimedia", true); 540 IndexLetterPerPage = ini.ReadBool("Common", "IndexLetterPerPage", false); 541 MiniTreeColourBranch = ConvertColour(ini.ReadString("Common", "MiniTreeColourBranch", "#000000")); 542 MiniTreeColourIndiBorder = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiBorder", "#000000")); 543 MiniTreeColourIndiBackground = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiBackground", "#ffffd2")); 544 MiniTreeColourIndiHighlight = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiHighlight", "#ffffff")); 545 MiniTreeColourIndiShade = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiShade", "#ffffd2")); 546 ShowFrontPageStats = ini.ReadBool("Common", "ShowFrontPageStats", true); 547 CommentaryText = ini.ReadString("Common", "CommentaryText", ""); 548 TreeFontName = ini.ReadString("Common", "TreeFontName", "Arial"); 549 TreeFontSize = (float)ini.ReadFloat("Common", "TreeFontSize", 8.0f); 550 TargetTreeWidth = ini.ReadInteger("Common", "TargetTreeWidth", 800); 551 MiniTreeImageFormat = ini.ReadString("Common", "MiniTreeImageFormat", "gif"); 552 MiniTreeColourIndiText = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiText", "#000000")); 553 MiniTreeColourIndiLink = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiLink", "#3333ff")); 554 MiniTreeColourBackground = ConvertColour(ini.ReadString("Common", "MiniTreeColourBackground", "#aaaaaa")); 555 ShowMiniTrees = ini.ReadBool("Common", "ShowMiniTrees", true); 556 UserEmailAddress = ini.ReadString("Common", "UserEmailAddress", ""); 557 FakeMiniTreeTransparency = ini.ReadBool("Common", "FakeMiniTreeTransparency", false); 558 559 int nKeyIndividuals = ini.ReadInteger("Individuals", "Count", 0); 560 KeyIndividuals = new List<string>(); 561 for (int i = 0; i < nKeyIndividuals; i++) { 562 string keyXref = ini.ReadString("Individuals", "I_" + i, ""); 563 KeyIndividuals.Add(keyXref); 564 } 565 566 MultiPageIndexes = ini.ReadBool("Common", "MultiPageIndexes", true); 567 IndividualsPerIndexPage = ini.ReadInteger("Common", "IndividualsPerIndexPage", 1000); 568 OpenWebsiteOnExit = ini.ReadBool("Common", "OpenWebsiteOnExit", true); 569 FrontPageFilename = ini.ReadString("Common", "FrontPageFilename", "home"); 570 CreateCDROMFiles = ini.ReadBool("Common", "CreateCDROMFiles", false); 571 AllowMultipleImages = ini.ReadBool("Common", "AllowMultipleImages", false); 572 AllowNonPictures = ini.ReadBool("Common", "AllowNonPictures", true); 573 MaxThumbnailImageWidth = ini.ReadInteger("Common", "MaxThumbnailImageWidth", 45); 574 MaxThumbnailImageHeight = ini.ReadInteger("Common", "MaxThumbnailImageHeight", 45); 575 MainWebsiteLink = ini.ReadString("Common", "MainWebsiteLink", ""); 576 PreserveFrontPage = ini.ReadBool("Common", "PreserveFrontPage", false); 577 PreserveStylesheet = ini.ReadBool("Common", "PreserveStylesheet", false); 578 StylesheetFilename = ini.ReadString("Common", "StylesheetFilename", "gedmill-style"); 579 MiniTreeColourIndiBgConcealed = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiBgConcealed", "#cccccc")); 580 OnlyConceal = ini.ReadBool("Common", "OnlyConceal", false); 581 ConcealedName = ini.ReadString("Common", "ConcealedName", "Private Record"); 582 MiniTreeColourIndiFgConcealed = ConvertColour(ini.ReadString("Common", "MiniTreeColourIndiFgConcealed", "#000000")); 583 LinkOriginalPicture = ini.ReadBool("Common", "LinkOriginalPicture", false); 584 RenameOriginalPicture = ini.ReadBool("Common", "RenameOriginalPicture", false); 585 ExcludeFileDir = ini.ReadString("Common", "ExcludeFileDir", ""); 586 ExcludeFileName = ini.ReadString("Common", "ExcludeFileName", ""); 587 ObfuscateEmails = ini.ReadBool("Common", "ObfuscateEmails", false); 588 AddHomePageCreateTime = ini.ReadBool("Common", "AddHomePageCreateTime", true); 589 IncludeValiditySticker = ini.ReadBool("Common", "IncludeValiditySticker", false); 590 IncludeNickNamesInIndex = ini.ReadBool("Common", "IncludeNickNamesInIndex", true); 591 CustomFooter = ini.ReadString("Common", "CustomFooter", ""); 592 IncludeUserRefInIndex = ini.ReadBool("Common", "IncludeUserRefInIndex", false); 593 OccupationHeadline = ini.ReadBool("Common", "OccupationHeadline", true); 594 CommentaryIsHtml = ini.ReadBool("Common", "CommentaryIsHtml", false); 595 FooterIsHtml = ini.ReadBool("Common", "FooterIsHtml", false); 596 UserRecFilename = ini.ReadBool("Common", "UserRecFilename", false); 597 IncludeNavbar = ini.ReadBool("Common", "IncludeNavbar", true); 598 UseWithheldNames = ini.ReadBool("Common", "UseWithheldNames", false); 599 ConserveTreeWidth = ini.ReadBool("Common", "ConserveTreeWidth", false); 600 AllowMultimedia = ini.ReadBool("Common", "AllowMultimedia", true); 601 SupressBackreferences = ini.ReadBool("Common", "SupressBackreferences", false); 602 KeepSiblingOrder = ini.ReadBool("Common", "KeepSiblingOrder", false); 603 604 versionMajor = ini.ReadInteger("Common", "VersionMajor", 0); 605 versionMinor = ini.ReadInteger("Common", "VersionMinor", 0); 606 versionPatch = ini.ReadInteger("Common", "VersionPatch", 0); 607 } 608 } catch (Exception ex) { 609 fLogger.WriteError("CConfig.Load()", ex); 610 } 611 } 612 613 // Reset those settings that can be modified by the user on the config screen. Reset()614 public void Reset() 615 { 616 TreeFontName = "Arial"; 617 TreeFontSize = 8.0f; 618 TargetTreeWidth = 800; 619 MiniTreeImageFormat = "gif"; 620 MiniTreeColourBranch = ConvertColour("#000000"); 621 MiniTreeColourIndiBorder = ConvertColour("#000000"); 622 MiniTreeColourIndiBackground = ConvertColour("#ffffd2"); 623 MiniTreeColourIndiHighlight = ConvertColour("#ffffff"); 624 MiniTreeColourIndiBgConcealed = ConvertColour("#cccccc"); 625 MiniTreeColourIndiFgConcealed = ConvertColour("#000000"); 626 MiniTreeColourIndiShade = ConvertColour("#ffffd2"); 627 MiniTreeColourIndiText = ConvertColour("#000000"); 628 MiniTreeColourIndiLink = ConvertColour("#3333ff"); 629 MiniTreeColourBackground = ConvertColour("#aaaaaa"); 630 FakeMiniTreeTransparency = false; 631 ShowMiniTrees = true; 632 UserEmailAddress = ""; 633 KeyIndividuals = new List<string>(); 634 MultiPageIndexes = true; 635 IndividualsPerIndexPage = 1000; 636 OpenWebsiteOnExit = true; 637 FrontPageFilename = "home"; 638 AllowMultipleImages = false; 639 CreateCDROMFiles = false; 640 AllowNonPictures = true; 641 MainWebsiteLink = ""; 642 PreserveFrontPage = false; 643 PreserveStylesheet = false; 644 StylesheetFilename = "gedmill-style"; 645 OnlyConceal = false; 646 ConcealedName = "Private Record"; 647 LinkOriginalPicture = false; 648 RenameOriginalPicture = false; 649 ExcludeFileDir = ""; 650 ExcludeFileName = ""; 651 ObfuscateEmails = false; 652 AddHomePageCreateTime = true; 653 IncludeValiditySticker = false; 654 IncludeNickNamesInIndex = true; 655 CustomFooter = ""; 656 IncludeUserRefInIndex = false; 657 OccupationHeadline = true; 658 CommentaryIsHtml = false; 659 FooterIsHtml = false; 660 UserRecFilename = false; 661 IncludeNavbar = true; 662 UseWithheldNames = false; 663 ConserveTreeWidth = false; 664 KeepSiblingOrder = false; 665 AllowMultimedia = true; 666 SupressBackreferences = false; 667 } 668 669 // Converts a string of the form #RRGGBB to a Color instance. 670 // Used when retrieving colours from the config. ConvertColour(string s)671 private static Color ConvertColour(string s) 672 { 673 if (string.IsNullOrEmpty(s)) { 674 return Color.Black; 675 } 676 677 int nRed = 0; 678 int nGreen = 0; 679 int nBlue = 0; 680 681 // FIXME: temp hack, IniFile cuts values with leading # 682 if (s[0] != '#') { 683 s = '#' + s; 684 } 685 686 switch (s.Length) { 687 case 4: 688 s = s.Substring(1); 689 goto case 3; 690 case 3: 691 nRed = int.Parse(s.Substring(0, 1), NumberStyles.HexNumber); 692 nGreen = int.Parse(s.Substring(1, 1), NumberStyles.HexNumber); 693 nBlue = int.Parse(s.Substring(2, 1), NumberStyles.HexNumber); 694 break; 695 case 7: 696 s = s.Substring(1); 697 goto case 6; 698 case 6: 699 nRed = int.Parse(s.Substring(0, 2), NumberStyles.HexNumber); 700 nGreen = int.Parse(s.Substring(2, 2), NumberStyles.HexNumber); 701 nBlue = int.Parse(s.Substring(4, 2), NumberStyles.HexNumber); 702 break; 703 } 704 705 return Color.FromArgb(nRed, nGreen, nBlue); 706 } 707 708 // Converts a Color instance to a string of the form #RRGGBB. 709 // Used when storing colours in the config. ConvertColour(Color c)710 private static string ConvertColour(Color c) 711 { 712 string s = string.Format("{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B); 713 return s; 714 } 715 } 716 } 717