/// <summary> /// 删除一个配置 /// </summary> /// <param name="PrimaryGuid"></param> public void Delete(String PrimaryGuid) { mDB.Delete(new FontDB() { PrimaryGuid = PrimaryGuid }); mDB.Commit(); }
/// <summary> /// 应用程序单击事件 /// </summary> private void App_Click(object sender, RoutedEventArgs e) { if (!isEditable) { //获取当前活动Tab索引 int mType = Tab.SelectedIndex; //获取Button Button mBtn = (Button)sender; //获取当前父控件 StackPanel mPanel = (StackPanel)mBtn.Parent; Grid mGrid = (Grid)mPanel.Parent; SmartAppControl mControl = (SmartAppControl)mGrid.Parent; //获取父控件在Grid中的行数和列数 int mRow = (int)mControl.GetValue(Grid.RowProperty); int mCol = (int)mControl.GetValue(Grid.ColumnProperty); //计算元素索引 int mIndex = 4 * mRow + mCol; //获取指定类型的应用程序列表 mAppList = getAppList(mType); //获取应用程序 SmartApp mApp = mAppList[mIndex]; if (!File.Exists(mApp.AppPath)) { if (MessageBox.Show("文件不存在或者应用程序无法打开!是否删除该应用?", "删除应用", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { //从列表中移除mApp mAppList.RemoveAt(mIndex); //修改数据文件 XmlDB mDB = XmlDBFactory.LoadXmlDB(mFileName); mDB.Delete(new SmartApp(mApp.AppName, mApp.AppPath, mNames[mType])); mDB.Commit(); //从桌面中移除该应用程序 getGrid(mNames[mType]).Children.Remove(mControl); //移除全部应用程序 getGrid(mNames[mType]).Children.Clear(); //重新加载应用程序 CreateAppForGrid(getGrid(mNames[mType]), mAppList); } } else { //启动应用程序 mApp.Start(); } } else { //获取当前活动Tab索引 int mType = Tab.SelectedIndex; //获取Button Button mBtn = (Button)sender; //获取当前父控件 Grid mGrid = (Grid)mBtn.Parent; SmartAppControl mControl = (SmartAppControl)mGrid.Parent; //获取父控件在Grid中的行数和列数 int mRow = (int)mControl.GetValue(Grid.RowProperty); int mCol = (int)mControl.GetValue(Grid.ColumnProperty); //计算元素索引 int mIndex = 4 * mRow + mCol; //获取指定类型的应用程序列表 mAppList = getAppList(mType); //获取应用程序 SmartApp mApp = mAppList[mIndex]; //从列表中移除mApp mAppList.RemoveAt(mIndex); //修改数据文件 XmlDB mDB = XmlDBFactory.LoadXmlDB(mFileName); mDB.Delete(new SmartApp(mApp.AppName, mApp.AppPath, mNames[mType])); mDB.Commit(); //从桌面中移除该应用程序 getGrid(mNames[mType]).Children.Remove(mControl); //移除全部应用程序 getGrid(mNames[mType]).Children.Clear(); //重新加载应用程序 CreateAppForGrid(getGrid(mNames[mType]), mAppList); //将状态还原为可编辑 isEditable = true; //将每一个App设为可编辑状态 foreach (SmartAppControl m in getGrid(mNames[mType]).Children) { m.SetControlEditable(true); } } }