예제 #1
0
 public ScreenForm(Rectangle bounds, ConsolidatedViewer masterViewer)
 {
     _masterViewer = masterViewer;
     SetupScreenSaver();
     InitializeComponent();
     this.Bounds = bounds;
     Application.AddMessageFilter(this);
     this.FormClosed += (s, e) => Application.RemoveMessageFilter(this);
 }
예제 #2
0
        public ScreenForm(IntPtr PreviewHandle, ConsolidatedViewer masterViewer)
        {
            _masterViewer = masterViewer;
            InitializeComponent();
            //set the preview window as the parent of this window
            SetParent(this.Handle, PreviewHandle);

            //make this a child window, so when the select screensaver dialog closes, this will also close
            SetWindowLong(this.Handle, -16, new IntPtr(GetWindowLong(this.Handle, -16) | 0x40000000));

            //set our window's size to the size of our window's new parent
            Rectangle ParentRect;

            GetClientRect(PreviewHandle, out ParentRect);
            this.Size = ParentRect.Size;

            //set our location at (0, 0)
            this.Location = new Point(0, 0);

            IsPreviewMode       = true;
            buttonClose.Visible = false;
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Kick off reading the repository in the background
            PictureRepository rep = PictureRepository.Instance;
            // MessageBox.Show("Attach your debugger now");

            Action action = Action.ScreenSaver;

            if (args.Length > 0)
            {
                string firstArg = args[0].ToLower();
                if (firstArg.StartsWith("/c"))
                {
                    action = Action.Configure;
                }
                if (firstArg.StartsWith("/p"))
                {
                    action = Action.Preview;
                }
                if (firstArg.StartsWith("/d"))
                {
                    action = Action.Debug;
                }
            }

            //MessageBox.Show("Action was" + action + Environment.NewLine + string.Join(",", args));

            switch (action)
            {
            case Action.Preview:
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                ConsolidatedViewer masterViewer = new ConsolidatedViewer();
                masterViewer.Init();
                Application.Run(new ScreenForm(new IntPtr(long.Parse(args[1])), masterViewer));
            }
            break;

            case Action.Configure:
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new SettingsForm());
                break;

            case Action.Debug:
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Screen otherScreen = null;

                foreach (Screen screen in Screen.AllScreens)
                {
                    if (!screen.Primary)
                    {
                        otherScreen = screen;
                    }
                }

                if (otherScreen == null)
                {
                    otherScreen = Screen.AllScreens[0];
                }

                ConsolidatedViewer masterViewer = new ConsolidatedViewer();
                Rectangle          bounds       = new Rectangle(otherScreen.Bounds.X + otherScreen.Bounds.Width / 4,
                                                                otherScreen.Bounds.Y + otherScreen.Bounds.Height / 8,
                                                                otherScreen.Bounds.Width / 3,
                                                                otherScreen.Bounds.Height / 3);
                ScreenForm screenForm = new ScreenForm(bounds, masterViewer);
                screenForm.Show();

                bounds = new Rectangle(otherScreen.Bounds.X + otherScreen.Bounds.Width / 4,
                                       otherScreen.Bounds.Y + otherScreen.Bounds.Height / 2,
                                       otherScreen.Bounds.Width / 3,
                                       otherScreen.Bounds.Height / 3);
                screenForm = new ScreenForm(bounds, masterViewer);
                screenForm.Show();

                masterViewer.Init();
                Application.Run();
            }
            break;

            case Action.ScreenSaver:
            default:
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                ConsolidatedViewer masterViewer = new ConsolidatedViewer();
                foreach (Screen screen in Screen.AllScreens)
                {
                    //creates a form just for that screen and passes it the bounds of that screen
                    ScreenForm screenForm = new ScreenForm(screen.Bounds, masterViewer);
                    screenForm.Show();
                }
                masterViewer.Init();
                Application.Run();
            }
            break;
            }
        }