public void WriteCss() { if (MediaType.ToLower() == "web" && IsPropertyModified() == true) { if (ValidateWebAttributes()) { _validateWebInput = true; XmlNodeList baseNodeList = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); HashUtilities hashUtil = new HashUtilities(); hashUtil.Key = "%:#@?,*&"; hashUtil.Salt = "$%^&*#$%"; foreach (XmlNode baseNode in baseNodeList) { string attribName = baseNode.Attributes["name"].Value.ToLower(); SetAttributesForWebProperties(attribName, baseNode, hashUtil); } Param.Write(); } else { _validateWebInput = false; return; } } if (IsPropertyModified() == false || (FileType.ToLower() == "standard")) return; if (MediaType.ToLower() != "web") { try { string path = Param.Value["UserSheetPath"]; // all user path string file = Common.PathCombine(path, FileName); string importStatement = string.Empty; if (File.Exists(file)) { //Reading the existing file for 1st Line (@import statement) var sr = new StreamReader(file); while ((importStatement = sr.ReadLine()) != null) { if (importStatement.Contains("@import")) { break; } } sr.Close(); } //Start Writing the Changes var writeCss = new StreamWriter(file); if (!string.IsNullOrEmpty(importStatement)) writeCss.WriteLine(importStatement); // changes for paper media if (MediaType == "paper") { SetAttributesForPaperProperties(writeCss); } // write out the changes writeCss.Flush(); writeCss.Close(); PreviewFileName1 = ""; PreviewFileName2 = ""; if (cTool.StylesGrid.Rows.Count >= SelectedRowIndex) { if (PreviewFileName1.Trim().Length > 0 && PreviewFileName2.Trim().Length > 0) { cTool.StylesGrid[PreviewFile1, SelectedRowIndex].Value = PreviewFileName1; cTool.StylesGrid[PreviewFile2, SelectedRowIndex].Value = PreviewFileName2; XmlNode baseNode = Param.GetItem("//styles/" + MediaType + "/style[@name='" + StyleName + "']"); Param.SetAttrValue(baseNode, "previewfile1", PreviewFileName1); Param.SetAttrValue(baseNode, "previewfile2", PreviewFileName1); Param.Write(); } } } catch (Exception ex) { var confirmationStringMessage = LocalizationManager.GetString("ConfigurationToolBL.NoDuplicateStyleName.Message", "Sorry, your recent changes cannot be saved because Pathway cannot find the stylesheet file '{0}'", ""); confirmationStringMessage = string.Format(confirmationStringMessage, ex.Message); var caption = LocalizationManager.GetString("ConfigurationToolBL.MessageBoxCaption.Caption", _caption, ""); Utils.MsgBox(confirmationStringMessage, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } _screenMode = ScreenMode.Edit; }
private void SetWebProperty(XmlNodeList baseNode2, HashUtilities hashUtil) { foreach (XmlNode VARIABLE in baseNode2) { string attribName = VARIABLE.Attributes["name"].Value.ToLower(); string attribValue = VARIABLE.Attributes["value"].Value; switch (attribName) { case "ftpaddress": cTool.TxtFtpAddress.Text = attribValue; break; case "ftpuserid": cTool.TxtFtpUsername.Text = attribValue; break; case "ftppwd": if (attribValue.Trim().Length > 0) { cTool.TxtFtpPassword.Text = hashUtil.Decrypt(attribValue); } break; case "dbservername": cTool.TxtSqlServerName.Text = attribValue; break; case "dbname": cTool.TxtSqlDBName.Text = attribValue; break; case "dbuserid": cTool.TxtSqlUsername.Text = attribValue; break; case "dbpwd": if (attribValue.Trim().Length > 0) { cTool.TxtSqlPassword.Text = hashUtil.Decrypt(attribValue); } break; case "weburl": cTool.TxtWebUrl.Text = attribValue; break; case "webadminusrnme": cTool.TxtWebAdminUsrNme.Text = attribValue; break; case "webadminpwd": if (attribValue.Trim().Length > 0) { cTool.TxtWebAdminPwd.Text = hashUtil.Decrypt(attribValue); } break; case "webadminsitenme": cTool.TxtWebAdminSiteNme.Text = attribValue; break; case "webemailid": cTool.TxtWebEmailId.Text = attribValue; break; case "webftpfldrnme": cTool.TxtWebFtpFldrNme.Text = attribValue; break; case "comment": cTool.TxtComment.Text = attribValue; break; default: break; } } }
/// <summary> /// Fills Values in Display property Tab and Properties Tab /// </summary> protected void ShowCSSValue() { _screenMode = ScreenMode.View; _errProvider.Clear(); if (cTool.TxtName.Text.Length <= 0) return; string path = Param.StylePath(cTool.TxtName.Text); ParseCSS(path, Param.Value["InputType"]); double left = MarginLeft.Length > 0 ? Math.Round(double.Parse(MarginLeft, CultureInfo.GetCultureInfo("en-US")), 0) : 0; cTool.TxtPageInside.Text = left + "pt"; double right = MarginRight.Length > 0 ? Math.Round(double.Parse(MarginRight, CultureInfo.GetCultureInfo("en-US")), 0) : 0; cTool.TxtPageOutside.Text = right + "pt"; double top = MarginTop.Length > 0 ? Math.Round(double.Parse(MarginTop, CultureInfo.GetCultureInfo("en-US")), 0) : 0; cTool.TxtPageTop.Text = top + "pt"; double bottom = MarginBottom.Length > 0 ? Math.Round(double.Parse(MarginBottom, CultureInfo.GetCultureInfo("en-US")), 0) : 0; cTool.TxtPageBottom.Text = bottom + "pt"; cTool.TxtPageGutterWidth.Text = GutterWidth; if (GutterWidth.IndexOf('%') == -1) { if (cTool.TxtPageGutterWidth.Text.Length > 0) cTool.TxtPageGutterWidth.Text = cTool.TxtPageGutterWidth.Text + "pt"; } cTool.DdlPageColumn.SelectedItem = (ComboBoxItem)cTool.DdlPageColumn.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == ColumnCount); cTool.DdlFontSize.SelectedItem = (ComboBoxItem)cTool.DdlFontSize.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == FontSize); cTool.DdlLeading.SelectedItem = (ComboBoxItem)cTool.DdlLeading.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == Leading); cTool.ChkDisableWO.Checked = DisableWidowOrphan; cTool.ChkFixedLineHeight.Checked = FixedLineHeight; cTool.DdlPicture.SelectedItem = (ComboBoxItem)cTool.DdlPicture.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == Picture); cTool.DdlJustified.SelectedItem = (ComboBoxItem)cTool.DdlJustified.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == JustifyUI); cTool.DdlPagePageSize.SelectedItem = (ComboBoxItem)cTool.DdlPagePageSize.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == PageSize); cTool.DdlRunningHead.SelectedItem = (ComboBoxItem)cTool.DdlRunningHead.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == RunningHeader); cTool.DdlHeaderFontSize.SelectedItem = (ComboBoxItem)cTool.DdlHeaderFontSize.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == HeaderFontSize); cTool.ChkSplitFileByLetter.Checked = SplitFileByLetter; cTool.ChkCenterTitleHeader.Checked = CenterTitleHeader; string pageType = GetDdlRunningHead(); DdlRunningHeadSelectedIndexChangedBl(pageType); if (pageType != "None") { cTool.TxtGuidewordLength.Text = GuidewordLength; } SetScriptureValues(); cTool.DdlPageNumber.SelectedItem = (ComboBoxItem)cTool.DdlPageNumber.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == PageNumber); cTool.DdlRules.SelectedItem = (ComboBoxItem)cTool.DdlRules.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == ColumnRule); cTool.DdlSense.SelectedItem = (ComboBoxItem)cTool.DdlSense.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == Sense); cTool.DdlVerticalJustify.SelectedItem = (ComboBoxItem)cTool.DdlVerticalJustify.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == VerticalJustify); try { if (inputTypeBL.ToLower() == "scripture" && MediaType.ToLower() == "mobile") { string filePath = string.Empty; if (File.Exists(Param.SettingOutputPath)) { filePath = Param.SettingOutputPath; } else if (File.Exists(Param.SettingPath)) { filePath = Param.SettingPath; } XmlNodeList baseNode1 = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); ShowMoblieCss(baseNode1); SetMobileSummary(null, null); } else if (MediaType.ToLower() == "others") { XmlNodeList baseNode1 = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); // show/hide epub UI controls based on the input type SetEpubUIControls(inputTypeBL == "Scripture"); ShowOthersCss(baseNode1); SetOthersSummary(null, null); } else if (MediaType.ToLower() == "web") { XmlNodeList baseNode1 = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); HashUtilities hashUtil = new HashUtilities(); hashUtil.Key = "%:#@?,*&"; hashUtil.Salt = "$%^&*#$%"; // show/hide web UI controls based on the input type SetWebUIControls(inputTypeBL == "Dictionary"); ShowWebCss(baseNode1, hashUtil); SetWebSummary(null, null); } else { cTool.DdlFileProduceDict.SelectedItem = (ComboBoxItem)cTool.DdlFileProduceDict.Items.OfType<ComboBoxItem>().SingleOrDefault(s => s.Value == FileProduced); ShowCssSummary(); if (cTool.StylesGrid.RowCount > 0) { cTool.TxtCss.Text = cTool.StylesGrid[ColumnDescription, SelectedRowIndex].Value.ToString(); } } SavePropertyValue(); } catch { } _screenMode = ScreenMode.Edit; }
/// <summary> /// Display the appropriate property tab (mobile, others or paper/web). /// </summary> protected void SetPropertyTab() { if (cTool.TabControl1.TabCount > 1) cTool.TabControl1.TabPages.Remove(cTool.TabControl1.TabPages[1]); if (cTool.TabControl1.TabPages.ContainsKey("tabPreview")) cTool.TabControl1.TabPages.Remove(cTool.TabControl1.TabPages["tabPreview"]); switch (MediaType) { case "mobile": if (inputTypeBL.ToLower() == "dictionary") { cTool.TabControl1.TabPages.Insert(1, tabDict4Mids); return; } cTool.TabControl1.TabPages.Insert(1, tabmob); XmlNodeList baseNode1 = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); SetMobileProperty(baseNode1); SetMobileSummary(null, null); break; case "others": cTool.TabControl1.TabPages.Insert(1, tabothers); cTool.TabControl1.TabPages.Insert(2, tabpreview); XmlNodeList baseNode = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); // show/hide chapter numbers and references UI SetEpubUIControls(inputTypeBL == "Scripture"); SetOthersProperty(baseNode); SetOthersSummary(null, null); break; case "web": HashUtilities hashUtil = new HashUtilities(); hashUtil.Key = "%:#@?,*&"; hashUtil.Salt = "$%^&*#$%"; cTool.TabControl1.TabPages.Insert(1, tabweb); XmlNodeList baseNode2 = Param.GetItems("//styles/" + MediaType + "/style[@name='" + StyleName + "']/styleProperty"); // show/hide chapter numbers and references UI SetEpubUIControls(inputTypeBL == "Scripture"); SetWebProperty(baseNode2, hashUtil); SetWebSummary(null, null); break; default: // web, paper cTool.TabControl1.TabPages.Add(tabDisplay); cTool.TabControl1.TabPages.Add(tabpreview); ShowCssSummary(); break; } if (Common.GetOsName().IndexOf("Windows") >= 0) // Hide Preview if LibreOffice not exist { string regEntryWin7 = Common.GetValueFromRegistry("SOFTWARE\\Wow6432Node\\LibreOffice\\UNO\\InstallPath", ""); string regEntryWinXP = Common.GetValueFromRegistry("SOFTWARE\\LibreOffice\\UNO\\InstallPath", ""); if (regEntryWin7 == null && regEntryWinXP == null) { if (cTool.TabControl1.TabPages.ContainsKey("tabPreview")) cTool.TabControl1.TabPages.Remove(cTool.TabControl1.TabPages["tabPreview"]); } } }
private void SetAttributesForWebProperties(string attribName, XmlNode baseNode, HashUtilities hashUtil) { switch (attribName) { case "ftpaddress": baseNode.Attributes["value"].Value = cTool.TxtFtpAddress.Text; break; case "ftpuserid": baseNode.Attributes["value"].Value = cTool.TxtFtpUsername.Text; break; case "ftppwd": if (cTool.TxtFtpPassword.Text.Trim().Length > 0) { baseNode.Attributes["value"].Value = hashUtil.Encrypt(cTool.TxtFtpPassword.Text); } else { baseNode.Attributes["value"].Value = ""; } break; case "dbservername": baseNode.Attributes["value"].Value = cTool.TxtSqlServerName.Text; break; case "dbname": baseNode.Attributes["value"].Value = cTool.TxtSqlDBName.Text; break; case "dbuserid": baseNode.Attributes["value"].Value = cTool.TxtSqlUsername.Text; break; case "dbpwd": if (cTool.TxtSqlPassword.Text.Trim().Length > 0) { baseNode.Attributes["value"].Value = hashUtil.Encrypt(cTool.TxtSqlPassword.Text); } else { baseNode.Attributes["value"].Value = ""; } break; case "weburl": baseNode.Attributes["value"].Value = cTool.TxtWebUrl.Text; break; case "webadminusrnme": baseNode.Attributes["value"].Value = cTool.TxtWebAdminUsrNme.Text; break; case "webadminpwd": if (cTool.TxtWebAdminPwd.Text.Trim().Length > 0) { baseNode.Attributes["value"].Value = hashUtil.Encrypt(cTool.TxtWebAdminPwd.Text); } else { baseNode.Attributes["value"].Value = ""; } break; case "webadminsitenme": baseNode.Attributes["value"].Value = cTool.TxtWebAdminSiteNme.Text; break; case "webemailid": baseNode.Attributes["value"].Value = cTool.TxtWebEmailId.Text; break; case "webftpfldrnme": baseNode.Attributes["value"].Value = cTool.TxtWebFtpFldrNme.Text; break; case "comment": baseNode.Attributes["value"].Value = cTool.TxtComment.Text; break; default: break; } }