public FullScreenWindow(ref GLRenderer renderer, ref GLCamera camera,
            ref AnimationController animationController,
            ref GLControl control,
            float fieldOfView, float nearPlane, float farPlane)
        {
            // Store references
            this.renderer = renderer;
            this.camera = camera;
            this.animationController = animationController;
            this.fieldOfView = fieldOfView;
            this.nearPlane = nearPlane;
            this.farPlane = farPlane;
            this.mainGLControl = control;

            InitializeComponent();

            //
            // Set up callbacks.
            //

            // GLControl Callbacks
            glControlMain.Load += new EventHandler(GLControlMainOnLoad);
            glControlMain.Resize += new EventHandler(GLControlMainOnResize);
            glControlMain.Paint += new PaintEventHandler(GLControlMainOnPaint);

            // Set mouse events
            glControlMain.MouseDown += new MouseEventHandler(GLControlOnMouseDown);
            glControlMain.MouseUp += new MouseEventHandler(GLControlOnMouseUp);
            glControlMain.MouseWheel += new MouseEventHandler(GLControlOnMouseWheel);
            glControlMain.MouseMove += new MouseEventHandler(GLControlOnMouseMove);

            // Set keyboard events
            glControlMain.KeyDown += new KeyEventHandler(GLControlMainOnKeyDown);
            glControlMain.KeyUp += new KeyEventHandler(GLControlMainOnKeyUp);
        }
Example #2
0
        public MainWindow()
        {
            logger = new Logger(DEFAULT_LOG_FILE); // Not checking result.
            logger.Event("Program Start.");

            isGLLoaded = false;
            timer      = new Stopwatch();

            camera = new GLCamera();
            camera.SetViewParameters(new Vector3(0.0f, 0.0f, 2.0f), Vector3.Zero);
            renderer = new GLRenderer();

            // Set up the reader and initialize its root to the value in 'lolviewer.dat' if
            // the file exists.
            {
                reader = new LOLDirectoryReader();

                bool       isFileOpen = false;
                FileStream file       = null;
                try
                {
                    FileInfo fileInfo = new FileInfo(DEFAULT_DATA_FILE);
                    if (fileInfo.Exists == true)
                    {
                        file       = new FileStream(fileInfo.FullName, FileMode.Open);
                        isFileOpen = true;
                    }
                    else
                    {
                        logger.Warning("Failed to locate " + DEFAULT_DATA_FILE + ".");
                    }
                }
                catch
                {
                    logger.Warning("Failed to open " + DEFAULT_DATA_FILE + ".");
                }

                if (isFileOpen == true)
                {
                    BinaryReader fileReader = null;
                    if (file != null)
                    {
                        try
                        {
                            logger.Event("Reading " + DEFAULT_DATA_FILE + ".");

                            fileReader  = new BinaryReader(file);
                            reader.Root = fileReader.ReadString();
                            fileReader.Close();
                        }
                        catch
                        {
                            logger.Warning("Failed to read " + DEFAULT_DATA_FILE + ".");
                            file.Close();
                        }
                    }
                }
            }

            InitializeComponent();

            mainWindowProgressBar.Style = ProgressBarStyle.Marquee;
            mainWindowProgressBar.Value = 100;

            lastSearch          = String.Empty;
            currentSearchSubset = new List <String>();

            // Main window Callbacks
            this.Shown += new EventHandler(OnMainWindowShown);

            // GLControl Callbacks
            glControlMain.Load     += new EventHandler(GLControlMainOnLoad);
            glControlMain.Resize   += new EventHandler(GLControlMainOnResize);
            glControlMain.Paint    += new PaintEventHandler(GLControlMainOnPaint);
            glControlMain.Disposed += new EventHandler(GLControlMainOnDispose);

            // Set mouse events
            glControlMain.MouseDown  += new MouseEventHandler(GLControlOnMouseDown);
            glControlMain.MouseUp    += new MouseEventHandler(GLControlOnMouseUp);
            glControlMain.MouseWheel += new MouseEventHandler(GLControlOnMouseWheel);
            glControlMain.MouseMove  += new MouseEventHandler(GLControlOnMouseMove);

            // Set keyboard events
            glControlMain.KeyDown += new KeyEventHandler(GLControlMainOnKeyDown);
            glControlMain.KeyUp   += new KeyEventHandler(GLControlMainOnKeyUp);

            // Menu Callbacks
            exitToolStripMenuItem.Click          += new EventHandler(OnExit);
            aboutToolStripMenuItem.Click         += new EventHandler(OnAbout);
            readDirectoryMainMenuStripItem.Click += new EventHandler(OnReadModels);
            readMainMenuStripItem.Click          += new EventHandler(OnSetDirectory);

            // Model View Callbacks
            modelListBox.DoubleClick += new EventHandler(OnModelListDoubleClick);
            modelListBox.KeyPress    += new KeyPressEventHandler(OnModelListKeyPress);

            // Buttons
            resetCameraButton.Click     += new EventHandler(OnResetCameraButtonClick);
            backgroundColorButton.Click += new EventHandler(OnBackgroundColorButtonClick);
            fullscreenButton.Click      += new EventHandler(OnFullscreenButtonClick);

            //
            // Animation Controller
            //

            // TODO: Pass the references and callbacks into constructor instead of doing them out here.
            // Kind of ugly code. :(
            animationController = new AnimationController();

            // Set references
            animationController.enableAnimationButton    = enableAnimationButton;
            animationController.currentAnimationComboBox = currentAnimationComboBox;
            animationController.playAnimationButton      = playAnimationButton;
            animationController.glControlMain            = glControlMain;
            animationController.timelineTrackBar         = timelineTrackBar;
            animationController.mainWindowStatusLabel    = mainWindowStatusLabel;

            animationController.renderer = renderer;

            // Set callbacks.
            enableAnimationButton.Click += new EventHandler(animationController.OnEnableAnimationButtonClick);
            playAnimationButton.Click   += new EventHandler(animationController.OnPlayAnimationButtonClick);
            currentAnimationComboBox.SelectedIndexChanged += new EventHandler(animationController.OnCurrentAnimationComboBoxSelectedIndexChanged);
            timelineTrackBar.Scroll += new EventHandler(animationController.OnTimelineTrackBar);

            animationController.DisableAnimation();

            //
            // End Animation Controller
            //

            // Search Box
            modelSearchBox.TextChanged += new EventHandler(OnModelSearchBoxTextChanged);
            modelSearchBox.KeyPress    += new KeyPressEventHandler(OnModelSearchBoxKeyPress);
            modelSearchBox.KeyDown     += new KeyEventHandler(OnModelSearchBoxKeyDown);
        }
Example #3
0
        public MainWindow()
        {
            logger = new Logger(DEFAULT_LOG_FILE); // Not checking result.
            logger.Event("Program Start.");

            isGLLoaded = false;
            timer = new Stopwatch();

            camera = new GLCamera();
            camera.SetViewParameters(new Vector3(0.0f, 0.0f, 2.0f), Vector3.Zero);
            renderer = new GLRenderer();

            // Set up the reader and initialize its root to the value in 'lolviewer.dat' if
            // the file exists.
            {
                reader = new LOLDirectoryReader();

                bool isFileOpen = false;
                FileStream file = null;
                try
                {
                    FileInfo fileInfo = new FileInfo(DEFAULT_DATA_FILE);
                    if (fileInfo.Exists == true)
                    {
                        file = new FileStream(fileInfo.FullName, FileMode.Open);
                        isFileOpen = true;
                    }
                    else
                    {
                        logger.Warning("Failed to locate " + DEFAULT_DATA_FILE + ".");
                    }
                }
                catch
                {
                    logger.Warning("Failed to open " + DEFAULT_DATA_FILE + ".");
                }

                if (isFileOpen == true)
                {
                    BinaryReader fileReader = null;
                    if (file != null)
                    {
                        try
                        {
                            logger.Event("Reading " + DEFAULT_DATA_FILE + ".");

                            fileReader = new BinaryReader(file);
                            reader.Root = fileReader.ReadString();
                            fileReader.Close();
                        }
                        catch
                        {
                            logger.Warning("Failed to read " + DEFAULT_DATA_FILE + ".");
                            file.Close();
                        }
                    }
                }
            }

            InitializeComponent();

            mainWindowProgressBar.Style = ProgressBarStyle.Marquee;
            mainWindowProgressBar.Value = 100;

            lastSearch = String.Empty;
            currentSearchSubset = new List<String>();

            // Main window Callbacks
            this.Shown += new EventHandler(OnMainWindowShown);

            // GLControl Callbacks
            glControlMain.Load += new EventHandler(GLControlMainOnLoad);
            glControlMain.Resize += new EventHandler(GLControlMainOnResize);
            glControlMain.Paint += new PaintEventHandler(GLControlMainOnPaint);
            glControlMain.Disposed += new EventHandler(GLControlMainOnDispose);

            // Set mouse events
            glControlMain.MouseDown += new MouseEventHandler(GLControlOnMouseDown);
            glControlMain.MouseUp += new MouseEventHandler(GLControlOnMouseUp);
            glControlMain.MouseWheel += new MouseEventHandler(GLControlOnMouseWheel);
            glControlMain.MouseMove += new MouseEventHandler(GLControlOnMouseMove);

            // Set keyboard events
            glControlMain.KeyDown += new KeyEventHandler(GLControlMainOnKeyDown);
            glControlMain.KeyUp += new KeyEventHandler(GLControlMainOnKeyUp);

            // Menu Callbacks
            exitToolStripMenuItem.Click += new EventHandler(OnExit);
            aboutToolStripMenuItem.Click += new EventHandler(OnAbout);
            readDirectoryMainMenuStripItem.Click += new EventHandler(OnReadModels);
            readMainMenuStripItem.Click += new EventHandler(OnSetDirectory);

            // Model View Callbacks
            modelListBox.DoubleClick += new EventHandler(OnModelListDoubleClick);
            modelListBox.KeyPress += new KeyPressEventHandler(OnModelListKeyPress);

            // Buttons
            resetCameraButton.Click += new EventHandler(OnResetCameraButtonClick);
            backgroundColorButton.Click += new EventHandler(OnBackgroundColorButtonClick);
            fullscreenButton.Click += new EventHandler(OnFullscreenButtonClick);

            //
            // Animation Controller
            //

            // TODO: Pass the references and callbacks into constructor instead of doing them out here.
            // Kind of ugly code. :(
            animationController = new AnimationController();

            // Set references
            animationController.enableAnimationButton = enableAnimationButton;
            animationController.currentAnimationComboBox = currentAnimationComboBox;
            animationController.playAnimationButton = playAnimationButton;
            animationController.glControlMain = glControlMain;
            animationController.timelineTrackBar = timelineTrackBar;
            animationController.mainWindowStatusLabel = mainWindowStatusLabel;

            animationController.renderer = renderer;

            // Set callbacks.
            enableAnimationButton.Click += new EventHandler(animationController.OnEnableAnimationButtonClick);
            playAnimationButton.Click += new EventHandler(animationController.OnPlayAnimationButtonClick);
            currentAnimationComboBox.SelectedIndexChanged += new EventHandler(animationController.OnCurrentAnimationComboBoxSelectedIndexChanged);
            timelineTrackBar.Scroll += new EventHandler(animationController.OnTimelineTrackBar);

            animationController.DisableAnimation();

            //
            // End Animation Controller
            //

            // Search Box
            modelSearchBox.TextChanged += new EventHandler(OnModelSearchBoxTextChanged);
            modelSearchBox.KeyPress += new KeyPressEventHandler(OnModelSearchBoxKeyPress);
            modelSearchBox.KeyDown += new KeyEventHandler(OnModelSearchBoxKeyDown);
        }