public static void ReadFromXML(string path) { try { ser_data dt = new ser_data(); XmlSerializer formatter = new XmlSerializer(typeof(ser_data)); FileStream fs = new FileStream(path, FileMode.OpenOrCreate); if (fs == null) { return; } if (fs.Length == 0) { return; } // десериализация using (fs) { dt = (ser_data)formatter.Deserialize(fs); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Ошибка в файле настроек "); } }
public MainWindow() { header = this; InitializeComponent(); this.Title = "IPTV manager v1.1"; ser_data dt = SETTING.ReadFromXML(); dt.Update_new_data(); data.temppath = System.IO.Path.GetTempPath() + "temp_m3u_IPTVmanager"; ViewModelMain.Event_UpdateLIST += new Action <int>(updateLIST); ViewModelMain.EVENT_CLOSE_ALL += new Action(CLOSE_ALL); // use a timer to periodically update the memory usage DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 100); timer.Tick += timer_Tick; timer.Start(); changefav = true; data.canal.name = ""; best1.Text = data.favorite1_1; best2.Text = data.favorite1_2; data.current_favorites = 1; data.best1 = best1.Text; data.best2 = best2.Text; changefav = false; //this.KeyDown += new System.Windows.Input.KeyEventHandler(Window1_KeyDown); }
public static void ReadFromXML(string path) { FileStream fs = null; try { ser_data dt = new ser_data(); XmlSerializer formatter = new XmlSerializer(typeof(ser_data)); fs = new FileStream(path, FileMode.OpenOrCreate); if (fs.Length == 0 || fs == null) { //файл настроек VST еще не создан if (fs != null) { fs.Dispose(); } SAVEtoXML(path); return; } // десериализация using (fs) { dt = (ser_data)formatter.Deserialize(fs); } if (dt.pathVST.Count > 0) { for (ushort i = 0; i < dt.pathVST.Count; i++) { if (dt.pathVST[i].Contains("*")) { string s = dt.pathVST[i].Replace("*", data.rootpath); dt.pathVST[i] = s; } } } if (dt.workVST.Count > 0) { for (ushort i = 0; i < dt.workVST.Count; i++) { if (dt.workVST[i].Contains("*")) { string s = dt.workVST[i].Replace("*", data.rootpath); dt.workVST[i] = s; } } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Ошибка в файле настроек "); } }
private void ButtonUPDATE(object sender, RoutedEventArgs e) { Model.bd_data.filter1 = ViewModelWindowMDB.sel1; Model.bd_data.filter2 = ViewModelWindowMDB.sel2; Model.bd_data.mask = ViewModelWindowMDB._mask; ser_data dt = new ser_data(); dt.Prepare_to_save(); Model.SETTING.SaveInXmlFormat(dt); }
public static void SAVEtoXML(string path) { try { ser_data dt = new ser_data(); XmlSerializer formatter = new XmlSerializer(typeof(ser_data)); using (Stream fStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { formatter.Serialize(fStream, dt); } } catch (Exception ex) { System.Windows.MessageBox.Show("Ошибка " + ex.Message); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Model.data.Utils.Find_and_Close_Window("update_mdb"); Model.data.Utils.Find_and_Close_Window("winPING"); Model.data.Utils.Find_and_Close_Window("winReplace"); Model.data.Utils.Find_and_Close_Window("win2iptvMOVE"); Model.data.Utils.Find_and_Close_Window("win2iptvMOVEred"); Model.data.Utils.Find_and_Close_Window("win2iptvEDIT"); ser_data dt = new ser_data(); dt.Prepare_to_save(); SETTING.SaveInXmlFormat(dt); }
public static void SAVEtoXML(string path) { try { ser_data dt = new ser_data(); XmlSerializer formatter = new XmlSerializer(typeof(ser_data)); if (dt.pathVST.Count > 0) { for (ushort i = 0; i < dt.pathVST.Count; i++) { if (dt.pathVST[i].Contains(data.rootpath)) { string s = dt.pathVST[i].Replace(data.rootpath, "*"); dt.pathVST[i] = s; } } } if (dt.workVST.Count > 0) { for (ushort i = 0; i < dt.workVST.Count; i++) { if (dt.workVST[i].Contains(data.rootpath)) { string s = dt.workVST[i].Replace(data.rootpath, "*"); dt.workVST[i] = s; } } } using (Stream fStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { formatter.Serialize(fStream, dt); } } catch (Exception ex) { System.Windows.MessageBox.Show("Ошибка " + ex.Message); } }