Example #1
0
        internal void DrawMe(object sender)
        {
            Panel      displayPanel = sender as Panel;
            ScreenForm parentForm   = formLookup[displayPanel];
            Graphics   g            = Graphics.FromHwnd(displayPanel.Handle);

            Bitmap bitmap = parentForm.GetCurrentBitmap();

            if (bitmap == null)
            {
                return;
            }
            try
            {
                double ratioHeight = (double)displayPanel.Height / bitmap.Height;
                double masterRatio = (double)displayPanel.Width / bitmap.Width;
                if (ratioHeight < masterRatio)
                {
                    masterRatio = ratioHeight;
                }
                Bitmap displayBitmap = new Bitmap(bitmap, (int)(bitmap.Width * masterRatio), (int)(bitmap.Height * masterRatio));
                //bitmap.Dispose();
                g.Clear(BackgroundColor);
                g.DrawImage(
                    displayBitmap,
                    displayPanel.Width / 2 - displayBitmap.Width / 2,
                    displayPanel.Height / 2 - displayBitmap.Height / 2);
                displayBitmap.Dispose();

                string[] parts     = viewModel.CurrentPicture.Name.Split('\\');
                string   labelText = "";

                int partCount = 2;
                for (int i = 0; i < partCount; i++)
                {
                    int index = parts.Length - partCount + i;
                    if (index < 0)
                    {
                        continue;
                    }
                    if (labelText.Length > 0)
                    {
                        labelText += "\\";
                    }
                    labelText += parts[index];
                }

                if (_paused)
                {
                    g.DrawString(labelText, pictureFont, Brushes.Black, 1, 1);
                    g.DrawString(labelText, pictureFont, Brushes.White, 0, 0);
                }
            }
            catch (System.Exception err)
            {
                Debug.WriteLine("ERROR: " + err.ToString());
            }
        }
Example #2
0
 internal void AddForm(ScreenForm screenForm)
 {
     if (pictureFont == null)
     {
         pictureFont = new Font("Arial", 8f);
     }
     this.forms.Add(screenForm);
     formLookup.Add(screenForm.DisplayPanel, screenForm);
 }
Example #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;
            }
        }