Example #1
0
//---------------------------------------------------------------------------
void FileListCreator(AnsiString TopDir, TStringList *SL, AnsiString Exts, bool SubFolder)
{
    void *Handle;
    TWin32FindData Data;
    Exts = UpperCase(Exts);
    Handle = FindFirstFile((TopDir + "\\*.*").c_str(), &Data);
    if (Handle == INVALID_HANDLE_VALUE) return;

    if (!((AnsiString(Data.cFileName) == ".") || (AnsiString(Data.cFileName) == ".."))){
        if (Exts.Pos(ExtractFileExt(Data.cFileName).UpperCase())){
            SL->Add(TopDir + "\\" + Data.cFileName);
        }

        if ((Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && SubFolder){
            FileListCreator(TopDir + "\\" + Data.cFileName, SL, Exts);
        }
    }

    while (FindNextFile(Handle, &Data)){
        if (!((AnsiString(Data.cFileName) == ".") || (AnsiString(Data.cFileName) == ".."))){
            if (Exts.Pos(ExtractFileExt(Data.cFileName).UpperCase())){
                SL->Add(TopDir + "\\" + Data.cFileName);
            }

            if ((Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && SubFolder){
                FileListCreator(TopDir + "\\" + Data.cFileName, SL, Exts);
            }
        }
    }

    FindClose(Handle);
}
Example #2
0
void __fastcall TForm1::FileOpen1Accept(TObject *Sender)
{
String a = FileOpen1->Dialog->FileName;
if (a!=""){
// Öffnen
if (ExtractFileExt(a).UpperCase()!=".AD")a=a.SubString(1,a.Length()-ExtractFileExt(a).Length())+".ad";
TStringList *Liste = new TStringList();
Liste->LoadFromFile(a);

Max = StrToInt(Liste->Strings[0]);
Edit1->Text=Liste->Strings[1];
ListBox1->Clear();
Liste->Delete(0);
Liste->Delete(0);
for (int i=0;i<Max;i++){
ListBox1->Items->Add(Liste->Strings[i*67]);

for (int b=0;b<66;b++){
Data[i][b] = StrToInt(Liste->Strings[i*67 + b + 1]);
}
}
ListBox1->ItemIndex=0;
Selected = ListBox1->ItemIndex;
Load_Dat(Selected);
}
}
Example #3
0
// fires an event when a file, or files are dropped onto the application.
void __fastcall TForm1::WMDropFiles(TWMDropFiles &message)
{ AnsiString FileName;
  FileName.SetLength(MAX_PATH);
  FileName.SetLength(DragQueryFile((HDROP)message.Drop, 0,FileName.c_str(), MAX_PATH));

  if(UpperCase(ExtractFileExt(FileName)) == ".BMP")
  {   bmp->LoadFromFile(FileName) ;
      img->Picture->Bitmap->Assign(bmp) ;
  } else if(UpperCase(ExtractFileExt(FileName)) == ".JPG")
         {   TJPEGImage * jpeg = new TJPEGImage();
             jpeg->LoadFromFile(FileName);
             jpeg->DIBNeeded();   
             bmp->Assign(jpeg);
             img->Picture->Bitmap->Assign(bmp) ;
             delete jpeg;
         }
  preview->frmSelect->Position = 0 ;
  outType->ItemIndex = 1 ;
  if(preview->Visible) updatePreview();
  int l = bmp->Width, h = bmp->Height ;
  transType->ItemIndex = 0 ;
  //preview->TransparentColor = 0 ;
  // auto compute frame number and frameset way
   if(l < 142 || h < 142)
    {  
       int s ; int yyop ; int *v=&h, *vh=&l ;
       if(l > h*2) { v=&l ; vh=&h ; vertical=0 ; } // horizontal frameset
       else vertical = 1 ;
       flipWay->Checked = !vertical ;
       s = *vh + 3 ;
       do { yyop = (*v)/s ; } while(s && yyop*s-- != *v) ; ++s ;
       if(s < 4)
       {  frmNb->Text = 1 ;
          sprintf(msg,"frames of %i*%i",l,h) ;
          LabelSize->Caption = msg ; fsx = l ; fsy = h ;
       }
       else {nb = yyop ; fsx = s ; fsy = *vh ;
             frmNb->Text = yyop ;
             sprintf(msg,"frames of %i*%i",s,*vh) ;
             LabelSize->Caption = msg ;
       }
    } else { frmNb->Text = 1 ;
             sprintf(msg,"frames of %i*%i",l,h) ;
             LabelSize->Caption = msg ;
             nb=1 ;
           }
  preview->ClientHeight = h ;
  preview->ClientWidth  = l + (nb > 1)*15 ;
  preview->Caption      = FileName + " (" + nb + ")" ;
  fname = FileName ;
  outTypeChange((TObject*)42) ;
  Form1->Button1->Enabled = 1 ;
  Form1->Height = 304 ;
  Form1->StatusBar->Visible = 1 ;
  // tell the OS that you're finished...
  DragFinish((HDROP) message.Drop);
}
Example #4
0
//---------------------------------------------------------------------------
void __fastcall TRefEditForm::WMDropFiles(TWMDropFiles &message)
{
  AnsiString FileName;
  FileName.SetLength(MAX_PATH);

  int Count = DragQueryFile((HDROP)message.Drop, 0xFFFFFFFF, NULL, MAX_PATH);

  // index through the files and query the OS for each file name...
  for (int index = 0; index < Count; ++index)
  {
    // the following code gets the FileName of the dropped file.  I know it
    // looks cryptic but that's only because it is.  Hey, Why do you think
    // Delphi and C++ Builder are so popular anyway?
    FileName.SetLength(DragQueryFile((HDROP)message.Drop, index,
      FileName.c_str(), MAX_PATH));

    // examine the filename's extension.
    // If it's a Word file then ...
    if (UpperCase(ExtractFileExt(FileName)) == ".DOC")

    {
      ListBox_Words->Items->Add(FileName);
    }
  }
  // tell the OS that we're finished...
  DragFinish((HDROP) message.Drop);
}
Example #5
0
void doc2txt::convertPro(AnsiString WordFile,AnsiString PathPutTxt)
{
	TStringList* word=new TStringList;
	String filename = WordFile;
	Variant  vVarApp,vVarDoc,vVarParagraphs,vVarParagraph;
	AnsiString resolution = ExtractFileExt(filename);
	AnsiString str = StringReplace( ExtractFileName(filename),resolution,"",TReplaceFlags()<< rfReplaceAll << rfIgnoreCase);

	try
	{
		vVarApp=CreateOleObject("Word.Application");
	}
	catch(...)
	{
		MessageBox(0, "Не удачно получилось открыть Word", "Внимание", MB_OK);
		return;
	}

	vVarApp.OlePropertySet("Visible",false);
	vVarDoc = vVarApp.OlePropertyGet("Documents");
	vVarDoc.OleProcedure("Open", StringToOleStr(filename));
	vVarDoc = vVarDoc.OleFunction("Item",1);
	vVarDoc.OleProcedure("Activate");
	String s = vVarDoc.OlePropertyGet("Content").OlePropertyGet("Text");
	word->Add(s);
	word->SaveToFile( PathPutTxt + str +".txt" );
	vVarApp.OleProcedure("Quit");
	delete word;
}
Example #6
0
bool TForm1::MakeBackup() {
	UnicodeString dir = ExtractFileDir(m_strFileName) + "\\backups";
	if (!DirectoryExists(dir) && !CreateDir(dir)) {
		return false;
	}
	UnicodeString newfilename = ExtractFileName(m_strFileName);
	newfilename.Delete(newfilename.Length() - ExtractFileExt(m_strFileName).Length() + 1, ExtractFileExt(m_strFileName).Length());

	newfilename =
		dir + L"\\" +
		newfilename + " (" + TDateTime::CurrentDateTime().FormatString("yyyy-mm-dd hh_nn") + ")" +
		ExtractFileExt(m_strFileName);
	Log->Lines->Add("Сохраняю резервную копию файла в " + newfilename);
	bool bResult = CopyFile(m_strFileName.c_str(),newfilename.c_str(),false);
	return bResult;
}
Example #7
0
bool ContactList::initialise( const std::string &fn, int slotno )
{

   if ( !initialise( slotno ) )
      return false;
   if ( MinosParameters::getMinosParameters() ->isListOpen( fn ) )
      return false;

   // open the List file

   cfileName = fn;
   String ext = ExtractFileExt( fn.c_str() );

   if ( stricmp( ext.c_str(), ".csl" ) == 0 )
   {
      cslFile = true;
   }
   else
   {
      return false;
   }

   bool loadOK = false;

   if ( cslFile )
   {
      if ( !cslLoad() )     // load the header so that we can display it
         return false;
      loadOK = cslLoadContacts();
   }

   return loadOK;
}
void __fastcall TForm1::OpenPicture1Click(TObject *Sender)
{
    OpenPictureDialog1->Filter =
       "Bmp files (*.bmp)|*.BMP| JPEG images (*.jpg) | *.jpg; " ;
    if (OpenPictureDialog1->Execute())
    {
        if (!FileExists(OpenPictureDialog1->FileName))
            return;
        AnsiString temp2 = ExtractFileName(OpenPictureDialog1->FileName);
        AnsiString temp = ExtractFileExt(OpenPictureDialog1->FileName);
        AnsiString Ext = temp.LowerCase();

        if (Ext.AnsiPos("jpg") > 0)
        {
            TJPEGImage *myjpeg = new TJPEGImage();
            myjpeg->LoadFromFile(OpenPictureDialog1->FileName);
            myjpeg->DIBNeeded();
            Image1->Picture->Bitmap->Assign(myjpeg);
            delete myjpeg;
        }
        else if (Ext.AnsiPos("bmp") > 0)
        {
            Image1->Picture->Bitmap->LoadFromFile(OpenPictureDialog1->FileName);
        }
    }
        {
        Undo1->Enabled=false; //apenergopoioume ta undo/redo
        Redo1->Enabled=false;
        ToolUndo->Enabled=false;
        ToolRedo->Enabled=false;
        }
}
Example #9
0
bool CEditableObject::Load(const char* fname)
{
	AnsiString ext=ExtractFileExt(fname);
    ext=ext.LowerCase();
    if 	(ext==".lwo")    		return Import_LWO(fname,false);
    else return LoadObject(fname);
}
//simvan gia tin apothikeusi tis eikonas otan patiete to save
//dinatotita gia apothikeusi se bmp & jpg morfi
void __fastcall TForm1::SavePic1Click(TObject *Sender)
{
  SavePictureDialog1->Title = "Save Image";
  SavePictureDialog1->DefaultExt = "jpg";
  SavePictureDialog1->Filter =
       "JPEG images (*.jpg) | *.jpg; | Bmp files (*.bmp)|*.BMP" ;
  SavePictureDialog1->FilterIndex = 1;
    if (SavePictureDialog1->Execute())
    {
        AnsiString temp2 = ExtractFileName(SavePictureDialog1->FileName);
        AnsiString temp = ExtractFileExt(SavePictureDialog1->FileName);
        AnsiString Ext = temp.LowerCase();

        if (Ext.AnsiPos("jpg") > 0)
        {
            TJPEGImage *jp = new TJPEGImage();
            try
            {
              jp->Assign(Image1->Picture->Bitmap);
              jp->SaveToFile(SavePictureDialog1->FileName);
            }
            __finally
            {
              delete jp;
            }
        }
Example #11
0
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
if (Key == 32 && Timer1->Enabled )
        {
                Timer1->Enabled = false;
                Image2->Picture->LoadFromFile("pic\\"+MainPath  );
                AnsiString FileName=ExtractFileName(MainPath);
                AnsiString FileExt=ExtractFileExt(MainPath);
                TReplaceFlags   rf; 
                rf   <<   rfReplaceAll;
                FileName=StringReplace( FileName, FileExt, "",   rf   );
                ShowMessage("恭喜您抽中 "+FileName);
                ADOQuery1->SQL->Text = "delete from MainTable where path = '" + MainPath +"' AND id="+IntToStr(uid);
                ADOQuery1->ExecSQL() ;
                ADOQuery1->SQL->Text = "insert into SecondTable (path,id) values ('" + MainPath +"','"+ uid +"')";
                ADOQuery1->ExecSQL() ;

        }
else if (Key == 32 && Timer1->Enabled == false)
        {

        Timer1->Enabled = true;
        }

}
Example #12
0
//===========================================================================
void __fastcall TfrmTargetList::ToolButton1Click(TObject *Sender)
{
  if (!Stoped) { MessageDlg("Операция доступна только при полностью остановленом моделировании ...", mtInformation, TMsgDlgButtons() << mbOK,0); return; }

  // --- Параметры Save Диалога ----
    OpenDialog1->Filter     = "Файлы целевой обстановки (*.trg)|*.trg";
    OpenDialog1->Title      = "Открыть файл целевой обстановки";
    OpenDialog1->InitialDir = ExtractFilePath(Application->ExeName);
    OpenDialog1->FileName   = "";

  if (OpenDialog1->Execute()){
      for (int i = 0; i < CheckListBox1->Items->Count; i ++) {
          if (CheckListBox1->Checked[i]) {
             CheckListBox1->Checked[i] = false;
             SetParamTargetWindow(i);
          }
      }
      aCurrentWindowPos = frmMain->ClientToScreen(Point(0, frmMain->cbWork->BoundsRect.Bottom));

      AnsiString aFileName = OpenDialog1->FileName;
      if (ExtractFileExt(aFileName) == "") aFileName = aFileName + ".trg";

      Targets_Load(aFileName);

  }
}
Example #13
0
//---------------------------------------------------------------------------
void __fastcall TDialogProjectNew::TreeViewGetImageIndex(TObject *Sender, TTreeNode *TreeNode)
{
  int Index = FormMain->FileExtensionToImageIndex(ExtractFileExt(TreeNode->Text));
  if ((Index >= 0) && (TreeNode->Level >= 1)) {
    TreeNode->ImageIndex = Index;
    TreeNode->SelectedIndex = Index;
  }
}
Example #14
0
void __fastcall TForm1::FileSaveAs1Accept(TObject *Sender)
{
String a = FileSaveAs1->Dialog->FileName;
if (a!=""){
// Speichern
if (ExtractFileExt(a).UpperCase()!=".AD")a=a.SubString(1,a.Length()-ExtractFileExt(a).Length())+".ad";
TStringList *List = new TStringList();
List->Add(IntToStr(Max));
List->Add(Edit1->Text);
for (int i=0;i<Max;i++){
List->Add(ListBox1->Items->Strings[i]);
for (int b=0;b<66;b++){
List->Add(IntToStr(Data[i][b]));
}
}
List->SaveToFile(a);
}
}
//---------------------------------------------------------------------------
// Returns true if the file is compressed with a method we know how to
// decompress
//
bool IsFileCompressed(std::string FileName)
{
  std::string Extension = ExtractFileExt(FileName);
  // At some point there may be more checking done here than just an extension check
  if (Extension == ".gz" || Extension == ".bz2")
    return true;
  else
    return false;
}  // bool IsCompressed(AnsiString FileName)
Example #16
0
/* ------------------------------------------------------------------------------
 function CompareFileExt(const Filename, Ext: string;
 CaseSensitive: boolean): integer;
 ------------------------------------------------------------------------------ */
int CompareFileExt(wxString const & Filename, wxString const & Ext,
  bool CaseSensitive)
{
	wxString FileExt = ExtractFileExt(Filename);
	if (CaseSensitive)
		return CompareStr(FileExt, Ext);
	else
		return CompareText(FileExt, Ext);
}
Example #17
0
//---------------------------------------------------------------------------
void __fastcall TRelDirSearchForm::GetFileList(AnsiString path, int baselen)
{
	TSearchRec r;
	int done;

	done=FindFirst(path + "*.*" ,faAnyFile, r);
	try
	{
		while(!done)
		{
			if(r.FindData.cFileName[0]!='.')
			{
				if(! (r.Attr & faDirectory))
				{
					// a file
					AnsiString name = AnsiString(path.c_str()+ baselen) +
						r.FindData.cFileName;
					FileList->Add(name);
					CurrentLabel->Caption = name;
					AnsiString fileext = ExtractFileExt(r.FindData.cFileName);
					ExtList->Add(fileext);

					// message processing
					Application->ProcessMessages();
					if(Aborted)
					{
						throw EAbort("Aborted");  // raise an aborting exception
					}
				}
				else
				{
					// a directory
					if(r.Name != "." && r.Name != ".." &&
						!(r.Name == "CVS" &&
							FileExists(path + AnsiString("CVS\\Repository"))))
								// ignoring CVS meta-data directory
					{
						GetFileList(path  + r.FindData.cFileName+
							AnsiString("\\"), baselen);
					}
				}
			}
			done=FindNext(r);
		}
	}
	catch(Exception &e)
	{
		FindClose(r);
		throw Exception(e);
	}
	FindClose(r);
}
Example #18
0
//---------------------------------------------------------------------
void TConfiguration::TemporaryLogging(const UnicodeString & ALogFileName)
{
  if (SameText(ExtractFileExt(ALogFileName), L".xml"))
  {
    TemporaryActionsLogging(ALogFileName);
  }
  else
  {
    FLogging = true;
    FLogFileName = ALogFileName;
    UpdateActualLogProtocol();
  }
}
Example #19
0
void HellPalette::Load(AnsiString NomeFile)
{
   if(FileExists(NomeFile))
   {
      if(ExtractFileExt(NomeFile)==".pal")
      {
        TStringList *TextFile = new TStringList;
        TextFile->LoadFromFile(NomeFile);
        for(int t=0;t<256;t++)
        {
           int red,green,blue;
           sscanf(TextFile->Strings[t].c_str(),"%d %d %d",&red,&green,&blue);
           Colore[t] = (TColor) (blue*0x010000 + green*0x000100 + red*0x000001);
        }
        delete TextFile;
      }
      else if(ExtractFileExt(NomeFile)==".act")
      {
         int fh = FileOpen(NomeFile,fmOpenRead);
         unsigned char *buf = new unsigned char[768];
         FileRead(fh,buf,768);
         FileClose(fh);
         for(int t=0;t<256;t++)
         {
           int red,green,blue;
           red   = buf[t*3+0];
           green = buf[t*3+1];
           blue  = buf[t*3+2];
           Colore[255-t] = (TColor) (blue*0x010000 + green*0x000100 + red*0x000001);
        }
        delete [] buf;
      }
   }
   else
   {
      MakeSeedPalette(1);
   }
}
//---------------------------------------------------------------------------
// Operaciones previas y llamada a la función de descarga
//---------------------------------------------------------------------------
void __fastcall TMainForm::b_descargarClick(TObject *Sender)
{
    DWORD       bytes;
    AnsiString  url("http://" + cb_url->Text);
    AnsiString  destino(IncludeTrailingBackslash(m_opciones.m_destino));

    // buscar la extensión. La función ExtractFileExt también nos sirve para Urls, porque
    // lo único que hace el buscar el punto comenzando por el final.
    destino += "datos" + ExtractFileExt(cb_url->Text);

    Screen->Cursor = crHourGlass;

    e_localizacion->Text = "Descargando...";
    e_asociado->Text     = e_localizacion->Text;
    b_abrir->Enabled     = false;
    ts_archivo->Repaint();

    __try
    {
        lb_log->Items->Clear();
        lb_log->Repaint();

        bytes = Descargar(url.c_str(), destino.c_str(), &m_opciones, &DescargaCallback);
    }
    __finally
    {
        Screen->Cursor = crDefault;

        if ( DWORD(-1) == bytes )
        {
            e_localizacion->Text = "";
            e_asociado->Text     = "";

            lb_log->ItemIndex = MainForm->lb_log->Items->Add("Se ha producido un error descargando el recurso.");
        }
        else
        {
            char buff[256];

            FindExecutable(destino.c_str(), NULL, buff);
            e_localizacion->Text = destino;
            e_asociado->Text     = buff;
            b_abrir->Enabled     = true;
            m_vista->Lines->Clear();

            lb_log->ItemIndex = MainForm->lb_log->Items->Add("El recurso ha sido descargado en " +
                    destino + ". Tamaño total: " + IntToStr(bytes) + " bytes.");
        }
    }
}
Example #21
0
void Supported::CabForzaRead(FILE* in){

struct{
	char sig[8];
	int files;
	int version;
	int compSize;
	int decompSize;
	int filenameIndexSize;
}cab;

struct{
	int offset;
	int compSize;
	int decompSize;
	int filenameOffset;
	int null;
	int unknown;
}cabEntry;

fseek(in, 0, 0);
fread(&cab, sizeof(cab), 1, in);
CItem.Files = cab.files;

int pos = 306;
int fileNameIndex = (cab.files * 24) + (306); // Filename index offset

for (int i = 0; i < CItem.Files; ++i, pos += 24)
{
	fseek(in, pos, 0);
	fread(&cabEntry, sizeof(cabEntry), 1, in);

	FItem.Offset.push_back(cabEntry.offset);
	FItem.Chunk.push_back(cabEntry.compSize);

	char eachname[120];
	fseek(in, fileNameIndex + cabEntry.filenameOffset, 0);
	fread(eachname, sizeof(eachname), 1, in);

	sys.PushFileName((char*)eachname);
	sys.PushExtension(ExtractFileExt((char*)eachname));

	FItem.Format.push_back(FItem.Ext[i]);
	FItem.Channels.push_back(0);
	FItem.SampleRate.push_back(0);
	FItem.Bits.push_back(0);
}

fclose(in);
}
Example #22
0
//---------------------------------------------------------------------------
void TScriptEditFrame::SetupEdit(String FileName)
{
	String Ext = ExtractFileExt(FileName);

	if(SameStr(Ext,".dcm"))Edit->Highlighter = SynDcmSyn1;
	else if(SameStr(Ext,".ini"))Edit->Highlighter = SynIniSyn1;
	else if(SameStr(Ext,".lng"))Edit->Highlighter = SynIniSyn1;
	else if(SameStr(Ext,".xml"))Edit->Highlighter = SynXMLSyn1;
	else
	{
		Edit->Highlighter = 0;
    }

}
Example #23
0
//---------------------------------------------------------------------------
AnsiString ExtractFileNameOnly(AnsiString S)
{
    S = ExtractFileName(S);
    while (true){
        AnsiString Ext = ExtractFileExt(S);
        if (Ext != ""){
            S = S.SubString (1, S.Length() - Ext.Length());
            break;//1段階だけ拡張子を取る。全部とりきる場合はコメントアウト
        }else{
            break;
        }
    }
    return S;
}
Example #24
0
void Supported::PodRead(FILE* in){

Supported file;

struct
{
	u_int 	index[4];
	u_int 	fileNameIndexSize[4];
	u_char	fileName[70];
}pod;


// Num of files
fseek(in, 88, 0);
fread(&CItem.Files, 4, 1, in);

// Index
fseek(in, 264, 0);
fread(pod.index, 4, 1, in);

// FileName index size
fseek(in, 272, 0);
fread(pod.fileNameIndexSize, 4, 1, in);


// Offsets / sizes
file.pos = *pod.index + 4;
for (int x = 0; x < CItem.Files; ++x, file.pos += 20)
{                              
	fseek(in, file.pos, 0);
	sys.PushChunk(in, 4);
	sys.PushOffset(in, 4);
}

// FileNames
file.pos = CItem.FileSize - *pod.fileNameIndexSize;
for (int x = 0; x < CItem.Files; ++x)
{
	fseek(in, file.pos, 0);
	fgets((char*)pod.fileName, sizeof(pod.fileName), in);

	file.pos += (long)strlen((char*)pod.fileName) + 1;
	FItem.FileName.push_back((char*)pod.fileName);
	FItem.Ext.push_back(ToLower("." + ExtractFileExt((char*)pod.fileName)));
}

sys.RiffSpecs(in, false);

}
Example #25
0
//===========================================================================
void __fastcall TfrmTargetList::ToolButton2Click(TObject *Sender)
{
  // --- Параметры Save Диалога ----
    SaveDialog1->Filter     = "Файлы целевой обстановки (*.trg)|*.trg";
    SaveDialog1->Title      = "Записать файл целевой обстановки";
    SaveDialog1->InitialDir = ExtractFilePath(Application->ExeName);
    SaveDialog1->FileName   = "";

  if (SaveDialog1->Execute()){
      AnsiString aFileName = SaveDialog1->FileName;
      if (ExtractFileExt(aFileName) == "") aFileName = aFileName + ".trg";

      Targets_Save(aFileName);
  }
}
Example #26
0
void Load(String path)
        {
        lasty=-1;
        String ext=ExtractFileExt(path).UpperCase();
        if(ext==".JPEG" || ext==".JPG")
                {
                TJPEGImage*im=new TJPEGImage();
                im->LoadFromFile(path);
                Assign(im);
                delete im;
                }else
                {
                LoadFromFile(path);
                }
        }
Example #27
0
//---------------------------------------------------------------------------
void __fastcall TNewEn::btnOpenClick(TObject *Sender)
{
    OpenDialog->Filter = "Model File|*.xml";
    OpenDialog->DefaultExt = "*.XML";
    OpenDialog->FileName = "*.XML";
    if(g_pProject->m_bModified)
    {
      switch (Application->MessageBox("Model File has been modified, save£¿","Hint",MB_YESNOCANCEL))
      {  case ID_YES :
            SaveCommand();
            break;
         case ID_CANCEL :
            return;
      }
    }
    ClearProject();
    InitialProject();
    if(OpenDialog->Execute())
    {
        g_pProject->m_strFileName=OpenDialog->FileName;
        AnsiString exten = ExtractFileExt(OpenDialog->FileName);
        exten = exten.UpperCase();
        if(exten == ".XML")
        {
          g_pProject->XMLDoc = XMLDocument1;
          g_pProject->LoadFromXML(g_pProject->m_strFileName);

          if( graphic==NULL)
             graphic=new Graphics::TBitmap();
          if(g_pProject->m_strLayout.Length()>2)
          {
           try {
              graphic->LoadFromFile(g_pProject->m_strLayout);
           } catch (Exception &e)
           {  ShowMessage(e.Message);delete graphic;graphic=NULL;
           }
          }
          this->Caption="Smart Environment----"+g_pProject->m_strFileName;
        }
        else
        {
          return;
        }
        FrameProperty->RefreshProjectTree();
        Refresh();
    }

}
Example #28
0
//---------------------------------------------------------------------------
void __fastcall Tform_Main::N1Click(TObject *Sender)
{

    LoadedData.Clear();

    if ( OpenDialog1->Execute() == false ) return;

    ClearSeries(Chart2, true);
    ClearSeries(Chart4, true);
    ClearSeries(Chart5, true);
    ClearSeries(Chart6, true);
    ClearSeries(Chart7, true);
    ClearSeries(Chart8, true);

    PageControl1->TabIndex = 0;

    Caption = AnsiString(ProjectCaption) + "[" + OpenDialog1->FileName + "]";

    Application->ProcessMessages();

    float mean = 0;
    int series_index = 0;
    bool second_mode = false;
    if ( ExtractFileExt(OpenDialog1->FileName) == ".bin" )
         LoadedData.Load_binary(OpenDialog1->FileName.t_str());
    else {
        //LoadedData.Load(OpenDialog1->FileName.t_str(), NULL);
        //second_mode = true;
        //series_index = 1;
    }

    if ( second_mode == false )
        WorkFreq = 48000;
    else
        WorkFreq = 200;

    mean = LoadedData.Items[series_index]->Get_Mean();

    SoundData.Clear();

    for ( unsigned int i = 0; i < LoadedData.Items[0]->ValuesCount; i++)
        SoundData.Add(LoadedData.Items[series_index]->Values[i] - mean);

    Draw_ChartSeries(Chart4, 0, true, false, 3000, 0, 0, LoadedData.Items[series_index]->ValuesCount, NULL, LoadedData.Items[series_index]);

    bBPF_Start->Enabled = true;
}
Example #29
0
void __fastcall Tform_Main::N2Click(TObject *Sender)
{
    if ( SaveDialog1->Execute() == true )
    {
        Caption = AnsiString(ProjectCaption) + "[" + SaveDialog1->FileName + "]";

        CCollectionStorage<float>  SavedData;
        SavedData.SetItemsCount(1);

        for ( unsigned int i = 0; i < SoundData.ValuesCount; i++ )
            SavedData.Items[0]->Add(SoundData.Values[i]);

        if (  ExtractFileExt(SaveDialog1->FileName) == "") SaveDialog1->FileName = SaveDialog1->FileName + ".bin";
        SavedData.Save_binary(SaveDialog1->FileName.t_str());

    }
}
Example #30
0
void __fastcall TLoggerFile::Reset() {
  if(_outp) {
    Info("--------------------------------------------------------------------------------\nДо встречи в следующем файле!");
    fclose(_outp);
    _file_name = _path+Now().FormatString("yyyymmdd")+".log";
  }
  if(!bool(_outp = fopen(_file_name.c_str(), "at"))) throw Exception("");
  if(_max_file_count) {
    String Mask = ExtractFilePath(_file_name)+"*"+ExtractFileExt(_file_name);
    ns_Functions::TFileList FileList;
    ns_Functions::GetFileList(FileList, Mask);
    FileList.sort();
    while(FileList.size()>_max_file_count) {
      DeleteFile(FileList.front());
      FileList.pop_front();
    }
  }
}