예제 #1
0
 public static CustomFormatResource ToResource(this CustomFormat model)
 {
     return(new CustomFormatResource
     {
         Id = model.Id,
         Name = model.Name,
         FormatTags = model.FormatTags.Select(t => t.Raw.ToUpper()).ToList(),
     });
 }
예제 #2
0
 public static CustomFormatResource ToResource(this CustomFormat model)
 {
     return(new CustomFormatResource
     {
         Id = model.Id,
         Name = model.Name,
         IncludeCustomFormatWhenRenaming = model.IncludeCustomFormatWhenRenaming,
         Specifications = model.Specifications.Select(x => x.ToSchema()).ToList()
     });
 }
예제 #3
0
        public void GenerateFields <T>(List <T> list, CustomFormat customFormat)
        {
            // Create new stopwatch
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            foreach (var data in list)
            {
                foreach (var excelColumn in _excelColumns)
                {
                    excelColumn.LastIndex++;

                    var value          = Convert.ToString(data.GetReflectedValue(excelColumn.PropertyName), CultureInfo.InvariantCulture);
                    var style          = excelColumn.Style;
                    var excelCellValue = excelColumn.ExcelCellValue;

                    if (excelColumn.DataFormatString.ToLower() == "custom" && customFormat != null)
                    {
                        value = customFormat(Type.GetType(excelColumn.PropertyType), value);
                    }
                    else
                    {
                        if (excelColumn.PropertyType == typeof(TimeSpan).FullName)
                        {
                            var tmv = (TimeSpan)data.GetReflectedValue(excelColumn.PropertyName);
                            value = string.Format("{0:00}:{1:00}:{2:00}", tmv.Hours, tmv.Minutes, tmv.Seconds);
                        }
                        else if (excelColumn.PropertyType == typeof(DateTime).FullName ||
                                 excelColumn.PropertyType == typeof(DateTime?).FullName)
                        {
                            try
                            {
                                var tmv = (DateTime)data.GetReflectedValue(excelColumn.PropertyName);
                                value = string.Format(excelColumn.DataFormatString, tmv);
                                //tmv.ToString(excelColumn.DataFormatString.Replace("{0:", "").Replace("}", ""));
                            }
                            catch (Exception)
                            {
                                value = string.Empty;
                            }
                            excelCellValue = CellValues.SharedString;
                        }
                    }

                    var address = excelColumn.ExcelCol + (excelColumn.ExcelRow + excelColumn.LastIndex);
                    _wbPart.UpdateValue(SheetName, address, value, style, excelCellValue, _sharedStrings);
                }
            }
            // Actualizo los condicionales
            foreach (var ex in _excelColumns.Where(e => !string.IsNullOrEmpty(e.ConditionalFormatStart)))
            {
                _wbPart.UpdateConditionalOver(SheetName, ex.ConditionalFormatStart, ex.ConditionalFormatStart + ":" + ex.ExcelCol + (ex.ExcelRow + ex.LastIndex));
            }

            stopwatch.Stop();
        }
예제 #4
0
        private void GivenCustomFormatHigher()
        {
            _customFormat = new CustomFormat("My Format", new ResolutionSpecification {
                Value = (int)Resolution.R1080p
            })
            {
                Id = 1
            };

            CustomFormatsFixture.GivenCustomFormats(_customFormat);
        }
예제 #5
0
        private static IEnumerable <IInputFile> CreateInputFiles()
        {
            List <IInputFile> resultList   = new List <IInputFile>();
            IInputFile        customFormat = new CustomFormat("Custom Format", "RRSP", "C", "BcdCode");

            resultList.Add(customFormat);
            IInputFile standardFormat = new StandardFormat("Standard", 2, "CD", "123|AbcCode", DateTime.Now);

            resultList.Add(standardFormat);
            return(resultList);
        }
예제 #6
0
        /// <summary>
        /// 验证是否有效
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public override bool IsValid(object value)
        {
            if (!base.IsValid(value))
            {
                return(false);
            }

            var str = value?.ToString();

            if (string.IsNullOrEmpty(str))
            {
                if (!AllowEmpty)
                {
                    ErrorMessage = $"\"{Name.GetValue()}\"不允许空值";
                    return(false);
                }
                return(true);
            }

            if (string.IsNullOrWhiteSpace(str))
            {
                if (!AllowSpace)
                {
                    ErrorMessage = $"\"{Name.GetValue()}\"不允许空白字符";
                    return(false);
                }
                return(true);
            }

            if (RegexPattern.IsValid())
            {
                var rgx = new Regex(RegexPattern, RegexOptions);
                if (!rgx.IsMatch(value?.ToString()))
                {
                    ErrorMessage = $"\"{Name.GetValue()}\"{RegExMessage.GetValue("格式错误")}";
                    return(false);
                }
            }

            CustomFormat format = null;

            if (DateTimeFormat.IsValid())
            {
                format = CustomFormat.DateTimeFormat(DateTimeFormat);
                var error = InputHelper.ValidateInput(TextInputMode.All, value?.ToString().GetValue(), false, format);
                if (error.IsValid())
                {
                    ErrorMessage = $"\"{Name.GetValue()}\"{error}";
                    return(false);
                }
            }

            return(true);
        }
예제 #7
0
        public int Compare(List <CustomFormat> left, CustomFormat right)
        {
            if (left.Count == 0)
            {
                left.Add(CustomFormat.None);
            }

            var leftIndicies = GetIndicies(left, _profile);
            var rightIndex   = _profile.FormatItems.FindIndex(v => Equals(v.Format, right));

            return(leftIndicies.Select(i => i.CompareTo(rightIndex)).Sum());
        }
        /// <summary>
        /// 验证是否有效
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public override bool IsValid(object value)
        {
            if (!base.IsValid(value))
            {
                return(false);
            }

            var mode = TextInputMode.All;

            if (AllowDot) //小数
            {
                mode = IsSigned ? TextInputMode.SignedFloat : TextInputMode.UnsignedFloat;
            }
            else //整数
            {
                mode = IsSigned ? TextInputMode.SignedInt : TextInputMode.UnsignedInt;
            }

            CustomFormat format   = null;
            double?      minValue = (MinValue > double.MinValue) ? MinValue : (double?)null;
            double?      maxValue = (MaxValue < double.MaxValue) ? MaxValue : (double?)null;

            if (DecimalPlace > 0 || minValue.HasValue || maxValue.HasValue)
            {
                format = CustomFormat.DecimalFormat(
                    decimalPlace: (DecimalPlace > 0 ? (uint?)DecimalPlace : null),
                    minValue: (minValue.HasValue ? (decimal?)minValue.Value : null),
                    maxValue: (maxValue.HasValue ? (decimal?)maxValue.Value : null));
            }

            ErrorMessage = InputHelper.ValidateInput(mode, value?.ToString().GetValue(), AllowZero, format);
            if (ErrorMessage.IsValid())
            {
                if (DecimalPlace > 0 && ErrorMessage.Contains(InputHelper.InvalidFormat))
                {
                    ErrorMessage = $"\"{Name.GetValue()}\"最多只能输入 {DecimalPlace} 位小数";
                }
                else
                {
                    ErrorMessage = $"\"{Name.GetValue()}\"{ErrorMessage}";
                }

                return(false);
            }

            if (!AllowEmpty && !(value?.ToString().IsValid() ?? false))
            {
                ErrorMessage = $"\"{Name.GetValue()}\"不能为空";
                return(false);
            }

            return(true);
        }
예제 #9
0
    private void SelectFunction(ShapeType _shapeType)
    {
        switch (_shapeType)
        {
        case ShapeType.圆球:
            shapeContext = CustomFormat.ShapeContextFormat("Sphere(p{0},{1})", positionXYZ, rotationXYZ, sizeXYZ.x);
            break;

        case ShapeType.正方体:
            shapeContext = CustomFormat.ShapeContextFormat("Cube(p{0},{1})", positionXYZ, rotationXYZ, sizeXYZ.x);
            break;

        case ShapeType.长方体:
            shapeContext = "";
            break;

        case ShapeType.圆柱体:
            shapeContext = "";
            break;

        case ShapeType.胶囊体:
            shapeContext = "";
            break;

        case ShapeType.椎体:
            shapeContext = "";
            break;

        case ShapeType.甜甜圈:
            shapeContext = "";
            break;

        case ShapeType.Line3D:
            shapeContext = "";
            break;

        case ShapeType.平面:
            shapeContext = "";
            break;

        case ShapeType.贝塞尔3D:
            shapeContext = "";
            break;

        default:
            break;
        }
        data_outAll[0].Shape_or_Morph_context = shapeContext;
    }
 private void DateTimeInputDialog_Load(object sender, EventArgs e)
 {
     if (!CustomFormat.IsNullOrEmpty())
     {
         dateTimePicker.CustomFormat = CustomFormat;
     }
     else
     {
         dateTimePicker.CustomFormat = "yyyy-MM-dd HH:mm:ss";
     }
     if (dateTimePicker.CustomFormat == "yyyy-MM")
     {
         this.dateTimePicker.Value = DateTime.Now.AddDays(1 - DateTime.Now.Day);
     }
 }
예제 #11
0
        public void AddCustomFormat(CustomFormat customFormat)
        {
            var all = All();

            foreach (var profile in all)
            {
                profile.FormatItems.Add(new ProfileFormatItem
                {
                    Allowed = true,
                    Format  = customFormat
                });

                Update(profile);
            }
        }
예제 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RadarrClient" /> class.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="apiKey">The API key.</param>
        /// <param name="urlBase">The URL base.</param>
        /// <param name="useSsl">if set to <c>true</c> [use SSL].</param>
        public RadarrClient(string host, int port, string apiKey, [Optional] string urlBase, [Optional] bool useSsl)
        {
            // Initialize properties
            Host    = host;
            Port    = port;
            ApiKey  = apiKey;
            UrlBase = urlBase;
            UseSsl  = useSsl;

            // Set API URL
            var sb = new StringBuilder();

            sb.Append("http");
            if (UseSsl)
            {
                sb.Append("s");
            }
            sb.Append($"://{host}:{Port}");
            if (UrlBase != null)
            {
                sb.Append($"/{UrlBase}");
            }
            sb.Append("/api");
            ApiUrl = sb.ToString();

            // Initialize endpoints
            Calendar          = new Calendar(this);
            Command           = new Command(this);
            Diskspace         = new Diskspace(this);
            History           = new History(this);
            Movie             = new Movie(this);
            SystemStatus      = new SystemStatus(this);
            Profile           = new Profile(this);
            Wanted            = new Wanted(this);
            Log               = new Log(this);
            Queue             = new Queue(this);
            Release           = new Release(this);
            QualityDefinition = new QualityDefinition(this);
            Indexer           = new Indexer(this);
            Restriction       = new Restriction(this);
            Blacklist         = new Blacklist(this);
            Notification      = new Notification(this);
            RootFolder        = new RootFolder(this);
            Config            = new Config(this);
            ExtraFile         = new ExtraFile(this);
            CustomFormat      = new CustomFormat(this);
        }
    private void SelectFunction(MorphType _morphType)
    {
        switch (_morphType)
        {
        case MorphType.融合:
            ModelContext = CustomFormat.MorphContextFormat(this, "min", data_inAll);
            break;

        case MorphType.相交:
            ModelContext = CustomFormat.MorphContextFormat(this, "max", data_inAll);
            break;

        case MorphType.相差:
            ModelContext = CustomFormat.MorphContextFormat(this, "Subtract", data_inAll);
            break;
        }
    }
예제 #14
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                FormatBase result    = null;
                string     className = (string)value;
                switch (className)
                {
                case "Boolean":
                    result = new BooleanFormat();
                    break;

                case "Currency":
                    result = new CurrencyFormat();
                    break;

                case "Custom":
                    result = new CustomFormat();
                    break;

                case "Date":
                    result = new DateFormat();
                    break;

                case "General":
                    result = new GeneralFormat();
                    break;

                case "Number":
                    result = new NumberFormat();
                    break;

                case "Percent":
                    result = new PercentFormat();
                    break;

                case "Time":
                    result = new TimeFormat();
                    break;
                }
                return(result);
            }
            return(base.ConvertFrom(context, culture, value));
        }
예제 #15
0
    public bool ConsumeItemList(List <List <int> > item_list, bool is_check = false)
    {
        item_list = this.MergeItem(item_list);
        if (item_list == null)
        {
            return(false);
        }

        foreach (List <int> item_info in item_list)
        {
            int item_id = 0, count = 0, bind = 0, addition = 0;
            CustomFormat.ParseItemInfo(item_info, ref item_id, ref count, ref bind, ref addition);
            if (!this.ReduceItem(item_id, count, bind, is_check))
            {
                return(false);
            }
        }
        return(true);
    }
예제 #16
0
 private void OnCustomColumnDisplayText(object sender, DevExpress.Xpf.Grid.CustomColumnDisplayTextEventArgs e)
 {
     CustomFormat.FormatStorageColumns(e);
 }
예제 #17
0
 public CustomFormatAddedEvent(CustomFormat format)
 {
     CustomFormat = format;
 }
예제 #18
0
        /// <summary>
        /// Prepare report when finished
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reportBuilder"></param>
        /// <returns></returns>
        public static Report Prepare <T>(this ReportBuilder <T> reportBuilder)
        {
            var report = new Report();
            var name   = typeof(T).Name;

            report.RegisterData(reportBuilder._data, name);
            report.GetDataSource(name).Enabled = true;

            ReportPage page = new ReportPage();

            report.Pages.Add(page);
            page.CreateUniqueName();

            page.ReportTitle        = new ReportTitleBand();
            page.ReportTitle.Height = Units.Centimeters * 1;
            page.ReportTitle.CreateUniqueName();
            page.ReportTitle.Visible = reportBuilder._reportTitle.Visible;

            TextObject titleText = new TextObject();

            titleText.Parent = page.ReportTitle;
            titleText.CreateUniqueName();
            titleText.Bounds    = new RectangleF(Units.Centimeters * 5, 0, Units.Centimeters * 10, Units.Centimeters * 1);
            titleText.Font      = reportBuilder._reportTitle.Font;
            titleText.Text      = reportBuilder._reportTitle.Text;
            titleText.TextColor = reportBuilder._reportTitle.TextColor;
            titleText.FillColor = reportBuilder._reportTitle.FillColor;
            titleText.HorzAlign = HorzAlign.Center;

            DataBand dataBand = new DataBand();

            dataBand.Parent = page;
            dataBand.CreateUniqueName();
            dataBand.DataSource = report.GetDataSource(name);
            dataBand.Height     = Units.Centimeters * 0.5f;

            if (reportBuilder._groupHeader.Visible)
            {
                GroupHeaderBand groupHeader = new GroupHeaderBand();
                groupHeader.CreateUniqueName();
                groupHeader.Height    = Units.Centimeters * 0.5f;
                groupHeader.Condition = string.IsNullOrEmpty(reportBuilder._groupHeader.Expression)
                    ? $"[{name}.{reportBuilder._groupHeader.Name}]"
                    : string.Format(reportBuilder._groupHeader.Expression, $"[{name}.{reportBuilder._groupHeader.Name}]");
                groupHeader.Data      = dataBand;
                groupHeader.SortOrder = reportBuilder._groupHeader.SortOrder;
                groupHeader.Parent    = page;

                if (reportBuilder._groupHeader.TextVisible)
                {
                    TextObject textGroupHeader = new TextObject();
                    textGroupHeader.CreateUniqueName();
                    textGroupHeader.Bounds = new RectangleF(0, 0, Units.Centimeters * 2, Units.Centimeters * 0.5f);
                    textGroupHeader.Text   = $"[{groupHeader.Condition}]";
                    textGroupHeader.Font   = new Font("Tahoma", 10, FontStyle.Bold);
                    textGroupHeader.Parent = groupHeader;
                }
            }

            var dataHeaderBand = new DataHeaderBand();

            if (reportBuilder._dataHeader.Visible)
            {
                dataHeaderBand.Parent = dataBand;
                dataHeaderBand.CreateUniqueName();
                dataHeaderBand.Height = Units.Centimeters * 0.5f;
            }

            float leftCm       = 0.0f;
            float size         = 0.0f;
            float pageWidth    = page.PaperWidth - (page.LeftMargin + page.RightMargin);
            float cellWidth    = pageWidth / 100;
            var   remainColumn = reportBuilder._columns.Count(a => a.Width == 0);
            float remainSize   = 100 - reportBuilder._columns.Sum(a => a.Width);
            float remainWidth  = remainSize / (remainColumn * 10);

            foreach (var item in reportBuilder._columns)
            {
                size = item.Width == 0 ? remainWidth : (float)item.Width / 10;
                if (reportBuilder._dataHeader.Visible)
                {
                    TextObject headerText = new TextObject();
                    headerText.CreateUniqueName();
                    headerText.Bounds       = new RectangleF(leftCm, 0f * Units.Centimeters, cellWidth * Units.Centimeters * size, 0.1f * Units.Centimeters);
                    headerText.VertAlign    = reportBuilder._reportTitle.VertAlign ?? reportBuilder._report.VertAlign;
                    headerText.HorzAlign    = reportBuilder._reportTitle.HorzAlign ?? reportBuilder._report.HorzAlign;
                    headerText.Font         = reportBuilder._dataHeader.Font;
                    headerText.TextColor    = reportBuilder._dataHeader.TextColor;
                    headerText.FillColor    = reportBuilder._dataHeader.FillColor;
                    headerText.Border.Lines = BorderLines.All;
                    headerText.Text         = item.Title;
                    headerText.GrowToBottom = true;
                    headerText.Parent       = dataHeaderBand;
                }

                TextObject text = new TextObject();
                text.Parent = dataBand;
                text.CreateUniqueName();
                text.Bounds = new RectangleF(leftCm, 0, Units.Centimeters * cellWidth * size, Units.Centimeters * 0.5f);
                text.Text   = string.IsNullOrEmpty(item.Expression)
                    ? $"[{name}.{item.Name}]"
                    : string.Format($"[{item.Expression}]", $"[{name}.{item.Name}]");
                text.Border.Lines = BorderLines.All;
                text.TextColor    = Color.Black;
                text.VertAlign    = item.VertAlign ?? reportBuilder._report.VertAlign;
                text.HorzAlign    = item.HorzAlign ?? reportBuilder._report.HorzAlign;

                if (!string.IsNullOrEmpty(item.Format))
                {
                    CustomFormat format = new CustomFormat();
                    format.Format = item.Format;
                    text.Format   = format;
                }

                leftCm += cellWidth * Units.Centimeters * size;
            }

            report.Prepare();

            return(report);
        }
예제 #19
0
 public CustomFormatDeletedEvent(CustomFormat format)
 {
     CustomFormat = format;
 }
예제 #20
0
        public string ToString(HourAngleFormat format)
        {
            string text = string.Empty;
            int    hours;
            int    minutes;
            double doubleMinutes;
            double seconds;
            int    increment;

            switch (format)
            {
            case HourAngleFormat.DecimalHours:
                text = CustomFormat.ToString(Resources.HourAngleInDecimalHours, _NumberDecimalDigitsForHours, Value);
                break;

            case HourAngleFormat.HoursDecimalMinutes:
                increment     = (Value >= 0.0 ? 1 : -1);
                doubleMinutes = Math.Round((double)Minutes + (Seconds / 60.0), _NumberDecimalDigitsForHours);
                if (Math.Abs(doubleMinutes) < 60.0)
                {
                    hours = Hours;
                }
                else
                {
                    doubleMinutes = 0.0;
                    hours         = Hours + increment;
                }

                text = CustomFormat.ToString(Resources.HourAngleInHoursDecimalMinutes, _NumberDecimalDigitsForHours,
                                             hours, doubleMinutes);
                break;

            case HourAngleFormat.HoursMinutesSeconds:
            case HourAngleFormat.CadHoursMinutesSeconds:
            case HourAngleFormat.CompactHoursMinutesSeconds:
                increment = (Value >= 0.0 ? 1 : -1);
                seconds   = Math.Round(Seconds, format != HourAngleFormat.CompactHoursMinutesSeconds ? _NumberDecimalDigitsForSeconds
                                                                                                      : HourAngle.NumberDecimalDigitsForCompactSeconds);

                if (Math.Abs(seconds) < 60.0)
                {
                    minutes = Minutes;
                }
                else
                {
                    seconds = 0.0;
                    minutes = Minutes + increment;
                }

                if (Math.Abs(minutes) < 60)
                {
                    hours = Hours;
                }
                else
                {
                    minutes = 0;
                    hours   = Hours + increment;
                }

                if (format == HourAngleFormat.HoursMinutesSeconds)
                {
                    text = CustomFormat.ToString(Resources.HourAngleInHoursMinutesSeconds, _NumberDecimalDigitsForSeconds,
                                                 hours, minutes, seconds);
                }
                else if (format == HourAngleFormat.CompactHoursMinutesSeconds)
                {
                    text = CustomFormat.ToString(Resources.HoursAngleInCompactHoursMinutesSeconds, _NumberDecimalDigitsForSeconds,
                                                 hours, minutes, seconds);
                }
                else
                {
                    /* Because 'CAD' coordinates use a comma as the lat/long delimiter, a period must
                     * be used as the double point, hence the use of the InvariantCulture.
                     */
                    text = CustomFormat.ToString(CultureInfo.InvariantCulture,
                                                 Resources.HourAngleInCadHoursMinutesSeconds, _NumberDecimalDigitsForSeconds,
                                                 hours, minutes, seconds);
                }
                break;


            default:
                Debug.Assert(format == HourAngleFormat.NotSpecified, "Unrecognised HourAngleFormat value - " + format.ToString());
                text = CustomFormat.ToString(Resources.HourAngleWithNoFormat, _NumberDecimalDigitsForHours, Value);
                break;
            }

            return(text);
        }