Example #1
0
 public static void Compare(IStyleSet savedDesign, IStyleSet loadedDesign, int version)
 {
     foreach (ICapStyle savedStyle in savedDesign.CapStyles)
     {
         ICapStyle loadedStyle = loadedDesign.CapStyles[savedStyle.Name];
         Compare(savedStyle, loadedStyle, version);
     }
     foreach (ICharacterStyle savedStyle in savedDesign.CharacterStyles)
     {
         ICharacterStyle loadedStyle = loadedDesign.CharacterStyles[savedStyle.Name];
         Compare(savedStyle, loadedStyle, version);
     }
     foreach (IColorStyle savedStyle in savedDesign.ColorStyles)
     {
         IColorStyle loadedStyle = loadedDesign.ColorStyles[savedStyle.Name];
         Compare(savedStyle, loadedStyle, version);
     }
     foreach (IFillStyle savedStyle in savedDesign.FillStyles)
     {
         IFillStyle loadedStyle = loadedDesign.FillStyles[savedStyle.Name];
         Compare(savedStyle, loadedStyle, version);
     }
     foreach (ILineStyle savedStyle in savedDesign.LineStyles)
     {
         ILineStyle loadedStyle = loadedDesign.LineStyles[savedStyle.Name];
         Compare(savedStyle, loadedStyle, version);
     }
     foreach (IParagraphStyle savedStyle in savedDesign.ParagraphStyles)
     {
         IParagraphStyle loadedStyle = loadedDesign.ParagraphStyles[savedStyle.Name];
         Compare(savedStyle, loadedStyle, version);
     }
 }
Example #2
0
 public static void Compare(IStyleSet designA, IStyleSet designB, int version)
 {
     foreach (ICapStyle styleA in designA.CapStyles)
     {
         ICapStyle styleB = designB.CapStyles[styleA.Name];
         Compare(styleA, styleB, version);
     }
     foreach (ICharacterStyle styleA in designA.CharacterStyles)
     {
         ICharacterStyle styleB = designB.CharacterStyles[styleA.Name];
         Compare(styleA, styleB, version);
     }
     foreach (IColorStyle styleA in designA.ColorStyles)
     {
         IColorStyle styleB = designB.ColorStyles[styleA.Name];
         Compare(styleA, styleB, version);
     }
     foreach (IFillStyle styleA in designA.FillStyles)
     {
         IFillStyle styleB = designB.FillStyles[styleA.Name];
         Compare(styleA, styleB, version);
     }
     foreach (ILineStyle styleA in designA.LineStyles)
     {
         ILineStyle styleB = designB.LineStyles[styleA.Name];
         Compare(styleA, styleB, version);
     }
     foreach (IParagraphStyle styleA in designA.ParagraphStyles)
     {
         IParagraphStyle styleB = designB.ParagraphStyles[styleA.Name];
         Compare(styleA, styleB, version);
     }
 }
        private void ceh_BindingMetrixSyleEvent(Report report)
        {
            ColorStyleHandler csh = new ColorStyleHandler();
            IColorStyle       cs  = ReportFontColorHelper.GetColorStyle(ClientReportContext.Login.UfMetaCnnString, report.ColorStyleID);

            csh.ApplyColorStyle(report, cs);
        }
Example #4
0
        private void CreateLineStyles()
        {
            // Create custom line styles
            for (int j = 1; j <= 5; ++j)
            {
                for (int i = 1; i <= 10; ++i)
                {
                    string      name       = string.Empty;
                    IColorStyle colorStyle = null;
                    DashType    dashType   = DashType.Solid;
                    switch (j)
                    {
                    case 1:
                        name       = styleNameVeryPoor;
                        colorStyle = project.Design.ColorStyles.Gray;
                        dashType   = DashType.Dot;
                        break;

                    case 2:
                        name       = styleNamePoor;
                        colorStyle = project.Design.ColorStyles.Gray;
                        dashType   = DashType.Dash;
                        break;

                    case 3:
                        name       = styleNameNormal;
                        colorStyle = project.Design.ColorStyles.Black;
                        dashType   = DashType.Solid;
                        break;

                    case 4:
                        name       = styleNameGood;
                        colorStyle = project.Design.ColorStyles.Black;
                        dashType   = DashType.Solid;
                        break;

                    case 5:
                        name       = styleNameExcellent;
                        colorStyle = project.Design.ColorStyles.Black;
                        dashType   = DashType.Solid;
                        break;

                    default: Debug.Fail(""); break;
                    }
                    LineStyle lineStyle = new LineStyle(string.Format("{0} {1}0%", name, i));
                    lineStyle.LineWidth  = Math.Max(1, j / 2);
                    lineStyle.ColorStyle = colorStyle;
                    lineStyle.DashType   = dashType;

                    // Add the new line style to the current design (make it usable in shapes)
                    project.Design.AddStyle(lineStyle);
                    // Add the new line style to the repository (otherwise it won't be saved)
                    project.Repository.Insert(project.Design, lineStyle);
                }
            }
        }
Example #5
0
 public static void Compare(IColorStyle styleA, IColorStyle styleB, int version)
 {
     if (styleA == ColorStyle.Empty && styleB == ColorStyle.Empty)
     {
         return;
     }
     CompareBaseStyle(styleA, styleB, version);
     Assert.AreEqual <int>(styleA.Color.ToArgb(), styleB.Color.ToArgb());
     if (version >= 3)
     {
         Assert.AreEqual <bool>(styleA.ConvertToGray, styleB.ConvertToGray);
     }
     Assert.AreEqual <byte>(styleA.Transparency, styleB.Transparency);
 }
Example #6
0
 public static void Compare(IColorStyle savedStyle, IColorStyle loadedStyle, int version)
 {
     if (savedStyle == ColorStyle.Empty && loadedStyle == ColorStyle.Empty)
     {
         return;
     }
     CompareBaseStyle(savedStyle, loadedStyle, version);
     Assert.AreEqual <int>(savedStyle.Color.ToArgb(), loadedStyle.Color.ToArgb());
     if (version > 2)
     {
         Assert.AreEqual <bool>(savedStyle.ConvertToGray, loadedStyle.ConvertToGray);
     }
     Assert.AreEqual <byte>(savedStyle.Transparency, loadedStyle.Transparency);
 }
Example #7
0
        private void CreateLineStyles()
        {
            // Create Line Styles
            for (int j = 1; j <= 5; ++j)
            {
                for (int i = 1; i <= 10; ++i)
                {
                    string      name       = string.Empty;
                    IColorStyle colorStyle = null;
                    switch (j)
                    {
                    case 1:
                        name       = "Very poor";
                        colorStyle = project.Design.ColorStyles.Gray;
                        break;

                    case 2:
                        name       = "Poor";
                        colorStyle = project.Design.ColorStyles.Black;
                        break;

                    case 3:
                        name       = "Normal";
                        colorStyle = project.Design.ColorStyles.Green;
                        break;

                    case 4:
                        name       = "Good";
                        colorStyle = project.Design.ColorStyles.Blue;
                        break;

                    case 5:
                        name       = "Excellent";
                        colorStyle = project.Design.ColorStyles.Highlight;
                        break;

                    default: Debug.Fail(""); break;
                    }
                    LineStyle lineStyle = new LineStyle(string.Format("{0} {1}0%", name, i));
                    lineStyle.LineWidth  = i;
                    lineStyle.ColorStyle = colorStyle;
                    project.Design.AddStyle(lineStyle);
                    project.Repository.InsertStyle(project.Design, lineStyle);
                }
            }
        }
Example #8
0
        /// <summary>
        /// Creates a solid color brush from the given <see cref="T:Dataweb.NShape.IColorStyle"/>.
        /// </summary>
        public static Brush GetBrush(IColorStyle colorStyle)
        {
            if (colorStyle == null)
            {
                throw new ArgumentNullException("colorStyle");
            }

            SolidBrush brush = null;

            if (!_solidBrushCache.TryGetValue(colorStyle, out brush))
            {
                brush = new SolidBrush(GetColor(colorStyle, colorStyle.ConvertToGray));
                // Add created brush to the BrushCache
                _solidBrushCache.Add(colorStyle, brush);
            }
            return(brush);
        }
Example #9
0
 /// <summary>
 /// Creates a solid color brush from the given <see cref="T:Dataweb.NShape.IColorStyle"/> or <see cref="T:Dataweb.NShape.ILineStyle"/>.
 /// If the color style is ColorStyle.Empty, the line style's color style is used.
 /// </summary>
 public static Brush GetBrush(IColorStyle colorStyle, ILineStyle lineStyle)
 {
     if (colorStyle == null)
     {
         throw new ArgumentNullException("colorStyle");
     }
     if (lineStyle == null)
     {
         throw new ArgumentNullException("lineStyle");
     }
     if (colorStyle == ColorStyle.Empty)
     {
         return(GetBrush(lineStyle.ColorStyle));
     }
     else
     {
         return(GetBrush(colorStyle));
     }
 }
Example #10
0
        private static Color GetColor(IColorStyle colorStyle, bool convertToGray)
        {
            Debug.Assert(colorStyle != null);

            if (convertToGray)
            {
                int luminance = 0;
                luminance += (byte)Math.Round(colorStyle.Color.R * luminanceFactorRed);
                luminance += (byte)Math.Round(colorStyle.Color.G * luminanceFactorGreen);
                luminance += (byte)Math.Round(colorStyle.Color.B * luminanceFactorBlue);
                if (luminance > 255)
                {
                    luminance = 255;
                }
                return(Color.FromArgb(colorStyle.Color.A, luminance, luminance, luminance));
            }
            else
            {
                return((colorStyle != null) ? colorStyle.Color : Color.Empty);
            }
        }
Example #11
0
		/// <ToBeCompleted></ToBeCompleted>
		public static Brush GetBrush(IColorStyle colorStyle, ILineStyle lineStyle) {
			if (colorStyle == null) throw new ArgumentNullException("colorStyle");
			if (lineStyle == null) throw new ArgumentNullException("lineStyle");
			if (colorStyle == ColorStyle.Empty)
				return GetBrush(lineStyle.ColorStyle);
			else return GetBrush(colorStyle);
		}
Example #12
0
		private void DrawStyleItem(Graphics gfx, Rectangle previewBounds, IColorStyle colorStyle) {
			Brush brush = ToolCache.GetBrush(colorStyle);
			gfx.FillRectangle(brush, previewBounds);
		}
Example #13
0
        private void DrawStyleItem(Graphics gfx, Rectangle previewBounds, IColorStyle colorStyle)
        {
            Brush brush = ToolCache.GetBrush(colorStyle);

            gfx.FillRectangle(brush, previewBounds);
        }
Example #14
0
        /// <summary>
        /// Deletes all tools based on the given ColorStyle.
        /// </summary>
        private static void NotifyColorStyleChanged(IColorStyle colorStyle)
        {
            Debug.Assert(colorStyle != null);

            // Dispose affected SolidBrushes
            while (_solidBrushCache.ContainsKey(colorStyle))
            {
                Brush brush = _solidBrushCache[colorStyle];
                _solidBrushCache.Remove(colorStyle);
                brush.Dispose();
                brush = null;
            }

            // Collect affected Brushes
            List <IFillStyle> fillStyles = new List <IFillStyle>();

            foreach (KeyValuePair <BrushKey, Brush> item in _brushCache)
            {
                if (item.Key.FillStyle != null &&
                    item.Key.FillStyle.FillMode != FillMode.Image &&
                    (item.Key.FillStyle.AdditionalColorStyle == colorStyle || item.Key.FillStyle.BaseColorStyle == colorStyle))
                {
                    fillStyles.Add(item.Key.FillStyle);
                }
            }
            // Delete affected Brushes and notify that FillStyles have changed
            foreach (IFillStyle fillStyle in fillStyles)
            {
                NotifyFillStyleChanged(fillStyle);
            }
            fillStyles.Clear();

            // Collect affected Pens
            List <PenKey> penKeys = new List <PenKey>();

            foreach (KeyValuePair <PenKey, Pen> item in _penCache)
            {
                if (item.Key.LineStyle.ColorStyle == colorStyle)
                {
                    penKeys.Add(item.Key);
                }
                else if (item.Key.StartCapStyle != null && item.Key.StartCapStyle.ColorStyle == colorStyle)
                {
                    penKeys.Add(item.Key);
                }
                else if (item.Key.EndCapStyle != null && item.Key.EndCapStyle.ColorStyle == colorStyle)
                {
                    penKeys.Add(item.Key);
                }
            }
            // Delete affected Pens
            foreach (PenKey penKey in penKeys)
            {
                // notify only affected LineStyles, affected CapStyles are notified later
                NotifyLineStyleChanged(penKey.LineStyle);
            }
            penKeys.Clear();

            // Collect affected CustomLineCaps
            List <CapKey> capKeys = new List <CapKey>();

            foreach (KeyValuePair <CapKey, CustomLineCap> item in _capCache)
            {
                if (item.Key.CapStyle.ColorStyle == colorStyle || item.Key.CapStyle.ColorStyle == colorStyle)
                {
                    capKeys.Add(item.Key);
                }
            }
            // Delete affected CustomLineCaps
            foreach (CapKey capKey in capKeys)
            {
                NotifyCapStyleChanged(capKey.CapStyle);
            }
            capKeys.Clear();
        }
Example #15
0
		private static Color GetColor(IColorStyle colorStyle, bool convertToGray) {
			Debug.Assert(colorStyle != null);

			if (convertToGray) {
				int luminance = 0;
				luminance += (byte)Math.Round(colorStyle.Color.R * luminanceFactorRed);
				luminance += (byte)Math.Round(colorStyle.Color.G * luminanceFactorGreen);
				luminance += (byte)Math.Round(colorStyle.Color.B * luminanceFactorBlue);
				if (luminance > 255)
					luminance = 255;
				return Color.FromArgb(colorStyle.Color.A, luminance, luminance, luminance);
			} else return (colorStyle != null) ? colorStyle.Color : Color.Empty;
		}
Example #16
0
		/// <summary>
		/// Deletes all tools based on the given ColorStyle.
		/// </summary>
		private static void NotifyColorStyleChanged(IColorStyle colorStyle) {
			Debug.Assert(colorStyle != null);

			// dispose affected SolidBrushes
			while (solidBrushCache.ContainsKey(colorStyle)) {
				Brush brush = solidBrushCache[colorStyle];
				solidBrushCache.Remove(colorStyle);
				brush.Dispose();
				brush = null;
			}

			// collect affected Brushes
			List<IFillStyle> fillStyles = new List<IFillStyle>();
			foreach (KeyValuePair<BrushKey, Brush> item in brushCache) {
				if (item.Key.FillStyle != null
					&& item.Key.FillStyle.FillMode != FillMode.Image &&
					(item.Key.FillStyle.AdditionalColorStyle == colorStyle || item.Key.FillStyle.BaseColorStyle == colorStyle)) {
					fillStyles.Add(item.Key.FillStyle);
				}
			}
			// delete affected Brushes and notify that FillStyles have changed
			foreach (IFillStyle fillStyle in fillStyles)
				NotifyFillStyleChanged(fillStyle);
			fillStyles.Clear();

			// collect affected Pens
			List<PenKey> penKeys = new List<PenKey>();
			foreach (KeyValuePair<PenKey, Pen> item in penCache) {
				if (item.Key.LineStyle.ColorStyle == colorStyle)
					penKeys.Add(item.Key);
				else if (item.Key.StartCapStyle != null && item.Key.StartCapStyle.ColorStyle == colorStyle)
					penKeys.Add(item.Key);
				else if (item.Key.EndCapStyle != null && item.Key.EndCapStyle.ColorStyle == colorStyle)
					penKeys.Add(item.Key);
			}
			// delete affected Pens
			foreach (PenKey penKey in penKeys)
				// notify only affected LineStyles, affected CapStyles are notified later
				NotifyLineStyleChanged(penKey.LineStyle);
			penKeys.Clear();

			// collect affected CustomLineCaps
			List<CapKey> capKeys = new List<CapKey>();
			foreach (KeyValuePair<CapKey, CustomLineCap> item in capCache)
				if (item.Key.CapStyle.ColorStyle == colorStyle || item.Key.CapStyle.ColorStyle == colorStyle)
					capKeys.Add(item.Key);
			// delete affected CustomLineCaps
			foreach (CapKey capKey in capKeys)
				NotifyCapStyleChanged(capKey.CapStyle);
			capKeys.Clear();
		}
 /// <override></override>
 public override void MakePreview(IStyleSet styleSet)
 {
     base.MakePreview(styleSet);
     privateColumnCharacterStyle = styleSet.GetPreviewStyle(ColumnCharacterStyle);
     privateColumnParagraphStyle = styleSet.GetPreviewStyle(ColumnParagraphStyle);
     privateColumnBackgroundColorStyle = styleSet.GetPreviewStyle(ColumnBackgroundColorStyle);
 }
Example #18
0
		/// <ToBeCompleted></ToBeCompleted>
		public static Brush GetBrush(IColorStyle colorStyle) {
			if (colorStyle == null) throw new ArgumentNullException("colorStyle");
			
			SolidBrush brush = null;
			solidBrushCache.TryGetValue(colorStyle, out brush);
			if (brush == null) {
				brush = new SolidBrush(GetColor(colorStyle, colorStyle.ConvertToGray));
				// add created brush to the BrushCache
				solidBrushCache.Add(colorStyle, brush);
			}
			return brush;
		}
 /// <override></override>
 protected override void ProcessExecModelPropertyChange(IModelMapping propertyMapping)
 {
     switch (propertyMapping.ShapePropertyId) {
         case PropertyIdColumnBackgroundColorStyle:
             privateColumnBackgroundColorStyle = (propertyMapping.GetStyle() as IColorStyle);
             Invalidate();
             break;
         case PropertyIdColumnCharacterStyle:
             privateColumnCharacterStyle = (propertyMapping.GetStyle() as ICharacterStyle);
             InvalidateDrawCache();
             Invalidate();
             break;
         case PropertyIdColumnParagraphStyle:
             privateColumnParagraphStyle = (propertyMapping.GetStyle() as IParagraphStyle);
             InvalidateDrawCache();
             Invalidate();
             break;
         default:
             base.ProcessExecModelPropertyChange(propertyMapping);
             break;
     }
 }
 /// <override></override>
 protected override void InitializeToDefault(IStyleSet styleSet)
 {
     base.InitializeToDefault(styleSet);
     privateColumnBackgroundColorStyle = styleSet.ColorStyles.White;
     privateColumnCharacterStyle = styleSet.CharacterStyles.Caption;
     privateColumnParagraphStyle = styleSet.ParagraphStyles.Label;
     Width = 80;
     Height = 120;
     Text = "Table";
 }