/// <summary> /// Switch Data tables based on seleceted mode /// </summary> /// <param name="mode">APP_MODE.[injection|elevation]</param> private void SwitchDataTable(APP_MODE mode) { if (mode == APP_MODE.FileInjection) { dtvFileSelections.DataSource = fileDataTable; SetFileDataTableStyle(); // Connect event listeners dtvFileSelections.DragDrop += DtvFileSelections_DragDrop; dtvFileSelections.DragEnter += DtvFileSelections_DragEnter; dtvFileSelections.MouseDoubleClick += DtvFileSelections_MouseDoubleClick; // Allow user adding files dtvFileSelections.AllowUserToDeleteRows = true; } else { dtvFileSelections.DataSource = handleDataTable; SetHandleDataTableStyle(); // Disconnect event listeners dtvFileSelections.DragDrop -= DtvFileSelections_DragDrop; dtvFileSelections.DragEnter -= DtvFileSelections_DragEnter; dtvFileSelections.MouseDoubleClick -= DtvFileSelections_MouseDoubleClick; // prevent user adding files dtvFileSelections.AllowUserToDeleteRows = false; } }
public APP_MODE getNextMode(APP_MODE _curr_app_mode) { APP_MODE next_app_mode = APP_MODE.MODE_NONE; switch (_curr_app_mode) { case APP_MODE.MODE_NONE: { next_app_mode = APP_MODE.MODE_LOGIN; } break; case APP_MODE.MODE_LOGIN: { next_app_mode = APP_MODE.MODE_MAIN; } break; case APP_MODE.MODE_UPDATE: { next_app_mode = APP_MODE.MODE_MAIN; } break; default: { next_app_mode = APP_MODE.MODE_NONE; } break; } return(next_app_mode); }
public void goNextMode() { // go next mode APP_MODE curr_app_mode = m_cur_app_mode; APP_MODE next_app_mode = getNextMode(curr_app_mode); setAppMode(next_app_mode); }
// application mode control public ApplicationContext setAppMode(APP_MODE _app_mode) { // check context if (null == m_context) { m_context = new ApplicationContext(); } // old - new Form oldForm = null; // set old form if ((null != m_context) && (null != m_context.MainForm)) { oldForm = m_context.MainForm; } // set next form ... switch (_app_mode) { case APP_MODE.MODE_LOGIN: { m_cur_app_mode = APP_MODE.MODE_LOGIN; m_context.MainForm = new FormDlgLogin(null); } break; case APP_MODE.MODE_UPDATE: { m_cur_app_mode = APP_MODE.MODE_UPDATE; m_context.MainForm = new FormDlgUpdate(null, UPDATE_URL, UPDATE_KEY, UPDATE_VERSION, UPDATE_SKIP_POSSIBLE); } break; case APP_MODE.MODE_MAIN: { m_cur_app_mode = APP_MODE.MODE_MAIN; m_context.MainForm = new FormMain(); } break; case APP_MODE.MODE_NONE: { m_cur_app_mode = APP_MODE.MODE_NONE; m_context.MainForm = null; } break; case APP_MODE.MODE_EXIT: { m_cur_app_mode = APP_MODE.MODE_EXIT; } return(m_context); } // hide, show, close ... if (null != oldForm) { oldForm.Hide(); oldForm.Close(); } if ((null != m_context) && (null != m_context.MainForm)) { m_context.MainForm.Show(); } // return return(m_context); }