|
using System;
using System.Collections.Generic;
using System.Linq;
using UPImage;
using System.Drawing;
using UPImage.FileFormat;
namespace UPImage.Data
{
public class UPFile : IDisposable
{
private String safeName;
private String fullpath;
UPFolder parent;
UPDataSet dataset;
bool isDataEmply;
public UPDataSet Dataset
{
get
{
return dataset;
}
}
public bool IsDataEmply
{
get
{
isDataEmply = !CheckDataSet(fullpath);
return isDataEmply;
}
}
public String SafeFileName
{
get
{
return safeName;
}
}
public String FullPath
{
get
{
return fullpath;
}
set
{
if (fullpath == value)
{
return;
}
else
{
fullpath = value;
isDataEmply = !CheckDataSet(fullpath);
}
}
}
public UPFolder Parent
{
get
{
return parent;
}
}
public UPFile(String filename,UPFolder parentNode)
{
parent = parentNode;
safeName = filename;
fullpath = String.Format("{0}\\{1}",parentNode.FullName,filename);
dataset = new UPDataSet();
}
public bool FillupDataSet()
{
//check if it is UNIPEN data file
bool result = false;
String path = fullpath;
if( dataset.FillDataSetFromFile(path))
{
if (dataset.Datalayouts.Count > 0)
{
foreach (var dl in dataset.Datalayouts)
{
// if file contains unipen stream return true
if (dl.UpUnipens.Count > 0)
{
result = true;
break;
}
}
}
}
return result;
}
private bool CheckDataSet(String path)
{
//check if it is UNIPEN data file
bool result = false;
UPImage.FileFormat.UPDataSet ds = new UPDataSet();
if (ds.FillDataSetFromFile(path))
{
if (ds.Datalayouts.Count > 0)
{
foreach (var dl in ds.Datalayouts)
{
// if file contains unipen stream return true
if (dl.UpUnipens.Count > 0)
{
result = true;
break;
}
}
}
}
ds = null;
return result;
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// dispose managed resources
}
// free native resources
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.