/// <summary> /// Saves collection of series into database /// </summary> /// <param name="series">Collection of series</param> /// <param name="theme">The theme associated with data series</param> /// <param name="overwriteOption">Option to how save series</param> /// <returns>The number of saved data values</returns> public int SaveDataSeries(IEnumerable <Series> series, Theme theme, OverwriteOptions overwriteOption) { var result = 0; var enumerator = series.GetEnumerator(); while (enumerator.MoveNext()) { result += SaveDataSeries(enumerator.Current, theme, overwriteOption); } return(result); }
/// <summary> /// Creates a new DataSeries from a xml file and saves it to database. /// This function uses the underlying NHibernate framework to /// communicate with the database /// </summary> /// <param name="series">The data series to be saved</param> /// <param name="theme">The theme associated with this data series</param> /// <param name="overwriteOption">Option to how save series</param> /// <returns>The number of saved data values</returns> /// <exception cref="SaveDataSeriesException">Something wrong during SaveDataSeries</exception> private int SaveDataSeries(Series series, Theme theme, OverwriteOptions overwriteOption) { if (series.GetValueCount() == 0) { return(0); } try { return(_repositoryManager.SaveSeries(series, theme, overwriteOption)); } catch (Exception ex) { throw new SaveDataSeriesException(ex.Message, ex); } }
public MainViewModel(IMainModel model , IIOServices ioServices , IUIServices uiServices , IWindowFactory windowFactory) { Model = model; IOServices = ioServices; UIServices = uiServices; WindowFactory = windowFactory; m_TaskIsRunning = false; m_SelectedOverwriteOption = OverwriteOptions.First(); RemainingTimeCalculator = new RemainingTimeCalculator(); WindowsProgressBarHandler = new WindowsProgressBarHandler(); Synchronizer = new Synchronizer(Application.Current.Dispatcher); ReadLastRecentFile(); }
/// <summary> /// Whether to download the file or not /// </summary> /// <param name="strLocalFile"></param> /// <param name="strRemoteFile"></param> /// <param name="FileD"></param> /// <param name="Overwrite"></param> /// <returns></returns> public static bool DownloadFile(string strLocalFile, string strRemoteFile,RemoteFile FileD, OverwriteOptions Overwrite) { bool blOverwriteFile = false; bool blFileFound = false; if (File.Exists(strLocalFile) || File.Exists(strLocalFile + ".7z")) { blFileFound = true; FileInfo fileL; if (File.Exists(strLocalFile)) { fileL = new FileInfo(strLocalFile); } else { fileL = new FileInfo(strLocalFile + ".7z"); } if (fileL.Length != FileD.Length) { blOverwriteFile = true; } } return ((blFileFound == false || blOverwriteFile || (Overwrite == OverwriteOptions.ForceOverwrite && blFileFound)) && !(Overwrite == OverwriteOptions.NoOverwrite && blFileFound == true)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Read the paragraph properties from the XML node and set the properties in the given /// props builder. /// </summary> /// <param name="styleName">Name of style being created/updated (for error reporting) /// </param> /// <param name="styleTag">XML node that has the paragraph properties</param> /// <param name="setIntProp">the delegate to set each int property</param> /// <param name="options">Indicates which properties to overwrite.</param> /// ------------------------------------------------------------------------------------ private void SetParagraphProperties(string styleName, XmlNode styleTag, Action<int, int, int> setIntProp, OverwriteOptions options) { XmlNode node = styleTag.SelectSingleNode("paragraph"); if (node == null) { ReportInvalidInstallation(String.Format( FrameworkStrings.ksMissingParagraphNode, styleName, ResourceFileName)); } XmlAttributeCollection paraAttributes = node.Attributes; node = paraAttributes.GetNamedItem("keepWithNext"); if (node != null) { setIntProp((int)FwTextPropType.ktptKeepWithNext, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(paraAttributes, "keepWithNext", styleName, ResourceFileName) ? (int)FwTextToggleVal.kttvForceOn : (int)FwTextToggleVal.kttvOff); } node = paraAttributes.GetNamedItem("keepTogether"); if (node != null) { setIntProp((int)FwTextPropType.ktptKeepTogether, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(paraAttributes, "keepTogether", styleName, ResourceFileName) ? (int)FwTextToggleVal.kttvForceOn : (int)FwTextToggleVal.kttvOff); } node = paraAttributes.GetNamedItem("widowOrphan"); if (node != null) { setIntProp((int)FwTextPropType.ktptWidowOrphanControl, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(paraAttributes, "widowOrphan", styleName, ResourceFileName) ? (int)FwTextToggleVal.kttvForceOn : (int)FwTextToggleVal.kttvOff); } if (options == OverwriteOptions.FunctionalPropertiesOnly) return; // Set alignment node = paraAttributes.GetNamedItem("alignment"); if (node != null) { string sAlign = node.Value; int nAlign = (int)FwTextAlign.ktalLeading; switch (sAlign) { case "left": break; case "center": nAlign = (int)FwTextAlign.ktalCenter; break; case "right": nAlign = (int)FwTextAlign.ktalTrailing; break; case "full": nAlign = (int)FwTextAlign.ktalJustify; break; default: ReportInvalidInstallation(String.Format( FrameworkStrings.ksUnknownAlignmentValue, styleName, ResourceFileName)); break; } setIntProp((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, nAlign); } node = paraAttributes.GetNamedItem("background"); if (node != null && node.Value != "white") ReportInvalidInstallation(String.Format( FrameworkStrings.ksUnknownBackgroundValue, styleName, ResourceFileName)); // set leading indentation node = paraAttributes.GetNamedItem("indentLeft"); if (node != null) { int nLeftIndent = InterpretMeasurementAttribute(node.Value, "indentLeft", styleName, ResourceFileName); setIntProp( (int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, nLeftIndent); } // Set trailing indentation node = paraAttributes.GetNamedItem("indentRight"); if (node != null) { int nRightIndent = InterpretMeasurementAttribute(node.Value, "indentRight", styleName, ResourceFileName); setIntProp( (int)FwTextPropType.ktptTrailingIndent, (int)FwTextPropVar.ktpvMilliPoint, nRightIndent); } // Set first-line/hanging indentation int nFirstIndent = 0; bool fFirstLineOrHangingIndentSpecified = false; node = paraAttributes.GetNamedItem("firstLine"); if (node != null) { nFirstIndent = InterpretMeasurementAttribute(node.Value, "firstLine", styleName, ResourceFileName); fFirstLineOrHangingIndentSpecified = true; } int nHangingIndent = 0; node = paraAttributes.GetNamedItem("hanging"); if (node != null) { nHangingIndent = InterpretMeasurementAttribute(node.Value, "hanging", styleName, ResourceFileName); fFirstLineOrHangingIndentSpecified = true; } if (nFirstIndent != 0 && nHangingIndent != 0) ReportInvalidInstallation(String.Format( FrameworkStrings.ksInvalidFirstLineHanging, styleName, ResourceFileName)); nFirstIndent -= nHangingIndent; if (fFirstLineOrHangingIndentSpecified) { setIntProp( (int)FwTextPropType.ktptFirstIndent, (int)FwTextPropVar.ktpvMilliPoint, nFirstIndent); } // Set space before node = paraAttributes.GetNamedItem("spaceBefore"); if (node != null) { int nSpaceBefore = InterpretMeasurementAttribute(node.Value, "spaceBefore", styleName, ResourceFileName); setIntProp( (int)FwTextPropType.ktptSpaceBefore, (int)FwTextPropVar.ktpvMilliPoint, nSpaceBefore); } // Set space after node = paraAttributes.GetNamedItem("spaceAfter"); if (node != null) { int nSpaceAfter = InterpretMeasurementAttribute(node.Value, "spaceAfter", styleName, ResourceFileName); setIntProp( (int)FwTextPropType.ktptSpaceAfter, (int)FwTextPropVar.ktpvMilliPoint, nSpaceAfter); } // Set lineSpacing node = paraAttributes.GetNamedItem("lineSpacingType"); string sLineSpacingType = ""; if (node != null) { sLineSpacingType = node.Value; switch (sLineSpacingType) { //verify valid line spacing types case "atleast": break; case "exact": break; default: ReportInvalidInstallation(String.Format( FrameworkStrings.ksUnknownLineSpacingValue, styleName, ResourceFileName)); break; } } node = paraAttributes.GetNamedItem("lineSpacing"); if (node != null) { int lineSpacing = InterpretMeasurementAttribute(node.Value, "lineSpacing", styleName, ResourceFileName); if (lineSpacing < 0) { ReportInvalidInstallation(String.Format( FrameworkStrings.ksNegativeLineSpacing, styleName, ResourceFileName)); } if(sLineSpacingType == "exact") { lineSpacing *= -1; // negative lineSpacing indicates exact line spacing } setIntProp( (int)FwTextPropType.ktptLineHeight, (int)FwTextPropVar.ktpvMilliPoint, lineSpacing); } // Set borders node = paraAttributes.GetNamedItem("border"); if (node != null) { int nBorder = 0; switch (node.Value) { case "top": nBorder = (int)FwTextPropType.ktptBorderTop; break; case "bottom": nBorder = (int)FwTextPropType.ktptBorderBottom; break; case "leading": nBorder = (int)FwTextPropType.ktptBorderLeading; break; case "trailing": nBorder = (int)FwTextPropType.ktptBorderTrailing; break; default: ReportInvalidInstallation(String.Format( FrameworkStrings.ksUnknownBorderValue, styleName, ResourceFileName)); break; } setIntProp(nBorder, (int)FwTextPropVar.ktpvDefault, 500); } node = paraAttributes.GetNamedItem("bulNumScheme"); if (node != null) { setIntProp((int)FwTextPropType.ktptBulNumScheme, (int)FwTextPropVar.ktpvEnum, InterpretBulNumSchemeAttribute(node.Value, styleName, ResourceFileName)); } node = paraAttributes.GetNamedItem("bulNumStartAt"); if (node != null) { int nVal; if (!Int32.TryParse(node.Value, out nVal)) { ReportInvalidInstallation(String.Format(FrameworkStrings.ksUnknownBulNumStartAtValue, styleName, ResourceFileName)); nVal = 0; } setIntProp((int)FwTextPropType.ktptBulNumStartAt, (int)FwTextPropVar.ktpvDefault, nVal); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Read the font properties from the XML node and set the properties in the given /// props builder. /// </summary> /// <param name="styleName">Name of style being created/updated (for error reporting)</param> /// <param name="styleTag">XML node that has the font properties</param> /// <param name="setIntProp">the delegate to set each int property</param> /// <param name="setStrProp">the delegate to set each string property</param> /// <param name="options">Indicates which properties to overwrite.</param> /// ------------------------------------------------------------------------------------ private void SetFontProperties(string styleName, XmlNode styleTag, Action<int, int, int> setIntProp, Action<int, string> setStrProp, OverwriteOptions options) { // Get character properties var fontNode = styleTag.SelectSingleNode("font"); XmlAttributeCollection fontAttributes = fontNode.Attributes; XmlNode attr = fontAttributes.GetNamedItem("spellcheck"); bool fSpellcheck = (attr == null ? true : (attr.Value == "true")); // The default is to do normal spell-checking, so we only need to set this property // if we want to suppress spell-checking or if we're forcing an existing // user-modified style to have the correct value. if (!fSpellcheck || options == OverwriteOptions.FunctionalPropertiesOnly) { setIntProp((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)(fSpellcheck ? SpellingModes.ksmNormalCheck : SpellingModes.ksmDoNotCheck)); } if (options == OverwriteOptions.FunctionalPropertiesOnly) return; attr = fontAttributes.GetNamedItem("italic"); if (attr != null) { setIntProp((int)FwTextPropType.ktptItalic, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(fontAttributes, "italic", styleName, ResourceFileName) ? (int)FwTextToggleVal.kttvInvert : (int)FwTextToggleVal.kttvOff); } attr = fontAttributes.GetNamedItem("bold"); if (attr != null) { setIntProp((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(fontAttributes, "bold", styleName, ResourceFileName) ? (int)FwTextToggleVal.kttvInvert : (int)FwTextToggleVal.kttvOff); } // superscript and subscript should be considered mutually exclusive. // Results of setting one to true and the other to false may not be intuitive. attr = fontAttributes.GetNamedItem("superscript"); if (attr != null) { setIntProp((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(fontAttributes, "superscript", styleName, ResourceFileName) ? (int)FwSuperscriptVal.kssvSuper : (int)FwSuperscriptVal.kssvOff); } attr = fontAttributes.GetNamedItem("subscript"); if (attr != null) { setIntProp((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, GetBoolAttribute(fontAttributes, "subscript", styleName, ResourceFileName) ? (int)FwSuperscriptVal.kssvSub : (int)FwSuperscriptVal.kssvOff); } attr = fontAttributes.GetNamedItem("size"); if (attr != null) { int nSize = InterpretMeasurementAttribute(attr.Value, "size", styleName, ResourceFileName); setIntProp((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, nSize); } attr = fontAttributes.GetNamedItem("color"); string sColor = (attr == null ? "default" : attr.Value); if (sColor != "default") { setIntProp((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, ColorVal(sColor, styleName)); } attr = fontAttributes.GetNamedItem("underlineColor"); sColor = (attr == null ? "default" : attr.Value); if (sColor != "default") { setIntProp((int)FwTextPropType.ktptUnderColor, (int)FwTextPropVar.ktpvDefault, ColorVal(sColor, styleName)); } attr = fontAttributes.GetNamedItem("underline"); string sUnderline = (attr == null) ? null : attr.Value; if (sUnderline != null) { int unt = InterpretUnderlineType(sUnderline); setIntProp((int)FwTextPropType.ktptUnderline, (int)FwTextPropVar.ktpvEnum, unt); } var overrides = new Dictionary<int, FontInfo>(); foreach (XmlNode child in fontNode.ChildNodes) { if (child.Name == "override") // skip comments { int wsId = GetWs(child.Attributes); if (wsId == 0) continue; // WS not in use in this project? string family = XmlUtils.GetOptionalAttributeValue(child, "family"); string sizeText = XmlUtils.GetOptionalAttributeValue(child, "size"); var fontInfo = new FontInfo(); if (family != null) { fontInfo.m_fontName = new InheritableStyleProp<string>(family); } if (sizeText != null) { int nSize = InterpretMeasurementAttribute(sizeText, "override.size", styleName, ResourceFileName); fontInfo.m_fontSize = new InheritableStyleProp<int>(nSize); } overrides[wsId] = fontInfo; } } if (overrides.Count > 0) setStrProp((int)FwTextPropType.ktptWsStyle, StyleInfo.GetOverridesString(overrides)); // TODO: Handle dropcap attribute }