PowerPreviewViewModel.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Runtime.CompilerServices; 7 8 using global::PowerToys.GPOWrapper; 9 using Microsoft.PowerToys.Settings.UI.Library; 10 using Microsoft.PowerToys.Settings.UI.Library.Helpers; 11 using Microsoft.PowerToys.Settings.UI.Library.Interfaces; 12 using Settings.UI.Library.Enumerations; 13 14 namespace Microsoft.PowerToys.Settings.UI.ViewModels 15 { 16 public partial class PowerPreviewViewModel : Observable 17 { 18 private const string ModuleName = PowerPreviewSettings.ModuleName; 19 20 private PowerPreviewSettings Settings { get; set; } 21 22 private Func<string, int> SendConfigMSG { get; } 23 24 private string _settingsConfigFileFolder = string.Empty; 25 26 private GeneralSettings GeneralSettingsConfig { get; set; } 27 28 public PowerPreviewViewModel(ISettingsRepository<PowerPreviewSettings> moduleSettingsRepository, ISettingsRepository<GeneralSettings> generalSettingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "") 29 { 30 // Update Settings file folder: 31 _settingsConfigFileFolder = configFileSubfolder; 32 33 // To obtain the general Settings configurations of PowerToys 34 ArgumentNullException.ThrowIfNull(generalSettingsRepository); 35 36 GeneralSettingsConfig = generalSettingsRepository.SettingsConfig; 37 38 // To obtain the PowerPreview settings if it exists. 39 // If the file does not exist, to create a new one and return the default settings configurations. 40 ArgumentNullException.ThrowIfNull(moduleSettingsRepository); 41 42 Settings = moduleSettingsRepository.SettingsConfig; 43 44 // set the callback functions value to handle outgoing IPC message. 45 SendConfigMSG = ipcMSGCallBackFunc; 46 47 _svgRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredSvgPreviewEnabledValue(); 48 if (_svgRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _svgRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 49 { 50 // Get the enabled state from GPO. 51 _svgRenderEnabledStateIsGPOConfigured = true; 52 _svgRenderIsEnabled = _svgRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 53 _svgRenderIsGpoEnabled = _svgRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 54 _svgRenderIsGpoDisabled = _svgRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 55 } 56 else 57 { 58 _svgRenderIsEnabled = Settings.Properties.EnableSvgPreview; 59 } 60 61 _svgBackgroundColorMode = Settings.Properties.SvgBackgroundColorMode.Value; 62 _svgBackgroundSolidColor = Settings.Properties.SvgBackgroundSolidColor.Value; 63 _svgBackgroundCheckeredShade = Settings.Properties.SvgBackgroundCheckeredShade.Value; 64 65 _mdRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredMarkdownPreviewEnabledValue(); 66 if (_mdRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _mdRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 67 { 68 // Get the enabled state from GPO. 69 _mdRenderEnabledStateIsGPOConfigured = true; 70 _mdRenderIsEnabled = _mdRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 71 _mdRenderIsGpoEnabled = _mdRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 72 _mdRenderIsGpoDisabled = _mdRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 73 } 74 else 75 { 76 _mdRenderIsEnabled = Settings.Properties.EnableMdPreview; 77 } 78 79 _monacoRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredMonacoPreviewEnabledValue(); 80 if (_monacoRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _monacoRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 81 { 82 // Get the enabled state from GPO. 83 _monacoRenderEnabledStateIsGPOConfigured = true; 84 _monacoRenderIsEnabled = _monacoRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 85 _monacoRenderIsGpoEnabled = _monacoRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 86 _monacoRenderIsGpoDisabled = _monacoRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 87 } 88 else 89 { 90 _monacoRenderIsEnabled = Settings.Properties.EnableMonacoPreview; 91 } 92 93 _monacoWrapText = Settings.Properties.EnableMonacoPreviewWordWrap; 94 _monacoPreviewTryFormat = Settings.Properties.MonacoPreviewTryFormat; 95 _monacoMaxFileSize = Settings.Properties.MonacoPreviewMaxFileSize.Value; 96 _monacoFontSize = Settings.Properties.MonacoPreviewFontSize.Value; 97 _monacoStickyScroll = Settings.Properties.MonacoPreviewStickyScroll; 98 _monacoMinimap = Settings.Properties.MonacoPreviewMinimap; 99 100 _pdfRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredPdfPreviewEnabledValue(); 101 if (_pdfRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _pdfRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 102 { 103 // Get the enabled state from GPO. 104 _pdfRenderEnabledStateIsGPOConfigured = true; 105 _pdfRenderIsEnabled = _pdfRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 106 _pdfRenderIsGpoEnabled = _pdfRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 107 _pdfRenderIsGpoDisabled = _pdfRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 108 } 109 else 110 { 111 _pdfRenderIsEnabled = Settings.Properties.EnablePdfPreview; 112 } 113 114 _gcodeRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredGcodePreviewEnabledValue(); 115 if (_gcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _gcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 116 { 117 // Get the enabled state from GPO. 118 _gcodeRenderEnabledStateIsGPOConfigured = true; 119 _gcodeRenderIsEnabled = _gcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 120 _gcodeRenderIsGpoEnabled = _gcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 121 _gcodeRenderIsGpoDisabled = _gcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 122 } 123 else 124 { 125 _gcodeRenderIsEnabled = Settings.Properties.EnableGcodePreview; 126 } 127 128 _bgcodeRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredBgcodePreviewEnabledValue(); 129 if (_bgcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _bgcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 130 { 131 // Get the enabled state from GPO. 132 _bgcodeRenderEnabledStateIsGPOConfigured = true; 133 _bgcodeRenderIsEnabled = _bgcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 134 _bgcodeRenderIsGpoEnabled = _bgcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 135 _bgcodeRenderIsGpoDisabled = _bgcodeRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 136 } 137 else 138 { 139 _bgcodeRenderIsEnabled = Settings.Properties.EnableBgcodePreview; 140 } 141 142 _qoiRenderEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredQoiPreviewEnabledValue(); 143 if (_qoiRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _qoiRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 144 { 145 // Get the enabled state from GPO. 146 _qoiRenderEnabledStateIsGPOConfigured = true; 147 _qoiRenderIsEnabled = _qoiRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 148 _qoiRenderIsGpoEnabled = _qoiRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 149 _qoiRenderIsGpoDisabled = _qoiRenderEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 150 } 151 else 152 { 153 _qoiRenderIsEnabled = Settings.Properties.EnableQoiPreview; 154 } 155 156 _svgThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredSvgThumbnailsEnabledValue(); 157 if (_svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 158 { 159 // Get the enabled state from GPO. 160 _svgThumbnailEnabledStateIsGPOConfigured = true; 161 _svgThumbnailIsEnabled = _svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 162 _svgThumbnailIsGpoEnabled = _svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 163 _svgThumbnailIsGpoDisabled = _svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 164 } 165 else 166 { 167 _svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail; 168 } 169 170 _pdfThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredPdfThumbnailsEnabledValue(); 171 if (_pdfThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _pdfThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 172 { 173 // Get the enabled state from GPO. 174 _pdfThumbnailEnabledStateIsGPOConfigured = true; 175 _pdfThumbnailIsEnabled = _pdfThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 176 _pdfThumbnailIsGpoEnabled = _pdfThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 177 _pdfThumbnailIsGpoDisabled = _pdfThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 178 } 179 else 180 { 181 _pdfThumbnailIsEnabled = Settings.Properties.EnablePdfThumbnail; 182 } 183 184 _gcodeThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredGcodeThumbnailsEnabledValue(); 185 if (_gcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _gcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 186 { 187 // Get the enabled state from GPO. 188 _gcodeThumbnailEnabledStateIsGPOConfigured = true; 189 _gcodeThumbnailIsEnabled = _gcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 190 _gcodeThumbnailIsGpoEnabled = _gcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 191 _gcodeThumbnailIsGpoDisabled = _gcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 192 } 193 else 194 { 195 _gcodeThumbnailIsEnabled = Settings.Properties.EnableGcodeThumbnail; 196 } 197 198 _bgcodeThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredBgcodeThumbnailsEnabledValue(); 199 if (_bgcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _bgcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 200 { 201 // Get the enabled state from GPO. 202 _bgcodeThumbnailEnabledStateIsGPOConfigured = true; 203 _bgcodeThumbnailIsEnabled = _bgcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 204 _bgcodeThumbnailIsGpoEnabled = _bgcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 205 _bgcodeThumbnailIsGpoDisabled = _bgcodeThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 206 } 207 else 208 { 209 _bgcodeThumbnailIsEnabled = Settings.Properties.EnableBgcodeThumbnail; 210 } 211 212 _stlThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredStlThumbnailsEnabledValue(); 213 if (_stlThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _stlThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 214 { 215 // Get the enabled state from GPO. 216 _stlThumbnailEnabledStateIsGPOConfigured = true; 217 _stlThumbnailIsEnabled = _stlThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 218 _stlThumbnailIsGpoEnabled = _stlThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 219 _stlThumbnailIsGpoDisabled = _stlThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 220 } 221 else 222 { 223 _stlThumbnailIsEnabled = Settings.Properties.EnableStlThumbnail; 224 } 225 226 _stlThumbnailColor = Settings.Properties.StlThumbnailColor.Value; 227 228 _qoiThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredQoiThumbnailsEnabledValue(); 229 if (_qoiThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _qoiThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled) 230 { 231 // Get the enabled state from GPO. 232 _qoiThumbnailEnabledStateIsGPOConfigured = true; 233 _qoiThumbnailIsEnabled = _qoiThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 234 _qoiThumbnailIsGpoEnabled = _qoiThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled; 235 _qoiThumbnailIsGpoDisabled = _qoiThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled; 236 } 237 else 238 { 239 _qoiThumbnailIsEnabled = Settings.Properties.EnableQoiThumbnail; 240 } 241 } 242 243 private GpoRuleConfigured _svgRenderEnabledGpoRuleConfiguration; 244 private bool _svgRenderEnabledStateIsGPOConfigured; 245 private bool _svgRenderIsGpoEnabled; 246 private bool _svgRenderIsGpoDisabled; 247 private bool _svgRenderIsEnabled; 248 private int _svgBackgroundColorMode; 249 private string _svgBackgroundSolidColor; 250 private int _svgBackgroundCheckeredShade; 251 252 private GpoRuleConfigured _mdRenderEnabledGpoRuleConfiguration; 253 private bool _mdRenderEnabledStateIsGPOConfigured; 254 private bool _mdRenderIsGpoEnabled; 255 private bool _mdRenderIsGpoDisabled; 256 private bool _mdRenderIsEnabled; 257 258 private GpoRuleConfigured _monacoRenderEnabledGpoRuleConfiguration; 259 private bool _monacoRenderEnabledStateIsGPOConfigured; 260 private bool _monacoRenderIsGpoEnabled; 261 private bool _monacoRenderIsGpoDisabled; 262 private bool _monacoRenderIsEnabled; 263 private bool _monacoWrapText; 264 private bool _monacoPreviewTryFormat; 265 private int _monacoMaxFileSize; 266 private bool _monacoStickyScroll; 267 private int _monacoFontSize; 268 private bool _monacoMinimap; 269 270 private GpoRuleConfigured _pdfRenderEnabledGpoRuleConfiguration; 271 private bool _pdfRenderEnabledStateIsGPOConfigured; 272 private bool _pdfRenderIsGpoEnabled; 273 private bool _pdfRenderIsGpoDisabled; 274 private bool _pdfRenderIsEnabled; 275 276 private GpoRuleConfigured _gcodeRenderEnabledGpoRuleConfiguration; 277 private bool _gcodeRenderEnabledStateIsGPOConfigured; 278 private bool _gcodeRenderIsGpoEnabled; 279 private bool _gcodeRenderIsGpoDisabled; 280 private bool _gcodeRenderIsEnabled; 281 282 private GpoRuleConfigured _bgcodeRenderEnabledGpoRuleConfiguration; 283 private bool _bgcodeRenderEnabledStateIsGPOConfigured; 284 private bool _bgcodeRenderIsGpoEnabled; 285 private bool _bgcodeRenderIsGpoDisabled; 286 private bool _bgcodeRenderIsEnabled; 287 288 private GpoRuleConfigured _qoiRenderEnabledGpoRuleConfiguration; 289 private bool _qoiRenderEnabledStateIsGPOConfigured; 290 private bool _qoiRenderIsGpoEnabled; 291 private bool _qoiRenderIsGpoDisabled; 292 private bool _qoiRenderIsEnabled; 293 294 private GpoRuleConfigured _svgThumbnailEnabledGpoRuleConfiguration; 295 private bool _svgThumbnailEnabledStateIsGPOConfigured; 296 private bool _svgThumbnailIsGpoEnabled; 297 private bool _svgThumbnailIsGpoDisabled; 298 private bool _svgThumbnailIsEnabled; 299 300 private GpoRuleConfigured _pdfThumbnailEnabledGpoRuleConfiguration; 301 private bool _pdfThumbnailEnabledStateIsGPOConfigured; 302 private bool _pdfThumbnailIsGpoEnabled; 303 private bool _pdfThumbnailIsGpoDisabled; 304 private bool _pdfThumbnailIsEnabled; 305 306 private GpoRuleConfigured _gcodeThumbnailEnabledGpoRuleConfiguration; 307 private bool _gcodeThumbnailEnabledStateIsGPOConfigured; 308 private bool _gcodeThumbnailIsGpoEnabled; 309 private bool _gcodeThumbnailIsGpoDisabled; 310 private bool _gcodeThumbnailIsEnabled; 311 312 private GpoRuleConfigured _bgcodeThumbnailEnabledGpoRuleConfiguration; 313 private bool _bgcodeThumbnailEnabledStateIsGPOConfigured; 314 private bool _bgcodeThumbnailIsGpoEnabled; 315 private bool _bgcodeThumbnailIsGpoDisabled; 316 private bool _bgcodeThumbnailIsEnabled; 317 318 private GpoRuleConfigured _stlThumbnailEnabledGpoRuleConfiguration; 319 private bool _stlThumbnailEnabledStateIsGPOConfigured; 320 private bool _stlThumbnailIsGpoEnabled; 321 private bool _stlThumbnailIsGpoDisabled; 322 private bool _stlThumbnailIsEnabled; 323 private string _stlThumbnailColor; 324 325 private GpoRuleConfigured _qoiThumbnailEnabledGpoRuleConfiguration; 326 private bool _qoiThumbnailEnabledStateIsGPOConfigured; 327 private bool _qoiThumbnailIsGpoEnabled; 328 private bool _qoiThumbnailIsGpoDisabled; 329 private bool _qoiThumbnailIsEnabled; 330 331 public bool SomePreviewPaneEnabledGposConfigured 332 { 333 get 334 { 335 return _svgRenderEnabledStateIsGPOConfigured || _mdRenderEnabledStateIsGPOConfigured 336 || _monacoRenderEnabledStateIsGPOConfigured || _pdfRenderEnabledStateIsGPOConfigured 337 || _gcodeRenderEnabledStateIsGPOConfigured || _qoiRenderEnabledStateIsGPOConfigured 338 || _bgcodeRenderEnabledStateIsGPOConfigured; 339 } 340 } 341 342 public bool SomeThumbnailEnabledGposConfigured 343 { 344 get 345 { 346 return _svgThumbnailEnabledStateIsGPOConfigured || _pdfThumbnailEnabledStateIsGPOConfigured 347 || _gcodeThumbnailEnabledStateIsGPOConfigured || _stlThumbnailEnabledStateIsGPOConfigured 348 || _qoiThumbnailEnabledStateIsGPOConfigured || _bgcodeThumbnailEnabledStateIsGPOConfigured; 349 } 350 } 351 352 public bool SVGRenderIsEnabled 353 { 354 get 355 { 356 return _svgRenderIsEnabled; 357 } 358 359 set 360 { 361 if (_svgRenderEnabledStateIsGPOConfigured) 362 { 363 // If it's GPO configured, shouldn't be able to change this state. 364 return; 365 } 366 367 if (value != _svgRenderIsEnabled) 368 { 369 _svgRenderIsEnabled = value; 370 Settings.Properties.EnableSvgPreview = value; 371 RaisePropertyChanged(); 372 } 373 } 374 } 375 376 public int SVGRenderBackgroundColorMode 377 { 378 get 379 { 380 return _svgBackgroundColorMode; 381 } 382 383 set 384 { 385 if (value != _svgBackgroundColorMode) 386 { 387 _svgBackgroundColorMode = value; 388 Settings.Properties.SvgBackgroundColorMode.Value = value; 389 RaisePropertyChanged(); 390 RaisePropertyChanged(nameof(IsSvgBackgroundColorVisible)); 391 RaisePropertyChanged(nameof(IsSvgCheckeredShadeVisible)); 392 } 393 } 394 } 395 396 public bool IsSvgBackgroundColorVisible 397 { 398 get 399 { 400 return (SvgPreviewColorMode)SVGRenderBackgroundColorMode == SvgPreviewColorMode.SolidColor; 401 } 402 } 403 404 public string SVGRenderBackgroundSolidColor 405 { 406 get 407 { 408 return _svgBackgroundSolidColor; 409 } 410 411 set 412 { 413 if (value != _svgBackgroundSolidColor) 414 { 415 _svgBackgroundSolidColor = value; 416 Settings.Properties.SvgBackgroundSolidColor = value; 417 RaisePropertyChanged(); 418 } 419 } 420 } 421 422 public bool IsSvgCheckeredShadeVisible 423 { 424 get 425 { 426 return (SvgPreviewColorMode)SVGRenderBackgroundColorMode == SvgPreviewColorMode.Checkered; 427 } 428 } 429 430 public int SVGRenderBackgroundCheckeredShade 431 { 432 get 433 { 434 return _svgBackgroundCheckeredShade; 435 } 436 437 set 438 { 439 if (value != _svgBackgroundCheckeredShade) 440 { 441 _svgBackgroundCheckeredShade = value; 442 Settings.Properties.SvgBackgroundCheckeredShade.Value = value; 443 RaisePropertyChanged(); 444 } 445 } 446 } 447 448 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 449 public bool SVGRenderIsGpoEnabled 450 { 451 get 452 { 453 return _svgRenderIsGpoEnabled; 454 } 455 } 456 457 // Used to disable the settings card on forced disabled state. 458 public bool SVGRenderIsGpoDisabled 459 { 460 get 461 { 462 return _svgRenderIsGpoDisabled; 463 } 464 } 465 466 public bool SVGThumbnailIsEnabled 467 { 468 get 469 { 470 return _svgThumbnailIsEnabled; 471 } 472 473 set 474 { 475 if (_svgThumbnailEnabledStateIsGPOConfigured) 476 { 477 // If it's GPO configured, shouldn't be able to change this state. 478 return; 479 } 480 481 if (value != _svgThumbnailIsEnabled) 482 { 483 _svgThumbnailIsEnabled = value; 484 Settings.Properties.EnableSvgThumbnail = value; 485 RaisePropertyChanged(); 486 } 487 } 488 } 489 490 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 491 public bool SVGThumbnailIsGpoEnabled 492 { 493 get 494 { 495 return _svgThumbnailIsGpoEnabled; 496 } 497 } 498 499 // Used to disable the settings card on forced disabled state. 500 public bool SVGThumbnailIsGpoDisabled 501 { 502 get 503 { 504 return _svgThumbnailIsGpoDisabled; 505 } 506 } 507 508 public bool MDRenderIsEnabled 509 { 510 get 511 { 512 return _mdRenderIsEnabled; 513 } 514 515 set 516 { 517 if (_mdRenderEnabledStateIsGPOConfigured) 518 { 519 // If it's GPO configured, shouldn't be able to change this state. 520 return; 521 } 522 523 if (value != _mdRenderIsEnabled) 524 { 525 _mdRenderIsEnabled = value; 526 Settings.Properties.EnableMdPreview = value; 527 RaisePropertyChanged(); 528 } 529 } 530 } 531 532 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 533 public bool MDRenderIsGpoEnabled 534 { 535 get 536 { 537 return _mdRenderIsGpoEnabled; 538 } 539 } 540 541 // Used to disable the settings card on forced disabled state. 542 public bool MDRenderIsGpoDisabled 543 { 544 get 545 { 546 return _mdRenderIsGpoDisabled; 547 } 548 } 549 550 public bool MonacoRenderIsEnabled 551 { 552 get 553 { 554 return _monacoRenderIsEnabled; 555 } 556 557 set 558 { 559 if (_monacoRenderEnabledStateIsGPOConfigured) 560 { 561 // If it's GPO configured, shouldn't be able to change this state. 562 return; 563 } 564 565 if (value != _monacoRenderIsEnabled) 566 { 567 _monacoRenderIsEnabled = value; 568 Settings.Properties.EnableMonacoPreview = value; 569 RaisePropertyChanged(); 570 } 571 } 572 } 573 574 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 575 public bool MonacoRenderIsGpoEnabled 576 { 577 get 578 { 579 return _monacoRenderIsGpoEnabled; 580 } 581 } 582 583 // Used to disable the settings card on forced disabled state. 584 public bool MonacoRenderIsGpoDisabled 585 { 586 get 587 { 588 return _monacoRenderIsGpoDisabled; 589 } 590 } 591 592 public bool MonacoWrapText 593 { 594 get 595 { 596 return _monacoWrapText; 597 } 598 599 set 600 { 601 if (_monacoWrapText != value) 602 { 603 _monacoWrapText = value; 604 Settings.Properties.EnableMonacoPreviewWordWrap = value; 605 RaisePropertyChanged(); 606 } 607 } 608 } 609 610 public bool MonacoPreviewTryFormat 611 { 612 get 613 { 614 return _monacoPreviewTryFormat; 615 } 616 617 set 618 { 619 if (_monacoPreviewTryFormat != value) 620 { 621 _monacoPreviewTryFormat = value; 622 Settings.Properties.MonacoPreviewTryFormat = value; 623 RaisePropertyChanged(); 624 } 625 } 626 } 627 628 public int MonacoPreviewMaxFileSize 629 { 630 get 631 { 632 return _monacoMaxFileSize; 633 } 634 635 set 636 { 637 if (_monacoMaxFileSize != value) 638 { 639 _monacoMaxFileSize = value; 640 Settings.Properties.MonacoPreviewMaxFileSize.Value = value; 641 RaisePropertyChanged(); 642 } 643 } 644 } 645 646 public bool MonacoPreviewStickyScroll 647 { 648 get 649 { 650 return _monacoStickyScroll; 651 } 652 653 set 654 { 655 if (_monacoStickyScroll != value) 656 { 657 _monacoStickyScroll = value; 658 Settings.Properties.MonacoPreviewStickyScroll = value; 659 RaisePropertyChanged(); 660 } 661 } 662 } 663 664 public bool MonacoPreviewMinimap 665 { 666 get => _monacoMinimap; 667 set 668 { 669 if (_monacoMinimap != value) 670 { 671 _monacoMinimap = value; 672 Settings.Properties.MonacoPreviewMinimap = value; 673 RaisePropertyChanged(); 674 } 675 } 676 } 677 678 public int MonacoPreviewFontSize 679 { 680 get 681 { 682 return _monacoFontSize; 683 } 684 685 set 686 { 687 if (_monacoFontSize != value) 688 { 689 _monacoFontSize = value; 690 Settings.Properties.MonacoPreviewFontSize.Value = value; 691 RaisePropertyChanged(); 692 } 693 } 694 } 695 696 public bool PDFRenderIsEnabled 697 { 698 get 699 { 700 return _pdfRenderIsEnabled; 701 } 702 703 set 704 { 705 if (_pdfRenderEnabledStateIsGPOConfigured) 706 { 707 // If it's GPO configured, shouldn't be able to change this state. 708 return; 709 } 710 711 if (value != _pdfRenderIsEnabled) 712 { 713 _pdfRenderIsEnabled = value; 714 Settings.Properties.EnablePdfPreview = value; 715 RaisePropertyChanged(); 716 } 717 } 718 } 719 720 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 721 public bool PDFRenderIsGpoEnabled 722 { 723 get 724 { 725 return _pdfRenderIsGpoEnabled; 726 } 727 } 728 729 // Used to disable the settings card on forced disabled state. 730 public bool PDFRenderIsGpoDisabled 731 { 732 get 733 { 734 return _pdfRenderIsGpoDisabled; 735 } 736 } 737 738 public bool PDFThumbnailIsEnabled 739 { 740 get 741 { 742 return _pdfThumbnailIsEnabled; 743 } 744 745 set 746 { 747 if (_pdfThumbnailEnabledStateIsGPOConfigured) 748 { 749 // If it's GPO configured, shouldn't be able to change this state. 750 return; 751 } 752 753 if (value != _pdfThumbnailIsEnabled) 754 { 755 _pdfThumbnailIsEnabled = value; 756 Settings.Properties.EnablePdfThumbnail = value; 757 RaisePropertyChanged(); 758 } 759 } 760 } 761 762 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 763 public bool PDFThumbnailIsGpoEnabled 764 { 765 get 766 { 767 return _pdfThumbnailIsGpoEnabled; 768 } 769 } 770 771 // Used to disable the settings card on forced disabled state. 772 public bool PDFThumbnailIsGpoDisabled 773 { 774 get 775 { 776 return _pdfThumbnailIsGpoDisabled; 777 } 778 } 779 780 public bool GCODERenderIsEnabled 781 { 782 get 783 { 784 return _gcodeRenderIsEnabled; 785 } 786 787 set 788 { 789 if (_gcodeRenderEnabledStateIsGPOConfigured) 790 { 791 // If it's GPO configured, shouldn't be able to change this state. 792 return; 793 } 794 795 if (value != _gcodeRenderIsEnabled) 796 { 797 _gcodeRenderIsEnabled = value; 798 Settings.Properties.EnableGcodePreview = value; 799 RaisePropertyChanged(); 800 } 801 } 802 } 803 804 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 805 public bool GCODERenderIsGpoEnabled 806 { 807 get 808 { 809 return _gcodeRenderIsGpoEnabled; 810 } 811 } 812 813 // Used to disable the settings card on forced disabled state. 814 public bool GCODERenderIsGpoDisabled 815 { 816 get 817 { 818 return _gcodeRenderIsGpoDisabled; 819 } 820 } 821 822 public bool BGCODERenderIsEnabled 823 { 824 get 825 { 826 return _bgcodeRenderIsEnabled; 827 } 828 829 set 830 { 831 if (_bgcodeRenderEnabledStateIsGPOConfigured) 832 { 833 // If it's GPO configured, shouldn't be able to change this state. 834 return; 835 } 836 837 if (value != _bgcodeRenderIsEnabled) 838 { 839 _bgcodeRenderIsEnabled = value; 840 Settings.Properties.EnableBgcodePreview = value; 841 RaisePropertyChanged(); 842 } 843 } 844 } 845 846 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 847 public bool BGCODERenderIsGpoEnabled 848 { 849 get 850 { 851 return _bgcodeRenderIsGpoEnabled; 852 } 853 } 854 855 // Used to disable the settings card on forced disabled state. 856 public bool BGCODERenderIsGpoDisabled 857 { 858 get 859 { 860 return _bgcodeRenderIsGpoDisabled; 861 } 862 } 863 864 public bool GCODEThumbnailIsEnabled 865 { 866 get 867 { 868 return _gcodeThumbnailIsEnabled; 869 } 870 871 set 872 { 873 if (_gcodeThumbnailEnabledStateIsGPOConfigured) 874 { 875 // If it's GPO configured, shouldn't be able to change this state. 876 return; 877 } 878 879 if (value != _gcodeThumbnailIsEnabled) 880 { 881 _gcodeThumbnailIsEnabled = value; 882 Settings.Properties.EnableGcodeThumbnail = value; 883 RaisePropertyChanged(); 884 } 885 } 886 } 887 888 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 889 public bool GCODEThumbnailIsGpoEnabled 890 { 891 get 892 { 893 return _gcodeThumbnailIsGpoEnabled; 894 } 895 } 896 897 // Used to disable the settings card on forced disabled state. 898 public bool GCODEThumbnailIsGpoDisabled 899 { 900 get 901 { 902 return _gcodeThumbnailIsGpoDisabled; 903 } 904 } 905 906 public bool BGCODEThumbnailIsEnabled 907 { 908 get 909 { 910 return _bgcodeThumbnailIsEnabled; 911 } 912 913 set 914 { 915 if (_bgcodeThumbnailEnabledStateIsGPOConfigured) 916 { 917 // If it's GPO configured, shouldn't be able to change this state. 918 return; 919 } 920 921 if (value != _bgcodeThumbnailIsEnabled) 922 { 923 _bgcodeThumbnailIsEnabled = value; 924 Settings.Properties.EnableBgcodeThumbnail = value; 925 RaisePropertyChanged(); 926 } 927 } 928 } 929 930 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 931 public bool BGCODEThumbnailIsGpoEnabled 932 { 933 get 934 { 935 return _bgcodeThumbnailIsGpoEnabled; 936 } 937 } 938 939 // Used to disable the settings card on forced disabled state. 940 public bool BGCODEThumbnailIsGpoDisabled 941 { 942 get 943 { 944 return _bgcodeThumbnailIsGpoDisabled; 945 } 946 } 947 948 public bool STLThumbnailIsEnabled 949 { 950 get 951 { 952 return _stlThumbnailIsEnabled; 953 } 954 955 set 956 { 957 if (_stlThumbnailEnabledStateIsGPOConfigured) 958 { 959 // If it's GPO configured, shouldn't be able to change this state. 960 return; 961 } 962 963 if (value != _stlThumbnailIsEnabled) 964 { 965 _stlThumbnailIsEnabled = value; 966 Settings.Properties.EnableStlThumbnail = value; 967 RaisePropertyChanged(); 968 } 969 } 970 } 971 972 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 973 public bool STLThumbnailIsGpoEnabled 974 { 975 get 976 { 977 return _stlThumbnailIsGpoEnabled; 978 } 979 } 980 981 // Used to disable the settings card on forced disabled state. 982 public bool STLThumbnailIsGpoDisabled 983 { 984 get 985 { 986 return _stlThumbnailIsGpoDisabled; 987 } 988 } 989 990 public string STLThumbnailColor 991 { 992 get 993 { 994 return _stlThumbnailColor; 995 } 996 997 set 998 { 999 if (value != _stlThumbnailColor) 1000 { 1001 _stlThumbnailColor = value; 1002 Settings.Properties.StlThumbnailColor.Value = value; 1003 RaisePropertyChanged(); 1004 } 1005 } 1006 } 1007 1008 public bool QOIRenderIsEnabled 1009 { 1010 get 1011 { 1012 return _qoiRenderIsEnabled; 1013 } 1014 1015 set 1016 { 1017 if (_qoiRenderEnabledStateIsGPOConfigured) 1018 { 1019 // If it's GPO configured, shouldn't be able to change this state. 1020 return; 1021 } 1022 1023 if (value != _qoiRenderIsEnabled) 1024 { 1025 _qoiRenderIsEnabled = value; 1026 Settings.Properties.EnableQoiPreview = value; 1027 RaisePropertyChanged(); 1028 } 1029 } 1030 } 1031 1032 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 1033 public bool QOIRenderIsGpoEnabled 1034 { 1035 get 1036 { 1037 return _qoiRenderIsGpoEnabled; 1038 } 1039 } 1040 1041 // Used to disable the settings card on forced disabled state. 1042 public bool QOIRenderIsGpoDisabled 1043 { 1044 get 1045 { 1046 return _qoiRenderIsGpoDisabled; 1047 } 1048 } 1049 1050 public bool QOIThumbnailIsEnabled 1051 { 1052 get 1053 { 1054 return _qoiThumbnailIsEnabled; 1055 } 1056 1057 set 1058 { 1059 if (_qoiThumbnailEnabledStateIsGPOConfigured) 1060 { 1061 // If it's GPO configured, shouldn't be able to change this state. 1062 return; 1063 } 1064 1065 if (value != _qoiThumbnailIsEnabled) 1066 { 1067 _qoiThumbnailIsEnabled = value; 1068 Settings.Properties.EnableQoiThumbnail = value; 1069 RaisePropertyChanged(); 1070 } 1071 } 1072 } 1073 1074 // Used to only disable enabled button on forced enabled state. (With this users still able to change the utility properties.) 1075 public bool QOIThumbnailIsGpoEnabled 1076 { 1077 get 1078 { 1079 return _qoiRenderIsGpoEnabled; 1080 } 1081 } 1082 1083 // Used to disable the settings card on forced disabled state. 1084 public bool QOIThumbnailIsGpoDisabled 1085 { 1086 get 1087 { 1088 return _qoiThumbnailIsGpoDisabled; 1089 } 1090 } 1091 1092 public string GetSettingsSubPath() 1093 { 1094 return _settingsConfigFileFolder + "\\" + ModuleName; 1095 } 1096 1097 public bool IsElevated 1098 { 1099 get 1100 { 1101 return GeneralSettingsConfig.IsElevated; 1102 } 1103 } 1104 1105 private void RaisePropertyChanged([CallerMemberName] string propertyName = null) 1106 { 1107 // Notify UI of property change 1108 OnPropertyChanged(propertyName); 1109 1110 if (SendConfigMSG != null) 1111 { 1112 SndPowerPreviewSettings snd = new SndPowerPreviewSettings(Settings); 1113 SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd); 1114 SendConfigMSG(ipcMessage.ToJsonString()); 1115 } 1116 } 1117 } 1118 }