Exemplo n.º 1
0
        public void Save()
        {
            try
            {
                DatSaveInfo info = new DatSaveInfo();

                foreach (TabItemUI ui in this.tabControl.Items)
                {
                    ShellObject shobj = (ShellObject)ui.DispExpBrowser.ExplorerBrowserControl.Tag;
                    info.Path.Add(shobj.ParsingName);
                }
                info.SelectedIndex = this.tabControl.SelectedIndex;
                foreach (KeyValuePair <string, string> kv in this.BookMarks)
                {
                    info.BookMarks.Add(kv);
                }


                FileStream fs = new FileStream(SaveFileName, FileMode.Create, FileAccess.Write);

                DataContractSerializer s = new DataContractSerializer(typeof(DatSaveInfo));
                s.WriteObject(fs, info);
                fs.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        public bool Load()
        {
            bool flg = true;

            try
            {
                FileStream             fs   = new FileStream(SaveFileName, FileMode.Open, FileAccess.Read);
                DataContractSerializer s    = new DataContractSerializer(typeof(DatSaveInfo));
                DatSaveInfo            info = (DatSaveInfo)s.ReadObject(fs);
                fs.Close();

                foreach (string path in info.Path)
                {
                    TabItemUI ti = this.CreateTabItem(ShellObject.FromParsingName(path));
                    this.tabControl.Items.Add(ti);
                }
                this.tabControl.SelectedIndex = info.SelectedIndex;
                foreach (KeyValuePair <string, string> kv in info.BookMarks)
                {
                    this.BookMarks.Add(kv);
                }
            }
            catch (Exception)
            {
                flg = false;
            }

            return(flg);
        }