示例#1
0
        private string SelectImageFile(string parnFnOld = null)
        {
            string imageName = null;

            try
            {
                imageName = OpenFileDialogEx.GetOpenFileName("选择图片", "图片文件|*.gif;*.jpeg;*.jpg;*.png;*.tif;*.tiff", null);
                if (!string.IsNullOrEmpty(imageName))
                {
                    if (FileEx.IsFileLengthMoreKB(imageName, 1024))
                    {
                        throw new Exception("图片大小不能超过1MB");
                    }
                    BitmapImage bitmapImage;
                    if (!BitmapImageEx.TryCreateFromFile(imageName, out bitmapImage))
                    {
                        throw new Exception("无法解析图片,请选择正常的图片");
                    }
                    imageName = ShortcutImageHelper.AddNewImage(imageName, parnFnOld);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                MsgBox.ShowErrTip(ex.Message, null);
            }
            return(imageName);
        }
示例#2
0
        private void SelectFile(string oldFileName = null)
        {
            var fileName = OpenFileDialogEx.GetOpenFileName("选择【快捷短语】文件", "CSV格式话术文件(*.csv)|*.csv", oldFileName);

            if (!string.IsNullOrEmpty(fileName) && fileName != oldFileName)
            {
                this.wtboxFilename.Text = fileName;
                var dbAccount = this.GetDbAccount(fileName);
                if (!string.IsNullOrEmpty(dbAccount))
                {
                    this.SetImportDataType(dbAccount);
                    this.ImportOtherNickDataTip(dbAccount);
                }
            }
        }