public static List <string> GetActions(int buttonID) { DBButton dummyButton = new DBButton(); dummyButton.btn_ID = buttonID; return(GetActions(dummyButton)); }
// Insert the new button in the Buttons table. public static void InsertButton(DBButton button) { CheckDatabase(); using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformGeneric(), DB_PATH)) { conn.RunInTransaction(() => { conn.Insert(button); }); } }
//Update existing button public static void UpdateDetails(DBButton button) { CheckDatabase(); using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformGeneric(), DB_PATH)) { var existingconact = conn.Query <DBButton>("select * from DBButton where btn_ID =" + button.btn_ID).FirstOrDefault(); if (existingconact != null) { conn.RunInTransaction(() => { conn.Update(button); }); } } }
/*Добавление кнопки с указанным текстом, позицией и результатом диалога*/ private Button NewButton(string text, Point location, DialogResult res) { DBButton bt = new DBButton(); bt.Text = text; bt.Location = location; bt.FlatStyle = FlatStyle.Flat; /*Обрабатываем нажатие на левую кнопку мыши*/ bt.MouseClick += new MouseEventHandler((o, mEv) => { if (mEv.Button == MouseButtons.Left) { result = res; this.Close(); } }); return(bt); }
// TODO multiple actions w/ same button, ordinality public static List <string> GetActions(DBButton buttonPressed) { CheckDatabase(); using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformGeneric(), DB_PATH)) { string keycodeQuery = "SELECT kc_Value FROM DBKeyCode " + "LEFT JOIN DBMacro ON DBKeyCode.kc_ID = DBMacro.mc_kc_ID " + "LEFT JOIN DBButton ON DBButton.btn_mc_ID = DBMacro.mc_ID " + "WHERE DBButton.btn_ID = " + buttonPressed.btn_ID; List <DBKeyCode> dbKeycodes = conn.Query <DBKeyCode>(keycodeQuery); List <string> actions = new List <string>(); foreach (var keycode in dbKeycodes) { actions.Add(keycode.kc_Value); } return(actions); } }