public void CreateBatch() { string batch = string.Format(@" set hour=%time:~0,2% rem Remove leading space if single digit if ""%hour:~0,1%"" == "" "" set hour=0%hour:~1,1% set /A min=%time:~3,2%+2 echo %min%>len for %%a in (len) do set /a len=%%~za - 2 rem Remove leading space if %len% == -2 set min=0%min% set st=%hour%:%min% schtasks /create /tn ""{0}"" /tr ""{1}"" /sc ONCE /st %st% /f ", Form.LB_BAT_INNER.SelectedItem, Form.TB_Batch_Other.Text); fileutils.FileWrite(fileutils.BatInnerPath + Form.LB_BAT_INNER.SelectedItem + @"\" + filename, batch, false); if (batchs != null) { if (batchs.Where(x => x.Name == filename).Count() == 0) { LV_UPLOAD_Item lv_upload_item = new LV_UPLOAD_Item(); lv_upload_item.Name = filename; lv_upload_item.Path = fileutils.BatInnerPath + Form.LB_BAT_INNER.SelectedItem + @"\" + filename; lv_upload_item.IsChecked = true; batchs.Add(lv_upload_item); } } Console.WriteLine("新建成功: " + filename); }
public void Load(string ItemPath) { batchs.Clear(); foreach (string file in fileutils.GetFiles(ItemPath)) { LV_UPLOAD_Item lv_upload_item = new LV_UPLOAD_Item(); lv_upload_item.Name = file.Split('\\').Last(); lv_upload_item.Path = file; if (lv_upload_item.Name == "readme.txt") { window.TB_Batch_Descriptions.Text = File.ReadAllText(lv_upload_item.Path, System.Text.Encoding.Default); lv_upload_item.IsChecked = false; } else { lv_upload_item.IsChecked = true; } batchs.Add(lv_upload_item); } window.LV_UPLOAD.ItemsSource = batchs; try { window.TB_Batch_ExecBat.Text = window.LV_UPLOAD.Items.Cast <LV_UPLOAD_Item>().ToList().Where(x => new[] { ".bat", ".vbs" }.Any(x.Name.Contains)).ElementAt(0).Name; } catch (Exception err) { window.TB_Batch_ExecBat.Text = ""; } }
/// 由ChecBox的Click事件来记录被选中行的 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LV_UPLOAD_CheckBox_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.CheckBox cb = sender as System.Windows.Controls.CheckBox; string tag = cb.Tag.ToString(); LV_UPLOAD_Item Item = batchs.Single(x => x.Name == tag); if (cb.IsChecked == true) { Item.IsChecked = true; } else { Item.IsChecked = false; } }
public void Add(string[] source) { if (source.Length > 0) { List <LV_UPLOAD_Item> LV_UPLOAD_List = new List <LV_UPLOAD_Item>(); foreach (string file in source) { LV_UPLOAD_Item item = new LV_UPLOAD_Item(); item.Name = System.IO.Path.GetFileName(file); item.Path = file; item.IsChecked = true; LV_UPLOAD_List.Add(item); ZkplayPlayList_Item zkplist_item = new ZkplayPlayList_Item(); zkplist_item.Initiation(item.Name); config.list.Insert(0, zkplist_item); } window.LV_UPLOAD.ItemsSource = LV_UPLOAD_List; Save(); } }