Esempio n. 1
0
System::Void
Upload::CUpload::eventOnClickOpen(
	System::Object		*sender,
	System::EventArgs	*e
)
{
	OpenFileDialog	*imageOpen = new OpenFileDialog();
	imageOpen->Filter = "Image (*.tif;*.iff;*.gif;*.bmp;*.tga)|*.tif;*.iff;*.gif;*.bmp;*.tga";
	imageOpen->Title = "Choose a Image File";

	if (imageOpen->ShowDialog() == System::Windows::Forms::DialogResult::OK) {
		this->textBoxPathname->Text = imageOpen->FileName->Replace('\\', '/');
	}
}
Esempio n. 2
0
int APIENTRY WinMain(HINSTANCE , HINSTANCE , LPSTR , int ) 
{
	Frame frame(L"ImageViewer");
	Bitmap bitmap;

	typedef Menu::ItemInfo Item;
	Item fileMenuItems[] = {
		Item(L"열기(&O)\tCtrl+O", Key::Modifier::ctrl | Key::o),
		Item(),
		Item(L"종료(&X)\tAlt+F4", Key::Modifier::alt | Key::f4)
	};
	Item menuBarItems[] = {
		Item(L"파일(&F)", fileMenuItems),
		Item(L"도움말(&H)", [&] (Menu::Click& ) { MsgBox::show(L"Image Viewer Ver 1.0", L"버전 정보"); })
	};
	MenuBar menuBar(menuBarItems);
	frame.menuBar(&menuBar);

	frame.onShortcutKey() = [&] (Frame::ShortcutKey& e) {
		switch (e.shortcut()) {
			case Key::Modifier::ctrl | Key::o : {
				OpenFileDialog dialog;
				dialog.filter(L"그림 파일\n*.bmp;*.gif;*.png;*.jpg;*.jpeg;*.tiff\n\n");
				if (dialog.show(frame)) {
					bitmap = Bitmap(dialog.filePath());
					if (bitmap != nullptr) {
						frame.scrollMinSize(bitmap.size()); // 윈도우 사이즈가 그림 사이즈보다 작으면 스크롤 할 수 있도록 한다
						frame.invalidate();
					}
				}
				e.handled(true);
			} break;
			case Key::Modifier::alt | Key::f4 : {
				frame.close();
				e.handled(true);
			} break;
		}
	};
	frame.onPaint() = [&] (Frame::Paint& e) {
		e.graphics().clear();
		if (bitmap != nullptr) {
			Graphics bitmapGraphics(bitmap);
			e.graphics().copy(frame.scrollPosition(), bitmapGraphics); // 스크롤을 빼고 이미지를 복사한다.
		}
	};

	frame.runMessageLoop();
	return 0;
}
void StarGeneratorInterface::__Button_Clicked( Button& sender, bool checked )
{
   if ( sender == GUI->StarDatabase_ToolButton )
   {
      OpenFileDialog d;
      d.DisableMultipleSelections();
      d.SetCaption( "StarGenerator: Select Star Database File" );
      if ( d.Execute() )
      {
         instance.starDatabasePath = d.FileName();
         GUI->StarDatabase_Edit.SetText( instance.starDatabasePath );
      }
   }
   else if ( sender == GUI->OutputFile_ToolButton )
   {
      SaveFileDialog d;
      d.SetCaption( "StarGenerator: Select Output CSV File" );
      d.EnableOverwritePrompt();

      FileFilter csvFilter;
      csvFilter.SetDescription( "CSV Text Files" );
      csvFilter.AddExtension( ".csv" );
      d.Filters().Add( csvFilter );
      FileFilter allFilter;
      allFilter.SetDescription( "Any Files" );
      allFilter.AddExtension( "*" );
      d.Filters().Add( allFilter );

      if ( d.Execute() )
      {
         instance.outputFilePath = d.FileName();
         GUI->OutputFile_Edit.SetText( instance.outputFilePath );
      }
   }
   else if ( sender == GUI->DecSouth_CheckBox )
   {
      if ( checked != (instance.centerDec < 0) )
      {
         instance.centerDec = -instance.centerDec;
         UpdateDecControls();
      }
   }
   else if ( sender == GUI->Nonlinear_CheckBox )
   {
      instance.nonlinear = checked;
      UpdateControls();
   }
}
Esempio n. 4
0
/* ---------------------------------------------- */
void MainWindow::LoadImage() {
    cout<<"TestingA"<<endl;
    OpenFileDialog *fileOpen = new OpenFileDialog(this);
    if (fileOpen->exec() == QDialog::Accepted) {
        cout<<"TestingB"<<endl;
        /* check if they actually selected any filenames */
        QStringList filenames = fileOpen->GetFilenames();
        if (filenames.count() > 0) {
            cout<<"TestingC"<<endl;
            /* get the loading parameters */
            QHash<QString, int> loadParams = fileOpen->GetLoadParams();
            MIViewImage *img = new MIViewImage();
            img->SetFilenames(filenames);
            img->SetLoadParams(loadParams);
            images.append(*img);
            cout<<"TestingC.1"<<endl;

            /* try to load the image */
            QString msg = images.last().Load();

            /* now render the image on the vtkImageViewer */
            imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
            imageViewer->SetInputConnection(images.last().reader->GetOutputPort());
            imageViewer->Render();
            imageViewer->GetRenderer()->ResetCamera();
            imageViewer->Render();
            cout<<"TestingC.2"<<endl;

            imageViewer->GetRenderWindow()->GetInteractor()->Start();
            //renderWindowInteractor->Start();

            cout<<"TestingC.3"<<endl;

            // VTK/Qt wedded
            ui->qvtkWidget->SetRenderWindow(imageViewer->GetRenderWindow());
            imageViewer->SetupInteractor(ui->qvtkWidget->GetInteractor());
            cout<<"TestingC.4"<<endl;

            ui->qvtkWidget->show();
            cout<<"TestingD"<<endl;
        }
    }
    else {
        cout<<"File dialog not successful?"<<endl;
    }
}
Esempio n. 5
0
void JObjectTree::LoadAsChild()
{
    if (!m_pSelected)
    {
        return;
    }
    OpenFileDialog of;
    of.SetDefaultExt( "rjml" );
    of.AddFilter( "Script Files", "*.rjml" );
    if (of.Show())
    {
        const char* fName = of.GetFilePath();
        JObject* pNode = g_pPersistServer->LoadObject( fName );
        m_pSelected->AddChild( pNode );
        if (!pNode)
        {
            rlog.err( "Could not load script from file: %s", fName );
        }
    }
} // JObjectTree::LoadAsChild
Esempio n. 6
0
bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv )
{
   // Allow the window manager to process command line inputs; this is
   // done to let web plugin functionality happen in a fairly transparent way.
   PlatformWindowManager::get()->processCmdLineArgs(argc, argv);

   Process::handleCommandLine( argc, argv );

   // Set up the command line args for the console scripts...
   Con::setIntVariable("Game::argc", argc);
   U32 i;
   for (i = 0; i < argc; i++)
      Con::setVariable(avar("Game::argv%d", i), argv[i]);

#ifdef TORQUE_PLAYER
   if(argc > 2 && dStricmp(argv[1], "-project") == 0)
   {
      char playerPath[1024];
      Platform::makeFullPathName(argv[2], playerPath, sizeof(playerPath));
      Platform::setCurrentDirectory(playerPath);

      argv += 2;
      argc -= 2;

      // Re-locate the game:/ asset mount.

      Torque::FS::Unmount( "game" );
      Torque::FS::Mount( "game", Platform::FS::createNativeFS( playerPath ) );
   }
#endif

   // Executes an entry script file. This is "main.cs"
   // by default, but any file name (with no whitespace
   // in it) may be run if it is specified as the first
   // command-line parameter. The script used, default
   // or otherwise, is not compiled and is loaded here
   // directly because the resource system restricts
   // access to the "root" directory.

#ifdef TORQUE_ENABLE_VFS
   Zip::ZipArchive *vfs = openEmbeddedVFSArchive();
   bool useVFS = vfs != NULL;
#endif

   Stream *mainCsStream = NULL;

   // The working filestream.
   FileStream str; 

   const char *defaultScriptName = "main.cs";
   bool useDefaultScript = true;

   // Check if any command-line parameters were passed (the first is just the app name).
   if (argc > 1)
   {
      // If so, check if the first parameter is a file to open.
      if ( (dStrcmp(argv[1], "") != 0 ) && (str.open(argv[1], Torque::FS::File::Read)) )
      {
         // If it opens, we assume it is the script to run.
         useDefaultScript = false;
#ifdef TORQUE_ENABLE_VFS
         useVFS = false;
#endif
         mainCsStream = &str;
      }
   }

   if (useDefaultScript)
   {
      bool success = false;

#ifdef TORQUE_ENABLE_VFS
      if(useVFS)
         success = (mainCsStream = vfs->openFile(defaultScriptName, Zip::ZipArchive::Read)) != NULL;
      else
#endif
         success = str.open(defaultScriptName, Torque::FS::File::Read);

#if defined( TORQUE_DEBUG ) && defined (TORQUE_TOOLS) && !defined(TORQUE_DEDICATED) && !defined( _XBOX )
      if (!success)
      {
         OpenFileDialog ofd;
         FileDialogData &fdd = ofd.getData();
         fdd.mFilters = StringTable->insert("Main Entry Script (main.cs)|main.cs|");
         fdd.mTitle   = StringTable->insert("Locate Game Entry Script");

         // Get the user's selection
         if( !ofd.Execute() )
            return false;

         // Process and update CWD so we can run the selected main.cs
         S32 pathLen = dStrlen( fdd.mFile );
         FrameTemp<char> szPathCopy( pathLen + 1);

         dStrcpy( szPathCopy, fdd.mFile );
         //forwardslash( szPathCopy );

         const char *path = dStrrchr(szPathCopy, '/');
         if(path)
         {
            U32 len = path - (const char*)szPathCopy;
            szPathCopy[len+1] = 0;

            Platform::setCurrentDirectory(szPathCopy);

            // Re-locate the game:/ asset mount.

            Torque::FS::Unmount( "game" );
            Torque::FS::Mount( "game", Platform::FS::createNativeFS( ( const char* ) szPathCopy ) );

            success = str.open(fdd.mFile, Torque::FS::File::Read);
            if(success)
               defaultScriptName = fdd.mFile;
         }
      }
#endif
      if( !success )
      {
         char msg[1024];
         dSprintf(msg, sizeof(msg), "Failed to open \"%s\".", defaultScriptName);
         Platform::AlertOK("Error", msg);
#ifdef TORQUE_ENABLE_VFS
         closeEmbeddedVFSArchive();
#endif

         return false;
      }

#ifdef TORQUE_ENABLE_VFS
      if(! useVFS)
#endif
         mainCsStream = &str;
   }

   // This should rarely happen, but lets deal with
   // it gracefully if it does.
   if ( mainCsStream == NULL )
      return false;

   U32 size = mainCsStream->getStreamSize();
   char *script = new char[size + 1];
   mainCsStream->read(size, script);

#ifdef TORQUE_ENABLE_VFS
   if(useVFS)
      vfs->closeFile(mainCsStream);
   else
#endif
      str.close();

   script[size] = 0;

   char buffer[1024], *ptr;
   Platform::makeFullPathName(useDefaultScript ? defaultScriptName : argv[1], buffer, sizeof(buffer), Platform::getCurrentDirectory());
   ptr = dStrrchr(buffer, '/');
   if(ptr != NULL)
      *ptr = 0;
   Platform::setMainDotCsDir(buffer);
   Platform::setCurrentDirectory(buffer);

   Con::evaluate(script, false, useDefaultScript ? defaultScriptName : argv[1]); 
   delete[] script;

#ifdef TORQUE_ENABLE_VFS
   closeEmbeddedVFSArchive();
#endif

   return true;
}
void HDRCompositionInterface::__InputImages_Click( Button& sender, bool checked )
{
   if ( sender == GUI->AddFiles_PushButton )
   {
      OpenFileDialog d;
      d.EnableMultipleSelections();
      d.LoadImageFilters();
      d.SetCaption( "HDRComposition: Select Input Images" );

      if ( d.Execute() )
      {
         size_type i0 = TreeInsertionIndex( GUI->InputImages_TreeBox );
         for ( StringList::const_iterator i = d.FileNames().Begin(); i != d.FileNames().End(); ++i )
            instance.images.Insert( instance.images.At( i0++ ), HDRCompositionInstance::ImageItem( *i ) );

         UpdateInputImagesList();
         UpdateImageSelectionButtons();
      }
   }
   else if ( sender == GUI->MoveUp_PushButton )
   {
      TreeBox::Node* node = GUI->InputImages_TreeBox.CurrentNode();
      if ( node != 0 )
      {
         int idx = GUI->InputImages_TreeBox.ChildIndex( node );
         if ( idx > 0 )
         {
            HDRCompositionInstance::ImageItem item = instance.images[idx];
            instance.images.Remove( instance.images.At( idx ) );
            instance.images.Insert( instance.images.At( idx-1 ), item );
            UpdateInputImagesList();
            GUI->InputImages_TreeBox.SetCurrentNode( GUI->InputImages_TreeBox[idx-1] );
            UpdateImageSelectionButtons();
         }
      }
   }
   else if ( sender == GUI->MoveDown_PushButton )
   {
      TreeBox::Node* node = GUI->InputImages_TreeBox.CurrentNode();
      if ( node != 0 )
      {
         int idx = GUI->InputImages_TreeBox.ChildIndex( node );
         if ( idx < int( instance.images.Length()-1 ) )
         {
            HDRCompositionInstance::ImageItem item = instance.images[idx];
            instance.images.Remove( instance.images.At( idx ) );
            instance.images.Insert( instance.images.At( idx+1 ), item );
            UpdateInputImagesList();
            GUI->InputImages_TreeBox.SetCurrentNode( GUI->InputImages_TreeBox[idx+1] );
            UpdateImageSelectionButtons();
         }
      }
   }
   else if ( sender == GUI->SelectAll_PushButton )
   {
      GUI->InputImages_TreeBox.SelectAllNodes();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->InvertSelection_PushButton )
   {
      for ( int i = 0, n = GUI->InputImages_TreeBox.NumberOfChildren(); i < n; ++i )
         GUI->InputImages_TreeBox[i]->Select( !GUI->InputImages_TreeBox[i]->IsSelected() );

      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->ToggleSelected_PushButton )
   {
      for ( int i = 0, n = GUI->InputImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( GUI->InputImages_TreeBox[i]->IsSelected() )
            instance.images[i].enabled = !instance.images[i].enabled;

      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->RemoveSelected_PushButton )
   {
      HDRCompositionInstance::image_list newImages;
      for ( int i = 0, n = GUI->InputImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( !GUI->InputImages_TreeBox[i]->IsSelected() )
            newImages.Add( instance.images[i] );
      instance.images = newImages;

      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->Clear_PushButton )
   {
      instance.images.Clear();
      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->FullPaths_CheckBox )
   {
      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
}
void DrizzleIntegrationInterface::__Click( Button& sender, bool checked )
{
   if ( sender == GUI->AddFiles_PushButton )
   {
      FileFilter drzFiles;
      drzFiles.SetDescription( "Drizzle Data Files" );
      drzFiles.AddExtension( ".drz" );

      OpenFileDialog d;
      d.EnableMultipleSelections();
      d.Filters().Clear();
      d.Filters().Add( drzFiles );
      d.SetCaption( "DrizzleIntegration: Select Drizzle Data Files" );
      if ( d.Execute() )
      {
         size_type i0 = TreeInsertionIndex( GUI->InputData_TreeBox );
         for ( StringList::const_iterator i = d.FileNames().Begin(); i != d.FileNames().End(); ++i )
            m_instance.p_inputData.Insert( m_instance.p_inputData.At( i0++ ), DrizzleIntegrationInstance::DataItem( *i ) );
         UpdateInputDataList();
         UpdateDataSelectionButtons();
      }
   }
   else if ( sender == GUI->SelectAll_PushButton )
   {
      GUI->InputData_TreeBox.SelectAllNodes();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->InvertSelection_PushButton )
   {
      for ( int i = 0, n = GUI->InputData_TreeBox.NumberOfChildren(); i < n; ++i )
         GUI->InputData_TreeBox[i]->Select( !GUI->InputData_TreeBox[i]->IsSelected() );
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->ToggleSelected_PushButton )
   {
      for ( int i = 0, n = GUI->InputData_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( GUI->InputData_TreeBox[i]->IsSelected() )
            m_instance.p_inputData[i].enabled = !m_instance.p_inputData[i].enabled;
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->RemoveSelected_PushButton )
   {
      DrizzleIntegrationInstance::input_data_list newImages;
      for ( int i = 0, n = GUI->InputData_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( !GUI->InputData_TreeBox[i]->IsSelected() )
            newImages.Add( m_instance.p_inputData[i] );
      m_instance.p_inputData = newImages;
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->Clear_PushButton )
   {
      m_instance.p_inputData.Clear();
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->FullPaths_CheckBox )
   {
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->InputDirectory_ToolButton )
   {
      GetDirectoryDialog d;
      d.SetCaption( "DrizzleIntegration: Select Input Directory" );
      if ( d.Execute() )
         GUI->InputDirectory_Edit.SetText( m_instance.p_inputDirectory = d.Directory() );
   }
   else if ( sender == GUI->EnableRejection_CheckBox )
   {
      m_instance.p_enableRejection = checked;
   }
   else if ( sender == GUI->EnableImageWeighting_CheckBox )
   {
      m_instance.p_enableImageWeighting = checked;
   }
   else if ( sender == GUI->EnableSurfaceSplines_CheckBox )
   {
      m_instance.p_enableSurfaceSplines = checked;
   }
   else if ( sender == GUI->ClosePreviousImages_CheckBox )
   {
      m_instance.p_closePreviousImages = checked;
   }
   else if ( sender == GUI->SelectPreview_Button )
   {
      PreviewSelectionDialog d;
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
            {
               m_instance.p_roi = view.Window().PreviewRect( view.Id() );
               UpdateROIControls();
            }
         }
   }
}
void GradientsMergeMosaicInterface::__TargetImages_Click( Button& sender, bool checked )
{
   if ( sender == GUI->AddFiles_PushButton )
   {
      OpenFileDialog d;
      d.EnableMultipleSelections();
      d.LoadImageFilters();
      d.SetCaption( "GradientsMergeMosaic: Select Target Frames" );

      if ( d.Execute() )
      {
         size_type i0 = TreeInsertionIndex( GUI->TargetImages_TreeBox );
         for ( StringList::const_iterator i = d.FileNames().Begin(); i != d.FileNames().End(); ++i )
            instance.targetFrames.Insert( instance.targetFrames.At( i0++ ), GradientsMergeMosaicInstance::ImageItem( *i ) );
         UpdateTargetImagesList();
         UpdateImageSelectionButtons();
      }
   }
   else if ( sender == GUI->MoveUp_PushButton )
   {
     for (int i=0,n = GUI->TargetImages_TreeBox.NumberOfChildren(); i<n; ++i) {
       if ( GUI->TargetImages_TreeBox[i]->IsSelected() ) {
	 if(i==0) {
	   // first is selected, we cannot really do something about this
	   break;
	 } else {
	   // swap order with previous one
	   GradientsMergeMosaicInstance::ImageItem tmp=instance.targetFrames[i-1];
	   instance.targetFrames[i-1]=instance.targetFrames[i];
	   instance.targetFrames[i]=tmp;
	   GUI->TargetImages_TreeBox[i]->Select(false);
	   GUI->TargetImages_TreeBox[i-1]->Select(true);
	   UpdateTargetImageItem(i);
	   UpdateTargetImageItem(i-1);
	 }
       }
     }
     // FIXME this restores the original selection list, which is just what I dont want.
     // Added UpdateTargetImageItem() above which is slightly less efficient
     // UpdateTargetImagesList();
   }
   else if ( sender == GUI->MoveDown_PushButton )
   {
     for (int n = GUI->TargetImages_TreeBox.NumberOfChildren(),i=n-1; i>=0; --i) {
       if ( GUI->TargetImages_TreeBox[i]->IsSelected() ) {
	 if(i==n-1) {
	   // first is selected, we cannot really do something about this
	   break;
	 } else {
	   // swap order with next one
	   GradientsMergeMosaicInstance::ImageItem tmp=instance.targetFrames[i];
	   instance.targetFrames[i]=instance.targetFrames[i+1];
	   instance.targetFrames[i+1]=tmp;
	   GUI->TargetImages_TreeBox[i]->Select(false);
	   GUI->TargetImages_TreeBox[i+1]->Select(true);
	   UpdateTargetImageItem(i);
	   UpdateTargetImageItem(i+1);
	 }
       }
     }
     // FIXME this restores the original selection list, which is just what I dont want.
     // Added UpdateTargetImageItem() above which is slightly less efficient
     // UpdateTargetImagesList();
   }
   else if ( sender == GUI->SelectAll_PushButton )
   {
      GUI->TargetImages_TreeBox.SelectAllNodes();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->InvertSelection_PushButton )
   {
      for ( int i = 0, n = GUI->TargetImages_TreeBox.NumberOfChildren(); i < n; ++i )
         GUI->TargetImages_TreeBox[i]->Select( !GUI->TargetImages_TreeBox[i]->IsSelected() );
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->ToggleSelected_PushButton )
   {
      for ( int i = 0, n = GUI->TargetImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( GUI->TargetImages_TreeBox[i]->IsSelected() )
            instance.targetFrames[i].enabled = !instance.targetFrames[i].enabled;
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->RemoveSelected_PushButton )
   {
      GradientsMergeMosaicInstance::image_list newTargets;
      for ( int i = 0, n = GUI->TargetImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( !GUI->TargetImages_TreeBox[i]->IsSelected() )
            newTargets.Add( instance.targetFrames[i] );
      instance.targetFrames = newTargets;
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->Clear_PushButton )
   {
      instance.targetFrames.Clear();
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->FullPaths_CheckBox )
   {
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
}