public void init(fileItemCtrl fileCtrl,bool flagLoadFile = false)
        {
            try
            {
                FileInfo curFileInfo;
                if ((prgDir.FullName == fileCtrl.fileInfo.DirectoryName) && (valmoWin.SIprCtrl.prgFileName == fileCtrl.fileInfo.Name))
                {
                    if (flagLoadFile)
                        flagReadonly = true;
                    else
                        flagReadonly = false;
                    //curFileInfo = new FileInfo(prgDir + valmoWin.SIprCtrl.prgFile);
                }
                else
                {

                    flagReadonly = true;

                    //curFile = new FileStream(fileCtrl.fileInfo.FullName, FileMode.Open);
                }
                curFileInfo = fileCtrl.fileInfo;
                if (curFileInfo != null)
                {
                    //XmlDocument xmlDoc = new XmlDocument();
                    //xmlDoc.Load(curFileInfo.FullName);
                    //XmlNodeList root = xmlDoc.SelectSingleNode("ipr").ChildNodes;

                    ////读取param 节点
                    //XmlNode xn = root.Item(0) as XmlNode;
                    //XmlElement xe=(XmlElement)xn;
                    //string userName = xe.GetAttribute("user");
                    //string strCreateTime = xe.GetAttribute("createTime");
                    //string strModifyTime = xe.GetAttribute("modifyTime");

                    lbFilename.Content = curFileInfo.Name;
                    lbCreateTm.Content = fileCtrl.fileInfo.CreationTime;
                    //lbCreater.Content = userName;
                    lbModifyTm.Content = fileCtrl.fileInfo.LastWriteTime;
                }
                curCtrl = fileCtrl;
            }
            catch (Exception ex)
            {
                if (curFile != null)
                    curFile.Close();
                curFile = null;
                vm.perror("[iprFileInfo.init] " + ex.ToString());
            }
        }
        private void refreshFolders()
        {
            curDir = PrgDir;
            curItem = null;
            cvsFolder.Children.Clear();
            Canvas.SetTop(cvsFolder, 0);
            //bool prgFileSaved = false;
            FileInfo[] iprFiles = PrgDir.GetFiles();
            foreach (FileInfo file in iprFiles)
            {
                if(file.Extension == ".ipr")
                {
                    fileItemCtrl item = new fileItemCtrl(file);
                    if (file.Name == prgName && curDir == PrgDir)
                    {
                        curItem = item;
                        //prgFileSaved = true;
                        curItem.focusState = true;
                    }
                    cvsFolder.Children.Add(item);
                    Canvas.SetTop(item, (cvsFolder.Children.Count - 1) * 43);
                    item.MouseDown += item_MouseDown;
                    item.MouseUp += item_MouseUp;
                    //item.MouseMove += item_MouseMove;
                    item.MouseLeave += item_MouseLeave;
                }
            }
            cvsFolder.Height = cvsFolder.Children.Count * 43;
            if (cvsFolder.Height < cvsFolderPanel.Height)
                cvsFolder.Height = cvsFolderPanel.Height;

            iprFileInfo1.init();
            //if (prgFileSaved)
            //{
            //    //iprFileInfo1.init(curItem);
            //    //cvsIprSave.Visibility = Visibility.Visible;
            //    //btnDel.Visibility = Visibility.Hidden;
            //    curItem.focusState = true;
            //}
            //else
            //{
            //    if (cvsFolder.Children.Count != 0)
            //    {
            //        curItem = cvsFolder.Children[0] as fileItemCtrl;
            //        iprFileInfo1.init(curItem);
            //        cvsIprSave.Visibility = Visibility.Hidden;
            //        btnDel.Visibility = Visibility.Visible;
            //        curItem.focusState = true;
            //    }
            //}
        }
        private void refreshUsbFolders()
        {
            try
            {
                DriveInfo[] uin = DriveInfo.GetDrives();
                foreach (DriveInfo drive in uin)
                {
                    if (drive.DriveType == DriveType.Removable)
                    {
                        cvsFolder.Children.Clear();
                        bool flagGetUsbIprDir = false;
                        DirectoryInfo dirDriver = new DirectoryInfo(drive.Name);
                        foreach (DirectoryInfo dir in dirDriver.GetDirectories())
                        {
                            if (dir.Name == "ipr")
                            {
                                flagGetUsbIprDir = true;
                                usbDir = dir;
                                foreach (FileInfo file in dir.GetFiles())
                                {
                                    if (file.Extension == ".ipr")
                                    {
                                        fileItemCtrl item = new fileItemCtrl(file);
                                        cvsFolder.Children.Add(item);
                                        Canvas.SetTop(item, (cvsFolder.Children.Count - 1) * 43);
                                        item.MouseDown += item_MouseDown;
                                        item.MouseUp += item_MouseUp;
                                        //item.MouseMove += item_MouseMove;
                                        item.MouseLeave += item_MouseLeave;
                                    }
                                }
                                cvsFolder.Height = cvsFolder.Children.Count * 43;
                                if (cvsFolder.Height < cvsFolderPanel.Height)
                                    cvsFolder.Height = cvsFolderPanel.Height;
                                break;
                            }
                        }
                        if (!flagGetUsbIprDir)
                        {
                            DirectoryInfo dirNew = new DirectoryInfo(drive.Name + "ipr");
                            dirNew.Create();
                        }
                        break;
                    }
                }
                //refreshCurIprFile();
            }
            catch
            {

            }
        }
 private void refreshCurFolder()
 {
     curItem = null;
     SavedFileInfo = valmoWin.SIprCtrl.prgFileinfo;
     cvsFolder.Children.Clear();
     Canvas.SetTop(cvsFolder, 0);
     FileInfo[] iprFiles = curDir.GetFiles();
     foreach (FileInfo file in iprFiles)
     {
         if (file.Extension == ".ipr")
         {
             fileItemCtrl item = new fileItemCtrl(file);
             if (file.Name == prgName && curDir == PrgDir)
             {
                 curItem = item;
                 SavedFileInfo = curItem.fileInfo;
                 curItem.focusState = true;
             }
             cvsFolder.Children.Add(item);
             Canvas.SetTop(item, (cvsFolder.Children.Count - 1) * 43);
             item.MouseDown += item_MouseDown;
             item.MouseUp += item_MouseUp;
             item.MouseLeave += item_MouseLeave;
             item.mouseUp = btnDel_MouseUp;
         }
     }
     cvsFolder.Height = cvsFolder.Children.Count * 43;
     if (cvsFolder.Height < cvsFolderPanel.Height)
         cvsFolder.Height = cvsFolderPanel.Height;
     iprFileInfo1.init();
 }
 private void item_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (isItemMousedown)
     {
         isItemMousedown = false;
         if (curItem != null)
             curItem.focusState = false;
         curItem = sender as fileItemCtrl;
         curItem.focusState = true;
         SavedFileInfo = curItem.fileInfo;
     }
 }
 private void refreshFolders()
 {
     cvsFolder.Children.Clear();
     Canvas.SetTop(cvsFolder, 0);
     bool prgFileSaved = false;
     FileInfo[] fileLst = PrgDir.GetFiles();
     foreach (FileInfo file in fileLst)
     {
         if (file.Extension == ".ipr")
         {
             fileItemCtrl item = new fileItemCtrl(file);
             if (file.Name == prgName)
             {
                 curItem = item;
                 prgFileSaved = true;
             }
             cvsFolder.Children.Add(item);
             Canvas.SetTop(item, (cvsFolder.Children.Count - 1) * 43);
             item.MouseDown += item_MouseDown;
             item.MouseUp += item_MouseUp;
             item.MouseMove += item_MouseMove;
             item.MouseLeave += item_MouseLeave;
         }
     }
     cvsFolder.Height = cvsFolder.Children.Count * 43;
     if (cvsFolder.Height < cvsFolderPanel.Height)
         cvsFolder.Height = cvsFolderPanel.Height;
     if (prgFileSaved)
     {
         iprFileInfo1.init(curItem,true);
         cvsIprSave.Visibility = Visibility.Hidden;
         curItem.focusState = true;
     }
     else
     {
         if (cvsFolder.Children.Count != 0)
         {
             curItem = cvsFolder.Children[0] as fileItemCtrl;
             iprFileInfo1.init(curItem, true);
             cvsIprSave.Visibility = Visibility.Visible;
             curItem.focusState = true;
         }
     }
 }
        private void refreshCurFolder()
        {
            cvsIprSave.Visibility = Visibility.Hidden;
            curItem = null;
            loadedFileInfo = null;
            cvsFolder.Children.Clear();
            Canvas.SetTop(cvsFolder, 0);
            FileInfo[] iprFiles = curDir.GetFiles();
            foreach (FileInfo file in iprFiles)
            {
                if (file.Extension == ".ipr")
                {
                    fileItemCtrl item = new fileItemCtrl(file);
                    //if (file.Name == prgName && curDir == PrgDir)
                    //{
                    //    curItem = item;
                    //    //SavedFileInfo = curItem.fileInfo;
                    //    //curItem.focusState = true;
                    //}
                    cvsFolder.Children.Add(item);
                    Canvas.SetTop(item, (cvsFolder.Children.Count - 1) * 43);
                    item.MouseDown += item_MouseDown;
                    item.MouseUp += item_MouseUp;
                    item.MouseLeave += item_MouseLeave;
                    item.mouseUp = btnDel_MouseUp;
                }
            }
            cvsFolder.Height = cvsFolder.Children.Count * 43;
            if (cvsFolder.Height < cvsFolderPanel.Height)
                cvsFolder.Height = cvsFolderPanel.Height;
            foreach (fileItemCtrl ctrl in cvsFolder.Children)
            {
                if (ctrl.fileInfo.FullName != valmoWin.SIprCtrl.prgFileinfo.FullName)
                {
                    curItem = ctrl;
                    curItem.focusState = true;
                    loadedFileInfo = ctrl.fileInfo;
                    cvsIprSave.Visibility = Visibility.Visible;
                    break;

                }
            }
            //iprFileInfo1.init();
        }
        private void item_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (isItemMousedown)
            {
                isItemMousedown = false;
                if (curItem != null)
                    curItem.focusState = false;
                curItem = sender as fileItemCtrl;

                curItem.focusState = true;
                loadedFileInfo = curItem.fileInfo;
                if (curItem.fileInfo.Name == prgName && tbFolders.SelectedIndex == 0)
                {
                    cvsIprSave.Visibility = Visibility.Hidden;
                }
                else
                {
                    cvsIprSave.Visibility = Visibility.Visible;
                }
                iprFileInfo1.init(curItem,true);
            }
        }