Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            this.screenSaverMode = ScreenSaverMode.Application;

            this.MouseCaptured = true;

            setup();
        }
Exemplo n.º 2
0
        public frmMain(Rectangle Bounds)
        {
            InitializeComponent();

            this.screenSaverMode = ScreenSaverMode.ScreenSaver;

            this.Bounds      = Bounds;
            this.WindowState = FormWindowState.Maximized;

            setup(FormBorderStyle.None);

            this.MouseCaptured = true;
        }
Exemplo n.º 3
0
        public DrawingSurface(ScreenSaverMode ScreenSaverMode)
        {
            this.DoubleBuffered = true;
            switch (ScreenSaverMode)
            {
            case ScreenSaverMode.ScreenSaverPreview:
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
                break;

            default:
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
                break;
            }
        }
Exemplo n.º 4
0
        public frmMain()
        {
            InitializeComponent();

            //HorizonsDownload.GetData(new DateTime(2011, 2, 19, 12, 0, 0));

            //for (int i = 1951; i <= 1969; i++)
            //{
            //    if (i != 1955 && i != 1960 && i != 1965)
            //        HorizonsDownload.GetData(new DateTime(i, 1, 1, 12, 0, 0));
            //}
            this.screenSaverMode = ScreenSaverMode.Application;

            setup(Properties.Settings.Default.FullScreen ? FormBorderStyle.None : FormBorderStyle.Sizable);
            this.WindowState = Properties.Settings.Default.FullScreen ? FormWindowState.Maximized : FormWindowState.Normal;

            this.MouseCaptured = true;
        }
Exemplo n.º 5
0
        public frmMain(IntPtr PreviewWndHandle)
        {
            InitializeComponent();

            this.screenSaverMode           = ScreenSaverMode.ScreenSaverPreview;
            screensaverPreviewWindowHandle = PreviewWndHandle;

            // Set the preview window as the parent of this window
            SetParent(this.Handle, screensaverPreviewWindowHandle);

            // Make this a child window so it will close when the parent dialog closes
            SetWindowLong(this.Handle, -16, new IntPtr(GetWindowLong(this.Handle, -16) | 0x40000000));

            // Place our window inside the parent
            Rectangle ParentRect;

            GetClientRect(screensaverPreviewWindowHandle, out ParentRect);
            this.Size     = ParentRect.Size;
            this.Location = Point.Empty;

            setup(FormBorderStyle.None);

            this.MouseCaptured = false;
        }
Exemplo n.º 6
0
        public Renderer(ScreenSaverMode ScreenSaverMode, Projector Projector)
        {
            this.projector = Projector;

            this.ScreenSize = ScreenSize;
#if WPF
            PendingText = new List <Tuple <string, QPoint, QPen, QFont, bool> >();
#endif
            switch (ScreenSaverMode)
            {
            case SolarMax.ScreenSaverMode.ScreenSaverPreview:
                this.SmallFont       = new QFont(DEFAULT_SMALL_FONT_NAME, 4);
                this.SmallItalicFont = new QFont(DEFAULT_SMALL_FONT_NAME, 4, true);
                this.Font            = new QFont(DEFAULT_SMALL_FONT_NAME, 5);
                this.LargeFont       = new QFont(DEFAULT_FONT_NAME, 6);
                this.LargeItalicFont = new QFont(DEFAULT_FONT_NAME, 6.5f, true);
                this.ExtraLargeFont  = new QFont(DEFAULT_FONT_NAME, 7);
                break;

            default:
                this.SmallFont       = new QFont(DEFAULT_SMALL_FONT_NAME, Preferences.LabelFontSize);
                this.SmallItalicFont = new QFont(DEFAULT_SMALL_FONT_NAME, Preferences.LabelFontSize, true);
                this.Font            = new QFont(DEFAULT_SMALL_FONT_NAME, 10);
                this.LargeFont       = new QFont(DEFAULT_FONT_NAME, 12);
                this.LargeItalicFont = new QFont(DEFAULT_FONT_NAME, 13, true);
                this.ExtraLargeFont  = new QFont(DEFAULT_FONT_NAME, 16);
                break;
            }

            RenderLocations = new List <CelestialBody>(MAX_RENDER_LOCATIONS);

            for (int i = 0; i < MAX_RENDER_LOCATIONS; i++)
            {
                RenderLocations.Add(null);
            }
        }
Exemplo n.º 7
0
        private void NewTerrarium()
        {
            SaveFileDialog save = new SaveFileDialog();
            save.Filter = ".NET Terrariums (*.ter)|*.ter|All Files (*.*)|*.*";
            save.Title = "New Terrarium";
            save.DefaultExt = "Ter";
            DialogResult result = save.ShowDialog();
            if (result == DialogResult.OK)
            {
                // Clear out the file and directory
                try
                {
                    if (File.Exists(save.FileName))
                    {
                        File.Delete(save.FileName);
                    }

                    string pacPath = PrivateAssemblyCache.GetBaseAssemblyDirectory(
                        Path.GetDirectoryName(save.FileName), Path.GetFileName(save.FileName));

                    if (Directory.Exists(pacPath))
                    {
                        Directory.Delete(pacPath, true);
                    }
                }
                catch (Exception exception)
                {
                    ErrorLog.LogHandledException(exception);
                    MessageBox.Show("Problem creating new Terrarium: " + exception.Message);
                    return;
                }

                if (CloseTerrarium())
                {
                    this.Hide();
                    FileInfo fileInfo = new FileInfo(save.FileName);
                    relaunch = true;
                    _gamePath = save.FileName;
                    screenSaverMode = ScreenSaverMode.RunLoadTerrarium;
                    this.Close();
                }
            }
        }
Exemplo n.º 8
0
        private void loadTerrarium_Click(object sender, System.EventArgs args)
        {
            if (screenSaverMode == ScreenSaverMode.Run)
            {
                MessageBox.Show(
                    this,
                    "This isn't permitted while running in screensaver mode because it could allow someone to get access to your machine when it is locked.  Try closing and starting the Terrarium normally to do this.",
                    "Operation Not Permitted",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                return;
            }

            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = ".NET Terrariums (*.ter)|*.ter|All Files (*.*)|*.*";
            dialog.Title = "Locate your Terrarium";
            dialog.DefaultExt = ".ter";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (CloseTerrarium())
                {
                    try
                    {
                        this.Hide();
                        FileInfo fileInfo = new FileInfo(dialog.FileName);
                        relaunch = true;
                        _gamePath = dialog.FileName;
                        screenSaverMode = ScreenSaverMode.RunLoadTerrarium;
                        this.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(this, e.Message, "Error Loading Terrarium", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void LoadEcosystem(string pathToDelete)
        {
            if (CloseTerrarium())
            {
                this.Hide();

                // Delete the old ecosystem if asked to
                if (pathToDelete != null)
                {
                    File.Delete(pathToDelete);
                }

                // We want to run in "normal" or Ecosystem mode
                this.screenSaverMode = ScreenSaverMode.NoScreenSaver;

                relaunch = true;
                _gamePath = "";

                this.Close();
            }
        }
Exemplo n.º 10
0
        internal MainForm(ScreenSaverMode mode, string gamePath, Int32 hwndParent)
        {
            firstActivate = true;
            screenSaverMode = mode;
            _gamePath = gamePath;
            hwndScreenSaverParent = hwndParent;
            startAtStartup = !_options.NoStart;

            // Check to see if this version has been blocked by the server (because of a security issue)
            // if it has, then don't actually start the game and just wait for
            // an updated version to get downloaded.
            if (GameConfig.BlockedVersion.Length != 0)
            {
                Version v = null;
                try
                {
                    v = new Version(GameConfig.BlockedVersion);
                }
                catch (Exception e)
                {
                    ErrorLog.LogHandledException(e);
                    GameConfig.BlockedVersion = "";
                }

                if (v != null && v >= Assembly.GetExecutingAssembly().GetName().Version)
                {
                    // They are running a blocked version
                    runningBlockedVersion = true;
                    startAtStartup = false;
                }
            }

            // Load the Glass Style
            GlassStyleManager.Refresh();
            GlassStyleManager.SetStyle(GameConfig.StyleName);

            InitializeComponent();

            if (this.screenSaverMode == ScreenSaverMode.Run)
            {
                this.ShowInTaskbar = false;
            }

            InitializeScreen();

            this.titleBar.ShowBugButton = false;

            // Post set-up of variables that aren't designed

            // Reset the Resize bar so it can detect the MainForm as the root parent
            this.bottomContainerPanel.Controls.Remove(this.resizeBar);
            this.bottomContainerPanel.Controls.Add(this.resizeBar);

            this.BackColor = GlassStyleManager.Active.DialogColor;

            this.developerPanel.WebRoot = GameConfig.WebRoot;

            this.developerPanel.ViewPortSize = this.tddGameView.Size;

            this.bottomPanel.Location = new Point(controlStripBottom.Left, controlStripBottom.Top);
            this.bottomPanel.AddAnimalButton.Click += new EventHandler(this.AddNewAnimal_Click);
            this.bottomPanel.AddAnimalComboBox.DropDown += new EventHandler(this.AddAnimalComboBox_DropDown);
            this.bottomPanel.PauseButton.Click += new EventHandler(this.Pause_Click);
            this.bottomPanel.IntroduceAnimalEcosystemButton.Click += new EventHandler(this.introduceAnimalEcosystem_Click);
            this.bottomPanel.IntroduceAnimalTerrariumButton.Click += new EventHandler(this.introduceAnimalTerrarium_Click);
            this.bottomPanel.ReintroduceAnimalButton.Click += new EventHandler(this.reintroduceAnimal_Click);
            this.bottomPanel.NewTerrariumButton.Click += new EventHandler(this.newTerrarium_Click);
            this.bottomPanel.LoadTerrariumButton.Click += new EventHandler(this.loadTerrarium_Click);
            this.developerPanel.NavigatePictureBox.MouseDown += new MouseEventHandler(this.navigatePictureBox_MouseDown);
            this.bottomPanel.JoinEcosystemButton.Click += new EventHandler(loadEcosystem_Click);

            this.bottomPanel.SettingsButton.Click += new EventHandler(SettingsButton_Click);
            this.bottomPanel.DetailsButton.Click += new EventHandler(DetailsButton_Click);
            this.bottomPanel.StatisticsButton.Click += new EventHandler(StatisticsButton_Click);
            this.bottomPanel.TraceButton.Click += new EventHandler(TraceButton_Click);
            this.bottomPanel.DeveloperButton.Click += new EventHandler(DeveloperButton_Click);
            //traceListener.TimerToStop = this.timer1;
            SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(PowerModeChanged);

            this.taskBar = new NotifyIcon();
            this.taskBar.DoubleClick += new EventHandler(taskBar_DoubleClick);
            MenuItem showMenu = new MenuItem("Show", new EventHandler(this.taskBar_DoubleClick));
            showMenu.DefaultItem = true;
            MenuItem settingsMenu = new MenuItem("Settings...", new EventHandler(this.SettingsButton_Click));
            MenuItem exitMenu = new MenuItem("Exit", new EventHandler(this.Close_Click));
            this.taskBar.ContextMenu = new ContextMenu(new MenuItem[] { showMenu, settingsMenu, new MenuItem("-"), exitMenu });

            this.taskBar.Icon = this.Icon;
            this.taskBar.Visible = false;
            this.taskBar.Text = "Terrarium";

            // Set up the game view
            if (!this.DesignMode)
            {
                if (!tddGameView.InitializeGraphicEngine(false))
                {
                    _options.NoDirectX = true;
                }
                else
                {
                    try
                    {
                        tddGameView.DrawBackgroundGrid = GameConfig.BackgroundGrid;
                        tddGameView.AddBackgroundSlide();
                        tddGameView.AddComplexSpriteSurface("cursor", 1, 9);
                        tddGameView.AddComplexSpriteSurface("teleporter", 16, 1);
                        tddGameView.AddComplexSizedSpriteSurface("plant", 1, 1);
                    }
                    catch { }
                }

            }

            if (screenSaverMode == ScreenSaverMode.Run)
            {
                // Start the scrolling timer
                this.screenSaverTimer = new System.Windows.Forms.Timer();
                this.screenSaverTimer.Interval = 30000;
                this.screenSaverTimer.Tick += new EventHandler(screenSaverTimer_Tick);
                this.screenSaverTimer.Start();
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Starts the Screen Saver (Vertical scroll, Horizontal panning, Fade in/out, etc.)
 /// </summary>
 /// <param name="mode">The <see cref="ScreenSaverMode"/> to use.</param>
 /// <param name="scrollDelay">The delay between frames.</param>
 /// <remarks>The <see cref="ScreenSaverMode.PixelVibration"/> uses the delay parameter as a Pixel offset for the vibrations rather than a delay between frames.</remarks>
 /// <example>Example usage:
 /// <code language = "C#">
 ///	for (byte x = 0; x <![CDATA[<]]> 8; x++)
 ///	{
 ///		_oled.StartScreenSaver((OLEDCClick.ScreenSaverMode) x, x == 7 ? (byte) 0x02 : (byte) 0x00);
 ///		Thread.Sleep(5000);
 ///		_oled.StopScreenSaver();
 ///	}
 /// </code>
 /// <code language = "VB">
 ///	For x As Integer = 0 To 7
 ///		_oled.StartScreenSaver(DirectCast(x, OLEDCClick.ScreenSaverMode), If(x = 7, CByte(<![CDATA[&]]>H2), CByte(<![CDATA[&]]>H0)))
 ///		Thread.Sleep(5000)
 ///		_oled.StopScreenSaver()
 /// Next
 /// </code>
 /// </example>
 public void StartScreenSaver(ScreenSaverMode mode, byte scrollDelay)
 {
     SendCommand(SEPS114A_SCREEN_SAVER_MODE, (byte)mode);
     SendCommand(SEPS114A_SS_UPDATE_TIMER, scrollDelay);
     SendCommand(SEPS114A_SCREEN_SAVER_CONTEROL, 0x88);
 }
Exemplo n.º 12
0
        public Controller(ScreenSaverMode ScreenSaverMode, ShutdownRequestDelegate ShutdownCallback, int FrameRate, bool AllowLoadSnapshot)
        {
            this.shutdownCallback = ShutdownCallback;
            this.screenSaverMode  = ScreenSaverMode;
            this.projector        = new Projector(Properties.Settings.Default.ProjectionMode);

            this.renderer = new Renderer(screenSaverMode, projector);

            this.defaultPen = new QPen(Colors.GetColor("default_interface_color"));
            this.borderPen  = new QPen(Colors.GetColor("border"));

            this.constellationBoundaryPen = new QPen(Colors.GetColor("constellation_boundary"));

            this.eclipticCompassPen = new QPen(Colors.GetColor("ecliptic_compass"));
            this.eclipticGridPen    = new QPen(Colors.GetColor("ecliptic_grid"));

            this.equatorialCompassPen = new QPen(Colors.GetColor("equatorial_compass"));
            this.equatorialGridPen    = new QPen(Colors.GetColor("equatorial_grid"));

            this.localCompassPen = new QPen(Colors.GetColor("local_compass"));
            this.localGridPen    = new QPen(Colors.GetColor("local_grid"));

            this.instrumentLinePen    = new QPen(Colors.GetColor("instrument_line"));
            this.instrumentOutlinePen = new QPen(Colors.GetColor("instrument_outline"));
            this.instrumentDataPen    = new QPen(Colors.GetColor("instrument_data"));

            physics = new Physics(new IntegratorVelocityVerlet(true), AllowLoadSnapshot, physicsStartupDoneCallback);

            setupGrids();

            this.camera = new Camera(Properties.Settings.Default.ViewMode, CelestialBody.Earth, CelestialBody.Sun, Properties.Settings.Default.SurfaceLatitude, Properties.Settings.Default.SurfaceLongitude);

            setupInstrumentsAndWidgets(FrameRate);

            switch (ScreenSaverMode)
            {
            case SolarMax.ScreenSaverMode.Application:
                physics.SleepBetweenCycles = 0;
                break;

            case SolarMax.ScreenSaverMode.ScreenSaver:
                physics.SleepBetweenCycles = 10;
                break;

            case SolarMax.ScreenSaverMode.ScreenSaverPreview:
                physics.SleepBetweenCycles = 100;
                break;
            }

            physics.Go(System.Threading.ThreadPriority.AboveNormal);

            this.ShowData                    = Properties.Settings.Default.ShowData;
            this.ShowEquatorialGrid          = Properties.Settings.Default.ShowEquatorialGrid;
            this.ShowEclipticGrid            = Properties.Settings.Default.ShowEclipticGrid;
            this.showLocalGrid               = Properties.Settings.Default.ShowLocalGrid;
            this.InHelpMode                  = Properties.Settings.Default.ShowHelp;
            this.showInstruments             = Properties.Settings.Default.ShowInstruments;
            this.CaptionMode                 = screenSaverMode == SolarMax.ScreenSaverMode.ScreenSaverPreview ? CaptionMode.DynamicOnly : Properties.Settings.Default.CaptionMode;
            this.ConstellationMode           = Properties.Settings.Default.ConstellationMode;
            Constellation.UseAltShapes       = Properties.Settings.Default.UseAltConstellationShapes;
            this.ShowConstellationBoundaries = Properties.Settings.Default.ShowConstellationBoundaries;
            this.MinStarBrightness           = Properties.Settings.Default.MinStarBrightness;
            this.DisplayTimeUTC              = Properties.Settings.Default.DisplayTimeUTC;

            renderer.WireFrameBodyRender  = Properties.Settings.Default.WireFrameBodyRender;
            renderer.HighlightSunlitAreas = Properties.Settings.Default.HighlightSunlitAreas;

            this.HighQualityRender = Properties.Settings.Default.HighQualityRender;

            camera.SetTarget(getDefaultViewTarget());
            this.ShowCredits = true;
            creditsSize      = QSize.Empty;
        }
Exemplo n.º 13
0
 public static extern Status XForceScreenSaver(IntPtr display, ScreenSaverMode mode);