Example #1
0
        protected override void DetachFromProfileOnMainThread(HeliosProfile oldProfile)
        {
            // stop updating shadow collections
            oldProfile.Monitors.CollectionChanged -= Monitors_CollectionChanged;
            oldProfile.PropertyChanged            -= Profile_PropertyChanged;

            base.DetachFromProfileOnMainThread(oldProfile);

            // deallocate timer we allocate on Attach
            _geometryChangeTimer?.Stop();
            _geometryChangeTimer = null;

            // deallocate renderer we allocate on Attach
            _renderer?.Dispose();
            _renderer = null;

            ClearShadowObjects();
        }
Example #2
0
        protected override void AttachToProfileOnMainThread()
        {
            base.AttachToProfileOnMainThread();

            // customize naming in case of custom Documents folder
            string documentsFolderName = Path.GetFileName(ConfigManager.DocumentPath);

            _combinedMonitorSetupName = string.IsNullOrEmpty(documentsFolderName) ? "Helios" : documentsFolderName;

            // read persistent config
            _monitorLayoutMode = ConfigManager.SettingsManager.LoadSetting(PREFERENCES_SETTINGS_GROUP,
                                                                           "MonitorLayoutMode", MonitorLayoutMode.FromTopLeftCorner);

            // real initialization, not just a test instantiation
            Combined.Initialize();
            CurrentProfileName = string.IsNullOrWhiteSpace(Profile.Path) ? null : Profile.Name;

            // NOTE: intentional crash if there is no Application.Current.Dispatcher
            _geometryChangeTimer = new DispatcherTimer(
                TimeSpan.FromMilliseconds(100),
                DispatcherPriority.Normal,
                OnDelayedGeometryChange,
                Application.Current.Dispatcher)
            {
                IsEnabled = false
            };
            _renderer = new MonitorSetupGenerator(this);

            CreateShadowObjects();

            // we only update our models if the monitor layout matches
            _monitorsValid = CheckMonitorsValid;

            // calculate initial geometry, if we can
            UpdateAllGeometry();

            // register for changes
            Profile.Monitors.CollectionChanged += Monitors_CollectionChanged;
            Profile.PropertyChanged            += Profile_PropertyChanged;
        }