예제 #1
0
        public MainWindow()
        {
            InitializeComponent();
            treeFolderMap        = new List <KeyValuePair <TreeViewItem, FileAndFolderModel> >();
            treeSingleVersionMap = new List <KeyValuePair <TreeViewItem, SingleVersionFile> >();
            treeVersionMap       = new List <KeyValuePair <TreeViewItem, VersionModel> >();
            if (File.Exists("record.xml"))
            {
                XmlDecoder xmlDecoder = new XmlDecoder("record.xml");
                MainFolder = xmlDecoder.MainFolder;
                Versions   = xmlDecoder.Versions;
            }
            else
            {
                MainFolder = new FileAndFolderModel("Folder");
                Versions   = new List <VersionModel>();
            }
            refManager              = new RefManager();
            newFile.IsEnabled       = false;
            refreshFile.IsEnabled   = false;
            deleteFile.IsEnabled    = false;
            newFolder.IsEnabled     = false;
            renameFolder.IsEnabled  = false;
            deleteFolder.IsEnabled  = false;
            createVerion.IsEnabled  = false;
            deleteVersion.IsEnabled = false;
            newRef.IsEnabled        = false;
            deleteRef.IsEnabled     = false;
            //MessageBox.Show(MainFolder.GetTreeInfo(0));
            //MessageBox.Show(VersionModel.ShowAllVersion(Versions));
            ShowFolderTree();
            ShowVersionTree();
            treeView.SelectedItemChanged        += TreeView_SelectedItemChanged;
            treeViewVersion.SelectedItemChanged += TreeViewVersion_SelectedItemChanged;

            /*Directory.CreateDirectory(targetFolder);
             * MessageBox.Show("" + Directory.Exists(targetFolder));
             * Directory.Delete(targetFolder, true); //不能删除非空文件夹
             * MessageBox.Show("" + Directory.Exists(targetFolder));*/
            this.KeyDown        += MainWindow_KeyDown;
            newRef.Click        += NewRef_Click;
            deleteRef.Click     += DeleteRef_Click;
            createVerion.Click  += CreateVerion_Click;
            deleteVersion.Click += DeleteVersion_Click;
            newFolder.Click     += NewFolder_Click;
            newFile.Click       += NewFile_Click;
        }
예제 #2
0
        private void NewFile_Click(object sender, RoutedEventArgs e)
        {
            if (foundFileOrFolder == null || foundFileOrFolder.Type !=
                FileAndFolderModel.Type_Folder)
            {
                return;
            }
            AskSelectList.InputData inputData     = new AskSelectList.InputData();
            List <String>           refSelectList = new List <string>();

            foreach (VersionModel x in Versions)
            {
                refSelectList.Add(x.FileName);
            }
            inputData.listItems = refSelectList;
            if (AskSelectList.Show("选择引用", inputData) == true)
            {
                VersionModel            versionModel      = Versions[inputData.SelectIndex];
                AskSelectList.InputData inputData2        = new AskSelectList.InputData();
                List <String>           versionSelectList = new List <string>();
                foreach (SingleVersionFile x in versionModel.versionList)
                {
                    versionSelectList.Add(x.VersionName);
                }
                inputData2.listItems = versionSelectList;
                if (AskSelectList.Show("选择版本", inputData2) == true)
                {
                    SingleVersionFile  svf = versionModel.versionList[inputData2.SelectIndex];
                    FileAndFolderModel ffm = new FileAndFolderModel("File");
                    ffm.FileName    = svf.FatherName;
                    ffm.VersionName = svf.VersionName;
                    foundFileOrFolder.Children.Add(ffm);
                    ShowFolderTree();
                }
            }
        }
예제 #3
0
 private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     if (treeView.SelectedItem != null)
     {
         FileAndFolderModel fileOrFolder = null;
         TreeViewItem       x            = (TreeViewItem)treeView.SelectedItem;
         foreach (KeyValuePair <TreeViewItem, FileAndFolderModel>
                  pair in treeFolderMap)
         {
             if (pair.Key == x)
             {
                 fileOrFolder = pair.Value;
                 break;
             }
         }
         if (fileOrFolder == null)
         {
             return;
         }
         foundFileOrFolder = fileOrFolder;
         //MessageBox.Show("FileName = " + fileOrFolder.FileName);
         onSelectFileChanged();
     }
 }