Ejemplo n.º 1
0
        void Window_Drop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                MessageBox.Show("只支持拖拽包含Images的文件夹或者bmfc文件", "提示");
                return;
            }

            var tFiles = (string[])e.Data.GetData(DataFormats.FileDrop);

            if (tFiles.Length > 1)
            {
                MessageBox.Show("只支持拖拽包含Images的文件夹或者bmfc文件", "提示");
                return;
            }

            if (tFiles[0].EndsWith("bmfc") && File.Exists(tFiles[0]))
            {
                mBMFontType         = BMFontType.Config;
                MyPrefs.sConfigPath = tFiles[0];
                InitConfig(tFiles[0]);
                return;
            }

            var tDirectoryInfo = new DirectoryInfo(tFiles[0]);

            if (!tDirectoryInfo.Exists)
            {
                MessageBox.Show("只支持拖拽包含Images的文件夹或者bmfc文件", "提示");
                return;
            }

            mBMFontType = BMFontType.ImageFolder;
            imageFolderNameTextBox.Text = tDirectoryInfo.Name;
            var tPath = tDirectoryInfo.FullName;

            tPath = tPath.Substring(0, tPath.LastIndexOf("\\"));
            generateAbsoluteUri = new Uri(tPath, UriKind.Absolute);
            var tPngFiles = tDirectoryInfo.GetFiles("*.png", SearchOption.AllDirectories);

            if (tPngFiles == null || tPngFiles.Length == 0)
            {
                MessageBox.Show("该文件夹下不包含一个png图片", "提示");
                return;
            }

            mInfos.Clear();
            foreach (var item in tPngFiles)
            {
                var tAbsoluteUri = new Uri(item.FullName, UriKind.Absolute);
                var tInfo        = new BMFontInfo(tAbsoluteUri);
                tInfo.SetCharSymbol(string.Empty);
                mInfos.Add(tInfo);
            }

            RefreshDataGrid();
        }
Ejemplo n.º 2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     mBMFontType = string.IsNullOrEmpty(MyPrefs.sConfigPath) ? BMFontType.ImageFolder : BMFontType.Config;
     InitConfig(MyPrefs.sConfigPath);
 }