Exemple #1
0
        public SolidColorBrush GetBackgroundBrush(LiveItems item)
        {
            string key = string.Empty;

            if ((bool)SettingHelper.Get(Constants.LIVETILE_RANDOM_BACKGROUND_COLOR))
            {
                int index = new Random().Next(0, ColorItem.UintColors.Length - 1);
                return(new SolidColorBrush(ColorItem.ConvertColor(ColorItem.UintColors[index])));
            }
            else
            {
                switch (item)
                {
                case LiveItems.Calendar:
                    key = Constants.LIVETILE_CALENDAR_BACKGROUND_COLOR;
                    break;

                case LiveItems.Weather:
                    key = Constants.LIVETILE_WEATHER_BACKGROUND_COLOR;
                    break;

                case LiveItems.Battery:
                    key = Constants.LIVETILE_BATTERY_BACKGROUND_COLOR;
                    break;
                }

                return(new SolidColorBrush((SettingHelper.Get(key) as ColorItem).Color));
            }
        }
Exemple #2
0
 private bool IsEnabledButton(LiveItems item)
 {
     foreach (LivetileTemplateItem lti in LivetileSelector.ItemsSource as List <LivetileTemplateItem> )
     {
         if (lti.LiveItem == item)
         {
             return(lti.PinIconOpacity != 1);
         }
     }
     return(false);
 }
Exemple #3
0
        private void DisableItem(LiveItems item)
        {
            foreach (LivetileTemplateItem lti in LivetileSelector.ItemsSource as List <LivetileTemplateItem> )
            {
                if (lti.LiveItem == item)
                {
                    lti.PinIconOpacity = 1;
                }
            }

            foreach (ApplicationBarIconButton button in IAppBarLivetile.Buttons.AsQueryable())
            {
                if ((item == LiveItems.Weather && button.Text == AppResources.PinWeatherLivetile) ||
                    (item == LiveItems.Calendar && button.Text == AppResources.PinCalendarLivetile) ||
                    (item == LiveItems.Battery && button.Text == AppResources.PinBatteryLivetile))
                {
                    button.IsEnabled = false;
                }
            }
        }
Exemple #4
0
        private void PinLivetile(LiveItems item)
        {
            if (!ExistsActiveTile && Microsoft.Phone.Scheduler.ScheduledActionService.Find(Constants.PERIODIC_TASK_NAME) == null)
            {
                StartPeriodicAgent();
            }

            switch (item)
            {
            case LiveItems.Weather:
                PinWeatherLivetile();
                break;

            case LiveItems.Calendar:
                PinCalendarLivetile();
                break;

            case LiveItems.Battery:
                PinBatteryLivetile();
                break;
            }
        }
Exemple #5
0
 public LivetileTemplateItem(LiveItems liveItem)
 {
     visibility     = System.Windows.Visibility.Collapsed;
     LiveItem       = liveItem;
     pinIconOpacity = 0.3;
 }
Exemple #6
0
        public static void CreateLivetileImage(LivetileData data, LiveItems liveItem)
        {
            Canvas          panel = null;
            WriteableBitmap wb    = null;

            switch (liveItem)
            {
            case LiveItems.Calendar:
                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    panel            = GetCalendarCanvas(data);
                    panel.Background = data.GetBackgroundBrush(LiveItems.Calendar);

                    System.Diagnostics.Debug.WriteLine("달력 전 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.calendar.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        wb = new WriteableBitmap(panel, null);
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }

                    System.Diagnostics.Debug.WriteLine("달력 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    wb = wb.Resize(159, 159, WriteableBitmapExtensions.Interpolation.NearestNeighbor);
                    System.Diagnostics.Debug.WriteLine("달력 줄임 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.calendar.small.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("작은 달력 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);

                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.calendar.back.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        panel.Children.Clear();
                        panel.Width  = 1;
                        panel.Height = 1;
                        wb           = new WriteableBitmap(panel, null);
                        //System.Diagnostics.Debug.WriteLine("###########달력 이미지 저장전 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                        //System.Diagnostics.Debug.WriteLine("###########달력 이미지 저장후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    }
                    System.Diagnostics.Debug.WriteLine("타일 뒷면 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                }
                break;

            case LiveItems.Weather:
                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    SolidColorBrush backBrush = data.GetBackgroundBrush(LiveItems.Weather);
                    panel            = GetWeatherCanvas(data);
                    panel.Background = backBrush;

                    System.Diagnostics.Debug.WriteLine("날씨 전 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.weather.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        wb = new WriteableBitmap(panel, null);
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("날씨 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    wb = wb.Resize(159, 159, WriteableBitmapExtensions.Interpolation.NearestNeighbor);
                    System.Diagnostics.Debug.WriteLine("날씨 줄임 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.weather.small.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("작은 날씨 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);

                    //날씨 백타일 (주간 일보)
                    panel            = GetWeatherBackCanvas(data);
                    panel.Background = backBrush;

                    System.Diagnostics.Debug.WriteLine("주간 날씨 전 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.weather.back.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        wb = new WriteableBitmap(panel, null);
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("주간 날씨 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                }
                break;

            case LiveItems.Battery:
                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    panel            = GetBatteryCanvas(data);
                    panel.Background = data.GetBackgroundBrush(LiveItems.Battery);

                    System.Diagnostics.Debug.WriteLine("배터리 전 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.battery.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        wb = new WriteableBitmap(panel, null);
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("배터리 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    wb = wb.Resize(159, 159, WriteableBitmapExtensions.Interpolation.NearestNeighbor);
                    System.Diagnostics.Debug.WriteLine("배터리 줄임 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.battery.small.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("작은 배터리 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);


                    using (IsolatedStorageFileStream targetStream = isoStore.OpenFile("Shared/ShellContent/livetile.battery.back.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write))
                    {
                        panel.Children.Clear();
                        panel.Width  = 1;
                        panel.Height = 1;
                        wb           = new WriteableBitmap(panel, null);
                        //wb.SaveJpeg(targetStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                        pngEncoder.Encode(wb.ToImage(), targetStream);
                    }
                    System.Diagnostics.Debug.WriteLine("배터리 뒷면 저장 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);
                }
                break;
            }

            wb = null;
            GC.Collect();
        }