Пример #1
0
void RebrandingHelper::ApplyBranding(wxRibbonPanel * panel, wxString scope)
{
	if (!panel) return;

	wxString panelScope = scope + "." + panel->GetLabel();
	if (ShouldDelete(panelScope))
    {
    	panel->Destroy();
    	return;
    }

    if (ShouldRename(panelScope)) panel->SetLabel(GetNewName(panelScope));

    wxWindowList & children = panel->GetChildren();
    for(auto childIt = children.begin();childIt != children.end();++childIt)
    {
        wxWindow * child = *childIt;
        if (!child) continue;

	    if (wxRibbonButtonBar * buttonBar = dynamic_cast<wxRibbonButtonBar*>(child))
	    {
	        ApplyBranding(buttonBar, panelScope + ".ButtonBar");
	    }
    }
	panel->Realize();
}
Пример #2
0
void RebrandingHelper::ApplyBranding(wxStaticText * text, wxString scope)
{
    if (!text) return;

    wxString textScope = scope + "." + text->GetLabel();
    if (ShouldRename(textScope)) text->SetLabel(GetNewName(textScope));
}
Пример #3
0
void RebrandingHelper::ApplyBranding(wxRibbonBar * bar, wxString scope)
{
    for (size_t pageIndex = 0;pageIndex < bar->GetPageCount();pageIndex++)
    {
        wxRibbonPage * page = bar->GetPage(pageIndex);
        if (page)
        {
	        wxString pageScope = scope + "." + page->GetLabel();
	        if (ShouldDelete(pageScope)) bar->HidePage(pageIndex);
			else if (ShouldRename(pageScope)) page->SetLabel(GetNewName(pageScope));

	        wxWindowList & children = page->GetChildren();
	        for(auto childIt = children.begin();childIt != children.end();++childIt)
	        {
	            wxWindow * child = *childIt;
	            if (!child) continue;

			    if (wxRibbonPanel * panel = dynamic_cast<wxRibbonPanel*>(child))
			    {
			        ApplyBranding(panel, pageScope);
			    }
	        }
        }
    }
	bar->Realize();
}
Пример #4
0
int main( int argc, char *argv[] )
{
    int     i, j, err;
    char   *pattern;
    char   *filename;
    char    newname[NAME_LEN];

    verbose   = FALSE;
    debug     = FALSE;
    copyFiles = FALSE;
    preserveFiles = FALSE;
    progname  = argv[0];
    if (argc < 3) UsageAbort();
    pattern = argv[argc-1];
    for (i=1; i<argc-1; i++) {
        filename = argv[i];
        if (filename[0] == '-') {
            for (j=1; filename[j]!='\0'; j++) {
                switch( filename[j] ) {
                case 'v':
                    verbose = 1;
                    fprintf(stderr, "%s\n", VERSION);
                    break;
                case 'd':
                    debug = 1;
                    fprintf(stderr, "%s: debugging output activated\n",
                        progname);
                    break;
                default:
                    UsageAbort();
                    break;
                }
            }
        } else {
            err = GetNewName( filename, pattern, newname );
            if (err==ERR_PATMATCH) {
                fprintf(stderr,
                    "%s: filename \"%s\" does not match pattern \"%s\"\n",
                    progname, filename, pattern);
            } else if (err==ERR_PATINVAL) {
                fprintf(stderr, "%s: invalid pattern \"%s\", aborting\n",
                    progname, pattern);
                exit( 1 );
            } else if (err==ERR_TOOCOMPL) {
                fprintf(stderr, "%s: pattern \"%s\" too complicated, aborting\n"
                    ,progname, pattern);
                exit( 1 );
            } else {
                if (strcmp(filename, newname)==0) {
                    fprintf(stderr,
                        "%s: error, \"%s\": old and new names match\n",
                        progname, filename);
                } else {
                    MoveFile( filename, newname );
                }
            }
        }
    }
    return( 0 );
}
Пример #5
0
static void AddToLinkerComdat( symbol *sym )
/******************************************/
/* this tries to add "size" bytes to an existing comdat segment, and if it
 * can't, it creates a new segment for the data */
{
    seg_leader *        leader;
    class_entry *       class;
    offset              seglen;
    section *           sect;
    segdata *           sdata;
    byte                alloc;
    byte                align;

    sdata = sym->p.seg;
    alloc = sdata->alloc;
    align = sdata->align;
    leader = CDatSegments[alloc];
    if( leader == NULL ) {
        sdata->u.name = GetNewName();
        sym->addr.off = 0;
        if( !(FmtData.type & MK_OVERLAYS) || !(alloc & 1) ) {
            sect = Root;
        } else {
            sect = NonSect;             /* data in an overlaid app */
        }
        class = FindClass( sect, CDatClassNames[alloc], alloc > 1, alloc & 1 );
    } else {
Пример #6
0
wxString RebrandingHelper::ApplyBranding(wxString str, wxString scope)
{
    wxString updatedStr = str;
    wxString strScope = scope + "." + str;
    if (ShouldRename(strScope)) updatedStr = GetNewName(strScope);

    return updatedStr;
}
Пример #7
0
void RebrandingHelper::ApplyBranding(wxPropertyGrid * grid, wxString scope)
{
    wxPropertyGridIterator it = grid->GetIterator();
    while (!it.AtEnd())
    {
        wxPGProperty * property = it.GetProperty();
        it.Next();
        if (property) {
            wxString propertyScope = scope + "." + property->GetName();
            if (ShouldDelete(propertyScope)) property->Hide(true);
            else if(ShouldRename(propertyScope)) property->SetLabel(GetNewName(propertyScope));
        }
    }

}
Пример #8
0
void RebrandingHelper::ApplyBranding(wxTreeCtrl * treeCtrl, wxTreeItemId item, wxString scope)
{
    while(item.IsOk())
    {
        wxTreeItemId next = treeCtrl->GetNextSibling(item);

        wxString itemScope = scope + "." + treeCtrl->GetItemText(item);
        if (ShouldDelete(itemScope)) treeCtrl->Delete(item);
        else
        {
        	if (treeCtrl->ItemHasChildren(item))
            {
                void * cookie;
                ApplyBranding(treeCtrl, treeCtrl->GetFirstChild(item, cookie), itemScope);
            }

        	if (ShouldRename(itemScope)) treeCtrl->SetItemText(item, GetNewName(itemScope));
        }


        item = next;
    }
}
Пример #9
0
void RebrandingHelper::ApplyBranding(wxMenu & menu, wxString scope)
{
    size_t separatorIndex = 0;

	wxMenuItemList & itemsList = menu.GetMenuItems();
	for(auto itemIt = itemsList.begin(); itemIt != itemsList.end();++itemIt)
	{
	    wxMenuItem * item = *itemIt;
	    if (!item) continue;

        wxString name = menu.GetLabelText(item->GetId());
        if (item->GetId() == wxID_SEPARATOR)
        {
            name = "Separator_";
            name << separatorIndex;
            separatorIndex++;
        }

	    wxString itemScope = scope + "." + name;

	    if (ShouldDelete(itemScope)) menu.Destroy(item);
	    else if (ShouldRename(itemScope)) item->SetItemLabel(GetNewName(itemScope));
	}
}
Пример #10
0
void CPhotoPubView::OnTimer(UINT_PTR nIDEvent)
{
	KillTimer(1);
	CPhotoPubDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: Add your message handler code here and/or call default
	int nFiles=m_CurFiles.size();
	set<CString> CurFiles1;
	const int nFiles1=GetAllFolderFile(m_WatchingPath, "*.jpg", CurFiles1);
	if (nFiles==nFiles1) {
		SetTimer(1,500,NULL);
		return;
	}else if (nFiles>nFiles1){
		AfxMessageBox("同步发生错误,无法恢复,请重新运行!\n");
		exit(1);
	}
	
	//Here Comes a new Photo
	//wait transfering
	Sleep(1000);
	//process
	set<CString>::iterator it1;
	for (it1=CurFiles1.begin();it1!=CurFiles1.end();++it1)
	{
		if ( m_CurFiles.find(*it1)==m_CurFiles.end() ) //not exist before
		{
			((CMainFrame*)GetParent())->ShowWindow(SW_SHOWMAXIMIZED);

			CClientDC cdc(this);
			CRect clrct;
			GetClientRect(&clrct);
			int width=clrct.Width();
			int height=clrct.Height();

			if (pDoc->m_pOpenedImage) ReleaseFImage(&pDoc->m_pOpenedImage);
			IplImage *pImg=pDoc->m_pOpenedImage=LoadFImage(m_WatchingPath+"\\"+*it1+".jpg");
			m_ratio=min(double(width)/pImg->width,double(height)/pImg->height);
			((CMainFrame*)GetParent())->SetRatio(int(m_ratio*100));
			OnUpdate(NULL,NULL,NULL);
			DrawImage(&cdc,pImg);

			CString newname;
			int res;
			do {
				GetNewName(m_InitStr,newname);
				res=rename(m_WatchingPath+"\\"+*it1+".jpg",m_WatchingPath+"\\"+newname+".jpg");
			}while( 
				(res==0) ? false : (true,
					(errno==EEXIST) ? AfxMessageBox("文件名重复!请重试"): (
						(errno==EINVAL) ? AfxMessageBox("文件名含非法字符!请重试"):AfxMessageBox("未知错误!请重试")
				) ) );
			m_CurFiles.insert(newname);
			m_InitStr=newname;
			CStringNumber snum(m_InitStr);
			snum.Increase();
			snum.ToString(m_InitStr);
			//break;
		}
	}
	
	CScrollView::OnTimer(nIDEvent);

	SetTimer(1,500,NULL);
}
Пример #11
0
//---------------------------------------------------------------------------
void __fastcall TCopyProgress::TimerTimer(TObject *Sender)
{
//Надо переделать постановку в очередь файлов загруженных в память и выгрузку их
//переменные i,j,k 
  static __int64 memsize,rwconst;
  static int i, j, k;
  static bool firstwrite;
  static int exitcode = EX_EOF, len;
  try
    {
  switch(FMode)
    {
    case cmInit:
      memsize = FMemoryBuffer;
      rwconst = FRWConst;
      i = 0;
      j = 0;
      k = 0;
      FMode = cmLoad;
      ReadingProgressBar->Position = ReadingProgressBar->Min;
      ReadingLabel->Show();
      ReadingProgressBar->Show();
      firstwrite = true;
      break;

    case cmLoad:
      if(i != FFileList->Files)
        {
//        if(FFileList->Selected[i])
//          {
          AnsiString temp;
          if(!(FFile && FFileList->File[i]->Root))
            temp = FFileList->File[i]->FullName;
          else
            temp = GetNewName(FDestinationName,FFileList->File[i]->FullName);//get name from mask
          if(!VerifyStatements(FTarget + temp,i))
            {
            i++;
            break;
            }
          FMem[k] = new TFileCmd(FSource,FTarget,temp,FFileList->File[i],FBuffer,FAddFile);
          if(FMem[k]->SourceHandle == -1)
            throw EFOpenError("Couldn't open file " + FMem[k]->SourceName);
          if(FMem[k]->Type == fstFile)
            {
            AnsiString path = ExtractFilePath(FSource + FMem[k]->SourceName), temp = ExtractFileName(FMem[k]->SourceName);
            len = ReadingLabel->Canvas->TextWidth(temp);
            ReadingLabel->Caption = MinimizeName(path,ReadingLabel->Canvas,
              ReadingLabel->ClientWidth - len) + temp;
            ReadingProgressBar->Position = ReadingProgressBar->Min;
            }
          FMode = cmLoading;
          i++;
//          }
//        else
//          i++;
        }
      else
        {
        memsize = FMemoryBuffer;
        FMode = cmSave;
        }
      break;
      
    case cmLoading:
      exitcode = FMem[k]->LoadFileToMemory(memsize,rwconst);
      if(FMem[k]->Type == fstFile)
        ReadingProgressBar->Position = (int) ((FMem[k]->FileSourcePos + 1) * (ReadingProgressBar->Max -
          ReadingProgressBar->Min) / (FMem[k]->FileSize + 1));
      switch(exitcode)
        {
        case EX_NEXT:
          rwconst = FRWConst;
          memsize = FMemoryBuffer;
          FMode = cmSave;
          break;
        case EX_EOF:
          k++;
          rwconst = FRWConst;
          FMode = cmLoad;
        }
      break;
      
    case cmSave:
      if(firstwrite)
        {
        WritingProgressBar->Position = WritingProgressBar->Min;
        WritingLabel->Show(); 
        WritingProgressBar->Show(); 
        firstwrite = false;
        }
      if(j == k && i == FFileList->Files && exitcode == EX_EOF)
        {
        for (i = k - 1; i >= 0; i--)
          {
          if(FMove && FMem[i]->Type == fstDirectory)
            {
            if(!RemoveDir(FMem[j]->SourcePath + FMem[j]->SourceName))
              throw EInOutError("The directory " + FMem[j]->SourceName + " can't be deleted");
            }
          delete FMem[i];
          }
        FCopied = true;
        Close();
        return;
        }
      if(!FMem[j]->SaveContinue)
        {
        FMem[j]->CreateFile();
        if(FMem[j]->Type == fstFile)
          {
          AnsiString path = ExtractFilePath(FTarget + FMem[j]->DestinationName), temp = ExtractFileName(FMem[j]->DestinationName);
          len = WritingLabel->Canvas->TextWidth(temp);  
          WritingLabel->Caption = MinimizeName(path,WritingLabel->Canvas,
            WritingLabel->ClientWidth - len) + temp;
          WritingProgressBar->Position = WritingProgressBar->Min;
          }
        }
      FMode = cmSaving;//verify if directory then next save (not saving)
      break;
      
    case cmSaving:
      exitcode = FMem[j]->SaveMemoryToFile(memsize,rwconst);
      if(FMem[j]->Type == fstFile)
        WritingProgressBar->Position = (int) ((FMem[j]->FileDestinationPos + 1) * (WritingProgressBar->Max - 
          WritingProgressBar->Min) / (FMem[j]->FileSize + 1));
      switch(exitcode)
        {
        case EX_EOF:
          if(FMove && FMem[j]->Type == fstFile)
            {
            if(!DeleteFile(FMem[j]->SourcePath + FMem[j]->SourceName))
              throw EInOutError("Error occurs during deleting file " + FMem[j]->SourceName);
            }
          rwconst = FRWConst;
          j++;
          FMode = cmSave;
          break;
        case EX_NEXT:
          rwconst = FRWConst;
          memsize = FMemoryBuffer;
          FMode = cmLoading;
          break;
        case EX_TOBECONTINUED:
          break;
        }
    }
    }
  catch(...)
    {
/*      if(FMode == cmLoad)
        k --;*/
      for(j = 0; j <= k; j++)
        delete FMem[j];
      FCopied = true;
      Close();
      return;
    }
}