public bool isAutoCopyImgId = false; //是否自动复制图片的id,来让安卓更易用 public void saveConfig() { FileMoveConfigJson j = new FileMoveConfigJson(); j.removeLast = removeLast; j.removeFirst = removeFirst; j.oneName = oneName; j.addLast = addLast; j.addFirst = addFirst; j.imgDirType = imgDirType; j.repeatType = repeatType; j.isToWebP = isToWebP; j.webpValue = webpValue; j.isAutoCopyImgId = isAutoCopyImgId; FileMoveConfigJson nativeJ = getJsonConfig(); if (nativeJ != null) { LinkedList <String> list = nativeJ.copyToDirs; if (list != null) { list.Remove(copyToDir); list.AddFirst(copyToDir); } else { list = new LinkedList <string>(); list.AddFirst(copyToDir); } j.copyToDirs = list; } else { LinkedList <string> list = new LinkedList <string>(); list.AddFirst(copyToDir); j.copyToDirs = list; } FileStream fs = new FileStream("PhotoFileSeparator.config", FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, j); fs.Close(); }
//从本地获取配置 private void getConfigFromNative() { //初始化默认路径 String defaultDir = System.AppDomain.CurrentDomain.BaseDirectory; textBox1.Text = defaultDir.Substring(0, defaultDir.Length - 1); //尝试从本地获取配置,获取不到就使用默认配置 FileMoveConfigJson j = FileMoveConfig.getJsonConfig(); if (j == null) { return; } textBox2.Text = j.removeLast; textBox3.Text = j.removeFirst; textBox4.Text = j.oneName; textBox6.Text = j.addLast; textBox5.Text = j.addFirst; String imgDirType = j.imgDirType; if ("mipmap" == imgDirType) { rbMipmap.Checked = true; } else if ("drawable" == imgDirType) { rbDrawable.Checked = true; } else if ("" == imgDirType) { rbEmpty.Checked = true; } else { rbDiy.Checked = true; etDiy.Text = imgDirType; } int repeatType = j.repeatType; switch (repeatType) { case 0: radioButton2.Checked = true; break; case 1: radioButton1.Checked = true; break; case 2: radioButton3.Checked = true; break; case 3: radioButton4.Checked = true; break; } if (j.copyToDirs.First != null) { textBox1.Text = j.copyToDirs.First.Value; } cbWebp.Checked = j.isToWebP; tvWebp.Enabled = j.isToWebP; trackBar1.Enabled = j.isToWebP; trackBar1.Value = j.webpValue; cbCopyId.Checked = j.isAutoCopyImgId; tvWebp.Text = "压缩率" + j.webpValue + "(推荐75)"; textBox1.DataSource = j.copyToDirs.ToList(); //setAppTheme(1);emmm,太难看了,先这样吧 }