Beispiel #1
0
 void SetSide(Panel panel, SidesEnum currentSides, SidesEnum side, ref Color savedColor)
 {
     if (panel.BackColor != Color.Black)
     {
         autoCrop.Sides &= currentSides;
         savedColor      = panel.BackColor;
         panel.BackColor = Color.Black;
     }
     else
     {
         autoCrop.Sides |= side;
         panel.BackColor = savedColor;
     }
 }
Beispiel #2
0
 public void AddNeighbours(SidesEnum side, TileClass tile)
 {
     neighbours[(int)side] = tile;
     CalculateAutotileID();
 }
        /// <summary>
        /// Generates the attribute.
        /// </summary>
        /// <param name="domainType">Type of the domain.</param>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="closedFrom">The closed from.</param>
        /// <param name="length">The length.</param>
        /// <param name="column">The column.</param>
        /// <param name="boxIdentity">The box identity.</param>
        /// <returns>Generated attribute.</returns>
        public static GeneratedAttribute Generate(
            AttributeDomainEnum domainType,
            string from,
			string to,
			SidesEnum closedFrom,
			double length,
			ColumnInfo column,
			string boxIdentity)
        {
            if (length <= 0)
                throw Ferda.Modules.Exceptions.BadParamsError(null, boxIdentity, "Length have to be greater than 0!", restrictionTypeEnum.Minimum);

            DataTable distincts = null;

            //get from, to values
            switch (domainType)
            {
                case AttributeDomainEnum.WholeDomain:
                    from = column.statistics.ValueMin;
                    to = column.statistics.ValueMax;
                    break;
                case AttributeDomainEnum.SubDomainValueBounds:
                    break;
                case AttributeDomainEnum.SubDomainNumberOfValuesBounds:
                    int fromTmp, toTmp;
                    try
                    {
                        fromTmp = (String.IsNullOrEmpty(from)) ? 0 : Convert.ToInt32(from);
                    }
                    catch (System.ArgumentException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    catch (System.OverflowException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    catch (System.FormatException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    try
                    {
                        toTmp = (String.IsNullOrEmpty(to)) ? 0 : Convert.ToInt32(to);
                    }
                    catch (System.ArgumentException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    catch (System.OverflowException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    catch (System.FormatException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    distincts = Ferda.Modules.Helpers.Data.Column.GetDistincts(column.dataMatrix.database.odbcConnectionString, column.dataMatrix.dataMatrixName, column.columnSelectExpression, boxIdentity);
                    if (distincts.Rows.Count > fromTmp + toTmp)
                    {
                        from = distincts.Rows[fromTmp].ItemArray[0].ToString();
                        to = distincts.Rows[distincts.Rows.Count - toTmp - 1].ItemArray[0].ToString();
                    }
                    else
                    {
                        return new GeneratedAttribute();
                        //TODO ???
                    }
                    break;
                default:
                    throw Ferda.Modules.Exceptions.SwitchCaseNotImplementedError(domainType);
            }
            if (String.IsNullOrEmpty(from))
                from = column.statistics.ValueMin;
            if (String.IsNullOrEmpty(to))
                to = column.statistics.ValueMax;

            switch (Ferda.Modules.Helpers.Data.Column.GetColumnValueTypeByValueSubType(column.columnSubType))
            {
                case Ferda.Modules.Helpers.Data.Column.ValueType.Floating:
                    float fromTmpFl, toTmpFl;
                    try
                    {
                        fromTmpFl = (String.IsNullOrEmpty(from)) ? 0 : Convert.ToSingle(from);
                    }
                    catch (System.InvalidCastException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    try
                    {
                        toTmpFl = (String.IsNullOrEmpty(to)) ? 0 : Convert.ToSingle(to);
                    }
                    catch (System.InvalidCastException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    return generateFloating(fromTmpFl, toTmpFl, closedFrom, (float)length, column);
                case Ferda.Modules.Helpers.Data.Column.ValueType.Integral:
                    long fromTmpLn, toTmpLn;
                    try
                    {
                        fromTmpLn = (String.IsNullOrEmpty(from)) ? 0 : Convert.ToInt64(from);
                    }
                    catch (System.ArgumentException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    catch (System.OverflowException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    catch (System.FormatException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                    try
                    {
                        toTmpLn = (String.IsNullOrEmpty(to)) ? 0 : Convert.ToInt64(to);
                    }
                    catch (System.ArgumentException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    catch (System.OverflowException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    catch (System.FormatException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                    return generateIntegral(fromTmpLn, toTmpLn, closedFrom, (long)length, column);
                case Ferda.Modules.Helpers.Data.Column.ValueType.DateTime:
                    throw Ferda.Modules.Exceptions.BadParamsError(null, boxIdentity, null, restrictionTypeEnum.DbColumnDataType);
                //TODO
                /*
                DateTime fromTmpDt, toTmpDt;
                try
                {
                    fromTmpDt = Convert.ToDateTime(from);
                }
                catch (System.InvalidCastException ex) { throw badParamsError(boxIdentity, new string[] { "From" }, ex); }
                try
                {
                    toTmpDt = Convert.ToDateTime(to);
                }
                catch (System.InvalidCastException ex) { throw badParamsError(boxIdentity, new string[] { "To" }, ex); }
                return generateDateTime(fromTmpDt, toTmpDt, closedFrom, (long)length, column);
                 */
                case Ferda.Modules.Helpers.Data.Column.ValueType.String:
                    if (distincts == null)
                        distincts = Ferda.Modules.Helpers.Data.Column.GetDistincts(column.dataMatrix.database.odbcConnectionString, column.dataMatrix.dataMatrixName, column.columnSelectExpression, boxIdentity);
                    //TODO lepe distincts (dle from a to)
                    return generateString(from, to, (long)length, distincts);
                case Ferda.Modules.Helpers.Data.Column.ValueType.Boolean:
                    throw Ferda.Modules.Exceptions.BadParamsError(null, boxIdentity, null, restrictionTypeEnum.DbColumnDataType);
                //TODO
                //return generateBoolean(Convert.ToBoolean(from), Convert.ToBoolean(to), closedFrom, (long)length, column);
                case Ferda.Modules.Helpers.Data.Column.ValueType.Unknown:
                    //TODO
                    throw Ferda.Modules.Exceptions.BadParamsError(null, boxIdentity, null, restrictionTypeEnum.DbColumnDataType);
                default:
                    throw Ferda.Modules.Exceptions.SwitchCaseNotImplementedError(Ferda.Modules.Helpers.Data.Column.GetColumnValueTypeByValueSubType(column.columnSubType));
            }
        }
Beispiel #4
0
        private static void applyBorders(SidesEnum sides, int xPos, int yPos, FrameType verticalBorder, FrameType horizontalBorder, ZCharAttribute? colors)
        {
            var currentResult = currentBuffer[yPos, xPos];
            var currentNode = currentResult.NodeEnumItem;

            var resultLeft	= Math.Max((int)(currentNode & (NodeEnum.LeftSingle  | NodeEnum.LeftDouble)),  (int)(sides & SidesEnum.Left)  * (int)horizontalBorder);
            var resultRight = Math.Max((int)(currentNode & (NodeEnum.RightSingle | NodeEnum.RightDouble)), (int)(sides & SidesEnum.Right) * (int)horizontalBorder);
            var resultUp    = Math.Max((int)(currentNode & (NodeEnum.UpSingle    | NodeEnum.UpDouble)),    (int)(sides & SidesEnum.Up)    * (int)verticalBorder);
            var resultDown	= Math.Max((int)(currentNode & (NodeEnum.DownSingle  | NodeEnum.DownDouble)),  (int)(sides & SidesEnum.Down)  * (int)verticalBorder);

            currentResult.NodeEnumItem = (NodeEnum)(resultLeft | resultRight | resultUp | resultDown);
            currentResult.Colors = colors.HasValue ? colors.Value : currentResult.Colors;
            currentBuffer[yPos, xPos] = currentResult;
        }
 private static GeneratedAttribute generateIntegral(long from, long to, SidesEnum closedFrom, long length, ColumnInfo column)
 {
     LongIntervalStruct intervalTemplate = new LongIntervalStruct();
     char leftBound, rightBound;
     switch (closedFrom)
     {
         case SidesEnum.Left:
             intervalTemplate.leftBoundType = BoundaryEnum.Sharp;
             intervalTemplate.rightBoundType = BoundaryEnum.Round;
             leftBound = Constants.LeftClosedInterval;
             rightBound = Constants.RightOpenedInterval;
             break;
         case SidesEnum.Right:
             intervalTemplate.leftBoundType = BoundaryEnum.Round;
             intervalTemplate.rightBoundType = BoundaryEnum.Sharp;
             leftBound = Constants.LeftOpenedInterval;
             rightBound = Constants.RightClosedInterval;
             break;
         default:
             throw Ferda.Modules.Exceptions.SwitchCaseNotImplementedError(closedFrom);
     }
     CategoriesStruct result = new CategoriesStruct();
     result.longIntervals = new LongIntervalCategorySeq();
     long fromTmp = from;
     long toTmp = ((fromTmp + length) > to) ? to : fromTmp + length;
     for (; ; )
     {
         LongIntervalStruct interval = intervalTemplate;
         interval.leftBound = fromTmp;
         interval.rightBound = toTmp;
         result.longIntervals.Add(
             leftBound + fromTmp.ToString() + Constants.SeparatorInterval + toTmp.ToString() + rightBound,
             new LongIntervalStruct[] { interval });
         if (toTmp == to)
             break;
         fromTmp = toTmp;
         toTmp = ((toTmp + length) > to) ? to : toTmp + length;
     }
     return new GeneratedAttribute(
         result,
         null,
         result.longIntervals.Count);
 }