Example #1
0
        private DisplayCollection _GetAttachedDisplays()
        {
            DisplayCollection attachedDisplays = new DisplayCollection();

            List <MonitorHandle> monitorHandles = _EnumerateAllMonitors();

            foreach (MonitorHandle handle in monitorHandles)
            {
                List <PhysicalMonitorDesc> physicalMonitors = _GetPhysicalMonitors(handle);

                foreach (PhysicalMonitorDesc physicalMonitor in physicalMonitors)
                {
                    /*get the capabilities and supported color temperature of each display*/
                    uint capabilitiesFlags = 0, colorTempFlags = 0;
                    _QueryMonitorCapabilities(physicalMonitor, out capabilitiesFlags, out colorTempFlags);

                    /*get the min, max, and current brightness from the display*/
                    uint maxBrightness = 0, minBrightness = 0, currentBrightness = 0;
                    _QueryMonitorBrightnessInfo(physicalMonitor, out minBrightness, out maxBrightness, out currentBrightness);

                    lock ( m_displayListLock )
                    {
                        attachedDisplays.Add(new Display(physicalMonitor, minBrightness, maxBrightness, currentBrightness, capabilitiesFlags, colorTempFlags));
                    }
                }
            }

            return(attachedDisplays);
        }
Example #2
0
        private DisplayController()
        {
            m_attachedDisplays = new DisplayCollection();
            //m_brightnessLock = new object();
            m_displayListLock        = new object();
            m_displayChangeQueueLock = new object();
            m_shutdown = false;
            m_newDisplayChangeEvent      = new AutoResetEvent(false);
            m_displayChangeQueue         = new List <DisplayChange>();
            m_wmiBrightnessControls      = null;
            m_wmiBrightnessSetter        = null;
            m_integratedDisplaySupported = false;

            _InitializeWMIBrightness();

            if (m_wmiBrightnessControls != null && m_wmiBrightnessSetter != null)
            {
                m_integratedDisplaySupported = true;
                System.Diagnostics.Debug.WriteLine("Integrated displays are supported on this system");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Integrated displays are not supported on this system");
            }

            Initialization = Task.Run(() =>
            {
                DisplayCollection displays = _GetAttachedDisplays();

                lock (m_displayListLock) m_attachedDisplays = displays;
            });

            Task.Run(() => _DisplayChangeApplicatorAsync());
        }
        /// <summary>
        /// Builds a DisplayCollection.
        /// </summary>
        /// <returns>the DisplayCollection.</returns>
        protected override DisplayCollection BuildDisplayItem()
        {
            DisplayCollection tempDC = new DisplayCollection();

            tempDC.ClearDisplayFirst = true;
            tempDC.AddDisplayObject(this.Processor.Image.CopyObj(1, -1));

            return(tempDC);
        }
        /// <summary>
        /// Creates a new display collection containing the loaded image.
        /// </summary>
        /// <returns>The DisplayCollection created.</returns>
        protected virtual DisplayCollection BuildDisplayItem()
        {
            DisplayCollection tempDC = new DisplayCollection();

            tempDC.ClearDisplayFirst = true;

            //// Add display elements here.

            return(tempDC);
        }
        /// <summary>
        /// Builds a DisplayCollection.
        /// </summary>
        /// <returns>the DisplayCollection.</returns>
        protected override DisplayCollection BuildDisplayItem()
        {
            DisplayCollection tempDC = new DisplayCollection();

            tempDC.ClearDisplayFirst = true;
            tempDC.AddDisplayObject(this.MainViewModelRef.LoadImageVM.Image.CopyObj(1, -1));
            tempDC.AddDisplayObject(
                this.Processor.WaferRegion.CopyObj(1, -1),
                this.MainViewModelRef.ChangeColorProcessVM.CurrentDisplayColor,
                1,
                DrawModes.Margin);

            return(tempDC);
        }
Example #6
0
 private async void TypeSelectedItemChanged(string type)
 {
     if (type == "喜欢" && likePage != 0)
     {
         DisplayCollection.Clear();
         likeList.ForEach(x => DisplayCollection.Add(x));
     }
     else if (type == "收藏" && markPage != 0)
     {
         DisplayCollection.Clear();
         markList.ForEach(x => DisplayCollection.Add(x));
     }
     else
     {
         await QueryNote(type);
     }
 }
Example #7
0
        private async Task QueryNote(string type)
        {
            UserContentProvider user = new UserContentProvider();

            if (type == "喜欢")
            {
                if (likePage == 0)
                {
                    DisplayCollection = new ObservableCollection <NoteItem>();
                    likeList          = new List <NoteItem>();
                }

                List <Note> temp = await user.QueryLikeNotes(likePage, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

                temp.ForEach(x =>
                {
                    var v = ConvertToNoteItem(x);
                    likeList.Add(v);
                    DisplayCollection.Add(v);
                });
                likePage++;
            }
            else
            {
                if (markPage == 0)
                {
                    DisplayCollection = new ObservableCollection <NoteItem>();
                    markList          = new List <NoteItem>();
                }

                List <BookmarkResult> temp = await user.QueryBookmark(markPage, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

                temp.ForEach(x =>
                {
                    var v = ConvertToNoteItem(x.Note);
                    markList.Add(v);
                    DisplayCollection.Add(v);
                });
            }
        }
Example #8
0
        /// <summary>
        /// Performs a complete refresh of the displays. All current display handles will be invalidated
        /// </summary>
        public Task RefreshAsync()
        {
            return(Task.Run(async() =>
            {
                //ensure refresh doesn't happen before initalization
                await Initialization;
                DisplayCollection displays = _GetAttachedDisplays();

                lock ( m_displayListLock )
                {
                    foreach (Display display in m_attachedDisplays)
                    {
                        display.IsValid = false;
                    }
                    _DestroyPhysicalMonitors(m_attachedDisplays);

                    m_attachedDisplays = displays;
                }

                OnDisplayRefesh?.Invoke();
            }));
        }
Example #9
0
        /// <summary>
        /// closes a list of display monitor handles
        /// </summary>
        /// <param name="systemDisplays"></param>
        private void _DestroyPhysicalMonitors(DisplayCollection displays)
        {
            PhysicalMonitorDesc[] monitorArray = new PhysicalMonitorDesc[displays.Count];

            uint index = 0;

            foreach (Display display in displays)
            {
                monitorArray[index++] = display.Handle;
            }

            if (!DestroyPhysicalMonitors((uint)monitorArray.Length, monitorArray))
            {
                try
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }catch (Win32Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Error destroying physical monitors: " + e.Message);
                }
            }
        }