public void SetupLayout(LayoutCanvas layoutCanvas, Screen screen, bool isDesktopMode) { // Cache the references to the canvas and screen m_layoutCanvas = layoutCanvas; m_screen = screen; // Set initial canvas attributes canvas.Width = screen.Width; canvas.Height = screen.Height; // Set the canvas background canvas.Background = new SolidColorBrush( WpfToGdi.GdiColorToWpfColour(layoutCanvas.BackgroundColour)); canvas.ClearChildren(); foreach (LayoutObject lo in layoutCanvas) { LayoutImage lImage = new LayoutImage(lo); // Add to canvas (but don't add through the helper, because we want to manually manipulate // this object) canvas.Children.Add(lImage); // Set the preview image SetPreviewImage(lImage, lo.Source); // Set attributes onto the child RefreshCanvasChild(lImage); } // Set the manual edit flag so that we don't trigger events when we change // these objects m_isManuallyEditing = true; chkShuffle.Visibility = isDesktopMode ? Visibility.Visible : Visibility.Hidden; chkShuffle.IsChecked = layoutCanvas.IsShuffleEnabled; cmdChangeInterval.SelectedIndex = GetIntervalIndex(m_layoutCanvas.ShuffleMode); cmbFillMode.SelectedIndex = (int)m_layoutCanvas.SingleObjectStyle; m_isManuallyEditing = false; RefreshFillModeState(); RefreshAdvancedButtonState(); RefreshEditorState(); }
private MainWindow CreateWindow(Screen screen, LayoutCanvas canvas, bool primary) { MainWindow win = new MainWindow(primary); win.Closed += new EventHandler(winChild_Closed); win.SetImageLibraryController(m_libraryManager); win.SetupLayout(canvas, screen, m_mode == ManagerMode.Desktop); CentreWindow(win, screen); win.Show(); return win; }
private bool MonitorEnum(IntPtr hMonitor, IntPtr hdcMonitor, ref RectStruct lprcMonitor, IntPtr dwData) { MonitorInfo mi = new MonitorInfo(); mi.size = (uint)Marshal.SizeOf(mi); GetMonitorInfo(hMonitor, ref mi); bool isPrimary = (mi.flags == 1) ? true : false; Rectangle bounds = new Rectangle(mi.monitor.left, mi.monitor.top, mi.monitor.right - mi.monitor.left, mi.monitor.bottom - mi.monitor.top); Screen screen = new Screen(m_screens.Count, bounds, isPrimary); if (isPrimary) m_primary = m_screens.Count; m_screens.Add(screen); return true; }
private void CentreWindow(Window win, Screen screen) { win.Left = (screen.Width / 2) - (win.Width / 2) + screen.X; win.Top = (screen.Height / 2) - (win.Height / 2) + screen.Y; }