Ejemplo n.º 1
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            //dlg.FileName = "ChangeMe";
            dlg.DefaultExt = ".opf";
            dlg.Filter     = "Organizer Project Files (.opf)|*.opf";

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                myOI = DeSerializeObject(dlg.FileName);

                LoadImageList(myOI.ImageFolderName);

                TreeViewItem rootItem = FoldersTVI as TreeViewItem;

                if (rootItem != null)
                {
                    rootItem.Items.Clear();
                    currentFolderIndex = 0;

                    foreach (string fullPath in myOI.SortFolders)
                    {
                        DirectoryInfo  dir     = new DirectoryInfo(fullPath);
                        myTreeViewItem subItem = new myTreeViewItem(dir, currentFolderIndex);
                        currentFolderIndex++;
                        rootItem.Items.Add(subItem);
                        rootItem.IsExpanded = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void SerializeObject(string filename, OrganizerInfo objectToSerialize)
        {
            Stream          stream     = File.Open(filename, FileMode.Create);
            BinaryFormatter bFormatter = new BinaryFormatter();

            bFormatter.Serialize(stream, objectToSerialize);
            stream.Close();
        }