private void LoadApps() { //如果有不是OrderableExeApp的,则转换并替换 var appsArray = Controller.IntentStore.ToArray(); for (var i = 0; i < appsArray.Length; i++) { var app = appsArray[i]; if (!(app is OrderableExeApp)) { appsArray[i] = new OrderableExeApp(app); Controller.IntentStore.Remove(app); Controller.IntentStore.Add(appsArray[i]); } } Array.Sort(appsArray, (a, b) => ((OrderableExeApp)a).Order.CompareTo(((OrderableExeApp)b).Order)); listApps.BeginUpdate(); ResetListApps(); foreach (var app in appsArray) { AddAppToList(app); } listApps.Items[0].Selected = true; listApps.EndUpdate(); AdjustListAppsColumnWidth(); }
private void btnAddApp_Click(object sender, EventArgs e) { using (var frm = new EditAppForm(Controller.IntentStore)) { var result = frm.ShowDialog(); if (result != DialogResult.OK) { return; } var appPath = frm.AppPath; ExeApp found; if (Controller.IntentStore.TryGetExeApp(appPath, out found)) { HighlightAppInList(found); } else { var app = new OrderableExeApp() { ExecutablePath = appPath, Name = frm.AppName, Order = 1 }; AddAppToList(app); HighlightAppInList(app); Controller.IntentStore.Add(app); } } }
private void LoadApps() { //如果有不是OrderableExeApp的,则转换并替换 var appsArray = Controller.IntentStore.ToArray(); for(var i=0; i<appsArray.Length; i++) { var app = appsArray[i]; if (!(app is OrderableExeApp)) { appsArray[i] = new OrderableExeApp(app); Controller.IntentStore.Remove(app); Controller.IntentStore.Add(appsArray[i]); } } Array.Sort(appsArray, (a, b) => ((OrderableExeApp) a).Order.CompareTo(((OrderableExeApp) b).Order)); listApps.BeginUpdate(); ResetListApps(); foreach (var app in appsArray) { AddAppToList(app); } listApps.Items[0].Selected = true; listApps.EndUpdate(); AdjustListAppsColumnWidth(); }
private void btnAddApp_Click(object sender, EventArgs e) { using (var frm = new EditAppForm(Controller.IntentStore)) { var result = frm.ShowDialog(); if (result != DialogResult.OK) return; var appPath = frm.AppPath; ExeApp found; if (Controller.IntentStore.TryGetExeApp(appPath, out found)) { HighlightAppInList(found); } else { var app = new OrderableExeApp() { ExecutablePath = appPath, Name = frm.AppName, Order = 1}; AddAppToList(app); HighlightAppInList(app); Controller.IntentStore.Add(app); } } }