Ejemplo n.º 1
0
        public MapForm(ref byte[] bytes, Atlas atlas, string outFilename)
        {
            this.atlas       = atlas;
            this.outFilename = outFilename;

            InitializeComponent();

            canvasBox.DoubleBuffered(true);

            initColors();
            EntityTable.Init(entityTable);
            ColumnTable.Init(columnTable);
            BlockTexTable.Init(blockTexTable);
            UnknownTable247264.Init(unknownTable247264);
            UnknownTable358222.Init(unknownTable358222);

            data = bytes;
            findHeightExtremes();
            fillEntityTable();
            fillColumnTable();
            fillBlockTexTable();
            fillUnknownTable247264();
            fillUnknownTable358222();
            draw();
        }
Ejemplo n.º 2
0
        public string SetValue(ColumnTable column)
        {
            var defaultCode = $"{VarName}.{column.PropertyName}";

            var code = string.Empty;

            if (column.PropertyType.Equals("string"))
            {
                code = $"{defaultCode} ?? string.Empty";
            }
            else if (column.PropertyType.Equals("decimal"))
            {
                code = column.IsNull ? $"{defaultCode}.HasValue ? (double){defaultCode} : null" : $"(double){defaultCode}";
            }
            else if (column.PropertyType.Equals("DateTime"))
            {
                code = column.IsNull ? $"{defaultCode}.HasValue ? {defaultCode}.Value.ToString(\"yyyy-MM-dd\") : null" : $"{defaultCode}.ToString(\"yyyy-MM-dd\")";
            }
            else
            {
                code = $"{defaultCode} ?? string.Empty";
            }

            return(code);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Створює коллекцію лінійних обектів таблиці.
        /// </summary>
        /// <param name="numberRows">Кількість рядків таблиці.</param>
        /// <param name="stepRows">Крок рядків таблиці.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить лінійні обекти  таблиці.
        /// </returns>

        internal static AcDb.DBObjectCollection GetBoundTable(int numberRows, double stepRows, SettingTable settingTable)
        {
            AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection();

            double hTable = settingTable.GetHeightTable(numberRows, stepRows) * -1;
            double wTable = settingTable.GetWidthTable();

            AcGe.Point2dCollection pointsBoundTable =
                new AcGe.Point2dCollection(new AcGe.Point2d[]
            {
                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(0, 0)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(wTable, 0)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(wTable, hTable)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(0, hTable))
            });

            objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsBoundTable, true));

            AcGe.Point2dCollection pointsLine =
                new AcGe.Point2dCollection(new AcGe.Point2d[]
            {
                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(wTable, settingTable.GetHeightCapTable() * -1)),

                settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                .Add(new AcGe.Vector2d(0, settingTable.GetHeightCapTable() * -1))
            });

            objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsLine, false));

            double widthCur = 0;

            for (int i = 0; i < settingTable.Columns.Count - 1; i++)
            {
                ColumnTable value = settingTable.Columns.ToArray()[i];
                widthCur  += value.Width;
                pointsLine =
                    new AcGe.Point2dCollection(new AcGe.Point2d[]
                {
                    settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                    .Add(new AcGe.Vector2d(widthCur, 0)),

                    settingTable.BasePointDrawing.Convert2d(new AcGe.Plane())
                    .Add(new AcGe.Vector2d(widthCur, hTable))
                });
                objects.Add(ServiceSimpleElements.CreatePolyline2d(pointsLine, false));
            }

            return(objects);
        }
Ejemplo n.º 4
0
        void dt_ColumnChanged(object sender, DataColumnChangeEventArgs e)
        {
            if (!ColumnTable.ContainsKey(e.Column))
            {
                return;
            }
            if (!RowTable.ContainsKey(e.Row))
            {
                return;
            }


            int?newValue = null;
            int nv       = 0;

            if (int.TryParse(e.ProposedValue.ToString(), out nv))
            {
                newValue = nv;
            }

            if (newValue.HasValue)
            {
                if (newValue > GameService.MaxValue(Stage, RowTable[e.Row]) ||
                    newValue < GameService.MinValue(Stage, RowTable[e.Row]))
                {
                    newValue = null;
                }
            }
            if (!newValue.HasValue)
            {
                e.Row.SetColumnError(e.Column, "Неправильное значение");
            }
            else
            {
                e.Row.SetColumnError(e.Column, "");
            }

            var c = ColumnTable[e.Column];

            var gameResult = GameService.DbContext.GameResultSet.First(f => f.Game.Stage.Id == Stage.Id && f.Referee.Id == c.Id && f.Game.Team.Id == CurrentTeam.Id);
            var value      = gameResult.Values.FirstOrDefault(f => f.Type == RowTable[e.Row]);

            if (value == null)
            {
                GameService.DbContext.GameResultValueSet.Add(new GameResultValue()
                {
                    GameResult = gameResult, Type = RowTable[e.Row], Value = newValue
                });
            }
            else
            {
                value.Value = newValue;
            }
        }
Ejemplo n.º 5
0
        object _Normalise(int columnIndex, object obj, bool normalise)
        {
            object ret = null;

            if (ColumnTable.TryGetValue(columnIndex, out var norm))
            {
                double val;
                switch (norm.DataType)
                {
                case ColumnType.Byte:
                    val = (sbyte)obj;
                    break;

                case ColumnType.Double:
                    val = (double)obj;
                    break;

                case ColumnType.Float:
                    val = (float)obj;
                    break;

                case ColumnType.Int:
                    val = (int)obj;
                    break;

                case ColumnType.Long:
                    val = (long)obj;
                    break;

                default:
                    throw new NotImplementedException();
                }

                ret = normalise ? norm.Normalise(val) : norm.ReverseNormalise(val);
            }
            else if (VectorColumnTable != null &&
                     VectorColumnTable.TryGetValue(columnIndex, out var vectorNorm))
            {
                var vector     = (FloatVector)obj;
                var normalised = vector.Data.Zip(vectorNorm.VectorColumns,
                                                 (v, n) => (float)n.Normalise(Convert.ToDouble(v))).ToArray();
                ret = new FloatVector {
                    Data = normalised
                };
            }
            else
            {
                ret = obj;
            }

            return(ret);
        }
Ejemplo n.º 6
0
        private void editColumnButton_Click(object sender, EventArgs e)
        {
            ColumnItem   item = columnTable.SelectedItems[0].Tag as ColumnItem;
            EditItemForm f    = new EditItemForm(item);

            if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.None)
            {
                return;
            }

            item.UpdateCaptions();
            ColumnTable.Write(columnItems, ref data);
            writeButton.Enabled = true;
        }
Ejemplo n.º 7
0
 private void lvTables_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         OpenConn(AccessConnString);
         object[] objArrRestrict;
         if (lvTables.SelectedItem != null)
         {
             string TableName = lvTables.SelectedItem.ToString();
             //Object to Specify which Table to look inside of
             objArrRestrict = new object[] { null, null, TableName, null };
             //Get the Table Schema
             DataTable schemaCols = Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, objArrRestrict);
             //declare a Hashtable for the Column Data
             //Hashtable htCols = new Hashtable();
             //List the schema info for the selected table
             ColumnTableList.Clear();
             int i = 1;
             foreach (DataRow fieldrow in schemaCols.Rows)
             {
                 ColumnTable info = new ColumnTable();
                 info.TableName  = fieldrow["TABLE_NAME"].ToString();
                 info.ColumnName = fieldrow["COLUMN_NAME"].ToString();
                 info.TypeName   = fieldtypename(int.Parse(fieldrow["DATA_TYPE"].ToString()));
                 string length = fieldrow["CHARACTER_MAXIMUM_LENGTH"].ToString();
                 info.ColumnLength = string.IsNullOrWhiteSpace(length) ? 0 : Convert.ToInt32(length);
                 info.IsNull       = Convert.ToBoolean(fieldrow["IS_NULLABLE"].ToString());
                 if (i == 1)
                 {
                     info.Key = true;
                 }
                 else
                 {
                     info.Key = false;
                 }
                 ColumnTableList.Add(info);
                 i++;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
     }
 }
Ejemplo n.º 8
0
        public string GetValue(ColumnTable column)
        {
            var defaultCode     = $"rs.Fields.Item(\"{column.SqlColumnName}\").Value";
            var defaultCodeFull = $"{column.PropertyType}.Parse({defaultCode}.ToString())";

            var code = string.Empty;

            if (column.PropertyType.Equals("string"))
            {
                code = $"{defaultCode}.ToString() ?? string.Empty";
            }
            else
            {
                code = column.IsNull ? $"{defaultCode} == null ? null : {defaultCodeFull}" : $"{defaultCodeFull}";
            }

            return(code);
        }
Ejemplo n.º 9
0
 public ColumnTableScript(ColumnTable columnTable, SqlPreCommandSimple updateScript)
 {
     ColumnTable  = columnTable;
     UpdateScript = updateScript;
 }
Ejemplo n.º 10
0
 private void fillColumnTable()
 {
     columnItems          = ColumnTable.Fill(columnTable, ref data, ref lineColors, ref pointColors);
     columnTableInfo.Text = columnItems.Count + " items found";
 }
Ejemplo n.º 11
0
        private bool saveConfig()
        {
            try
            {
                if (!verifyInfo())
                {
                    return(false);
                }

                if (!varifySet(txtSet.Text))
                {
                    return(false);
                }

                pTable.TableSet = txtSet.Text;

                SqlBaseProvider.SaveTableSet(pTable);

                List <ColumnTable> cols = new List <ColumnTable>();

                foreach (PdmColumn pColumn in pTable.Columns)
                {
                    ColumnTable col = new ColumnTable();
                    col.DBID          = pTable.DBID;
                    col.TableCode     = pTable.TableCode;
                    col.ColumnCode    = pColumn.ColumnCode;
                    col.ColumnSerial  = 0;
                    col.Prefix        = Prefix[0];
                    col.RelaTable     = pTable.TableCode;
                    col.DisplayColumn = pColumn.ColumnCode;
                    col.RelaColumn    = pColumn.ColumnCode;

                    cols.Add(col);
                }

                string[] tablesets = PublicTools.TextReadToArr(txtSet.Text);

                int prefixcnt = 1;
                int i         = 0;
                int j         = 0;

                foreach (string tableset in tablesets)
                {
                    string[] sets = tableset.Split('|');
                    if (sets[0].ToLower() == "c")
                    {
                        SqlBaseProvider.SavePmtSet(pTable.DBID, tableset);

                        string[] relacols = sets[4].Split(',');

                        for (i = relacols.Length - 1; i >= 0; i--)
                        {
                            ColumnTable col = new ColumnTable();
                            col.DBID          = pTable.DBID;
                            col.TableCode     = pTable.TableCode;
                            col.ColumnCode    = sets[1];
                            col.ColumnSerial  = 0;
                            col.Prefix        = Prefix[prefixcnt];
                            col.RelaTable     = sets[2];
                            col.DisplayColumn = relacols[i];
                            col.RelaColumn    = sets[3];

                            for (j = 0; j < cols.Count; j++)
                            {
                                if (cols[j].ColumnCode.ToLower() == col.ColumnCode.ToLower())
                                {
                                    cols.Insert(j + 1, col);
                                    break;
                                }
                            }
                        }

                        prefixcnt++;
                    }
                }

                SqlBaseProvider.SaveColumnTable(pTable, cols);
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }