Advertisement
Guest User

Untitled

a guest
May 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.26 KB | None | 0 0
  1. #if FORMAT_STYLE
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Xml;
  13. using VL_Library.Helpers;
  14.  
  15. namespace VL_UI.StyleTemplate
  16. {
  17. public class ViewTemplateStyleModel
  18. {
  19. public ViewTemplateStyleModel()
  20. {
  21. _styleTemplateList = new BindingList<StyleTemplate>();
  22. _window = null;
  23.  
  24. SaveStyleTemplateCommand = new RelayCommand(new Action<object>(SaveStyleTemplatePress));
  25. AddNewStyleTemplateCommand = new RelayCommand(new Action<object>(AddStyleTemplatePress));
  26. CloseWindowCommand = new RelayCommand(new Action<object>(CloseWindowPress));
  27. ReloadStylesCommand = new RelayCommand(new Action<object>(ReloadStylePress));
  28.  
  29. LoadStyleTemplate();
  30.  
  31. InitEmptyStyleList();
  32. }
  33.  
  34. public void SetWindow(StyleTemplateWindow window)
  35. {
  36. _window = window;
  37. }
  38.  
  39. public BindingList<StyleTemplate> StyleTemplateList
  40. {
  41. get { return _styleTemplateList; }
  42. }
  43.  
  44. public Dictionary<Key, StyleTemplate> StyleKeys
  45. {
  46. get { return _styleKeys; }
  47. }
  48.  
  49. public ICommand SaveStyleTemplateCommand
  50. {
  51. get;
  52. set;
  53. }
  54.  
  55. public ICommand AddNewStyleTemplateCommand
  56. {
  57. get;
  58. set;
  59. }
  60.  
  61. public ICommand CloseWindowCommand
  62. {
  63. get;
  64. set;
  65. }
  66.  
  67. public ICommand ReloadStylesCommand
  68. {
  69. get;
  70. set;
  71. }
  72.  
  73. public void LoadStyleTemplate()
  74. {
  75. bool error = false;
  76. string fileName = VL_Library.Properties.Settings.Default.userDataPath + "\\templateStyle.xml";
  77. if (System.IO.File.Exists(fileName))
  78. {
  79. StreamEncryption stream = new StreamEncryption();
  80. if (stream.OpenStream(fileName, System.IO.FileAccess.Read, System.IO.FileMode.Open, false))
  81. {
  82. try
  83. {
  84. using (XmlTextReader reader = new XmlTextReader(stream.DataStream))
  85. {
  86. while (reader.Read())
  87. {
  88. if (reader.NodeType == XmlNodeType.Element && reader.Name == "style")
  89. {
  90. string id = reader.GetAttribute("id");
  91. string key = reader.GetAttribute("key");
  92. string sygnature = reader.GetAttribute("sygnature");
  93. string color = reader.GetAttribute("color");
  94. string bold = reader.GetAttribute("bold");
  95. string italic = reader.GetAttribute("italic");
  96. string underline = reader.GetAttribute("underline");
  97. string newline = reader.GetAttribute("newline");
  98. string alignleft = reader.GetAttribute("alignleft");
  99. string alignright = reader.GetAttribute("alignright");
  100. string aligncenter = reader.GetAttribute("aligncenter");
  101. string alignjustify = reader.GetAttribute("alignjustify");
  102. string fullstop = reader.GetAttribute("fullstop");
  103. string exclamationmark = reader.GetAttribute("exclamationmark");
  104. string questinmark = reader.GetAttribute("questionmark");
  105.  
  106. Key tmpKey = (Key)Enum.Parse(typeof(Key), key, true);
  107. StyleTemplate tmpStyle = null;
  108. if(_styleKeys != null)
  109. tmpStyle = new StyleTemplate(tmpKey, _styleKeys.Count);
  110. else
  111. tmpStyle = new StyleTemplate(tmpKey, 0);
  112.  
  113. tmpStyle.Number = id;
  114. tmpStyle.Sygnature = sygnature;
  115.  
  116. tmpStyle.SelectedColor = tmpStyle.ColorStyle[Convert.ToInt32(color)];
  117.  
  118. tmpStyle.Bold = Convert.ToBoolean(bold);
  119. tmpStyle.Italic = Convert.ToBoolean(italic);
  120. tmpStyle.Underline = Convert.ToBoolean(underline);
  121.  
  122. tmpStyle.FullStop = Convert.ToBoolean(fullstop);
  123. tmpStyle.ExclamationMark = Convert.ToBoolean(exclamationmark);
  124. tmpStyle.QuestionMark = Convert.ToBoolean(questinmark);
  125.  
  126. tmpStyle.NewLine = Convert.ToBoolean(newline);
  127.  
  128. tmpStyle.AlignLeft = Convert.ToBoolean(alignleft);
  129. tmpStyle.AlignRight = Convert.ToBoolean(alignright);
  130. tmpStyle.AlignCenter = Convert.ToBoolean(aligncenter);
  131. tmpStyle.AlignJustify = Convert.ToBoolean(alignjustify);
  132.  
  133. AddStyleTemplate(tmpKey, tmpStyle);
  134. }
  135. }
  136. }
  137. }
  138. catch (Exception e)
  139. {
  140. ErrorHandling.Instance.ErrorOccurred(e, "Nie można otworzyć pliku: " + fileName + "!\nNiektóre funkcje mogą nie działać poprawnie!\nCzy chcesz usunąć uszkodzony plik?", "", ErrorTypeEnum.ERROR_MSG,
  141. (Action)(() => { System.IO.File.Delete(fileName); }),
  142. null, null, NotificationButtonEnum.YesNo);
  143. error = true;
  144. }
  145. finally
  146. {
  147. stream.CloseStream(error);
  148. }
  149. }
  150. else
  151. {
  152. if (stream.Error.Message.Contains("Wrong HASH"))
  153. ErrorHandling.Instance.ErrorOccurred(stream.Error, "Nie można otworzyć pliku: " + fileName + "!\nNiektóre funkcje mogą nie działać poprawnie!\nCzy chcesz usunąć plik?",
  154. "", ErrorTypeEnum.ERROR_MSG,
  155. (Action)(() => { System.IO.File.Delete(fileName); }),
  156. null, null, NotificationButtonEnum.YesNo);
  157. else
  158. ErrorHandling.Instance.ErrorOccurred(stream.Error, "Nie można otworzyć pliku: " + fileName + "! Niektóre funkcje mogą nie działać poprawnie!", "",
  159. ErrorTypeEnum.ERROR_MSG, null, null, null, NotificationButtonEnum.OK);
  160. }
  161. }
  162. else
  163. {
  164. ErrorHandling.Instance.ErrorOccurred(null, "Plik: " + fileName + " nie istnieje!", "",
  165. ErrorTypeEnum.ERROR_CONTINUE, null, null, null, NotificationButtonEnum.OK);
  166. }
  167. }
  168.  
  169. public void SaveStyleTemplate()
  170. {
  171. bool error = false;
  172.  
  173. string fileName = VL_Library.Properties.Settings.Default.userDataPath + "\\templateStyle.xml";
  174. StreamEncryption stream = new StreamEncryption();
  175. if (stream.OpenStream(fileName, System.IO.FileAccess.Write, System.IO.FileMode.Create, false))
  176. {
  177. XmlWriterSettings settings = new XmlWriterSettings();
  178. settings.Indent = true;
  179. settings.IndentChars = "\t";
  180. settings.NewLineOnAttributes = true;
  181. XmlWriter writer = null;
  182. try
  183. {
  184. using (writer = XmlWriter.Create(stream.DataStream, settings))
  185. {
  186. writer.WriteStartElement("root");
  187. {
  188. writer.WriteStartElement("styles");
  189. {
  190. foreach (StyleTemplate tmp in _styleTemplateList)
  191. {
  192. writer.WriteStartElement("style");
  193. writer.WriteAttributeString("id", tmp.Number);
  194. writer.WriteAttributeString("key", tmp.KeyboardShortcut);
  195. writer.WriteAttributeString("sygnature", tmp.Sygnature);
  196. writer.WriteAttributeString("color", tmp.ColorStyle.IndexOf(tmp.SelectedColor).ToString());
  197.  
  198. writer.WriteAttributeString("bold", tmp.Bold.ToString());
  199. writer.WriteAttributeString("italic", tmp.Italic.ToString());
  200. writer.WriteAttributeString("underline", tmp.Underline.ToString());
  201.  
  202. writer.WriteAttributeString("fullstop", tmp.FullStop.ToString());
  203. writer.WriteAttributeString("questionmark", tmp.QuestionMark.ToString());
  204. writer.WriteAttributeString("exclamationmark", tmp.ExclamationMark.ToString());
  205.  
  206. writer.WriteAttributeString("newline", tmp.NewLine.ToString());
  207.  
  208. writer.WriteAttributeString("alignleft", tmp.AlignLeft.ToString());
  209. writer.WriteAttributeString("alignright", tmp.AlignRight.ToString());
  210. writer.WriteAttributeString("aligncenter", tmp.AlignCenter.ToString());
  211. writer.WriteAttributeString("alignjustify", tmp.AlignJustify.ToString());
  212. writer.WriteEndElement();
  213. }
  214. }
  215. writer.WriteEndElement();
  216. }
  217. writer.WriteEndElement();
  218. writer.Flush();
  219. }
  220. }
  221. catch (Exception e)
  222. {
  223. ErrorHandling.Instance.ErrorOccurred(e, "Błąd przy zapisie do pliku: " + fileName + "!", "",
  224. ErrorTypeEnum.ERROR_MSG, null, null, null, NotificationButtonEnum.OK);
  225. error = true;
  226. }
  227. finally
  228. {
  229. if (writer != null)
  230. writer.Close();
  231. stream.CloseStream(error);
  232. }
  233. }
  234. else
  235. {
  236. ErrorHandling.Instance.ErrorOccurred(stream.Error, "Błąd przy zapisie do pliku: " + fileName + "!", "",
  237. ErrorTypeEnum.ERROR_MSG, null, null, null, NotificationButtonEnum.OK);
  238. }
  239. }
  240.  
  241. private void InitEmptyStyleList()
  242. {
  243. while (_styleTemplateList.Count < 7)
  244. AddNewStyleTemplate();
  245. }
  246.  
  247. private bool AddNewStyleTemplate()
  248. {
  249. if (_styleTemplateList.Count() <= 6)
  250. {
  251. int elementNum = _styleTemplateList.Count() + 2;
  252. string shortKeyString = "F" + elementNum;
  253. Key tmpKey = (Key)Enum.Parse(typeof(Key), shortKeyString, true);
  254. return AddStyleTemplate(tmpKey);
  255. }
  256.  
  257. return false;
  258. }
  259.  
  260. private void ReloadStylePress(object obj)
  261. {
  262. _styleKeys.Clear();
  263. _styleTemplateList.Clear();
  264. LoadStyleTemplate();
  265.  
  266. InitEmptyStyleList();
  267. }
  268.  
  269. private void CloseWindowPress(object obj)
  270. {
  271. _window.Close();
  272. }
  273.  
  274. private void AddStyleTemplatePress(object obj)
  275. {
  276. AddNewStyleTemplate();
  277. }
  278.  
  279. private void SaveStyleTemplatePress(object obj)
  280. {
  281. SaveStyleTemplate();
  282. }
  283.  
  284. private bool AddStyleTemplate(Key shortCut)
  285. {
  286. if (_styleKeys == null)
  287. _styleKeys = new Dictionary<Key, StyleTemplate>();
  288.  
  289. if (_styleKeys.ContainsKey(shortCut))
  290. return false;
  291.  
  292. _styleKeys.Add(shortCut, new StyleTemplate(shortCut, _styleKeys.Count));
  293. _styleTemplateList.Add(_styleKeys[shortCut]);
  294.  
  295. return true;
  296. }
  297.  
  298. private bool AddStyleTemplate(Key shortCut, StyleTemplate style)
  299. {
  300. if (_styleKeys == null)
  301. _styleKeys = new Dictionary<Key, StyleTemplate>();
  302.  
  303. if (_styleKeys.ContainsKey(shortCut))
  304. return false;
  305.  
  306. _styleKeys.Add(shortCut, style);
  307. _styleTemplateList.Add(style);
  308.  
  309. return true;
  310. }
  311.  
  312. private BindingList<StyleTemplate> _styleTemplateList;
  313. private Dictionary<Key, StyleTemplate> _styleKeys;
  314. private StyleTemplateWindow _window;
  315. }
  316.  
  317. public class StyleTemplate : INotifyPropertyChanged
  318. {
  319. public StyleTemplate(Key keyboardShortcut, int num)
  320. {
  321. _fullStop = false;
  322. _exclamationMark = false;
  323. _questionMark = false;
  324.  
  325. _bold = false;
  326. _italic = false;
  327. _underline = false;
  328. _sygnature = "Sygnatura";
  329. _number = num;
  330. _shortCut = keyboardShortcut;
  331. _alignLeft = true;
  332.  
  333. if(_colorStyle == null)
  334. {
  335. _colorStyle = new List<ColorStyle>();
  336. _colorStyle.Add(new ColorStyle(Brushes.Black));
  337. _colorStyle.Add(new ColorStyle(Brushes.Blue));
  338. _colorStyle.Add(new ColorStyle(Brushes.Green));
  339. _colorStyle.Add(new ColorStyle(Brushes.Yellow));
  340. _colorStyle.Add(new ColorStyle(Brushes.Orange));
  341. _colorStyle.Add(new ColorStyle(Brushes.Red));
  342. _colorStyle.Add(new ColorStyle(Brushes.Pink));
  343. _colorStyle.Add(new ColorStyle(Brushes.Purple));
  344. _colorStyle.Add(new ColorStyle(Brushes.Brown));
  345. _colorStyle.Add(new ColorStyle(Brushes.DarkGray));
  346. _colorStyle.Add(new ColorStyle(Brushes.Cyan));
  347. }
  348.  
  349. SelectedColor = _colorStyle[0];
  350. ResetStyleCommand = new RelayCommand(new Action<object>(ResetStylePress));
  351. }
  352.  
  353. public ICommand ResetStyleCommand
  354. {
  355. get;
  356. set;
  357. }
  358.  
  359. public void ApplyStyle(System.Windows.Documents.TextRange tmpRange)
  360. {
  361. bool space = false;
  362. if (tmpRange.Text.Length > 0 && Char.IsSeparator(tmpRange.Text.Last()))
  363. {
  364. space = true;
  365. }
  366.  
  367. if (_fullStop && tmpRange.Text.Length > 0 && !Char.IsPunctuation(tmpRange.Text.Last()))
  368. tmpRange.Text = tmpRange.Text.TrimEnd() + "." + (space ? " " : "");
  369.  
  370. if (_exclamationMark && tmpRange.Text.Length > 0 && !Char.IsPunctuation(tmpRange.Text.Last()))
  371. tmpRange.Text = tmpRange.Text.TrimEnd() + "!" + (space ? " " : "");
  372.  
  373. if (_questionMark && tmpRange.Text.Length > 0 && !Char.IsPunctuation(tmpRange.Text.Last()))
  374. tmpRange.Text = tmpRange.Text.TrimEnd() + "?" + (space ? " " : "");
  375.  
  376. if (!String.IsNullOrWhiteSpace(_sygnature))
  377. {
  378. if (!tmpRange.Text.StartsWith(_sygnature))
  379. {
  380. tmpRange.Text = _sygnature + ": " + tmpRange.Text.TrimStart();
  381. }
  382. }
  383.  
  384. if(_newLine)
  385. {
  386. tmpRange.Text += "\r\n";
  387. if (_alignCenter)
  388. tmpRange.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Center);
  389. else if (_alignLeft)
  390. tmpRange.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Left);
  391. else if (_alignRight)
  392. tmpRange.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Right);
  393. else if (_alignJustify)
  394. tmpRange.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Justify);
  395. }
  396.  
  397. if (_bold)
  398. tmpRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
  399. else
  400. tmpRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);
  401.  
  402. if (_underline)
  403. tmpRange.ApplyPropertyValue(Inline.TextDecorationsProperty, TextDecorations.Underline);
  404. else
  405. tmpRange.ApplyPropertyValue(Inline.TextDecorationsProperty, null);
  406.  
  407. if (_italic)
  408. tmpRange.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic);
  409. else
  410. tmpRange.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Normal);
  411.  
  412. tmpRange.ApplyPropertyValue(TextElement.ForegroundProperty, _selectedColor.TextColor);
  413. }
  414.  
  415. public bool NewLine
  416. {
  417. get { return _newLine; }
  418. set { _newLine = value; if (!_newLine) TextAlignmentProperty = TextAlignment.Left; else UpdateTextAlign(); NotifyPropertyChange("NewLine"); }
  419. }
  420.  
  421. public bool FullStop
  422. {
  423. get { return _fullStop; }
  424. set { ResetPunctuation(value); _fullStop = value; if (_fullStop)EndSign = "."; CheckEndSign(); NotifyPropertyChange("FullStop"); }
  425. }
  426.  
  427. public bool ExclamationMark
  428. {
  429. get { return _exclamationMark; }
  430. set { ResetPunctuation(value); _exclamationMark = value; if (_exclamationMark)EndSign = "!"; CheckEndSign(); NotifyPropertyChange("Exclamationmark"); }
  431. }
  432.  
  433. public bool QuestionMark
  434. {
  435. get { return _questionMark; }
  436. set { ResetPunctuation(value); _questionMark = value; if (_questionMark)EndSign = "?"; CheckEndSign(); NotifyPropertyChange("QuestionMark"); }
  437. }
  438.  
  439. public bool Bold
  440. {
  441. get { return _bold; }
  442. set { _bold = value; if (_bold) FontWeightProperty = FontWeights.Bold; else FontWeightProperty = FontWeights.Normal; NotifyPropertyChange("Bold"); }
  443. }
  444.  
  445. public bool Italic
  446. {
  447. get { return _italic; }
  448. set { _italic = value; if (_italic) FontStyleProperty = FontStyles.Italic; else FontStyleProperty = FontStyles.Normal; NotifyPropertyChange("Italic"); }
  449. }
  450.  
  451. public bool Underline
  452. {
  453. get { return _underline; }
  454. set { _underline = value; if (_underline) TextDecorationProperty = TextDecorations.Underline; else TextDecorationProperty = null; NotifyPropertyChange("Underline"); }
  455. }
  456.  
  457. public bool AlignLeft
  458. {
  459. get { return _alignLeft; }
  460. set { ResetAlign(value); _alignLeft = value; if (_alignLeft)TextAlignmentProperty = TextAlignment.Left; NotifyPropertyChange("AlignLeft"); CheckAlign(); }
  461. }
  462.  
  463. public bool AlignRight
  464. {
  465. get { return _alignRight; }
  466. set { ResetAlign(value); _alignRight = value; if (_alignRight)TextAlignmentProperty = TextAlignment.Right; NotifyPropertyChange("AlignRight"); CheckAlign(); }
  467. }
  468.  
  469. public bool AlignCenter
  470. {
  471. get { return _alignCenter; }
  472. set { ResetAlign(value); _alignCenter = value; if (_alignCenter)TextAlignmentProperty = TextAlignment.Center; NotifyPropertyChange("AlignCenter"); CheckAlign(); }
  473. }
  474.  
  475. public bool AlignJustify
  476. {
  477. get { return _alignJustify; }
  478. set { ResetAlign(value); _alignJustify = value; if (_alignJustify)TextAlignmentProperty = TextAlignment.Justify; NotifyPropertyChange("AlignJustify"); CheckAlign(); }
  479. }
  480.  
  481. public string Sygnature
  482. {
  483. get { return _sygnature; }
  484. set { _sygnature = value; NotifyPropertyChange("Sygnature"); }
  485. }
  486.  
  487. public string Number
  488. {
  489. get { return Convert.ToString(_number); }
  490. set { _number = Int32.Parse(value); NotifyPropertyChange("Number"); }
  491. }
  492.  
  493. public List<ColorStyle> ColorStyle
  494. {
  495. get { return _colorStyle; }
  496. }
  497.  
  498. public TextAlignment TextAlignmentProperty
  499. {
  500. get { return _textAlignmentProperty; }
  501. set { _textAlignmentProperty = value; NotifyPropertyChange("TextAlignmentProperty"); }
  502. }
  503.  
  504. public string EndSign
  505. {
  506. get { return _endSign; }
  507. set { _endSign = value; NotifyPropertyChange("EndSign"); }
  508. }
  509.  
  510. public SolidColorBrush SelectedBrush
  511. {
  512. get { return _selectedColor.TextColor; }
  513. set { _selectedBrush = value; NotifyPropertyChange("SelectedBrush"); }
  514. }
  515.  
  516. public FontStyle FontStyleProperty
  517. {
  518. get { return _fontStyleProperty; }
  519. set { _fontStyleProperty = value; NotifyPropertyChange("FontStyleProperty"); }
  520. }
  521. public FontWeight FontWeightProperty
  522. {
  523. get { return _fontWeightProperty; }
  524. set { _fontWeightProperty = value; NotifyPropertyChange("FontWeightProperty"); }
  525. }
  526.  
  527. public TextDecorationCollection TextDecorationProperty
  528. {
  529. get { return _textDecoration; }
  530. set { _textDecoration = value; NotifyPropertyChange("TextDecorationProperty"); }
  531. }
  532.  
  533. public ColorStyle SelectedColor
  534. {
  535. get { return _selectedColor; }
  536. set { _selectedColor = value; SelectedBrush = _selectedColor.TextColor; NotifyPropertyChange("SelectedColor"); }
  537. }
  538.  
  539. public String KeyboardShortcut
  540. {
  541. get { return _shortCut.ToString(); }
  542. }
  543.  
  544. private void ResetStylePress(object obj)
  545. {
  546. AlignLeft = true;
  547. Bold = false;
  548. Italic = false;
  549. Underline = false;
  550. Sygnature = "Sygnatura";
  551. SelectedColor = _colorStyle[0];
  552. FullStop = false;
  553. ExclamationMark = false;
  554. QuestionMark = false;
  555. NewLine = false;
  556. }
  557.  
  558. private void UpdateTextAlign()
  559. {
  560. if (_alignCenter)
  561. TextAlignmentProperty = TextAlignment.Center;
  562. else if (_alignJustify)
  563. TextAlignmentProperty = TextAlignment.Justify;
  564. else if (_alignLeft)
  565. TextAlignmentProperty = TextAlignment.Left;
  566. else if (_alignRight)
  567. TextAlignmentProperty = TextAlignment.Right;
  568. }
  569.  
  570. private void ResetPunctuation(bool reset)
  571. {
  572. if (reset)
  573. {
  574. EndSign = "";
  575. _exclamationMark = false;
  576. _fullStop = false;
  577. _questionMark = false;
  578. NotifyPropertyChange("QuestionMark");
  579. NotifyPropertyChange("Exclamationmark");
  580. NotifyPropertyChange("FullStop");
  581. }
  582. }
  583.  
  584. private void CheckEndSign()
  585. {
  586. if (!_exclamationMark && !_fullStop && !_questionMark)
  587. EndSign = "";
  588. }
  589.  
  590. private void ResetAlign(bool reset)
  591. {
  592. if (reset)
  593. {
  594. _alignCenter = false;
  595. _alignJustify = false;
  596. _alignLeft = false;
  597. _alignRight = false;
  598. NotifyPropertyChange("AlignJustify");
  599. NotifyPropertyChange("AlignCenter");
  600. NotifyPropertyChange("AlignLeft");
  601. NotifyPropertyChange("AlignRight");
  602. }
  603. }
  604.  
  605. private void CheckAlign()
  606. {
  607. if (!_alignCenter && !_alignJustify && !_alignLeft && !_alignRight)
  608. {
  609. _alignLeft = true;
  610. TextAlignmentProperty = TextAlignment.Left;
  611. }
  612. NotifyPropertyChange("AlignLeft");
  613. }
  614.  
  615. private bool _fullStop, _exclamationMark, _questionMark, _newLine, _alignLeft, _alignRight, _alignCenter, _alignJustify;
  616. private bool _bold, _underline, _italic;
  617. private string _sygnature, _endSign;
  618. private int _number;
  619. private ColorStyle _selectedColor;
  620. private SolidColorBrush _selectedBrush;
  621. private TextDecorationCollection _textDecoration;
  622. private FontWeight _fontWeightProperty;
  623. private FontStyle _fontStyleProperty;
  624. private TextAlignment _textAlignmentProperty;
  625. private static List<ColorStyle> _colorStyle;
  626. private Key _shortCut;
  627.  
  628. protected void NotifyPropertyChange(string propertyName)
  629. {
  630. if (PropertyChanged != null)
  631. {
  632. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  633. }
  634. }
  635. public event PropertyChangedEventHandler PropertyChanged;
  636. }
  637.  
  638. public class ColorStyle : INotifyPropertyChanged
  639. {
  640. public ColorStyle(SolidColorBrush brush)
  641. {
  642. _textColor = brush;
  643. }
  644.  
  645. public ColorStyle()
  646. {
  647. _textColor = Brushes.Black;
  648. }
  649.  
  650. public SolidColorBrush TextColor
  651. {
  652. get { return _textColor; }
  653. set { _textColor = value; NotifyPropertyChange("TextColor"); }
  654. }
  655.  
  656. SolidColorBrush _textColor;
  657.  
  658. protected void NotifyPropertyChange(string propertyName)
  659. {
  660. if (PropertyChanged != null)
  661. {
  662. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  663. }
  664. }
  665. public event PropertyChangedEventHandler PropertyChanged;
  666. }
  667. }
  668. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement