Ejemplo n.º 1
0
 public MainForm(Rectangle bounds, FlipItSettings settings, ScreenSetting screenSetting)
 {
     _settings      = settings;
     _screenSetting = screenSetting;
     InitializeComponent();
     Bounds = bounds;
 }
Ejemplo n.º 2
0
 public MainForm(Rectangle bounds, bool display24HourTime, ScreenSetting screenSetting)
 {
     _display24HourTime = display24HourTime;
     _screenSetting     = screenSetting;
     InitializeComponent();
     Bounds   = bounds;
     fontSize = bounds.Height / fontScaleFactor;
 }
Ejemplo n.º 3
0
        private static FlipItSettings LoadSettings()
        {
            var     allScreens = Screen.AllScreens;
            IniFile iniFile    = null;

            var settings = new FlipItSettings();

            var settingsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FlipIt");
            var iniFilePath    = Path.Combine(settingsFolder, "Settings.ini");

            if (File.Exists(iniFilePath))
            {
                iniFile = new IniFile(iniFilePath);
                settings.Display24HrTime = iniFile.ReadBool("General", "Display24Hr", false);
                settings.Scale           = iniFile.ReadInt("General", "Scale", 70);
            }
            else
            {
                settings.Display24HrTime = false;
            }

            var screenNum = 0;

            foreach (var screen in allScreens)
            {
                screenNum++;
                var cleanDeviceName = CleanDeviceName(screen.DeviceName);
                var sectionName     = $"Screen {cleanDeviceName}";

                var screenSetting = new ScreenSetting(screenNum, cleanDeviceName, screen.Bounds.Width, screen.Bounds.Height);
                if (iniFile != null && iniFile.SectionExists(sectionName))
                {
                    screenSetting.DisplayType = (DisplayType)iniFile.ReadInt(sectionName, "DisplayType", (int)DisplayType.CurrentTime);
                }
                else
                {
                    screenSetting.DisplayType = DisplayType.CurrentTime;
                }
                settings.ScreenSettings.Add(screenSetting);
            }

            return(settings);
        }
Ejemplo n.º 4
0
        public MainForm(IntPtr previewWndHandle, FlipItSettings settings, ScreenSetting screenSetting)
        {
            _settings      = settings;
            _screenSetting = screenSetting;

            InitializeComponent();

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

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

            // Place our window inside the parent
            GetClientRect(previewWndHandle, out var parentRect);
            Size     = parentRect.Size;
            Location = new Point(0, 0);

            _isPreviewMode = true;
        }
Ejemplo n.º 5
0
        public MainForm(IntPtr previewWndHandle, bool display24HourTime, ScreenSetting screenSetting)
        {
            _display24HourTime = display24HourTime;
            _screenSetting     = screenSetting;

            InitializeComponent();

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

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

            // Place our window inside the parent
            GetClientRect(previewWndHandle, out var parentRect);
            Size     = parentRect.Size;
            Location = new Point(0, 0);

            // Make text smaller for preview window
            fontSize = Size.Height / fontScaleFactor;

            previewMode = true;
        }
Ejemplo n.º 6
0
        public static FlipItSettings Load(Screen[] allScreens)
        {
            IniFile iniFile = null;

            var settings       = new FlipItSettings();
            var settingsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FlipIt");
            var iniFilePath    = Path.Combine(settingsFolder, "Settings.ini");

            if (File.Exists(iniFilePath))
            {
                iniFile = new IniFile(iniFilePath);
                settings.Display24HrTime = iniFile.GetBool("General", "Display24Hr", false);
                settings.Scale           = iniFile.GetInt("General", "Scale", 70);
            }
            else
            {
                settings.Display24HrTime = false;
            }

            var screenNum = 0;

            foreach (var screen in allScreens)
            {
                screenNum++;
                var cleanDeviceName   = CleanScreenDeviceName(screen.DeviceName);
                var screenSectionName = $"Screen {cleanDeviceName}";

                var screenSetting = new ScreenSetting(screenNum, cleanDeviceName, screen.Bounds.Width, screen.Bounds.Height);
                if (iniFile != null)
                {
                    // if (iniFile.SectionExists(screenSectionName))
                    if (iniFile.SectionExists(screenSectionName))
                    {
                        screenSetting.DisplayType = (DisplayType)iniFile.GetInt(screenSectionName, "DisplayType", (int)DisplayType.CurrentTime);
                    }

                    var screenLocationsSectionName = $"Screen {cleanDeviceName} Locations";
                    if (iniFile.SectionExists(screenLocationsSectionName))
                    {
                        var locationNames = iniFile.GetKeys(screenLocationsSectionName);
                        foreach (var locationName in locationNames)
                        {
                            var timeZoneID = iniFile.GetString(screenLocationsSectionName, locationName);
                            if (!String.IsNullOrWhiteSpace(timeZoneID))
                            {
                                screenSetting.Locations.Add(new Location(timeZoneID, locationName));
                            }
                            else
                            {
                                iniFile.DeleteKey(screenLocationsSectionName, locationName);
                            }
                        }
                    }
                }
                else
                {
                    screenSetting.DisplayType = DisplayType.CurrentTime;
                }

                settings.ScreenSettings.Add(screenSetting);
            }
            return(settings);
        }