Esempio n. 1
0
        protected override void OnEnteredLayout(LayoutContext layoutContext, ILayout previousLayout)
        {
            var bitmap = LayoutContext.CreateBitmap();

            DefaultDrawingAlgs.DrawText(bitmap, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_arrow_left, GlobalContext.Options.Theme.ForegroundColor);
            DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) });
        }
Esempio n. 2
0
        private LayoutDrawElement GetHeaderElement(int x, int y, string text, Color color)
        {
            var bitmap         = _layoutContext.CreateBitmap();
            var textFontFamily = _layoutContext.Options.Theme.FontFamily;

            DefaultDrawingAlgs.DrawText(bitmap, textFontFamily, text, color);
            return(new LayoutDrawElement(new Location(x, y), bitmap));
        }
Esempio n. 3
0
            private BitmapEx DrawKey()
            {
                var bitmap     = LayoutContext.CreateBitmap();
                var fontFamily = GlobalContext.Options.Theme.FontFamily;

                DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _macroId.ToString(), GlobalContext.Options.Theme.ForegroundColor);
                return(bitmap);
            }
Esempio n. 4
0
        private void DrawKey()
        {
            var bitmap = LayoutContext.CreateBitmap();

            var fontFamily = FontService.Instance.AwesomeFontFamily;

            DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _options.Text, GlobalContext.Options.Theme.ForegroundColor);

            DrawInvoke(new [] { new LayoutDrawElement(new Location(0, 0), bitmap) });
        }
Esempio n. 5
0
        private static BitmapEx DrawText(string l, LayoutContext layoutContext)
        {
            var bitmap = layoutContext.CreateBitmap();

            var textFontFamily = layoutContext.Options.Theme.FontFamily;

            DefaultDrawingAlgs.DrawText(bitmap, textFontFamily, l, layoutContext.Options.Theme.ForegroundColor);

            return(bitmap);
        }
Esempio n. 6
0
        private BitmapEx DrawNumber(byte number)
        {
            var bitmap = LayoutContext.CreateBitmap();

            var fontFamily = GlobalContext.Options.Theme.FontFamily;

            var str = number.ToString("00");

            DefaultDrawingAlgs.DrawText(bitmap, fontFamily, str, GlobalContext.Options.Theme.ForegroundColor);

            return(bitmap);
        }
Esempio n. 7
0
        private void DrawCommon()
        {
            var bmp1 = LayoutContext.CreateBitmap();

            DefaultDrawingAlgs.DrawText(bmp1, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_undo, GlobalContext.Options.Theme.ForegroundColor);

            var bmp2 = LayoutContext.CreateBitmap();

            DefaultDrawingAlgs.DrawText(bmp2, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_hand_grab_o, GlobalContext.Options.Theme.ForegroundColor);

            DrawInvoke(new[] { new LayoutDrawElement(new Location(3, 0), bmp1), new LayoutDrawElement(new Location(4, 0), bmp2) });
        }
Esempio n. 8
0
        private BitmapEx DrawDate(DateTime date)
        {
            var bitmap = LayoutContext.CreateBitmap();

            var fontFamily = GlobalContext.Options.Theme.FontFamily;

            var day      = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedDayNames[(int)date.DayOfWeek];
            var dateStr1 = $"{day}, {date.Day}";
            var dateStr2 = $"{date.ToString("MM.yy")}";

            DefaultDrawingAlgs.DrawText(bitmap, fontFamily, $"{dateStr1}\n{dateStr2}", GlobalContext.Options.Theme.ForegroundColor);

            return(bitmap);
        }
Esempio n. 9
0
            private BitmapEx DrawKey()
            {
                var bitmap = LayoutContext.CreateBitmap();

                var fontFamily = GlobalContext.Options.Theme.FontFamily;

                string icon = null;

                if (!_audioSelectLayout._options.Names.TryGetValue(_device.Id, out var combName))
                {
                    combName = $"{_device.RealName.Split(' ')[0]}\n{_device.FriendlyName.Split(' ')[0]}";
                }
                else
                {
                    switch (_device.Type)
                    {
                    case MediaDeviceType.Speakers:
                        icon = FontAwesomeRes.fa_volume_down;
                        break;

                    case MediaDeviceType.Phone:
                        icon = FontAwesomeRes.fa_phone;
                        break;

                    case MediaDeviceType.Digital:
                        icon = FontAwesomeRes.fa_usb;
                        break;

                    case MediaDeviceType.Monitor:
                        icon = FontAwesomeRes.fa_tv;
                        break;
                    }
                }

                if (icon != null)
                {
                    DefaultDrawingAlgs.DrawCaptionedIcon(bitmap, FontService.Instance.AwesomeFontFamily, icon, fontFamily, combName, combName, GlobalContext.Options.Theme.ForegroundColor);
                }
                else
                {
                    DefaultDrawingAlgs.DrawText(bitmap, fontFamily, combName, GlobalContext.Options.Theme.ForegroundColor);
                }

                if (_device.Id == _audioSelectLayout._defaultDeviceId)
                {
                    DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme);
                }

                return(bitmap);
            }
Esempio n. 10
0
            private BitmapEx DrawKey()
            {
                var bitmap     = LayoutContext.CreateBitmap();
                var fontFamily = GlobalContext.Options.Theme.FontFamily;
                var combName   = $"{_device.RealName.Split(' ')[0]}\n{_device.FriendlyName.Split(' ')[0]}";

                DefaultDrawingAlgs.DrawText(bitmap, fontFamily, combName, GlobalContext.Options.Theme.ForegroundColor);

                if (_device.Mute)
                {
                    DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme);
                }

                return(bitmap);
            }
Esempio n. 11
0
        private void Draw()
        {
            var bitmap = LayoutContext.CreateBitmap();

            var fontFamily = GlobalContext.Options.Theme.FontFamily;

            DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _action.Text, GlobalContext.Options.Theme.ForegroundColor);

            if (_action.Active)
            {
                DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme);
            }

            DrawInvoke(new [] { new LayoutDrawElement(new Location(0, 0), bitmap) });
        }
Esempio n. 12
0
        private async void ProcessDraw()
        {
            try
            {
                var from = DateTime.Now.Subtract(_options.ExpiredMeetingTolerance);
                var to   = from.AddDays(2).Date;

                _appointments = _calendarServices.SelectMany(c => c.GetCalendar(from, to)).OrderBy(c => c.FromDateTime).ToArray();

                var rows    = _layoutContext.ButtonCount.Height;
                var columns = _layoutContext.ButtonCount.Width;
                LayoutDrawElement[] result = new LayoutDrawElement[columns * rows];

                for (byte i = 0; i < Math.Min(_layoutContext.ButtonCount.Height, _appointments.Length); i++)
                {
                    result[i * columns]     = new LayoutDrawElement(new Location(0, i), DrawText(FormatDateTime(_appointments[i].FromDateTime, _appointments[i].ToDateTime), _layoutContext));
                    result[i * columns + 1] = new LayoutDrawElement(new Location(2, i), DrawText(_appointments[i].Location, _layoutContext));
                    result[i * columns + 2] = new LayoutDrawElement(new Location(1, i), DrawText(_appointments[i].Organiser, _layoutContext));

                    byte firstNameIndex  = 3;
                    byte textButtonCount = (byte)(columns - firstNameIndex);
                    if (textButtonCount > 0)
                    {
                        using (var bitmap = new BitmapEx(_layoutContext.IconSize.Width * textButtonCount, _layoutContext.IconSize.Height))
                        {
                            bitmap.MakeTransparent();
                            DefaultDrawingAlgs.DrawText(bitmap, _layoutContext.Options.Theme.FontFamily, _appointments[i].Subject, _layoutContext.Options.Theme.ForegroundColor);
                            var elements = BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(textButtonCount, 1), firstNameIndex, i, _layoutContext);
                            int j        = firstNameIndex;
                            foreach (var e in elements)
                            {
                                result[i * columns + j] = e;
                                j++;
                            }
                        }
                    }
                }

                DrawLayout?.Invoke(this, new DrawEventArgs(result));
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Exception during weather station layout drawing: {ex}");
            }
        }
Esempio n. 13
0
        private void SetValue(byte value)
        {
            if (_currentIndex == 2 && value > 5)
            {
                return;
            }

            _values[_currentIndex] = value;

            var bmp = LayoutContext.CreateBitmap();

            DefaultDrawingAlgs.DrawText(bmp, GlobalContext.Options.Theme.FontFamily, value.ToString(), GlobalContext.Options.Theme.ForegroundColor);
            DrawInvoke(new[] { new LayoutDrawElement(new Location((byte)(3 + _currentIndex % 2), (byte)(_currentIndex / 2)), bmp) });

            _currentIndex++;
            if (_currentIndex == _values.Length)
            {
                LayoutContext.SetPreviousLayout();
            }
        }
Esempio n. 14
0
        private BitmapEx Draw(AppointmentInfo nextAppointment, byte opacity, LayoutContext layoutContext)
        {
            var bitmap = layoutContext.CreateBitmap();

            if (opacity != 0)
            {
                using (var graphics = bitmap.CreateGraphics())
                    using (var brush = new SolidBrush(Color.FromArgb(opacity, _options.UpcomingMeetingColor)))
                    {
                        graphics.FillRectangle(brush, 0, 0, bitmap.Width, bitmap.Height);
                    }
            }

            string result;

            result = nextAppointment != null ? $"{nextAppointment.FromDateTime:t}\n{nextAppointment.Location?.Split('(')[0].Trim()}" : "X";

            DefaultDrawingAlgs.DrawText(bitmap, layoutContext.Options.Theme.FontFamily, result, layoutContext.Options.Theme.ForegroundColor);

            return(bitmap);
        }
Esempio n. 15
0
        protected override void OnEnteredLayout(LayoutContext layoutContext, ILayout previousLayout)
        {
            string symbol = "";

            switch (GetAction())
            {
            case PowerAction.PowerOff:
                symbol = FontAwesomeRes.fa_power_off;
                break;

            case PowerAction.LogOff:
                symbol = FontAwesomeRes.fa_user;
                break;

            case PowerAction.Reboot:
                symbol = FontAwesomeRes.fa_undo;
                break;
            }

            var bitmap = LayoutContext.CreateBitmap();

            DefaultDrawingAlgs.DrawText(bitmap, FontService.Instance.AwesomeFontFamily, symbol, GlobalContext.Options.Theme.ForegroundColor);
            DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) });
        }
Esempio n. 16
0
        private void PerformDraw(PlayingInfo playingInfo)
        {
            if (_previousRepresentation != playingInfo?.BitmapRepresentation || _prevPlaying != playingInfo?.IsPlaying)
            {
                _previousRepresentation = playingInfo?.BitmapRepresentation;
                _prevPlaying            = playingInfo?.IsPlaying ?? false;

                var bitmap = LayoutContext.CreateBitmap();

                if (playingInfo?.BitmapRepresentation != null)
                {
                    using (var coverBitmap = playingInfo.BitmapRepresentation.CreateBitmap())
                    {
                        BitmapHelpers.ResizeBitmap(coverBitmap, bitmap, _prevPlaying ? null : BitmapHelpers.GrayColorMatrix);
                    }
                }
                else
                {
                    DefaultDrawingAlgs.DrawText(bitmap, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_headphones, LayoutContext.Options.Theme.ForegroundColor);
                }

                DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap, new TransitionInfo(TransitionType.ElementUpdate, TimeSpan.FromSeconds(1))) });
            }
        }
Esempio n. 17
0
        private BitmapEx Draw()
        {
            var bitmap = LayoutContext.CreateBitmap();

            if (!string.IsNullOrEmpty(_options.Symbol))
            {
                var fontFamily = FontService.Instance.AwesomeFontFamily;
                DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _options.Symbol, GlobalContext.Options.Theme.ForegroundColor);
            }
            else
            {
                using (var iconRepresentation = _bitmapDownloadService.GetBitmapForExecutable(_options.Executable).Result)
                    using (var iconBmpEx = iconRepresentation.CreateBitmap())
                    {
                        BitmapHelpers.ResizeBitmap(iconBmpEx, bitmap);
                        if (_selected)
                        {
                            DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme);
                        }
                    }
            }

            return(bitmap);
        }
Esempio n. 18
0
        private void PerformDraw(PlayingInfo playingInfo)
        {
            byte imageSize = 2;
            byte textSize  = 3;
            var  result    = new List <LayoutDrawElement>();

            if (playingInfo.IsPlaying != _isPlaying)
            {
                _isPlaying = playingInfo.IsPlaying;
                _playPauseButton.ReplaceText(_isPlaying.Value?FontAwesomeRes.fa_pause:FontAwesomeRes.fa_play);
            }

            if (_previousRepresentation != playingInfo?.BitmapRepresentation)
            {
                _previousRepresentation = playingInfo?.BitmapRepresentation;

                using (var bitmap = new BitmapEx(LayoutContext.IconSize.Width * imageSize, LayoutContext.IconSize.Height * imageSize))
                {
                    bitmap.MakeTransparent();
                    if (playingInfo?.BitmapRepresentation != null)
                    {
                        using (BitmapEx coverBitmap = playingInfo.BitmapRepresentation.CreateBitmap())
                        {
                            BitmapHelpers.ResizeBitmap(coverBitmap, bitmap);
                        }
                    }

                    result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(imageSize, imageSize), 0, 0, LayoutContext));
                }
            }

            using (var bitmap = new BitmapEx(LayoutContext.IconSize.Width * textSize, LayoutContext.IconSize.Height))
            {
                var lineWidth = 0.05;

                bitmap.MakeTransparent();
                var title = playingInfo?.Title;
                DefaultDrawingAlgs.DrawText(bitmap, GlobalContext.Options.Theme.FontFamily, title, LayoutContext.Options.Theme.ForegroundColor);

                if (playingInfo != null)
                {
                    using (var graphics = bitmap.CreateGraphics())
                        using (var brush = new SolidBrush(GlobalContext.Options.Theme.ForegroundColor))
                        {
                            var rect = new Rectangle(0, (int)(bitmap.Height * (1 - lineWidth)), (int)(bitmap.Width * playingInfo.CurrentPosition.TotalMilliseconds / playingInfo.DurationSpan.TotalMilliseconds), (int)(bitmap.Height * lineWidth));
                            graphics.FillRectangle(brush, rect);
                        }
                }

                result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(textSize, 1), imageSize, 0, LayoutContext));
            }

            using (var bitmap = new BitmapEx(LayoutContext.IconSize.Width * textSize, LayoutContext.IconSize.Height))
            {
                bitmap.MakeTransparent();
                var artist = playingInfo?.Artist ?? string.Empty;
                var album  = playingInfo?.Album ?? string.Empty;
                var text   = $"{artist}\n{album}";
                DefaultDrawingAlgs.DrawText(bitmap, GlobalContext.Options.Theme.FontFamily, text, GlobalContext.Options.Theme.ForegroundColor);
                result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(textSize, 1), imageSize, 1, LayoutContext));
            }

            DrawInvoke(result);
        }