Beispiel #1
0
        internal ForegroundColor ToForegroundColor()
        {
            ForegroundColor clr = new ForegroundColor();

            if (this.Auto != null)
            {
                clr.Auto = this.Auto.Value;
            }
            if (this.Indexed != null)
            {
                clr.Indexed = this.Indexed.Value;
            }
            if (this.Rgb != null)
            {
                clr.Rgb = new HexBinaryValue(this.Rgb);
            }
            if (this.Theme != null)
            {
                clr.Theme = this.Theme.Value;
            }
            if (this.Tint != null && this.Tint.Value != 0.0)
            {
                clr.Tint = this.Tint.Value;
            }

            return(clr);
        }
Beispiel #2
0
        public void CanConvertXLColorToColorType()
        {
            var xlColor1 = XLColor.Red;
            var xlColor2 = XLColor.FromIndex(20);
            var xlColor3 = XLColor.FromTheme(XLThemeColor.Accent1);
            var xlColor4 = XLColor.FromTheme(XLThemeColor.Accent2, 0.4);

            var color1 = new ForegroundColor().FromClosedXMLColor <ForegroundColor>(xlColor1);
            var color2 = new ForegroundColor().FromClosedXMLColor <ForegroundColor>(xlColor2);
            var color3 = new BackgroundColor().FromClosedXMLColor <BackgroundColor>(xlColor3);
            var color4 = new BackgroundColor().FromClosedXMLColor <BackgroundColor>(xlColor4);

            Assert.AreEqual("FFFF0000", color1.Rgb.Value);
            Assert.IsNull(color1.Indexed);
            Assert.IsNull(color1.Theme);
            Assert.IsNull(color1.Tint);

            Assert.IsNull(color2.Rgb);
            Assert.AreEqual(20, color2.Indexed.Value);
            Assert.IsNull(color2.Theme);
            Assert.IsNull(color2.Tint);

            Assert.IsNull(color3.Rgb);
            Assert.IsNull(color3.Indexed);
            Assert.AreEqual(4, color3.Theme.Value);
            Assert.IsNull(color3.Tint);

            Assert.IsNull(color4.Rgb);
            Assert.IsNull(color4.Indexed);
            Assert.AreEqual(5, color4.Theme.Value);
            Assert.AreEqual(0.4, color4.Tint.Value);
        }
Beispiel #3
0
        internal ForegroundColor ToForegroundColor()
        {
            var clr = new ForegroundColor();

            if (Auto != null)
            {
                clr.Auto = Auto.Value;
            }
            if (Indexed != null)
            {
                clr.Indexed = Indexed.Value;
            }
            if (Rgb != null)
            {
                clr.Rgb = new HexBinaryValue(Rgb);
            }
            if (Theme != null)
            {
                clr.Theme = Theme.Value;
            }
            if ((Tint != null) && (Tint.Value != 0.0))
            {
                clr.Tint = Tint.Value;
            }

            return(clr);
        }
Beispiel #4
0
 internal void FromForegroundColor(ForegroundColor clr)
 {
     SetAllNull();
     if (clr.Auto != null)
     {
         Auto = clr.Auto.Value;
     }
     if (clr.Indexed != null)
     {
         Indexed = clr.Indexed.Value;
     }
     if (clr.Rgb != null)
     {
         Rgb = clr.Rgb.Value;
     }
     if (clr.Theme != null)
     {
         Theme = clr.Theme.Value;
     }
     if (clr.Tint != null)
     {
         Tint = clr.Tint.Value;
     }
     SetDisplayColor();
 }
Beispiel #5
0
        public void Save()
        {
            var configuration = GetSettingsDtoForSave();

            if (configuration == null)
            {
                return;
            }

            using (new SecurityDisabler())
            {
                configuration.Edit(
                    p =>
                {
                    configuration[LastScriptSettingFieldName] = HttpUtility.HtmlEncode(LastScript);
                    ((CheckboxField)configuration.Fields[SaveLastScriptSettingFieldName]).Checked     = SaveLastScript;
                    ((CheckboxField)configuration.Fields[LiveAutocompletionSettingFieldName]).Checked = LiveAutocompletion;
                    configuration[HostWidthSettingFieldName]       = HostWidth.ToString(CultureInfo.InvariantCulture);
                    configuration[ForegroundColorSettingFieldName] = ForegroundColor.ToString();
                    configuration[BackgroundColorSettingFieldName] = BackgroundColor.ToString();
                    configuration[FontSizeSettingFieldName]        = FontSize.ToString();
                    configuration[FontFamilySettingFieldName]      = FontFamily;
                    if (IsPersonalized)
                    {
                        configuration.Fields[FieldIDs.DisplayName].Reset();
                    }
                });
            }
        }
        public static bool Save()
        {
            bool returnValue;

            try
            {
                using (RegistryKey registryKey = OpenRegistryKey())
                {
                    registryKey.SetValue(BACKGROUND_COLOR, BackgroundColor.ToArgb(), RegistryValueKind.DWord);
                    registryKey.SetValue(BACKGROUND_IMAGE, BackgroundImage, RegistryValueKind.String);
                    registryKey.SetValue(BORDER_COLOR, BorderColor.ToArgb(), RegistryValueKind.DWord);
                    registryKey.SetValue(FADE_DELAY, FadeDelay, RegistryValueKind.DWord);
                    registryKey.SetValue(FADESPEED, FadeSpeed, RegistryValueKind.DWord);
                    registryKey.SetValue(FOREGROUND_COLOR, ForegroundColor.ToArgb(), RegistryValueKind.DWord);
                    registryKey.SetValue(MAXIMUM_CACHE_ITEMS, MaximumCacheItems, RegistryValueKind.DWord);
                    registryKey.SetValue(RANDOM_VERSE, RandomVerse.ToString(), RegistryValueKind.String);
                    registryKey.SetValue(TEXT_FONT, TextFont.ToStringEx());
                    registryKey.SetValue(TITLE_FONT, TitleFont.ToStringEx());
                    registryKey.Close();
                }

                returnValue = true;
            }
            catch (Exception e)
            {
                Logging.LogException(e);
                returnValue = false;
            }

            return(returnValue);
        }
Beispiel #7
0
        public void Fill(Point point)
        {
            Color regionColor = _img.GetPixel(point.X, point.Y);

            if ((point.X == 0 || _img.GetPixel(point.X - 1, point.Y).ToArgb() == ForegroundColor.ToArgb()) &&
                (point.Y == 0 || _img.GetPixel(point.X, point.Y - 1).ToArgb() == ForegroundColor.ToArgb()) &&
                (point.X == _img.Width - 1 || _img.GetPixel(point.X + 1, point.Y).ToArgb() == ForegroundColor.ToArgb()) &&
                (point.Y == _img.Height - 1 || _img.GetPixel(point.X, point.Y + 1).ToArgb() == ForegroundColor.ToArgb()))
            {
                return;
            }
            int[,] flags = new int[_img.Width, _img.Height];
            Fill(point, regionColor, flags);
            for (int y = 0; y < _img.Height; y++)
            {
                for (int x = 0; x < _img.Width; x++)
                {
                    if (flags[x, y] > 0)
                    {
                        _img.SetPixel(x, y, ForegroundColor);
                    }
                }
            }
            this.Invalidate();
        }
Beispiel #8
0
        /// <summary>
        /// Create a new fill
        /// </summary>
        /// <param name="fillColorRgb">The foreground color of the fill</param>
        /// <param name="pattern">The fill pattern</param>
        /// <returns></returns>
        public static Fill CreateFill(string fillColorRgb, PatternValues?pattern = null)
        {
            PatternFill patternFill = new PatternFill();

            if (!string.IsNullOrEmpty(fillColorRgb))
            {
                patternFill.PatternType = pattern ?? PatternValues.Solid;
                ForegroundColor foregroundColor = new ForegroundColor()
                {
                    Rgb = fillColorRgb
                };
                BackgroundColor backgroundColor = new BackgroundColor()
                {
                    Indexed = (UInt32Value)64U
                };
                patternFill.Append(foregroundColor);
                patternFill.Append(backgroundColor);
            }
            else
            {
                patternFill.PatternType = pattern ?? PatternValues.None;
            }

            return(new Fill(patternFill));
        }
Beispiel #9
0
        private static UInt32Value CreateFill(Stylesheet templateSheetobj, string colorCode)
        {
            PatternFill patternFill = new PatternFill()
            {
                PatternType = PatternValues.Solid
            };
            ForegroundColor fgColor = new ForegroundColor()
            {
                Rgb = colorCode
            };
            BackgroundColor bgBolor = new BackgroundColor()
            {
                Indexed = (UInt32Value)64U
            };

            patternFill.Append(fgColor);
            patternFill.Append(bgBolor);
            Fill fill = new Fill(patternFill);

            templateSheetobj.Fills.Append(fill);
            UInt32Value result = templateSheetobj.Fills.Count;

            templateSheetobj.Fills.Count++;
            return(result);
        }
Beispiel #10
0
        private void SetTextStyle(TextView view)
        {
            if (view.Handle == IntPtr.Zero)
            {
                return;
            }
            if (Font.Size > 0)
            {
                view.SetTextSize(ComplexUnitType.Sp, (float)Font.Size);
            }

            if (!string.IsNullOrEmpty(Font.Name))
            {
                var format = (Android.Graphics.TypefaceStyle)Font.Formatting;
                view.SetTypeface(Android.Graphics.Typeface.Create(Font.Name, format), format);
            }

            if (!ForegroundColor.IsDefaultColor)
            {
                view.SetTextColor(ForegroundColor.ToColor());
            }

            if (!BackgroundColor.IsDefaultColor)
            {
                view.SetBackgroundColor(BackgroundColor.ToColor());
            }
        }
Beispiel #11
0
        protected void DrawHintAndInput()
        {
            if (!Experiment.Config.Gui.InputBarVisibility)
            {
                return;
            }

            /* Draw Hint */
            if (HintText != null)
            {
                SharedBrush.Color = new Color(ForegroundColor.ToVector3(), 0.7F);
                RenderTarget.DrawText(HintText, InputTextFormat, new RawRectangleF(10, 0, Width - 10, InputBoxHeight / 2),
                                      SharedBrush, D2D1.DrawTextOptions.None);
            }

            /* Draw user input text */
            if (InputTextLayout != null)
            {
                var rect = HintText == null
                    ? new RawRectangleF(10, 5, Width - 10, InputBoxHeight - 5)
                    : new RawRectangleF(10, InputBoxHeight / 2, Width - 10, InputBoxHeight);
                InputTextLayout.MaxWidth  = rect.Right - rect.Left;
                InputTextLayout.MaxHeight = rect.Bottom - rect.Top;
                InputTextLayout.Draw(_customColorRenderer, rect.Left, rect.Top);
            }

            /* Draw Input Box Bottom Line */
            SharedBrush.Color = ForegroundColor;
            RenderTarget.DrawLine(new RawVector2(10, InputBoxHeight + 2), new RawVector2(Width - 10, InputBoxHeight + 2), SharedBrush, 2);
        }
Beispiel #12
0
 private PSStyle()
 {
     Formatting = new FormattingData();
     Progress   = new ProgressConfiguration();
     Foreground = new ForegroundColor();
     Background = new BackgroundColor();
 }
Beispiel #13
0
        public static Fills GenerateFills()
        {
            Fills fills1 = new Fills()
            {
                Count = (UInt32Value)3U
            };

            Fill        fill1        = new Fill();
            PatternFill patternFill1 = new PatternFill()
            {
                PatternType = PatternValues.None
            };

            fill1.Append(patternFill1);

            Fill        fill2        = new Fill();
            PatternFill patternFill2 = new PatternFill()
            {
                PatternType = PatternValues.Gray125
            };

            fill2.Append(patternFill2);

            Fill        fill3        = new Fill();
            PatternFill patternFill3 = new PatternFill()
            {
                PatternType = PatternValues.Solid
            };
            ForegroundColor foregroundColor1 = new ForegroundColor() /*Theme = (UInt32Value)0U, Tint = -0.14999847407452621D*/ Rgb
            {
        } // IsEqual

        private int ComputeHashCode()
        {
            var hash = ForegroundColor.GetHashCode();

            hash = HashTool.AddHashCode(hash, BackgroundColor);
            hash = HashTool.AddHashCode(hash, FontFamily);
            hash = HashTool.AddHashCode(hash, FontSize);
            return(hash);
        } // ComputeHashCode
Beispiel #15
0
        public void ConvertBackThrowsException()
        {
            // Arrange
            var conv = new ForegroundColor();

            // Act

            // Assert
            ExceptionAssert.Throws <NotSupportedException>(() => conv.ConvertBack(null, null, null, null));
        }
Beispiel #16
0
        /// <summary>
        /// Creates a duplicate of the current value.
        /// </summary>
        /// <returns>The cloned value.</returns>
        /// <remarks>This method is a deep copy clone.</remarks>
        public object Clone()
        {
            var clone = (OpenExcelFill)MemberwiseClone();

            clone.PatternType     = (EnumValue <PatternValues>)PatternType?.Clone();
            clone.ForegroundColor = (ForegroundColor)ForegroundColor?.Clone();
            clone.BackgroundColor = (BackgroundColor)BackgroundColor?.Clone();

            return(clone);
        }
Beispiel #17
0
        /// <summary>
        /// persist settings to registry
        /// </summary>
        public void Save()
        {
            // Create or get existing Registry subkey
            RegistryKey key = Registry.CurrentUser.CreateSubKey("SOFTWARE\\todoscreensaver");

            key.SetValue("file", DataPath);
            key.SetValue("close_mode", (int)ScreensaverCloseMode);
            key.SetValue("background_color", BackgroundColor.ToString());
            key.SetValue("foreground_color", ForegroundColor.ToString());
        }
        private UInt32Value SetCellStyle(System.Drawing.Color fillColor, bool locked)
        {
            Fill        fill        = new Fill();
            PatternFill patternFill = new PatternFill()
            {
                PatternType = PatternValues.Solid
            };
            ForegroundColor foregroundColor1 = new ForegroundColor()
            {
                Rgb = System.Drawing.Color.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B).Name
            };
            BackgroundColor backgroundColor1 = new BackgroundColor()
            {
                Indexed = (UInt32Value)64U
            };

            patternFill.Append(foregroundColor1);
            patternFill.Append(backgroundColor1);
            fill.Append(patternFill);
            ExcelStyleSheet.Fills.Count++;
            ExcelStyleSheet.Fills.Append(fill);

            CellFormat myCellFormat =
                new CellFormat
            {
                FontId          = (UInt32Value)0U,
                FillId          = (UInt32Value)ExcelStyleSheet.Fills.Count - 1,
                ApplyFill       = true,
                NumberFormatId  = (UInt32Value)0U,
                FormatId        = (UInt32Value)0U,
                BorderId        = (UInt32Value)1U,
                ApplyBorder     = true,
                ApplyProtection = true
            };

            Alignment alignment = new Alignment()
            {
                WrapText = true
            };

            myCellFormat.Append(alignment);

            if (!locked)
            {
                Protection protection = new Protection()
                {
                    Locked = false
                };
                myCellFormat.Append(protection);
            }

            ExcelStyleSheet.CellFormats.Count++;
            ExcelStyleSheet.CellFormats.Append(myCellFormat);
            return((UInt32Value)ExcelStyleSheet.CellFormats.Count - 1);
        }
Beispiel #19
0
        public void ConvertInvalidValueResultsInUnset()
        {
            // Arrange
            var conv = new ForegroundColor();

            // Act
            object converted = conv.Convert(123, null, null, null);

            // Assert
            Assert.AreEqual(DependencyProperty.UnsetValue, converted);
        }
        public int CompareTo(ConsolePlusTheme other)
        {
            int foreCompare = BackgroundColor.CompareTo(other.BackgroundColor);

            if (foreCompare != 0)
            {
                return(foreCompare);
            }

            return(ForegroundColor.CompareTo(other.ForegroundColor));
        }
        private static ForegroundColor CreateForegroundColor(System.Drawing.Color color)
        {
            var ligthGrayForegroundColor = new ForegroundColor
            {
                Rgb = new HexBinaryValue {
                    Value = color.ToHexValue()
                }
            };

            return(ligthGrayForegroundColor);
        }
Beispiel #22
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + Char.GetHashCode();
                hash = hash * 23 + ForegroundColor.GetHashCode();
                hash = hash * 23 + BackgroundColor.GetHashCode();

                return(hash);
            }
        }
Beispiel #23
0
        public override int GetHashCode()
        {
            int hash = Text?.GetHashCode() ?? -1;

            hash ^= BackgroundColor.GetHashCode();
            hash ^= ForegroundColor.GetHashCode();
            hash ^= FontAttributes.GetHashCode();
            hash ^= FontSize.GetHashCode();
            hash ^= Command?.GetHashCode() ?? -1;
            hash ^= CommandParameter?.GetHashCode() ?? -1;
            return(hash);
        }
Beispiel #24
0
 /// <summary>
 /// Computes the hash code for this object.
 /// </summary>
 /// <returns>The hash code.</returns>
 public override int GetHashCode()
 {
     // Overflow is fine, just wrap
     unchecked
     {
         var hash = 17;
         hash = (hash * 23) + Content.GetHashCode();
         hash = (hash * 23) + ForegroundColor.GetHashCode();
         hash = (hash * 23) + BackgroundColor.GetHashCode();
         return(hash);
     }
 }
Beispiel #25
0
 public virtual void SaveToFile(BinaryWriter stream)
 {
     //Program.WriteLine("   * Saving {0} {1}...", this.GetType(), ID ?? "????");
     Toolkit.SaveExpectation(stream, "ENTT");
     stream.Write(ID ?? "<Null>");
     stream.Write((char)Glyph);
     BackgroundColor.SaveToFile(stream);
     ForegroundColor.SaveToFile(stream);
     stream.Write((byte)XPosition);
     stream.Write((byte)YPosition);
     stream.Write((byte)0);             //was Flow
     stream.Write(Blocking);
 }
Beispiel #26
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 17;

                hash = hash * 23 + PatternType.GetHashCode();
                hash = hash * 23 + ForegroundColor?.GetHashCode() ?? 0;
                hash = hash * 23 + BackgroundColor?.GetHashCode() ?? 0;

                return(hash);
            }
        }
Beispiel #27
0
        /// <summary>
        /// Compare to
        /// </summary>
        /// <param name="other">Other</param>
        /// <returns>Comparison result</returns>
        public int CompareTo(BufferCell other)
        {
            int ret = Character.CompareTo(other.Character);

            if (ret == 0)
            {
                ret = ForegroundColor.CompareTo(other.ForegroundColor);
                if (ret == 0)
                {
                    ret = BackgroundColor.CompareTo(other.BackgroundColor);
                }
            }
            return(ret);
        }
Beispiel #28
0
        public void RedBackgroundResultsInWhiteColor()
        {
            // Arrange
            var conv = new ForegroundColor();

            // Act
            object color = conv.Convert("ff0000", null, null, null);

            // Assert
            SolidColorBrush brush = color as SolidColorBrush;

            Assert.IsNotNull(brush);
            Assert.AreEqual(Colors.White, brush.Color);
        }
Beispiel #29
0
        public void LightGrayResultsInBlack()
        {
            // Arrange
            var conv = new ForegroundColor();

            // Act
            object color = conv.Convert("cccccc", null, null, null);

            // Assert
            SolidColorBrush brush = color as SolidColorBrush;

            Assert.IsNotNull(brush);
            Assert.AreEqual(Colors.Black, brush.Color);
        }
Beispiel #30
0
        public void AppendRtf(StringBuilder r, Dictionary <int, int> colorTable, Dictionary <string, int> fontTable)
        {
            var a = false;

            if (FontName != null && FontName.Length > 0)
            {
                var ci = fontTable[FontName];
                r.AppendFormat(@"\f{0}", ci);
                a = true;
            }
            if (FontSize > 1)
            {
                r.AppendFormat(@"\fs{0}", (int)(2 * FontSize + 0.5f));
                a = true;
            }

            if (ForegroundColor != null)
            {
                var ci = colorTable[ForegroundColor.ToArgb()];
                r.AppendFormat(@"\cf{0}", ci);
                a = true;
            }

            if (BackgroundColor != null)
            {
                var ci = colorTable[BackgroundColor.ToArgb()];
                r.AppendFormat(@"\highlight{0}", ci);
                a = true;
            }

            if (UnderlineStyle != UnderlineStyle.None)
            {
                var ci = colorTable[UnderlineColor.ToArgb()];
                r.AppendFormat(@"\ulc{0}\ulwave", ci);
                a = true;
            }

            if (!string.IsNullOrEmpty(Link))
            {
                //r.AppendFormat (@"{{{{\field{{\*\fldinst{{HYPERLINK ""{0}"" }}}}{{\fldrslt{{\ul ", Link.Replace ('\"', ' '));
                r.Append(@"\ul");
                a = true;
            }

            if (a)
            {
                r.Append(' ');
            }
        }
        // Generates content of workbookStyles.
        private void GenerateWorkbookStylesContent(WorkbookStylesPart workbookStyles)
        {
            Stylesheet stylesheet1 = new Stylesheet(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "x14ac" }  };
            stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");

            NumberingFormats numberingFormats1 = new NumberingFormats(){ Count = (UInt32Value)1U };
            NumberingFormat numberingFormat1 = new NumberingFormat(){ NumberFormatId = (UInt32Value)43U, FormatCode = "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)" };

            numberingFormats1.Append(numberingFormat1);

            Fonts fonts1 = new Fonts(){ Count = (UInt32Value)4U, KnownFonts = true };

            Font font1 = new Font();
            FontSize fontSize1 = new FontSize(){ Val = 11D };
            Color color1 = new Color(){ Theme = (UInt32Value)1U };
            FontName fontName1 = new FontName(){ Val = "Calibri" };
            FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering(){ Val = 2 };
            FontScheme fontScheme1 = new FontScheme(){ Val = FontSchemeValues.Minor };

            font1.Append(fontSize1);
            font1.Append(color1);
            font1.Append(fontName1);
            font1.Append(fontFamilyNumbering1);
            font1.Append(fontScheme1);

            Font font2 = new Font();
            Bold bold1 = new Bold();
            FontSize fontSize2 = new FontSize(){ Val = 11D };
            Color color2 = new Color(){ Theme = (UInt32Value)1U };
            FontName fontName2 = new FontName(){ Val = "Calibri" };
            FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering(){ Val = 2 };
            FontScheme fontScheme2 = new FontScheme(){ Val = FontSchemeValues.Minor };

            font2.Append(bold1);
            font2.Append(fontSize2);
            font2.Append(color2);
            font2.Append(fontName2);
            font2.Append(fontFamilyNumbering2);
            font2.Append(fontScheme2);

            Font font3 = new Font();
            Bold bold2 = new Bold();
            Italic italic1 = new Italic();
            FontSize fontSize3 = new FontSize(){ Val = 11D };
            Color color3 = new Color(){ Rgb = "FFFF0000" };
            FontName fontName3 = new FontName(){ Val = "Calibri" };
            FontFamilyNumbering fontFamilyNumbering3 = new FontFamilyNumbering(){ Val = 2 };
            FontScheme fontScheme3 = new FontScheme(){ Val = FontSchemeValues.Minor };

            font3.Append(bold2);
            font3.Append(italic1);
            font3.Append(fontSize3);
            font3.Append(color3);
            font3.Append(fontName3);
            font3.Append(fontFamilyNumbering3);
            font3.Append(fontScheme3);

            Font font4 = new Font();
            Italic italic2 = new Italic();
            FontSize fontSize4 = new FontSize(){ Val = 11D };
            Color color4 = new Color(){ Rgb = "FFFF0000" };
            FontName fontName4 = new FontName(){ Val = "Calibri" };
            FontFamilyNumbering fontFamilyNumbering4 = new FontFamilyNumbering(){ Val = 2 };
            FontScheme fontScheme4 = new FontScheme(){ Val = FontSchemeValues.Minor };

            font4.Append(italic2);
            font4.Append(fontSize4);
            font4.Append(color4);
            font4.Append(fontName4);
            font4.Append(fontFamilyNumbering4);
            font4.Append(fontScheme4);

            fonts1.Append(font1);
            fonts1.Append(font2);
            fonts1.Append(font3);
            fonts1.Append(font4);

            Fills fills1 = new Fills(){ Count = (UInt32Value)4U };

            Fill fill1 = new Fill();
            PatternFill patternFill1 = new PatternFill(){ PatternType = PatternValues.None };

            fill1.Append(patternFill1);

            Fill fill2 = new Fill();
            PatternFill patternFill2 = new PatternFill(){ PatternType = PatternValues.Gray125 };

            fill2.Append(patternFill2);

            Fill fill3 = new Fill();

            PatternFill patternFill3 = new PatternFill(){ PatternType = PatternValues.Solid };
            ForegroundColor foregroundColor1 = new ForegroundColor(){ Theme = (UInt32Value)0U, Tint = -4.9989318521683403E-2D };
            BackgroundColor backgroundColor1 = new BackgroundColor(){ Indexed = (UInt32Value)64U };

            patternFill3.Append(foregroundColor1);
            patternFill3.Append(backgroundColor1);

            fill3.Append(patternFill3);

            Fill fill4 = new Fill();

            PatternFill patternFill4 = new PatternFill(){ PatternType = PatternValues.Solid };
            ForegroundColor foregroundColor2 = new ForegroundColor(){ Rgb = "FFFFFFCC" };
            BackgroundColor backgroundColor2 = new BackgroundColor(){ Indexed = (UInt32Value)64U };

            patternFill4.Append(foregroundColor2);
            patternFill4.Append(backgroundColor2);

            fill4.Append(patternFill4);

            fills1.Append(fill1);
            fills1.Append(fill2);
            fills1.Append(fill3);
            fills1.Append(fill4);

            Borders borders1 = new Borders(){ Count = (UInt32Value)2U };

            Border border1 = new Border();
            LeftBorder leftBorder1 = new LeftBorder();
            RightBorder rightBorder1 = new RightBorder();
            TopBorder topBorder1 = new TopBorder();
            BottomBorder bottomBorder1 = new BottomBorder();
            DiagonalBorder diagonalBorder1 = new DiagonalBorder();

            border1.Append(leftBorder1);
            border1.Append(rightBorder1);
            border1.Append(topBorder1);
            border1.Append(bottomBorder1);
            border1.Append(diagonalBorder1);

            Border border2 = new Border();
            LeftBorder leftBorder2 = new LeftBorder();
            RightBorder rightBorder2 = new RightBorder();

            TopBorder topBorder2 = new TopBorder(){ Style = BorderStyleValues.Thin };
            Color color5 = new Color(){ Indexed = (UInt32Value)64U };

            topBorder2.Append(color5);
            BottomBorder bottomBorder2 = new BottomBorder();
            DiagonalBorder diagonalBorder2 = new DiagonalBorder();

            border2.Append(leftBorder2);
            border2.Append(rightBorder2);
            border2.Append(topBorder2);
            border2.Append(bottomBorder2);
            border2.Append(diagonalBorder2);

            borders1.Append(border1);
            borders1.Append(border2);

            CellStyleFormats cellStyleFormats1 = new CellStyleFormats(){ Count = (UInt32Value)1U };
            CellFormat cellFormat1 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U };

            cellStyleFormats1.Append(cellFormat1);

            CellFormats cellFormats1 = new CellFormats(){ Count = (UInt32Value)16U };
            CellFormat cellFormat2 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U };

            CellFormat cellFormat3 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment1 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat3.Append(alignment1);
            CellFormat cellFormat4 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true };

            CellFormat cellFormat5 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment2 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Left };

            cellFormat5.Append(alignment2);

            CellFormat cellFormat6 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment3 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat6.Append(alignment3);

            CellFormat cellFormat7 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment4 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat7.Append(alignment4);

            CellFormat cellFormat8 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment5 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Right };

            cellFormat8.Append(alignment5);

            CellFormat cellFormat9 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment6 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Left };

            cellFormat9.Append(alignment6);

            CellFormat cellFormat10 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment7 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat10.Append(alignment7);

            CellFormat cellFormat11 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)3U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment8 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat11.Append(alignment8);
            CellFormat cellFormat12 = new CellFormat(){ NumberFormatId = (UInt32Value)43U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFont = true, ApplyFill = true };

            CellFormat cellFormat13 = new CellFormat(){ NumberFormatId = (UInt32Value)9U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment9 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Left };

            cellFormat13.Append(alignment9);

            CellFormat cellFormat14 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true, ApplyAlignment = true };
            Alignment alignment10 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat14.Append(alignment10);

            CellFormat cellFormat15 = new CellFormat(){ NumberFormatId = (UInt32Value)37U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFont = true, ApplyFill = true, ApplyBorder = true, ApplyAlignment = true };
            Alignment alignment11 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center };

            cellFormat15.Append(alignment11);
            CellFormat cellFormat16 = new CellFormat(){ NumberFormatId = (UInt32Value)43U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFont = true, ApplyFill = true, ApplyBorder = true };
            CellFormat cellFormat17 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyBorder = true };

            cellFormats1.Append(cellFormat2);
            cellFormats1.Append(cellFormat3);
            cellFormats1.Append(cellFormat4);
            cellFormats1.Append(cellFormat5);
            cellFormats1.Append(cellFormat6);
            cellFormats1.Append(cellFormat7);
            cellFormats1.Append(cellFormat8);
            cellFormats1.Append(cellFormat9);
            cellFormats1.Append(cellFormat10);
            cellFormats1.Append(cellFormat11);
            cellFormats1.Append(cellFormat12);
            cellFormats1.Append(cellFormat13);
            cellFormats1.Append(cellFormat14);
            cellFormats1.Append(cellFormat15);
            cellFormats1.Append(cellFormat16);
            cellFormats1.Append(cellFormat17);

            CellStyles cellStyles1 = new CellStyles(){ Count = (UInt32Value)1U };
            CellStyle cellStyle1 = new CellStyle(){ Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U };

            cellStyles1.Append(cellStyle1);
            DifferentialFormats differentialFormats1 = new DifferentialFormats(){ Count = (UInt32Value)0U };
            TableStyles tableStyles1 = new TableStyles(){ Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" };

            StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList();

            StylesheetExtension stylesheetExtension1 = new StylesheetExtension(){ Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
            stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
            DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles slicerStyles1 = new DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles(){ DefaultSlicerStyle = "SlicerStyleLight1" };

            stylesheetExtension1.Append(slicerStyles1);

            //StylesheetExtension stylesheetExtension2 = new StylesheetExtension(){ Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" };
            //stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
            //X15.TimelineStyles timelineStyles1 = new X15.TimelineStyles(){ DefaultTimelineStyle = "TimeSlicerStyleLight1" };

            //stylesheetExtension2.Append(timelineStyles1);

            stylesheetExtensionList1.Append(stylesheetExtension1);
            //stylesheetExtensionList1.Append(stylesheetExtension2);

            stylesheet1.Append(numberingFormats1);
            stylesheet1.Append(fonts1);
            stylesheet1.Append(fills1);
            stylesheet1.Append(borders1);
            stylesheet1.Append(cellStyleFormats1);
            stylesheet1.Append(cellFormats1);
            stylesheet1.Append(cellStyles1);
            stylesheet1.Append(differentialFormats1);
            stylesheet1.Append(tableStyles1);
            stylesheet1.Append(stylesheetExtensionList1);

            workbookStyles.Stylesheet = stylesheet1;
        }
        private UInt32Value SetCellStyle(System.Drawing.Color fillColor, bool locked)
        {
            Fill fill = new Fill();
            PatternFill patternFill = new PatternFill() { PatternType = PatternValues.Solid };
            ForegroundColor foregroundColor1 = new ForegroundColor() { Rgb = System.Drawing.Color.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B).Name };
            BackgroundColor backgroundColor1 = new BackgroundColor() { Indexed = (UInt32Value)64U };

            patternFill.Append(foregroundColor1);
            patternFill.Append(backgroundColor1);
            fill.Append(patternFill);
            ExcelStyleSheet.Fills.Count++;
            ExcelStyleSheet.Fills.Append(fill);

            CellFormat myCellFormat =
              new CellFormat
              {
                  FontId = (UInt32Value)0U,
                  FillId = (UInt32Value)ExcelStyleSheet.Fills.Count - 1,
                  ApplyFill = true,
                  NumberFormatId = (UInt32Value)0U,
                  FormatId = (UInt32Value)0U,
                  BorderId = (UInt32Value)1U,
                  ApplyBorder = true,
                  ApplyProtection = true
              };

            Alignment alignment = new Alignment() { WrapText = true };
            myCellFormat.Append(alignment);

            if (!locked)
            {
                Protection protection = new Protection() { Locked = false };
                myCellFormat.Append(protection);
            }

            ExcelStyleSheet.CellFormats.Count++;
            ExcelStyleSheet.CellFormats.Append(myCellFormat);
            return (UInt32Value)ExcelStyleSheet.CellFormats.Count - 1;
        }
Beispiel #33
0
        internal ForegroundColor ToForegroundColor()
        {
            ForegroundColor clr = new ForegroundColor();
            if (this.Auto != null) clr.Auto = this.Auto.Value;
            if (this.Indexed != null) clr.Indexed = this.Indexed.Value;
            if (this.Rgb != null) clr.Rgb = new HexBinaryValue(this.Rgb);
            if (this.Theme != null) clr.Theme = this.Theme.Value;
            if (this.Tint != null && this.Tint.Value != 0.0) clr.Tint = this.Tint.Value;

            return clr;
        }
Beispiel #34
0
 internal void FromForegroundColor(ForegroundColor clr)
 {
     this.SetAllNull();
     if (clr.Auto != null) this.Auto = clr.Auto.Value;
     if (clr.Indexed != null) this.Indexed = clr.Indexed.Value;
     if (clr.Rgb != null) this.Rgb = clr.Rgb.Value;
     if (clr.Theme != null) this.Theme = clr.Theme.Value;
     if (clr.Tint != null) this.Tint = clr.Tint.Value;
     this.SetDisplayColor();
 }
        //описвывает форматы ячеек
        protected void GenWorkbookStylesPart(WorkbookStylesPart workbookStylesPart)
        {
            Stylesheet stylesheet = new Stylesheet();

            Fonts fonts1 = new Fonts();

            Font font1 = new Font();

            Font font2 = new Font();
            FontSize fontSize2 = new FontSize() { Val = 11D };
            Color color1 = new Color() { Rgb = "FF00B050" };
            FontName fontName2 = new FontName() { Val = "Calibri" };
            FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 };
            FontCharSet fontCharSet1 = new FontCharSet() { Val = 204 };

            font2.Append(fontSize2);
            font2.Append(color1);
            font2.Append(fontName2);
            font2.Append(fontFamilyNumbering1);
            font2.Append(fontCharSet1);

            //fonts1.Append(font2);
            fonts1.Append(font1);

            Fills fills1 = new Fills();
            Fill fill1 = new Fill();
            Fill fill2 = new Fill();
            Fill fill3 = new Fill();
            PatternFill patternFill3 = new PatternFill() { PatternType = PatternValues.Solid };

            ForegroundColor foregroundColor1 = new ForegroundColor() { Rgb = "0000FF" };
            patternFill3.Append(foregroundColor1);
            fill3.Append(patternFill3);
            fills1.Append(fill1);
            fills1.Append(fill2);
            fills1.Append(fill3);

            Borders borders1 = new Borders();
            Border border1 = new Border();
            borders1.Append(border1);

            //Переопределяем номера формата 164U, 166U, 167U, 168U,
            NumberingFormats numberingFormats1 = new NumberingFormats() { Count = (UInt32Value)3U };
            NumberingFormat numberingFormat1 = new NumberingFormat() { NumberFormatId = (UInt32Value)164U, FormatCode = "[$-F800]dddd\\,\\ mmmm\\ dd\\,\\ yyyy" };
            NumberingFormat numberingFormat2 = new NumberingFormat() { NumberFormatId = (UInt32Value)166U, FormatCode = "#,##0.000\"р.\"" };
            NumberingFormat numberingFormat3 = new NumberingFormat() { NumberFormatId = (UInt32Value)167U, FormatCode = "#,##0\"р.\"" }; //"#,##0.00\"р.\"" };
            NumberingFormat numberingFormat4 = new NumberingFormat() { NumberFormatId = (UInt32Value)168U, FormatCode = "#,##0.00\"р.\"" };

            numberingFormats1.Append(numberingFormat1);
            numberingFormats1.Append(numberingFormat2);
            numberingFormats1.Append(numberingFormat3);
            numberingFormats1.Append(numberingFormat4);

            CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)6U };
            CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)0U }; // Формат № 0 по умолчанию общий
            CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)164U }; // Формат № 1 для дат FormatCode = "[$-F800]dddd\\,\\ mmmm\\ dd\\,\\ yyyy"
            CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)166U }; //формат № 2 для денег по тысяч. ###,### <-- (number/ 1000)
            CellFormat cellFormat5 = new CellFormat() { NumberFormatId = (UInt32Value)14U }; //формат № 3 для дат * 14.03.2015
            CellFormat cellFormat6 = new CellFormat() { NumberFormatId = (UInt32Value)2U }; //формат № 4 для чисел
            CellFormat cellFormat7 = new CellFormat() { NumberFormatId = (UInt32Value)1U }; //более подходящий формат № 5U для чисел (5U)
            CellFormat cellFormat8 = new CellFormat() { NumberFormatId = (UInt32Value)165U };//формат №6U для денег по умолчанию
            CellFormat cellFormat9 = new CellFormat() { NumberFormatId = (UInt32Value)167U };// формат №7U для денег(переопределенный) по три разряда ### ### р.
            CellFormat cellFormat10 = new CellFormat() { NumberFormatId = (UInt32Value)168U };// формат №8U для денег(переопределенный) ### ###,00 р.

            cellFormats1.Append(cellFormat2);
            cellFormats1.Append(cellFormat3);
            cellFormats1.Append(cellFormat4);
            cellFormats1.Append(cellFormat5);
            cellFormats1.Append(cellFormat6);
            cellFormats1.Append(cellFormat7);
            cellFormats1.Append(cellFormat8);
            cellFormats1.Append(cellFormat9);
            cellFormats1.Append(cellFormat10);

            stylesheet.Append(numberingFormats1);
            stylesheet.Append(fonts1);
            stylesheet.Append(fills1);
            stylesheet.Append(borders1);
            stylesheet.Append(cellFormats1);

            workbookStylesPart.Stylesheet = stylesheet;
        }
 = DependencyProperty.Register(nameof(ForegroundColor), typeof(Color), typeof(AccentProvider), new PropertyMetadata(0));