コード例 #1
0
        public List <ControllerMapping> GetMappings(string MidiDeviceName, MappingFilter filter)
        {
            List <ControllerMapping> mappings = new List <ControllerMapping>();
            DataTable t = GetTable(MidiDeviceName);

            for (int i = 0; i < t.Rows.Count; i++)
            {
                ControllerMapping mapping = GetRow(MidiDeviceName, i);
                mapping.CatCmd = CatCmdDb.Get(mapping.CatCmd.CatCommandId);
                if (filter == MappingFilter.None)
                {
                    mappings.Add(mapping);
                }
                else if (filter == MappingFilter.Active)
                {
                    if (mapping.CatCmd.CatCommandId != CatCmd.None)
                    {
                        mappings.Add(mapping);
                    }
                }
                else if (filter == MappingFilter.InActive)
                {
                    if (mapping.CatCmd.CatCommandId == CatCmd.None)
                    {
                        mappings.Add(mapping);
                    }
                }
            }
            return(mappings);
        }
コード例 #2
0
ファイル: EnumsDB.cs プロジェクト: W2PA/openPowerSDR
        private void AddCatCmds()
        {
            ds.Tables.Add("CatCmds");
            DataTable t = null;

            DataColumn[] keys = new DataColumn[1];
            t = ds.Tables["CatCmds"];
            t.Columns.Add("CmdId", typeof(int));
            t.Columns.Add("CmdDescription", typeof(string));
            t.Columns.Add("ControlType", typeof(int));
            t.Columns.Add("InUse", typeof(bool));
            keys[0]      = t.Columns[0];
            t.PrimaryKey = keys;

            CatCmd[] values = (CatCmd[])Enum.GetValues(typeof(CatCmd));
            foreach (CatCmd value in values)
            {
                CatCommandAttribute attr = CatCmdDb.Get(value);
                DataRow             dr   = t.NewRow();
                dr["CmdId"]          = (int)value;
                dr["CmdDescription"] = attr.Desc;
                dr["ControlType"]    = attr.ControlType;
                dr["InUse"]          = false;
                t.Rows.Add(dr);
                dr.AcceptChanges();
            }
        }
コード例 #3
0
        private ControllerMapping PopulateMapping(DataRow dr)
        {
            ControllerMapping mapping = new ControllerMapping();

            mapping.MidiControlId      = (int)dr["MidiControlId"];
            mapping.MidiControlName    = (string)dr["MidiControlName"];
            mapping.MidiControlType    = FixUp.FixControlType(((int)dr["MidiControlType"]));
            mapping.MinValue           = (int)dr["MinValue"];
            mapping.MaxValue           = (int)dr["MaxValue"];
            mapping.CatCmdId           = (CatCmd)dr["CatCmdId"];
            mapping.CatCmd             = CatCmdDb.Get(mapping.CatCmdId);
            mapping.MidiOutCmdDown     = ConvertFromDBVal <string>(dr["MidiOutCmdDown"]);
            mapping.MidiOutCmdUp       = ConvertFromDBVal <string>(dr["MidiOutCmdUp"]);
            mapping.MidiOutCmdSetValue = ConvertFromDBVal <string>(dr["MidiOutCmdSetValue"]);
            return(mapping);
        }