예제 #1
0
        private void HandleNote()
        {
            Note   note       = (Note)_element;
            double deltaTicks = CalculateDuration(note.DurationType, note.Dots);

            // Calculate height
            int noteHeight = _startHeight;

            if (note.Octaves != 0)
            {
                noteHeight += (note.Octaves * 12);
            }
            int index         = notesOrderWithCrosses.IndexOf(note.NoteType.ToString().ToLower());
            int previousIndex = (_startHeight % 12);

            if (index != previousIndex)
            {
                int difference = Math.Abs(previousIndex - index);
                int testIndex  = 12 - difference;//5

                if (index < previousIndex && testIndex < 6)
                {
                    noteHeight += testIndex;
                }
                else if (index < previousIndex && testIndex > 6)
                {
                    noteHeight -= (previousIndex - index);
                }
                else if (index > previousIndex && testIndex < 6)
                {
                    noteHeight -= testIndex;
                }
                else
                {
                    noteHeight -= (previousIndex - index);
                }
            }

            _startHeight = noteHeight;

            // Remember altertype
            _previousNoteAlteration = note.AlterType;

            // Check tie
            if (note.IsTied)
            {
                _previousIsTied        = true;
                _previousNoteDuration += deltaTicks;
                if (_isCreatingMidiFile)
                {
                    _previousNoteDuration = 0;
                    AddToTrack(deltaTicks, noteHeight);
                }
            }
            else
            {
                _previousIsTied = false;
                AddToTrack(deltaTicks, noteHeight);
            }
        }
 public AlterTableQuery(AlterTableQuery other)
 {
     TableName      = other.TableName.Clone();
     AlterType      = other.AlterType;
     AlteredColumns = new List <AlteredColumn>(other.AlteredColumns.Count);
     AlteredColumns.AddRange(other.AlteredColumns.Select(x => x.Clone() as AlteredColumn));
 }
예제 #3
0
        public AlterTableStatement(string tableName, AlterType type)
        {
            Check.NotNullOrEmpty(tableName, nameof(tableName));

            TableName = tableName;
            Type      = type;
        }
예제 #4
0
        public void AlterTableAddPrimary(DBColumn dBColumn)
        {
            Type = AlterType.addprimary;
            var dbc = DBColumn.Column(dBColumn.Name, dBColumn.Type, DBColumnFlags.PrimaryKey);

            this.add(dbc);
        }
예제 #5
0
파일: Alter.cs 프로젝트: Endahl/CSharpedSql
 protected Alter(AlterType alter, string table, WhatToAlter whatToAlter, NewColumn newColumnToAdd)
 {
     NewColumnToAdd = newColumnToAdd;
     AlterType      = alter;
     Table          = table;
     WhatToModify   = whatToAlter;
 }
예제 #6
0
        public void AlterTableDropPrimary(DBColumn dBColumn)
        {
            Type = AlterType.dropprimary;
            var dbc = DBColumn.Column(dBColumn.Name, dBColumn.Type, DBColumnFlags.Nullable);

            this.add(dbc);
        }
예제 #7
0
파일: Alter.cs 프로젝트: Endahl/CSharpedSql
 protected Alter(AlterType alter, string constraintName, string table, WhatToAlter whatToAlter, string column)
 {
     Column         = column;
     AlterType      = alter;
     ConstraintName = constraintName;
     Table          = table;
     WhatToModify   = whatToAlter;
 }
예제 #8
0
        public Dialog_AlteringNotification(Pawn pawn, List <string> actionList, AlterType type)
        {
            this.pawn       = pawn;
            this.type       = type;
            this.actionList = actionList;

            forcePause = true;
            absorbInputAroundWindow = true;
        }
예제 #9
0
파일: Alter.cs 프로젝트: Endahl/CSharpedSql
 protected Alter(AlterType alter, string table, WhatToAlter whatToAlter, string column, CSharpType dataType, uint size, int digits)
 {
     DataTypeToAlter       = dataType;
     Column                = column;
     AlterType             = alter;
     Table                 = table;
     WhatToModify          = whatToAlter;
     DataTypeDigitsToAlter = digits;
     DataTypeSizeToAlter   = size;
 }
예제 #10
0
        /// <summary>
        /// Configures the builder to use the specified column definition for an ALTER TABLE ADD COLUMN statement.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="isPrimary">if set to <c>true</c> [is primary].</param>
        /// <param name="isNotNull">if set to <c>true</c> [is not null].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns></returns>
        /// <exception cref="ColumnDefinitionException">Invalid column name.</exception>
        public AlterTableQueryBuilder AddColumn(string columnName, string dataType, bool isNotNull = true, object defaultValue = null)
        {
            if (string.IsNullOrWhiteSpace(columnName))
            {
                throw new ColumnDefinitionException("Invalid column name.");
            }

            column = new ColumnData
            {
                ColumnName   = columnName,
                DataType     = dataType,
                IsNotNull    = isNotNull,
                DefaultValue = defaultValue
            };

            alterType = AlterType.AddColumn;
            return(this);
        }
예제 #11
0
 public void ReplaceSwitchDispatch2(AlterType type)
 {
     if (mapping == null)
     {
         mapping = typeof(AlterType).GetEnumValues()
                   .Cast <AlterType>()
                   .Join(
             typeof(AlterHandler).GetMethods(BindingFlags.Static | BindingFlags.Public)
             , alterType => alterType.ToString()
             , alterHandlerMethods => alterHandlerMethods.Name.Replace("Alter", "")
             , (t, e) => new
         {
             Type = t
             ,
             EventHandler = e
         })
                   .ToDictionary(a => a.Type
                                 , a => new Action(() => a.EventHandler.Invoke(null, null)));
     }
     mapping[type].Invoke();
 }
예제 #12
0
        public static string GetAlterTypeCmd(AlterType type)
        {
            string cmd = "";

            switch (type)
            {
            case AlterType.DROP: cmd = "DROP"; break;

            case AlterType.ADD: cmd = "ADD"; break;

            case AlterType.MODIFY: cmd = "MODIFY"; break;

            case AlterType.CHANGE: cmd = "CHANGE"; break;

            case AlterType.RENAME: cmd = "RENAME TO"; break;

            default:
                break;
            }
            return(cmd);
        }
예제 #13
0
        public static int ALTER(string tableName, string key, AlterType alterType, DataType dataType = DataType.INT, string key2 = "", bool isFirst = false)
        {
            string dataTypeStr = "";
            string afterStr    = "";

            switch (alterType)
            {
            case AlterType.DROP:
                break;

            case AlterType.ADD:
                dataTypeStr = GetDataTypeCmd(dataType);
                if (!string.IsNullOrEmpty(key2))
                {
                    afterStr = isFirst ? "FIRST" : "AFTER " + key2;
                }
                break;

            case AlterType.MODIFY:
                dataTypeStr = GetDataTypeCmd(dataType);
                break;

            case AlterType.CHANGE:
                dataTypeStr = GetDataTypeCmd(dataType);
                key         = key + " " + key2;
                break;

            case AlterType.RENAME:
                break;

            default:
                break;
            }

            string cmd = string.Format("ALTER TABLE {0} {1} {2} {3} {4}", tableName, GetAlterTypeCmd(alterType), key, dataTypeStr, afterStr);

            object obj = MySqlHelper.ExecuteScalar(MySqlHelper.Conn, CommandType.Text, cmd, null);

            return(Convert.ToInt32(obj));
        }
예제 #14
0
 public void AlterTableDropColumn(DBColumn dBColumn)
 {
     Type = AlterType.dropcolumn;
     this.add(dBColumn);
 }
예제 #15
0
 public void AlterTableChangeColumn(DBColumn dBColumn)
 {
     Type = AlterType.altercolumn;
     this.add(dBColumn);
 }
예제 #16
0
 public void AlterTableAddColumn(DBColumn dBColumn)
 {
     Type = AlterType.addcolumn;
     this.add(dBColumn);
 }
예제 #17
0
        public override void ParseInside(ExpressionParser parser)
        {
            var collection = parser.Collection;

            if (!ParserUtils.ParseCommandPhrase(collection, "alter table"))
            {
                collection.ErrorUnexpected(collection.CurrentOrLast());
            }
            var lex = collection.GotoNextMust();

            Table = TableName.Parse(parser);

            lex = collection.GotoNextMust();
            string s = lex.LexemText.ToLower();

            if (ParserUtils.ParseCommandPhrase(collection, "set schema"))
            {
                lex       = collection.GotoNextMust();
                NewName   = CommonParserFunc.ReadColumnNameOnly(collection);
                AlterType = AlterType.RenameSchema;
                collection.GotoNext();
            }
            else
            if (ParserUtils.ParseCommandPhrase(collection, "rename to", true, false))
            {
                lex       = collection.GotoNextMust();
                NewName   = CommonParserFunc.ReadColumnNameOnly(collection);
                AlterType = AlterType.RenameTable;
                collection.GotoNext();
            }
            else if (ParserUtils.ParseCommandPhrase(collection, "rename column", true, false) || ParserUtils.ParseCommandPhrase(collection, "rename", true, false))
            {
                lex = collection.GotoNextMust();
                var col = CommonParserFunc.ReadColumnNameOnly(collection);
                OldColumnName = col;
                lex           = collection.GotoNextMust();
                if (lex.LexemText.ToLower() != "to")
                {
                    collection.ErrorWaitKeyWord("TO", collection.CurrentOrLast());
                }
                lex       = collection.GotoNextMust();
                NewName   = CommonParserFunc.ReadColumnNameOnly(collection);
                AlterType = AlterType.RenameColumn;
                collection.GotoNext();
            }
            else//actions
            {
                AlterType = AlterType.AlterColumn;
                while (true)
                {
                    lex = collection.CurrentLexem();
                    if (ParserUtils.ParseCommandPhrase(collection, "add column", true, false) || ParserUtils.ParseCommandPhrase(collection, "add", true, false))
                    {
                        collection.GotoNextMust();
                        var cd = CreateTable.ReadColumnInfo(collection);
                        cd.AlterColumn = AlterColumnType.AddColumn;
                        AlterColumns.Add(cd);
                    }
                    else if (ParserUtils.ParseCommandPhrase(collection, "drop column", true, false) || ParserUtils.ParseCommandPhrase(collection, "drop", true, false))
                    {
                        lex = collection.GotoNextMust();
                        var cd = new AlterColumnInfo();
                        cd.Name        = CommonParserFunc.ReadColumnNameOnly(collection);
                        cd.AlterColumn = AlterColumnType.DropColumn;
                        AlterColumns.Add(cd);
                    }
                    else if (ParserUtils.ParseCommandPhrase(collection, "alter column", true, false) || ParserUtils.ParseCommandPhrase(collection, "alter", true, false))
                    {
                        lex = collection.GotoNextMust();
                        var cd = CreateTable.ReadColumnInfo(collection);
                        AlterColumns.Add(cd);
                    }
                    else
                    {
                        collection.ErrorUnexpected(collection.CurrentOrLast());
                    }
                    lex = collection.CurrentLexem();
                    if (lex != null && lex.LexemType == LexType.Zpt)
                    {
                        collection.GotoNextMust();
                        continue;
                    }
                    break;
                }
                collection.GotoNext();
            }
        }
 public AlterTableQuery(AlterType type, TableRef table)
 {
     AlterType      = type;
     TableName      = table.Clone();
     AlteredColumns = new List <AlteredColumn>();
 }
 public AlterTableQuery(AlterType type, string tableName)
     : this(type, new TableRef(tableName))
 {
 }
 public AlterTableQuery(AlterType type = AlterType.ADD)
     : this(type, new TableRef(""))
 {
 }
예제 #21
0
파일: Alter.cs 프로젝트: Endahl/CSharpedSql
 protected Alter(AlterType alter, string constraintName, string table, WhatToAlter whatToAlter, string column, string[] primaryKeyColumns) :
     this(alter, constraintName, table, whatToAlter, column)
 {
     ExtraPrimaryKeyColumns = primaryKeyColumns;
 }
예제 #22
0
파일: Alter.cs 프로젝트: Endahl/CSharpedSql
 protected Alter(AlterType alter, string name, string table, WhatToAlter whatToAlter, string column, string referencesTable, string referencesColumn) :
     this(alter, name, table, whatToAlter, column)
 {
     ReferencesColumn = referencesColumn;
     ReferencesTable  = referencesTable;
 }