Example #1
0
 public string FormatStringFromStyle(FormatStyle formatStyle)
 {
     if (formatStyle == FormatStyle.Default)
     {
         return(this.Default);
     }
     else if (formatStyle == FormatStyle.Date)
     {
         return(this.Date);
     }
     else if (formatStyle == FormatStyle.Currency)
     {
         return(this.Currency);
     }
     else if (formatStyle == FormatStyle.Number)
     {
         return(this.Integer);
     }
     else if (formatStyle == FormatStyle.Decimal)
     {
         return(this.Decimal);
     }
     else if (formatStyle == FormatStyle.Percent)
     {
         return(this.Percent);
     }
     return("");
 }
Example #2
0
        private void ShowFormatString(FormatStyle formatStyle)
        {
            rButton_Style = formatStyle;

            #region 字典的实现

            lBox_FormatString.Items.Clear();
            tBox_FormatString.Text = "";
            label_Example.Text     = "";

            FormatStringGroup NowformatStringGroup = Groups[formatStyle];
            if (NowformatStringGroup != null)
            {
                for (int i = 0; i < NowformatStringGroup.FormatStrings.Count; i++)
                {
                    lBox_FormatString.Items.Add(NowformatStringGroup.FormatStrings[i]);
                }

                if (lBox_FormatString.Items.Count > 0)
                {
                    lBox_FormatString.SelectedIndex = 0;
                }
            }

            #endregion
        }
Example #3
0
 private void SaveFormatProperties()
 {
     if (this.currentFormatObject != null)
     {
         if (this.currentFormatObject is FormatStyle)
         {
             FormatStyle currentFormatObject = (FormatStyle)this.currentFormatObject;
             currentFormatObject.foreColor = this.foreColorCombo.Color;
             currentFormatObject.backColor = this.backColorCombo.Color;
             if (this.fontNameChanged)
             {
                 currentFormatObject.fontName        = this.fontNameCombo.Text.Trim();
                 currentFormatObject.fontNameChanged = true;
                 this.fontNameChanged = false;
             }
             currentFormatObject.bold      = this.boldCheck.Checked;
             currentFormatObject.italic    = this.italicCheck.Checked;
             currentFormatObject.underline = this.underlineCheck.Checked;
             currentFormatObject.strikeOut = this.strikeOutCheck.Checked;
             currentFormatObject.overline  = this.overlineCheck.Checked;
             if (this.fontSizeCombo.IsSet())
             {
                 currentFormatObject.fontType = this.fontSizeCombo.SelectedIndex;
                 if (currentFormatObject.fontType == 10)
                 {
                     currentFormatObject.fontSize = this.fontSizeUnit.Value;
                 }
             }
             else
             {
                 currentFormatObject.fontType = -1;
             }
             int selectedIndex = this.horzAlignCombo.SelectedIndex;
             if (selectedIndex == -1)
             {
                 selectedIndex = 0;
             }
             currentFormatObject.horzAlignment = selectedIndex;
             selectedIndex = this.vertAlignCombo.SelectedIndex;
             if (selectedIndex == -1)
             {
                 selectedIndex = 0;
             }
             currentFormatObject.vertAlignment = selectedIndex;
             currentFormatObject.allowWrapping = this.allowWrappingCheck.Checked;
         }
         else
         {
             FormatColumn column = (FormatColumn)this.currentFormatObject;
             column.width = this.widthUnit.Value;
         }
         this.currentFormatNode.Dirty = true;
     }
     this.propChangesPending = false;
 }
Example #4
0
        public static string Time(DateTime time, FormatStyle style)
        {
            switch (style)
            {
            case FormatStyle.Compact:
                return(string.Format("{0:00}:{1:00}", time.Hour, time.Minute));

            default:
                return(string.Format("{0:00}:{1:00}:{2:00}", time.Hour, time.Minute, time.Second));
            }
        }
        public static IAlbumFormatter GetAlbumFormatter(FormatStyle style)
        {
            switch (style)
            {
            case FormatStyle.Gav: return(new GavAlbumFormatter());

            case FormatStyle.Pete:  return(new PeteAlbumFormatter());

            default: throw new ApplicationException(string.Format("Unknown album format style: {0}", style));
            }
        }
Example #6
0
 public bool Equals(FormatStyle other)
 {
     if (other == null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Name, Name));
 }
        /// <inheritdoc />
        /// <summary> Логирует IDbCommand. </summary>
        /// <param name="message">Сообщение</param>
        /// <param name="command">Текст SQL</param>
        /// <param name="style">Стиль форматирования</param>
        public override void LogCommand(string message, DbCommand command, FormatStyle style)
        {
            if (string.IsNullOrEmpty(command.CommandText))
            {
                return;
            }

            style = DetermineActualStyle(style);
            var statement = style.Formatter.Format(GetCommandLineWithParameters(command));

            Logger.LogDebug(string.IsNullOrEmpty(message) ? statement : message + statement);
        }
Example #8
0
		public bool Equals(FormatStyle other)
		{
			if (other == null)
			{
				return false;
			}
			if (ReferenceEquals(this, other))
			{
				return true;
			}
			return Equals(other.Name, Name);
		}
Example #9
0
        public static string Whois(string user, Server server, FormatStyle style)
        {
            WhoisResult whois = XML.GetWhois(user, server);

            if (whois == null || !whois.Success)
            {
                return(UppercaseFirst(user));
            }
            else
            {
                return(Whois(whois, style));
            }
        }
Example #10
0
        public static string Time(TimeSpan time, FormatStyle style)
        {
            switch (style)
            {
            case FormatStyle.Compact:
                return(string.Format("{0:00}:{1:00}", Math.Floor(time.TotalHours), time.Minutes));

            case FormatStyle.Large:
                return(string.Format("{0} hours, {1} minutes and {2} seconds", Math.Floor(time.TotalHours), time.Minutes, time.Seconds));

            default:
                return(string.Format("{0:00}:{1:00}:{2:00}", Math.Floor(time.TotalHours), time.Minutes, time.Seconds));
            }
        }
Example #11
0
        public static string Date(DateTime date, FormatStyle style)
        {
            DateTimeFormatInfo dtfi = new CultureInfo("en-US", false).DateTimeFormat;

            switch (style)
            {
            case FormatStyle.Compact:
                return(date.ToString("dd/MM/yyyy", dtfi));

            case FormatStyle.Large:
                return(date.ToString("dddd, MMMM d, yyyy", dtfi));

            default:
                return(date.ToString("d MMMM yyyy", dtfi));
            }
        }
        public static ProfileGroupDefinition NumberGroupDefinition(
            string groupName, string propKey, float minimumValue, float maximumValue, float value,
            RebuildType rebuildType, FormatStyle formatStyle, string dependsOnKeyword, bool dependsOnValue, string tooltip)
        {
            ProfileGroupDefinition def = new ProfileGroupDefinition();

            def.type             = GroupType.Number;
            def.formatStyle      = formatStyle;
            def.groupName        = groupName;
            def.propertyKey      = propKey;
            def.value            = value;
            def.minimumValue     = minimumValue;
            def.maximumValue     = maximumValue;
            def.tooltip          = tooltip;
            def.rebuildType      = rebuildType;
            def.dependsOnFeature = dependsOnKeyword;
            def.dependsOnValue   = dependsOnValue;

            return(def);
        }
Example #13
0
        public static string Whois(WhoisResult whois, FormatStyle style)
        {
            if (whois == null || !whois.Success)
            {
                return(null);
            }

            string result = whois.Name.Nickname;

            switch (style)
            {
            case FormatStyle.Small:
                result += string.Format(" (L {0}/{1} {2})", whois.Stats.Level, whois.Stats.DefenderLevel, whois.Stats.Profession);
                break;

            case FormatStyle.Compact:
                result += string.Format(" (L {0}/{1} {2} {3})", whois.Stats.Level, whois.Stats.DefenderLevel, whois.Stats.Faction, whois.Stats.Profession);
                break;

            case FormatStyle.Medium:
                result += string.Format(" (Level {0}/{1} {2} {3})", whois.Stats.Level, whois.Stats.DefenderLevel, whois.Stats.Faction, whois.Stats.Profession);
                if (whois.InOrganization)
                {
                    result += string.Format(" {0} of {1}", whois.Organization.Rank, whois.Organization.Name);
                }
                break;

            case FormatStyle.Large:
                result += string.Format(" (Level {0} / Defender Rank {1}) {2} {3} {4}", whois.Stats.Level, whois.Stats.DefenderLevel, whois.Stats.Faction, whois.Stats.Breed, whois.Stats.Profession);
                if (whois.InOrganization)
                {
                    result += string.Format(", {0} of {1}", whois.Organization.Rank, whois.Organization.Name);
                }
                break;
            }
            return(result);
        }
Example #14
0
 /// <summary>
 /// Pushes a paragraph <see cref="FormatStyle"/> onto the stack.
 /// </summary>
 /// <param name="formatStyle">The paragraph  <see cref="FormatStyle"/>.</param>
 public void PushParagraphFormat(FormatStyle formatStyle)
 {
     _currentParagraphFormatStack.Add(formatStyle);
 }
Example #15
0
 public StringFromInt(int number, FormatStyle format)
 {
     this.Number = number;
     Format      = format;
 }
Example #16
0
 public static FormatStringGroup InitReportFormats(FormatStyle FormatStyle)
 {
     return(Agent.CallService("Yqun.BO.ReportManager.dll", "InitReportFormats", new object[] { FormatStyle }) as FormatStringGroup);
 }
Example #17
0
 public static string DateTime(long timestamp, FormatStyle style)
 {
     return(DateTime(TimeStamp.ToDateTime(timestamp), style));
 }
Example #18
0
 public static string DateTime(DateTime date, FormatStyle style)
 {
     return(Date(date, style) + ", " + Time(date, style));
 }
Example #19
0
 public virtual Y SetFormatStyle(FormatStyle style)
 {
     throw new Exception("Must override this function!!!");
 }
Example #20
0
 public void SetSelectedFormat(FormatStyle format)
 {
     m_selectedFormat = format;
 }
Example #21
0
        private void InitFormatTree()
        {
            FormatTreeNode node;
            FormatObject   obj2;

            if (base.IsDataGridMode)
            {
                System.Web.UI.WebControls.DataGrid baseControl = (System.Web.UI.WebControls.DataGrid)base.GetBaseControl();
                obj2 = new FormatStyle(baseControl.ControlStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EntireDG"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(baseControl.HeaderStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Header"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(baseControl.FooterStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Footer"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(baseControl.PagerStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Pager"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                FormatTreeNode node2 = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Items"), null);
                this.formatTree.Nodes.Add(node2);
                obj2 = new FormatStyle(baseControl.ItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_NormalItems"), obj2);
                node2.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(baseControl.AlternatingItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_AltItems"), obj2);
                node2.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(baseControl.SelectedItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_SelItems"), obj2);
                node2.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(baseControl.EditItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EditItems"), obj2);
                node2.Nodes.Add(node);
                this.formatNodes.Add(node);
                DataGridColumnCollection columns = baseControl.Columns;
                int count = columns.Count;
                if (count != 0)
                {
                    FormatTreeNode node3 = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Columns"), null);
                    this.formatTree.Nodes.Add(node3);
                    for (int i = 0; i < count; i++)
                    {
                        DataGridColumn runtimeColumn = columns[i];
                        string         text          = "Columns[" + i.ToString(NumberFormatInfo.CurrentInfo) + "]";
                        string         headerText    = runtimeColumn.HeaderText;
                        if (headerText.Length != 0)
                        {
                            text = text + " - " + headerText;
                        }
                        obj2 = new FormatColumn(runtimeColumn);
                        obj2.LoadFormatInfo();
                        FormatTreeNode node4 = new FormatTreeNode(text, obj2);
                        node3.Nodes.Add(node4);
                        this.formatNodes.Add(node4);
                        obj2 = new FormatStyle(runtimeColumn.HeaderStyle);
                        obj2.LoadFormatInfo();
                        node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Header"), obj2);
                        node4.Nodes.Add(node);
                        this.formatNodes.Add(node);
                        obj2 = new FormatStyle(runtimeColumn.FooterStyle);
                        obj2.LoadFormatInfo();
                        node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Footer"), obj2);
                        node4.Nodes.Add(node);
                        this.formatNodes.Add(node);
                        obj2 = new FormatStyle(runtimeColumn.ItemStyle);
                        obj2.LoadFormatInfo();
                        node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Items"), obj2);
                        node4.Nodes.Add(node);
                        this.formatNodes.Add(node);
                    }
                }
            }
            else
            {
                DataList list = (DataList)base.GetBaseControl();
                obj2 = new FormatStyle(list.ControlStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EntireDL"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(list.HeaderStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Header"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(list.FooterStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Footer"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
                FormatTreeNode node5 = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Items"), null);
                this.formatTree.Nodes.Add(node5);
                obj2 = new FormatStyle(list.ItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_NormalItems"), obj2);
                node5.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(list.AlternatingItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_AltItems"), obj2);
                node5.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(list.SelectedItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_SelItems"), obj2);
                node5.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(list.EditItemStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EditItems"), obj2);
                node5.Nodes.Add(node);
                this.formatNodes.Add(node);
                obj2 = new FormatStyle(list.SeparatorStyle);
                obj2.LoadFormatInfo();
                node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Separators"), obj2);
                this.formatTree.Nodes.Add(node);
                this.formatNodes.Add(node);
            }
        }
Example #22
0
 private void LoadFormatProperties()
 {
     if (this.currentFormatObject != null)
     {
         base.EnterLoadingMode();
         this.InitFormatUI();
         if (this.currentFormatObject is FormatStyle)
         {
             FormatStyle currentFormatObject = (FormatStyle)this.currentFormatObject;
             this.foreColorCombo.Color = currentFormatObject.foreColor;
             this.backColorCombo.Color = currentFormatObject.backColor;
             int num = -1;
             if (currentFormatObject.fontName.Length != 0)
             {
                 num = this.fontNameCombo.FindStringExact(currentFormatObject.fontName);
             }
             if (num != -1)
             {
                 this.fontNameCombo.SelectedIndex = num;
             }
             else
             {
                 this.fontNameCombo.Text = currentFormatObject.fontName;
             }
             this.boldCheck.Checked      = currentFormatObject.bold;
             this.italicCheck.Checked    = currentFormatObject.italic;
             this.underlineCheck.Checked = currentFormatObject.underline;
             this.strikeOutCheck.Checked = currentFormatObject.strikeOut;
             this.overlineCheck.Checked  = currentFormatObject.overline;
             if (currentFormatObject.fontType != -1)
             {
                 this.fontSizeCombo.SelectedIndex = currentFormatObject.fontType;
                 if (currentFormatObject.fontType == 10)
                 {
                     this.fontSizeUnit.Value = currentFormatObject.fontSize;
                 }
             }
             if (currentFormatObject.horzAlignment == 0)
             {
                 this.horzAlignCombo.SelectedIndex = -1;
             }
             else
             {
                 this.horzAlignCombo.SelectedIndex = currentFormatObject.horzAlignment;
             }
             if (currentFormatObject.vertAlignment == 0)
             {
                 this.vertAlignCombo.SelectedIndex = -1;
             }
             else
             {
                 this.vertAlignCombo.SelectedIndex = currentFormatObject.vertAlignment;
             }
             this.allowWrappingCheck.Checked = currentFormatObject.allowWrapping;
         }
         else
         {
             FormatColumn column = (FormatColumn)this.currentFormatObject;
             this.widthUnit.Value = column.width;
         }
         base.ExitLoadingMode();
     }
     this.UpdateEnabledVisibleState();
 }
 private void InitFormatTree()
 {
     FormatTreeNode node;
     FormatObject obj2;
     if (base.IsDataGridMode)
     {
         System.Web.UI.WebControls.DataGrid baseControl = (System.Web.UI.WebControls.DataGrid) base.GetBaseControl();
         obj2 = new FormatStyle(baseControl.ControlStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EntireDG"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(baseControl.HeaderStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Header"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(baseControl.FooterStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Footer"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(baseControl.PagerStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Pager"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         FormatTreeNode node2 = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Items"), null);
         this.formatTree.Nodes.Add(node2);
         obj2 = new FormatStyle(baseControl.ItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_NormalItems"), obj2);
         node2.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(baseControl.AlternatingItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_AltItems"), obj2);
         node2.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(baseControl.SelectedItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_SelItems"), obj2);
         node2.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(baseControl.EditItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EditItems"), obj2);
         node2.Nodes.Add(node);
         this.formatNodes.Add(node);
         DataGridColumnCollection columns = baseControl.Columns;
         int count = columns.Count;
         if (count != 0)
         {
             FormatTreeNode node3 = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Columns"), null);
             this.formatTree.Nodes.Add(node3);
             for (int i = 0; i < count; i++)
             {
                 DataGridColumn runtimeColumn = columns[i];
                 string text = "Columns[" + i.ToString(NumberFormatInfo.CurrentInfo) + "]";
                 string headerText = runtimeColumn.HeaderText;
                 if (headerText.Length != 0)
                 {
                     text = text + " - " + headerText;
                 }
                 obj2 = new FormatColumn(runtimeColumn);
                 obj2.LoadFormatInfo();
                 FormatTreeNode node4 = new FormatTreeNode(text, obj2);
                 node3.Nodes.Add(node4);
                 this.formatNodes.Add(node4);
                 obj2 = new FormatStyle(runtimeColumn.HeaderStyle);
                 obj2.LoadFormatInfo();
                 node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Header"), obj2);
                 node4.Nodes.Add(node);
                 this.formatNodes.Add(node);
                 obj2 = new FormatStyle(runtimeColumn.FooterStyle);
                 obj2.LoadFormatInfo();
                 node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Footer"), obj2);
                 node4.Nodes.Add(node);
                 this.formatNodes.Add(node);
                 obj2 = new FormatStyle(runtimeColumn.ItemStyle);
                 obj2.LoadFormatInfo();
                 node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Items"), obj2);
                 node4.Nodes.Add(node);
                 this.formatNodes.Add(node);
             }
         }
     }
     else
     {
         DataList list = (DataList) base.GetBaseControl();
         obj2 = new FormatStyle(list.ControlStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EntireDL"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(list.HeaderStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Header"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(list.FooterStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Footer"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
         FormatTreeNode node5 = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Items"), null);
         this.formatTree.Nodes.Add(node5);
         obj2 = new FormatStyle(list.ItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_NormalItems"), obj2);
         node5.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(list.AlternatingItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_AltItems"), obj2);
         node5.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(list.SelectedItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_SelItems"), obj2);
         node5.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(list.EditItemStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_EditItems"), obj2);
         node5.Nodes.Add(node);
         this.formatNodes.Add(node);
         obj2 = new FormatStyle(list.SeparatorStyle);
         obj2.LoadFormatInfo();
         node = new FormatTreeNode(System.Design.SR.GetString("BDLFmt_Node_Separators"), obj2);
         this.formatTree.Nodes.Add(node);
         this.formatNodes.Add(node);
     }
 }
Example #24
0
 protected virtual T Render(IWorkbook workbook, FormatStyle formatStyle)
 {
     throw new Exception("Must override this function!!!");
 }
Example #25
0
 public T Render(ICell cell, FormatStyle formatStyle)
 {
     return(Render(cell.Sheet.Workbook, formatStyle));
 }
Example #26
0
 public override XSSFNPoiStyle SetFormatStyle(FormatStyle style)
 {
     this.FormatStyle = style;
     this.CellFormat  = this.CellFormats.FormatStringFromStyle(style);
     return(this);
 }
Example #27
0
        protected override XSSFCellStyle Render(IWorkbook workbook, FormatStyle formatStyle)
        {
            //var saveCellFormat = this.CellFormat;
            //this.CellFormat = this.CellFormats.FormatStringFromStyle(formatStyle);
            string thisStyleCacheKey = GetSha256Hash(JsonConvert.SerializeObject(this));

            //this.CellFormat = saveCellFormat;

            if (NPoiExtentions.StyleCache.ContainsKey(thisStyleCacheKey))
            {
                return((XSSFCellStyle)NPoiExtentions.StyleCache[thisStyleCacheKey]);
            }

            XSSFCellStyle cellStyle        = (XSSFCellStyle)workbook.CreateCellStyle();
            var           defaultCellStyle = workbook.GetCellStyleAt(0);

            if (this.Border != CellBorder.None)
            {
                if (this.Border.HasFlag(CellBorder.Top))
                {
                    cellStyle.BorderTop = this.BorderStyle;
                    if (this.BorderColor == null)
                    {
                        cellStyle.TopBorderColor = defaultCellStyle.TopBorderColor;
                    }
                    else
                    {
                        cellStyle.SetTopBorderColor(this.BorderColor.AsXSSFColor());
                        cellStyle.SetBorderColor(NPOI.XSSF.UserModel.Extensions.BorderSide.TOP, this.BorderColor.AsXSSFColor());
                    }
                }
                if (this.Border.HasFlag(CellBorder.Bottom))
                {
                    cellStyle.BorderBottom = this.BorderStyle;
                    if (this.BorderColor == null)
                    {
                        cellStyle.BottomBorderColor = defaultCellStyle.BottomBorderColor;
                    }
                    else
                    {
                        cellStyle.SetBottomBorderColor(this.BorderColor.AsXSSFColor());
                        cellStyle.SetBorderColor(NPOI.XSSF.UserModel.Extensions.BorderSide.BOTTOM, this.BorderColor.AsXSSFColor());
                    }
                }
                if (this.Border.HasFlag(CellBorder.Right))
                {
                    cellStyle.BorderRight = this.BorderStyle;
                    if (this.BorderColor == null)
                    {
                        cellStyle.RightBorderColor = defaultCellStyle.RightBorderColor;
                    }
                    else
                    {
                        cellStyle.SetRightBorderColor(this.BorderColor.AsXSSFColor());
                        cellStyle.SetBorderColor(NPOI.XSSF.UserModel.Extensions.BorderSide.RIGHT, this.BorderColor.AsXSSFColor());
                    }
                }
                if (this.Border.HasFlag(CellBorder.Left))
                {
                    cellStyle.BorderLeft = this.BorderStyle;
                    if (this.BorderColor == null)
                    {
                        cellStyle.LeftBorderColor = defaultCellStyle.LeftBorderColor;
                    }
                    else
                    {
                        cellStyle.SetLeftBorderColor(this.BorderColor.AsXSSFColor());
                        cellStyle.SetBorderColor(NPOI.XSSF.UserModel.Extensions.BorderSide.LEFT, this.BorderColor.AsXSSFColor());
                    }
                }
            }
            if ((this.FontHeightInPoints.HasValue) || (this.FontName != null) || (this.FontColor != null) || (this.IsBold.HasValue) || (this.IsItalic.HasValue))
            {
                var defaultFont = workbook.GetFontAt(0);
                var font        = workbook.CreateFont();
                font.FontHeightInPoints = (this.FontHeightInPoints.HasValue) ? this.FontHeightInPoints.Value : defaultFont.FontHeightInPoints;
                font.FontName           = (this.FontName != null) ? this.FontName : defaultFont.FontName;           // this.FontName;
                font.Color    = (this.FontColor != null) ? this.FontColor.AsXSSFColor().Indexed: defaultFont.Color; //this.FontColor.Indexed;
                font.IsBold   = (this.IsBold.HasValue) ? this.IsBold.Value : defaultFont.IsBold;                    //this.IsBold;
                font.IsItalic = (this.IsItalic.HasValue) ? this.IsItalic.Value : defaultFont.IsItalic;              //this.IsItalic;
                cellStyle.SetFont(font);
            }
            if (this.BackgroundColor != null)
            {
                cellStyle.SetFillBackgroundColor(this.BackgroundColor.AsXSSFColor());
            }
            if (this.HorizontalAlignment != null)
            {
                cellStyle.Alignment = this.HorizontalAlignment.Value;
            }
            if (this.VerticalAlignment != null)
            {
                cellStyle.VerticalAlignment = this.VerticalAlignment.Value;
            }
            if (!string.IsNullOrEmpty(this.CellFormat))
            {
                cellStyle.DataFormat = workbook.CreateDataFormat().GetFormat(this.CellFormat);
            }
            if (this.FillForegroundColor != null)
            {
                cellStyle.SetFillForegroundColor(FillForegroundColor.AsXSSFColor());
            }
            if (this.FillPattern != null)
            {
                cellStyle.FillPattern = this.FillPattern.Value;
            }
            if (this.WrapText != null)
            {
                cellStyle.WrapText = this.WrapText.Value;
            }


            if (!NPoiExtentions.StyleCache.ContainsKey(thisStyleCacheKey))
            {
                NPoiExtentions.StyleCache.Remove(thisStyleCacheKey);
            }
            NPoiExtentions.StyleCache.Add(thisStyleCacheKey, cellStyle);
            return(cellStyle);
        }