Example #1
0
        // On form loading
        private void MainForm_Load( object sender, EventArgs e )
        {
            // collect available modules in application's directory
            CollectModules( Path.GetDirectoryName( Application.ExecutablePath ) );
            // add modules' name to application's menu
            foreach ( string routineName in processingRoutines.Keys )
            {
                ToolStripItem item = modulesToolStripMenuItem.DropDownItems.Add( routineName );

                item.Click += new System.EventHandler( this.module_Click );

                if ( ipRoutineToUse == null )
                {
                    ipRoutineToUse = processingRoutines[routineName];
                }
            }

            // load configuratio
            Configuration config = Configuration.Instance;

            if ( config.Load( ) )
            {
                try
                {
                    bool windowPositionIsValid = false;
                    // get window location/size
                    Size windowSize = new Size(
                        int.Parse( config.GetConfigurationOption( mainFormWidthOption ) ),
                        int.Parse( config.GetConfigurationOption( mainFormHeightOption ) ) );
                    System.Drawing.Point windowTopLeft = new System.Drawing.Point(
                        int.Parse( config.GetConfigurationOption( mainFormXOption ) ),
                        int.Parse( config.GetConfigurationOption( mainFormYOption ) ) );
                    System.Drawing.Point windowTopRight = new System.Drawing.Point(
                        windowTopLeft.X + windowSize.Width, windowTopLeft.Y );

                    // check if window location is within of the displays
                    foreach ( Screen screen in Screen.AllScreens )
                    {
                        if ( ( screen.WorkingArea.Contains( windowTopLeft ) ) ||
                             ( screen.WorkingArea.Contains( windowTopRight ) ) )
                        {
                            windowPositionIsValid = true;
                            break;
                        }
                    }

                    if ( windowPositionIsValid )
                    {
                        Location = windowTopLeft;
                        Size = windowSize;

                        WindowState = (FormWindowState) Enum.Parse( typeof( FormWindowState ),
                            config.GetConfigurationOption( mainFormStateOption ) );

                        mainSplitContainer.SplitterDistance = int.Parse( config.GetConfigurationOption( splitter1Option ) );
                        splitContainer1.SplitterDistance = int.Parse( config.GetConfigurationOption( splitter2Option ) );
                        splitContainer2.SplitterDistance = int.Parse( config.GetConfigurationOption( splitter3Option ) );
                    }

                    // get size mode of picture box
                    SetPictureBoxSizeMode( (PictureBoxSizeMode) Enum.Parse( typeof( PictureBoxSizeMode ),
                        config.GetConfigurationOption( pictureSizeModeOption ) ) );

                    // get recent folders
                    for ( int i = 0; i < 7; i++ )
                    {
                        string rf = config.GetConfigurationOption( recentFolderOption + i );

                        if ( rf != null )
                            recentFolders.Add( rf );
                    }

                    RebuildRecentFoldersList( );

                    bool openLast = bool.Parse( config.GetConfigurationOption( openLastOption ) );
                    openLastFolderOnStartToolStripMenuItem.Checked = openLast;

                    if ( ( openLast ) && ( recentFolders.Count > 0 ) )
                    {
                        OpenFolder( recentFolders[0] );
                    }
                }
                catch
                {
                }
            }
        }
Example #2
0
 // Item is clicked in modules' menu
 private void module_Click( object sender, EventArgs e )
 {
     ipRoutineToUse = processingRoutines[( (ToolStripMenuItem) sender ).Text];
     ProcessSelectedImage( );
 }
Example #3
0
        // On form loading
        private void MainForm_Load( object sender, EventArgs e )
        {
            // collect available modules in application's directory
            CollectModules( Path.GetDirectoryName( Application.ExecutablePath ) );
            // add modules' name to application's menu
            foreach ( string routineName in processingRoutines.Keys )
            {
                ToolStripItem item = modulesToolStripMenuItem.DropDownItems.Add( routineName );

                item.Click += new System.EventHandler( this.module_Click );

                if ( ipRoutineToUse == null )
                {
                    ipRoutineToUse = processingRoutines[routineName];
                }
            }

            // load configuratio
            Configuration config = Configuration.Instance;

            if ( config.Load( ) )
            {
                try
                {
                    // get window location/size
                    Location = new Point(
                        int.Parse( config.GetConfigurationOption( mainFormXOption ) ),
                        int.Parse( config.GetConfigurationOption( mainFormYOption ) ) );

                    Size = new Size(
                        int.Parse( config.GetConfigurationOption( mainFormWidthOption ) ),
                        int.Parse( config.GetConfigurationOption( mainFormHeightOption ) ) );

                    WindowState = (FormWindowState) Enum.Parse( typeof( FormWindowState ),
                        config.GetConfigurationOption( mainFormStateOption ) );

                    mainSplitContainer.SplitterDistance = int.Parse( config.GetConfigurationOption( splitter1Option ) );
                    splitContainer1.SplitterDistance = int.Parse( config.GetConfigurationOption( splitter2Option ) );
                    splitContainer2.SplitterDistance = int.Parse( config.GetConfigurationOption( splitter3Option ) );

                    // get size mode of picture box
                    pictureBox.SizeMode = (PictureBoxSizeMode) Enum.Parse( typeof( PictureBoxSizeMode ),
                        config.GetConfigurationOption( pictureSizeModeOption ) );

                    // get recent folders
                    for ( int i = 0; i < 5; i++ )
                    {
                        string rf = config.GetConfigurationOption( recentFolderOption + i );

                        if ( rf != null )
                            recentFolders.Add( rf );
                    }

                    RebuildRecentFoldersList( );

                    bool openLast = bool.Parse( config.GetConfigurationOption( openLastOption ) );
                    openLastFolderOnStartToolStripMenuItem.Checked = openLast;

                    if ( ( openLast ) && ( recentFolders.Count > 0 ) )
                    {
                        OpenFolder( recentFolders[0] );
                    }
                }
                catch
                {
                }
            }
        }