/// <summary> /// It updates Legend settings of oldTheme into NewTheme. /// <para>Following Theme properties are updated: BreakCount(LegendCount), Layer's Visibility, StartColor, EndColor, Theme.Visible, Legend's Color, Decimal, BorderColor, BorderStyle, BorderWidth. /// </para> /// </summary> /// <param name="oldTheme">Old Theme</param> /// <param name="newTheme">New Theme to retain properties of old theme.</param> /// <param name="preserveLegendsRanges">true, if oldtheme's Legend range values to be preserved in new theme as well(applicable to Break based Themes)</param> public void UpdateThemeLegendSettings(Theme oldTheme, Theme newTheme, bool preserveLegendsRanges) { try { if (newTheme != null) { // set Theme's common properties //--Layer's Visibility foreach (object key in oldTheme.LayerVisibility.Keys) { //Theme.LayerVisibility[Key, Value] //Key: LayerID //Value: bool if (newTheme.LayerVisibility.ContainsKey(key)) { newTheme.LayerVisibility[key] = (bool)oldTheme.LayerVisibility[key]; } } newTheme.Visible = oldTheme.Visible; newTheme.BorderColor = oldTheme.BorderColor; newTheme.BorderStyle = oldTheme.BorderStyle; newTheme.BorderWidth = oldTheme.BorderWidth; newTheme.LabelColor = oldTheme.LabelColor; newTheme.LabelFont = oldTheme.LabelFont; newTheme.LabelVisible = oldTheme.LabelVisible; newTheme.LabelField = oldTheme.LabelField; newTheme.LabelMultirow = oldTheme.LabelMultirow; newTheme.LabelIndented = oldTheme.LabelIndented; //-- Legend Settings newTheme.StartColor = oldTheme.StartColor; newTheme.EndColor = oldTheme.EndColor; newTheme.BreakCount = oldTheme.BreakCount; newTheme.BreakType = oldTheme.BreakType; newTheme.Decimals = oldTheme.Decimals; newTheme.LegendBodyColor = oldTheme.LegendBodyColor; newTheme.LegendBodyFont = oldTheme.LegendBodyFont; newTheme.LegendColor = oldTheme.LegendColor; newTheme.LegendFont = oldTheme.LegendFont; newTheme.MultiLegendCriteria = oldTheme.MultiLegendCriteria; newTheme.MultiLegend = oldTheme.MultiLegend; if (newTheme.Type != ThemeType.DotDensity && newTheme.Type != ThemeType.Chart) { newTheme.Legends.Clear(); this.setThemeRange(this.Themes.ItemIndex(newTheme.ID)); //- Preserve OldTheme's Minimum & Maximum values and Legend Ranges, Caption, Title etc. if (preserveLegendsRanges) { newTheme.Maximum = oldTheme.Maximum; newTheme.Minimum = oldTheme.Minimum; for (int i = 0; i < newTheme.Legends.Count; i++) { if (oldTheme.Legends[i] != null) { newTheme.Legends[i].Title = oldTheme.Legends[i].Title; newTheme.Legends[i].Caption = oldTheme.Legends[i].Caption; newTheme.Legends[i].RangeFrom = oldTheme.Legends[i].RangeFrom; newTheme.Legends[i].RangeTo = oldTheme.Legends[i].RangeTo; newTheme.Legends[i].Color = oldTheme.Legends[i].Color; } } newTheme.UpdateLegendBreakCount(); } else { //- update only Legend Colors for (int i = 0; i < newTheme.Legends.Count; i++) { if (oldTheme.Legends[i] != null) { newTheme.Legends[i].Color = oldTheme.Legends[i].Color; } } } } switch (newTheme.Type) { case ThemeType.Symbol: //*** Reset the Symbols legend for (int i = 0; i <= newTheme.Legends.Count - 1; i++) { newTheme.Legends[i].MarkerType = MarkerStyle.Custom; if (i < newTheme.Legends.Count - 1) { newTheme.Legends[i].MarkerFont = new Font("Webdings", 10 + i * 5); newTheme.Legends[i].MarkerSize = 10 + i * 5; } else { newTheme.Legends[i].MarkerFont = new Font("Webdings", 10); newTheme.Legends[i].MarkerSize = 10; newTheme.Legends[i].Color = Color.FromArgb(128, newTheme.MissingColor); } newTheme.Legends[i].MarkerChar = Strings.Chr(110); } break; case ThemeType.Label: //*** Reset the legend Font fnt = new Font("Arial", 8); for (int i = 0; i <= newTheme.Legends.Count - 1; i++) { newTheme.Legends[i].MarkerFont = fnt; } break; } } } catch { } }
/// <summary> /// It compares two themes and updates properties of oldTheme into NewTheme. /// <para>Following Theme properties are updated: BreakCount(LegendCount), Layer's Visibility, StartColor, EndColor, Theme.Visible, Legend's Color, Decimal, BorderColor, BorderStyle, BorderWidth, DotColor, DotFont, DotSize, LabelColor, LabelFont, LabelVisible. /// </para> /// </summary> /// <param name="oldTheme">Old Theme</param> /// <param name="newTheme">New Theme to retain properties of old theme.</param> /// <param name="preserveRoundingDecimals">true, if oldtheme's rounding Decmial to be preserved in new theme as well(applicable to Break based Themes)</param> private void UpdateThemeProperties(Theme oldTheme, Theme newTheme, bool preserveLegendsRanges, bool preserveRoundingDecimals) { IDictionaryEnumerator dicEnumerator = null; try { if (newTheme != null) { // set Theme's common properties foreach (object key in oldTheme.LayerVisibility.Keys) { if (newTheme.LayerVisibility.ContainsKey(key)) { newTheme.LayerVisibility[key] = (bool)oldTheme.LayerVisibility[key]; } } //-- Set Theme Name if (string.IsNullOrEmpty(newTheme.Name)) { if (newTheme.IndicatorName[0] == oldTheme.IndicatorName[0]) { newTheme.Name = oldTheme.Name; } else { if (newTheme.Type == ThemeType.Chart) { newTheme.Name = newTheme.IndicatorName[0] + " - " + newTheme.UnitName[0] + " - " + newTheme.SubgroupName[0]; } else { newTheme.Name = newTheme.IndicatorName[0] + " - " + newTheme.UnitName[0]; } } } newTheme.Visible = oldTheme.Visible; newTheme.BorderColor = oldTheme.BorderColor; newTheme.BorderStyle = oldTheme.BorderStyle; newTheme.BorderWidth = oldTheme.BorderWidth; newTheme.LabelColor = oldTheme.LabelColor; newTheme.LabelFont = oldTheme.LabelFont; newTheme.LabelVisible = oldTheme.LabelVisible; newTheme.LabelField = oldTheme.LabelField; newTheme.LabelMultirow = oldTheme.LabelMultirow; newTheme.LabelIndented = oldTheme.LabelIndented; //-- Set each Layer's Label visible properties foreach (Layer layer in this.Layers) { if (oldTheme.LabelVisible) { layer.LabelVisible = oldTheme.LabelVisible; } //- If new Layers are added in collection (i.e case of Area Replication) // then apply preserved Theme's Label Settings if (oldTheme.LayerVisibility.ContainsKey(layer.ID) == false) { layer.LabelField = oldTheme.LabelField; layer.LabelMultirow = oldTheme.LabelMultirow; layer.LabelIndented = oldTheme.LabelIndented; //////** Label Font layer.LabelFont = oldTheme.LabelFont; layer.LabelColor = oldTheme.LabelColor; } } //--Layer's Visibility dicEnumerator = oldTheme.LayerVisibility.GetEnumerator(); while (dicEnumerator.MoveNext()) { //Theme.LayerVisibility[Key, Value] //Key: LayerID //Value: bool if (newTheme.LayerVisibility.ContainsKey(dicEnumerator.Key)) { newTheme.LayerVisibility[dicEnumerator.Key] = oldTheme.LayerVisibility[dicEnumerator.Key]; } } //-- Legend Settings newTheme.StartColor = oldTheme.StartColor; newTheme.EndColor = oldTheme.EndColor; newTheme.BreakCount = oldTheme.BreakCount; newTheme.BreakType = oldTheme.BreakType; if (preserveRoundingDecimals) { newTheme.Decimals = oldTheme.Decimals; } newTheme.LegendBodyColor = oldTheme.LegendBodyColor; newTheme.LegendBodyFont = oldTheme.LegendBodyFont; newTheme.LegendColor = oldTheme.LegendColor; newTheme.LegendFont = oldTheme.LegendFont; newTheme.MultiLegendCriteria = oldTheme.MultiLegendCriteria; newTheme.MultiLegend = oldTheme.MultiLegend; if (newTheme.Type != ThemeType.DotDensity && newTheme.Type != ThemeType.Chart) { newTheme.Legends.Clear(); this.setThemeRange(this.Themes.ItemIndex(newTheme.ID)); //- Preserve OldTheme's Minimum & Maximum values and Legend Ranges, Caption, Title etc. if (preserveLegendsRanges) { newTheme.Maximum = oldTheme.Maximum; newTheme.Minimum = oldTheme.Minimum; for (int i = 0; i < newTheme.Legends.Count; i++) { if (oldTheme.Legends[i] != null) { newTheme.Legends[i].Title = oldTheme.Legends[i].Title; newTheme.Legends[i].Caption = oldTheme.Legends[i].Caption; newTheme.Legends[i].RangeFrom = oldTheme.Legends[i].RangeFrom; newTheme.Legends[i].RangeTo = oldTheme.Legends[i].RangeTo; } } newTheme.UpdateLegendBreakCount(); } } //-Set Legend Title only if OldTReme's IUS is same as NewTheme's IUS if (newTheme.I_U_S_GIDs.Length == oldTheme.I_U_S_GIDs.Length) { if (newTheme.I_U_S_GIDs[0] == oldTheme.I_U_S_GIDs[0] && newTheme.I_U_S_GIDs[0] == oldTheme.I_U_S_GIDs[0] && newTheme.I_U_S_GIDs[0] == oldTheme.I_U_S_GIDs[0]) { newTheme.LegendTitle = oldTheme.LegendTitle; } } //-- set Theme Type specific properties switch (oldTheme.Type) { case ThemeType.Color: // set Legend Colors for (int i = 0; i < newTheme.Legends.Count; i++) { if (oldTheme.Legends[i] != null) { newTheme.Legends[i].Color = oldTheme.Legends[i].Color; } } //MultiLegends TODO confirm if (oldTheme.MultiLegend == true) { newTheme.MultiLegend = oldTheme.MultiLegend; newTheme.MultiLegendCriteria = oldTheme.MultiLegendCriteria; newTheme.MultiLegendCol.Clear(); foreach (object m_Keys in oldTheme.MultiLegendCol.Keys) { newTheme.MultiLegendCol.Add(m_Keys, oldTheme.MultiLegendCol[m_Keys]); } } break; case ThemeType.DotDensity: newTheme.DotColor = oldTheme.DotColor; newTheme.DotFont = oldTheme.DotFont; newTheme.DotSize = oldTheme.DotSize; newTheme.DotChar = oldTheme.DotChar; newTheme.DotStyle = oldTheme.DotStyle; newTheme.DotValue = oldTheme.DotValue; break; case ThemeType.Chart: newTheme.Name = oldTheme.Name; newTheme.ChartLeaderColor = oldTheme.ChartLeaderColor; newTheme.ChartLeaderStyle = oldTheme.ChartLeaderStyle; newTheme.ChartLeaderVisible = oldTheme.ChartLeaderVisible; newTheme.ChartLeaderWidth = oldTheme.ChartLeaderWidth; newTheme.RoundDecimals = oldTheme.RoundDecimals; newTheme.ColumnsGap = oldTheme.ColumnsGap; newTheme.ShowChartAxis = oldTheme.ShowChartAxis; newTheme.ChartSize = oldTheme.ChartSize; newTheme.ChartType = oldTheme.ChartType; newTheme.ChartWidth = oldTheme.ChartWidth; newTheme.DisplayChartData = oldTheme.DisplayChartData; newTheme.ChartSeriestype = oldTheme.ChartSeriestype; newTheme.DisplayChartMRD = oldTheme.DisplayChartMRD; newTheme.PieAutoSize = oldTheme.PieAutoSize; newTheme.PieSize = oldTheme.PieSize; newTheme.PieAutoSizeFactor = oldTheme.PieAutoSizeFactor; newTheme.ChartLineThickness = oldTheme.ChartLineThickness; newTheme.ChartAxisLabelSettings = oldTheme.ChartAxisLabelSettings; newTheme.ChartDataLabelSettings = oldTheme.ChartDataLabelSettings; newTheme.ExcludeAreaIDs = oldTheme.ExcludeAreaIDs; if (newTheme.SubgroupNId.Length == oldTheme.SubgroupNId.Length) { newTheme.SubgroupVisible = oldTheme.SubgroupVisible; newTheme.SubgroupFillStyle = oldTheme.SubgroupFillStyle; } if (newTheme.SourceNIds != null && oldTheme.SourceNIds != null) { if (newTheme.SourceNIds.Length == oldTheme.SourceNIds.Length) { newTheme.SourceVisible = oldTheme.SourceVisible; } } for (int i = 0; i < Math.Min(newTheme.ChartTimePeriods.Count, oldTheme.ChartTimePeriods.Count); i++) { string timePeriodKey = oldTheme.ChartTimePeriods.Keys[i]; if (oldTheme.ChartTimePeriods.ContainsKey(timePeriodKey)) { newTheme.ChartTimePeriods[timePeriodKey] = oldTheme.ChartTimePeriods[timePeriodKey]; } } foreach (object key in oldTheme.ModifiedCharts.Keys) { if (newTheme.ModifiedCharts.ContainsKey(key) == false) { newTheme.ModifiedCharts.Add(key, oldTheme.ModifiedCharts[key]); } } break; case ThemeType.Hatch: for (int i = 0; i < newTheme.Legends.Count; i++) { newTheme.Legends[i].Color = oldTheme.Legends[i].Color; newTheme.Legends[i].FillStyle = oldTheme.Legends[i].FillStyle; } break; case ThemeType.Symbol: // set Legend Symbols for (int i = 0; i < newTheme.Legends.Count; i++) { if (oldTheme.Legends[i] != null) { newTheme.Legends[i].Color = oldTheme.Legends[i].Color; newTheme.Legends[i].SymbolImage = oldTheme.Legends[i].SymbolImage; newTheme.Legends[i].MarkerType = oldTheme.Legends[i].MarkerType; newTheme.Legends[i].MarkerSize = oldTheme.Legends[i].MarkerSize; newTheme.Legends[i].MarkerFont = oldTheme.Legends[i].MarkerFont; newTheme.Legends[i].MarkerChar = oldTheme.Legends[i].MarkerChar; } } newTheme.X_Offset = oldTheme.X_Offset; newTheme.Y_Offset = oldTheme.Y_Offset; break; case ThemeType.Label: newTheme.LabelField = oldTheme.LabelField; for (int i = 0; i < newTheme.Legends.Count; i++) { if (oldTheme.Legends[i] != null) { newTheme.Legends[i].Color = oldTheme.Legends[i].Color; newTheme.Legends[i].MarkerFont = oldTheme.Legends[i].MarkerFont; } } newTheme.X_Offset = oldTheme.X_Offset; newTheme.Y_Offset = oldTheme.Y_Offset; break; default: break; } } } catch { } }