public Item(Appconf ac) { InitializeComponent(); this.ac = ac; AppName = ac.AppName; FileName = ac.AppPath.Substring(ac.AppPath.LastIndexOf('\\') + 1); try { Image_AppIcon.Source = GetIcon(ac.AppPath); } catch (Exception e) { MessageBox.Show(e.Message, FindResource("MessageBoxTitle_Error") as string); } }
private void Down(object sender, RoutedEventArgs e) { int index = Lb_Apps.SelectedIndex; if (index < Lb_Apps.Items.Count - 1) { Appconf tmp1 = al[index]; Appconf tmp2 = al[index + 1]; al.RemoveAt(index, false); al.Insert(index, tmp2); al.RemoveAt(index + 1, false); al.Insert(index + 1, tmp1); Lb_Apps.Items.RemoveAt(index); Lb_Apps.Items.Insert(index, al[index].AppName); Lb_Apps.Items.RemoveAt(index + 1); Lb_Apps.Items.Insert(index + 1, al[index + 1].AppName); Lb_Apps.SelectedIndex = index + 1; } }
private void AddItem(object sender, RoutedEventArgs e) { try { OpenFileDialog ofd = new OpenFileDialog() { Filter = $"{FindResource("EditWindow_Filter_App")}|*.exe" }; if (ofd.ShowDialog() == true) { string file = ofd.FileName; string path = $"{AppDomain.CurrentDomain.BaseDirectory}APPCONF\\{DateTime.Now.Ticks}.appconf"; Appconf ac = Appconf.Create(path, file.Substring(file.LastIndexOf('\\') + 1, file.LastIndexOf('.') - file.LastIndexOf('\\') - 1), file); al.Add(ac); Lb_Apps.Items.Add(ac.AppName); Lb_Apps.SelectedIndex = Lb_Apps.Items.Count - 1; } } catch (Exception ex) { MessageBox.Show(ex.Message, FindResource("MessageBoxTitle_Error") as string); } }
/// <summary> /// 打开exe文件 /// </summary> /// <param name="ac"></param> public static void Start(Appconf ac) { Start(ac.AppPath); }