Esempio n. 1
0
 public NewFileWin(string path, bool isProj = false)
 {
     s_pW = this;
     m_curFileType = null;
     m_isProj = isProj;
     InitializeComponent();
     this.Owner = MainWindow.s_pW;
     if (isProj)
     {
         mx_projFrame.Visibility = System.Windows.Visibility.Visible;
         mx_fileFrame.Visibility = System.Windows.Visibility.Collapsed;
     }
     else
     {
         mx_projFrame.Visibility = System.Windows.Visibility.Collapsed;
         mx_fileFrame.Visibility = System.Windows.Visibility.Visible;
     }
     if (Directory.Exists(path))
     {
         m_tmplPath = path;
         refreshFolder(m_tmplPath, mx_tree, m_isProj, true, true, addTmplToRadioGroup);
     }
     else
     {
         MessageBox.Show("模板目录(" + path + ")不存在,UI编辑器可能已经损坏。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 2
0
        private void addTmplToRadioGroup(object sender, RoutedEventArgs e)
        {
            mx_fileTypeFrame.Children.Clear();
            if(sender is TreeViewItem)
            {
                string path = ((TreeViewItem)sender).ToolTip.ToString();
                if(Directory.Exists(path))
                {
                    DirectoryInfo di = new DirectoryInfo(path);
                    if(!m_isProj)
                    {
                        foreach (var fileInfo in di.GetFiles("*"))
                        {
                            FileTypeRadio ftr = new FileTypeRadio(this, System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name), di.Name);
                            ToolTip treeTip = new ToolTip();

                            treeTip.Content = path + "\\" + fileInfo.Name;
                            ftr.ToolTip = treeTip.Content;
                            mx_fileTypeFrame.Children.Add(ftr);
                        }
                    }
                    else
                    {
                        foreach (var dirInfo in di.GetDirectories("*"))
                        {
                            FileTypeRadio ftr = new FileTypeRadio(this, System.IO.Path.GetFileNameWithoutExtension(dirInfo.Name), di.Name);
                            ToolTip treeTip = new ToolTip();

                            treeTip.Content = path + "\\" + dirInfo.Name;
                            ftr.ToolTip = treeTip.Content;
                            mx_fileTypeFrame.Children.Add(ftr);
                        }
                    }
                }
            }
        }