/// <summary>КОНСТРУКТОР для отчета</summary> public UserPole_Image(string pText, int pVarID, int Shablon, int pZoom, MyFormat pFormat) { InitializeComponent(); PROP_VarId = pVarID; PROP_Shablon = Shablon; MET_LoadDataSet(); PART_Label.Visibility = Visibility.Collapsed; PROP_Format = pFormat; if (PROP_Format.MET_If("xH")) { PRI_Height = (int)(MyMet.MET_ParseInt(PROP_Format.PROP_Value["xH"]) * 3.4); } if (PROP_Format.MET_If("xW")) { PRI_Width = (int)(MyMet.MET_ParseInt(PROP_Format.PROP_Value["xW"]) * 3.4); } PRI_Height = PRI_Height == 0 ? 230 * pZoom : PRI_Height; PRI_Width = PRI_Width == 0 ? 320 * pZoom : PRI_Width; PRI_Opacity = 0.6; PROP_Text = pText; }
/// <summary>МЕТОД Заполняем данные из протокола </summary> /// <param name="pFlowDocument">Если null, то текущий отчет, иначе в заданный FlowDocument</param> protected void MET_Protokol(FlowDocument pFlowDocument = null) { // Список полей PUB_HashPole = new Hashtable(); // Пробегаемся по вопросам шаблона foreach (UserShablon _Shablon in PROP_Docum.PROP_Shablon) { eVopros _Type = (eVopros)_Shablon.PROP_Type; VirtualPoleOtchet _Pole = MET_CreateUserPole(_Type); // создаем поле, соответствующего типа _Pole.PROP_VarID = _Shablon.PROP_VarId; _Pole.PROP_Maska = MyMet.MET_ParseInt(_Shablon.PROP_Maska); _Pole.PROP_Format = new MyFormat(_Shablon.PROP_xFormat); _Pole.PROP_Shablon = _Shablon; _Pole.PROP_Protokol = PROP_Docum.PROP_Protokol; _Pole.PROP_StrProtokol = PROP_Docum.PROP_Protokol.PROP_Protokol; _Pole.PROP_Name = "Pole_" + _Pole.PROP_VarID; // имя поля PUB_HashPole.Add(_Pole.PROP_Name, _Pole); // записываем элемент в очередь _Pole.MET_Inicial(); // инициализация поля _Pole.PROP_Parent = (VirtualPoleOtchet)PUB_HashPole["Pole_" + _Pole.PROP_Maska]; // родительское поле, если есть // Добавляем форму в отчет if (_Pole.PROP_Parent != null && _Pole.PROP_Parent.PROP_Nested && !_Pole.PROP_Parent.PROP_HideChild) { _Pole.PROP_Parent.MET_AddElement(_Pole); } else { // Если родитель запретил печатать, то и мы запретим детям печататься if (_Pole.PROP_Parent != null && _Pole.PROP_Parent.PROP_HideChild) { _Pole.PROP_HideChild = true; _Pole.PROP_Hide = true; } // Если не печатаем поле, то следующее поле if (_Pole.PROP_Hide) { continue; } TextElement _Element = _Pole.MET_Print(); if (_Element is Block) { if (pFlowDocument != null) { pFlowDocument.Blocks.Add((Block)_Element); } else { Blocks.Add((Block)_Element); } if (_Element is Paragraph) { PRO_Paragraph = (Paragraph)_Element; } else { PRO_Paragraph = new Paragraph(); } } else { PRO_Paragraph.Inlines.Add((Inline)_Element); if (PRO_Paragraph.Parent == null) { if (pFlowDocument != null) { pFlowDocument.Blocks.Add(PRO_Paragraph); } else { Blocks.Add(PRO_Paragraph); } } } } } }
/// <summary>МЕТОД Возвращаем строку c Целым числом</summary> protected int MET_PoleInt(string pPole) { return(MyMet.MET_ParseInt(PRO_RowShablon[pPole].ToString())); }
///<summary>МЕТОД Форматируем данные</summary> /// <param name="pInline">Элемент, который форматируем</param> protected TextElement MET_FormatVoprosOtvet(Inline pInline) { TextElement _TextElement = pInline; // Табуляция if (PROP_Format.MET_If("t")) { try { int x = MyMet.MET_ParseInt(PROP_Format.PROP_Value["t"]); do { (pInline as Span).Inlines.InsertBefore((pInline as Span).Inlines.FirstInline, new Run("\t")); x--; } while (x > 0); } catch { (pInline as Span).Inlines.InsertBefore((pInline as Span).Inlines.FirstInline, new Run("\t")); } } // Пробел if (PROP_Format.MET_If("s")) { try { int x = MyMet.MET_ParseInt(PROP_Format.PROP_Value["s"]); do { (pInline as Span).Inlines.InsertBefore((pInline as Span).Inlines.FirstInline, new Run(" ")); x--; } while (x > 0); } catch { (pInline as Span).Inlines.InsertBefore((pInline as Span).Inlines.FirstInline, new Run(" ")); } } bool _NewPage = PROP_Format.MET_If("f"); bool _NewParagraf = PROP_Format.MET_If("p"); bool _NewLine = PROP_Format.MET_If("n"); if (_NewPage || _NewParagraf || _NewLine) { Paragraph _Paragraph = new Paragraph(pInline) { LineHeight = 1 }; // Новая страница if (_NewPage) { _Paragraph.BreakPageBefore = true; } // Новый параграф if (_NewParagraf) { Thickness _Thickness = new Thickness { Top = 5 }; if ((string)PROP_Format.PROP_Value["p"] != "") { try { int x = Convert.ToInt16(PROP_Format.PROP_Value["p"]); _Thickness.Top += x < 2 ? 0 : (x - 1) * 15; } catch { } } _Paragraph.Margin = _Thickness; } // Новая строка if (_NewLine) { if ((string)PROP_Format.PROP_Value["n"] != "") { try { Thickness _Thickness = new Thickness(); int x = Convert.ToInt16(PROP_Format.PROP_Value["n"]); _Thickness.Top = x < 2 ? 0 : (x - 1) * 12; _Paragraph.Margin = _Thickness; } catch { } } } if (PROP_Format.MET_If("ac")) { _Paragraph.TextAlignment = TextAlignment.Center; } if (PROP_Format.MET_If("ar")) { _Paragraph.TextAlignment = TextAlignment.Right; } _TextElement = _Paragraph; } return(_TextElement); }