/// <summary> /// 绘制x轴 /// </summary> /// <param name="YaxisPath"></param> /// <param name="CustomDrawLineWidth"></param> /// <param name="YLabelPoint"></param> /// <param name="LabelList"></param> public void DrawingXaxis(Geometry YaxisPath, double CustomDrawLineWidth, List <Point> YLabelPoint, List <string> LabelList) { YaxisPath.Freeze(); DrawingVisual drawingVisual = new DrawingVisual(); Brush blackbrush = Brushes.Black; blackbrush.Freeze(); Pen BlackPen = new Pen(blackbrush, CustomDrawLineWidth); BlackPen.Freeze(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawGeometry(null, BlackPen, YaxisPath); for (int i = 0; i < YLabelPoint.Count; i++) { drawingContext.DrawText(new FormattedText(LabelList[i].ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Tahoma"), 14, Brushes.Black), new Point(YLabelPoint[i].X + 2, YLabelPoint[i].Y)); } drawingContext.Close(); BitmapCache bc = new BitmapCache(); bc.SnapsToDevicePixels = true; bc.Freeze(); drawingVisual.CacheMode = bc; //drawingVisual.Drawing.Freeze(); this.AddVisualChild(drawingVisual); }
public void DrawingLines(List <Line> positiveGroup, List <Line> negativeGroup, double CustomDrawLineWidth) { DrawingVisual drawingVisual = new DrawingVisual(); Pen RedPen = new Pen(RedBrush, CustomDrawLineWidth); Pen GreenPen = new Pen(GreenBrush, CustomDrawLineWidth); RedPen.Freeze(); GreenPen.Freeze(); DrawingContext drawingContext = drawingVisual.RenderOpen(); foreach (var item in positiveGroup) { drawingContext.DrawLine(RedPen, item.StartLocation, item.EndLocation); } foreach (var item in negativeGroup) { drawingContext.DrawLine(GreenPen, item.StartLocation, item.EndLocation); } drawingContext.Close(); BitmapCache bc = new BitmapCache(); bc.SnapsToDevicePixels = true; bc.Freeze(); drawingVisual.CacheMode = bc; this.AddVisualChild(drawingVisual); }
protected override void OnSizeChanged(int w, int h, int oldw, int oldh) { base.OnSizeChanged(w, h, oldw, oldh); _drawingRect = new Rect { Left = PaddingLeft, Right = w - PaddingRight, Top = PaddingTop, Bottom = h - PaddingBottom }; //The need to be recreated because they depend on the size of the view. _valShader = null; _satShader = null; _alphaShader = null; // Clear those bitmap caches since the size may have changed. _satValBackgroundCache = null; _hueBackgroundCache = null; SetUpSatValRect(); SetUpHueRect(); SetUpAlphaRect(); }
public ManifoldViewHolder(SwipeRecyclerView parent, BitmapCache cache, Workbench workbench) : base(parent, Resource.Layout.list_item_viewer, Resource.Layout.view_delete) { this.cache = cache; name = foreground.FindViewById <TextView>(Resource.Id.name); status = foreground.FindViewById <TextView>(Resource.Id.status); measurement = foreground.FindViewById <TextView>(Resource.Id.measurement); measurement.Tag = new Java.Lang.String("Measurement"); unit = foreground.FindViewById <TextView>(Resource.Id.unit); alarm = foreground.FindViewById(Resource.Id.alarm); icon = foreground.FindViewById <ImageView>(Resource.Id.icon); battery = foreground.FindViewById <ImageView>(Resource.Id.battery); connection = foreground.FindViewById <ImageView>(Resource.Id.connection); progress = foreground.FindViewById <ProgressBar>(Resource.Id.progress); lastBattery = -1; var button = background as Button; button.SetText(Resource.String.remove); button.SetOnClickListener(new ViewClickAction((view) => { workbench.Remove(record.manifold); })); }
public static void Init() { InitializeTelemetry(); InitializeTilesAsync().FireAndForget(); BitmapCache.ClearCacheAsync(TimeSpan.FromHours(48)).FireAndForget(); }
public TimerSensorPropertyViewHolder(SwipeRecyclerView recyclerView, BitmapCache cache) : base(recyclerView, Resource.Layout.subview_timer_large) { this.cache = cache; title = foreground.FindViewById <TextView>(Resource.Id.title); icon = foreground.FindViewById <ImageView>(Resource.Id.icon); play = foreground.FindViewById <ImageView>(Resource.Id.play); divider = foreground.FindViewById(Resource.Id.view); measurement = foreground.FindViewById <TextView>(Resource.Id.measurement); handler = new Handler(HandleMessage); icon.SetOnClickListener(new ViewClickAction((v) => { if (record != null && record.sp.supportedReset) { record.sp.Reset(); } })); play.SetOnClickListener(new ViewClickAction((v) => { if (record != null) { record.sp.Toggle(); } })); play.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_action_play)); }
public CascadingAnimation() { FromOpacityDuration = TimeSpan.FromSeconds(0.1); NextLetterOn = TimeSpan.FromSeconds(0.05); FromLetterOffsetDuration = TimeSpan.FromSeconds(0); DelayExecution = TimeSpan.Zero; FromLetterOffset = new Point(0, 0); _storyboard.Completed += (sender, args) => Completed?.Invoke(); Loaded += delegate { if (DesignMode.DesignModeEnabled) { if (_children.Any()) { Grid container = new Grid(); foreach (FrameworkElement child in _children) { container.Children.Add(child); } Content = container; } } }; CacheMode = new BitmapCache(); UseLayoutRounding = false; }
private void CreateElements() { if (this._elements != null) { return; } this._elements = new List <FrameworkElement>(3); ((PresentationFrameworkCollection <UIElement>)((Panel)this).Children).Clear(); for (int index = 0; index < 3; ++index) { Border border1 = new Border(); TranslateTransform translateTransform = new TranslateTransform(); ((UIElement)border1).RenderTransform = ((Transform)translateTransform); BitmapCache bitmapCache = new BitmapCache(); ((UIElement)border1).CacheMode = ((CacheMode)bitmapCache); SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Transparent); border1.Background = ((Brush)solidColorBrush); Border border2 = border1; ((UIElement)border2).ManipulationStarted += (new EventHandler <ManipulationStartedEventArgs>(this.Element_OnManipulationStarted)); ((UIElement)border2).ManipulationDelta += (new EventHandler <ManipulationDeltaEventArgs>(this.Element_OnManipulationDelta)); ((UIElement)border2).ManipulationCompleted += (new EventHandler <ManipulationCompletedEventArgs>(this.Element_OnManipulationCompleted)); if (this.ItemTemplate != null) { ContentPresenter contentPresenter1 = new ContentPresenter(); DataTemplate itemTemplate = this.ItemTemplate; contentPresenter1.ContentTemplate = itemTemplate; ContentPresenter contentPresenter2 = contentPresenter1; BindingOperations.SetBinding((DependencyObject)contentPresenter2, (DependencyProperty)ContentPresenter.ContentProperty, (BindingBase) new Binding()); border2.Child = ((UIElement)contentPresenter2); } this._elements.Add((FrameworkElement)border2); ((PresentationFrameworkCollection <UIElement>)((Panel)this).Children).Add((UIElement)border2); } }
private async void OnClearCache(object sender, RoutedEventArgs e) { Page.Clear(); await Task.Delay(1000); await BitmapCache.ClearCacheAsync(); }
private void CreateElements() { if (this._elements != null) { return; } this._elements = new List <FrameworkElement>(3); this.Children.Clear(); for (int index = 0; index < 3; ++index) { Border border1 = new Border(); TranslateTransform translateTransform = new TranslateTransform(); border1.RenderTransform = (Transform)translateTransform; BitmapCache bitmapCache = new BitmapCache(); border1.CacheMode = (CacheMode)bitmapCache; SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Transparent); border1.Background = (Brush)solidColorBrush; Border border2 = border1; border2.ManipulationStarted += new EventHandler <ManipulationStartedEventArgs>(this.Element_OnManipulationStarted); border2.ManipulationDelta += new EventHandler <ManipulationDeltaEventArgs>(this.Element_OnManipulationDelta); border2.ManipulationCompleted += new EventHandler <ManipulationCompletedEventArgs>(this.Element_OnManipulationCompleted); if (this.ItemTemplate != null) { ContentPresenter contentPresenter = new ContentPresenter() { ContentTemplate = this.ItemTemplate }; BindingOperations.SetBinding((DependencyObject)contentPresenter, ContentPresenter.ContentProperty, (BindingBase) new Binding()); border2.Child = (UIElement)contentPresenter; } this._elements.Add((FrameworkElement)border2); this.Children.Add((UIElement)border2); } }
static ThemeShadowChrome() { s_bg1 = new SolidColorBrush(Colors.Black) { Opacity = 0.11 }; s_bg2 = new SolidColorBrush(Colors.Black) { Opacity = 0.13 }; s_bg3 = new SolidColorBrush(Colors.Black) { Opacity = 0.18 }; s_bg4 = new SolidColorBrush(Colors.Black) { Opacity = 0.22 }; s_bg1.Freeze(); s_bg2.Freeze(); s_bg3.Freeze(); s_bg4.Freeze(); s_bitmapCache = new BitmapCache { SnapsToDevicePixels = false }; s_bitmapCache.Freeze(); }
public CollectionsViewModel() { Status = TaskStatuses.Success; const double Radius = 10; Collections.Add(new OverpassCollection(new[] { "toilets" }, Radius) { Title = "Toilets", ImageSource = "em173", MakeIconFunc = _ => BitmapCache.GetBitmap("em173.png"), MaxVisibleCount = 100 }); Collections.Add(new OverpassCollection(new[] { "recycling" }, Radius) { Title = "Recycling", ImageSource = "em157", MakeIconFunc = _ => BitmapCache.GetBitmap("em157.png"), MaxVisibleCount = 100 }); var root = new MapObjectCollection() { Title = "Root", MaxVisibleCount = 10 }; root.Add(Collections.ToList()); Collections.Add(root); MapObjects.Add(root); }
public void TestCacheMode() { var element = Button(); var cache = new BitmapCache(); element.CacheMode(cache).CacheMode.Should().Be(cache); }
// Overridden form IONActivity protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); cache = new BitmapCache(Resources); ActionBar.SetDisplayHomeAsUpEnabled(true); }
public TileCanvas() { Layers = new ObservableCollection <Layer>(); Layers.Add(new Layer { Index = 0, Name = "Main" }); CacheMode = new BitmapCache(); }
public void AddBitmapCacheToSdv() { var bmc = new BitmapCache { RenderAtScale = 0.5 }; SingleDayWindowBody.CacheMode = bmc; }
public ViewerDialog(Context context, Analyzer analyzer, Sensor sensor, Analyzer.ESide side) { this.context = context; this.analyzer = analyzer; this.sensor = sensor; this.side = side; this.cache = new BitmapCache(context.Resources); }
public static void Main() { bugsnagClient = new Bugsnag.Client(new Bugsnag.Configuration { ApiKey = "fa43381b116de659fcf1cfda14884d98", AppVersion = Application.ProductVersion, AutoNotify = false }); // install custom handler for fatal exceptions AppDomain.CurrentDomain.UnhandledException += UnhandledException; // route UI thread exceptions to the fatal exception handler Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); RemoveOldVersionSettings(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mainForm = new MainForm(); var tileCache = new BitmapCache(); var dialogService = new DialogService(mainForm); var featureService = new FeatureService(); var sectionsService = new SectionService(); var sectionFactory = new SectionFactory(tileCache); var sectionBitmapService = new SectionBitmapService(sectionFactory); var mapModelFactory = new MapModelFactory(tileCache); var mapLoadingService = new MapLoadingService(sectionFactory, mapModelFactory); var imageImportingService = new ImageImportService(tileCache); var model = new CoreModel(); // Unsure if I should get the SectionViews to register themselves, or pass the dispatcher the SectionViews as params mainForm.SectionView.SetModel(new SectionViewViewModel(sectionsService)); mainForm.FeatureView.SetModel(new FeatureViewViewModel(featureService)); var dispatcher = new Dispatcher( model, dialogService, sectionsService, sectionBitmapService, featureService, mapLoadingService, imageImportingService, tileCache, mainForm); mainForm.SetModel(new MainFormViewModel(model, dispatcher)); mainForm.MapViewPanel.SetModel(new MapViewViewModel(model, dispatcher, featureService)); var minimapForm = new MinimapForm(); minimapForm.Owner = mainForm; minimapForm.SetModel(new MinimapFormViewModel(model, dispatcher)); Application.Run(mainForm); }
public sealed override void UpdateGeometry() { ScaleThickness = Image.State.HasFlag(ShapeStateFlags.Thickness); ScaleSize = Image.State.HasFlag(ShapeStateFlags.Size); if (!string.IsNullOrEmpty(Image.Key)) { ImageCached = BitmapCache.Get(Image.Key) as SKBitmap; if (ImageCached is null && ImageCache is { })
private void constructionInitialization() { //reset rotation var desiredAngle = _rotationAngle; RotationAngle = desiredAngle + 1; RotationAngle = desiredAngle; CacheMode = new BitmapCache(); }
public override void OnAttachedToRecyclerView(RecyclerView recyclerView) { base.OnAttachedToRecyclerView(recyclerView); if (cache == null) { cache = new BitmapCache(recyclerView.Context.Resources); } dragger.AttachToRecyclerView(recyclerView); }
public GridViewAdapter(Context context) { mContext = context; mMemoryCache = new BitmapCache(); for (int i = 0; i < 1000; i++) { add(i); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); cache = new BitmapCache(Resources); prefs = AppPrefs.Get(this); prefs.prefs.RegisterOnSharedPreferenceChangeListener(this); BindService(new Intent(this, typeof(AppService)), this, 0); }
public ROCSensorPropertyViewHolder(SwipeRecyclerView recyclerView, BitmapCache cache) : base(recyclerView, Resource.Layout.subview_graph_large) { this.cache = cache; plot = this.foreground.FindViewById <PlotView>(Resource.Id.graph); handler = new Handler(HandleMessage); title = foreground.FindViewById <TextView>(Resource.Id.title); icon = foreground.FindViewById <ImageView>(Resource.Id.icon); measurement = foreground.FindViewById <TextView>(Resource.Id.measurement); unit = foreground.FindViewById <TextView>(Resource.Id.unit); }
private void InitControl() { SwitchInteractiveState(isInteractive); this.SizeChanged += ChartControl_SizeChanged; //CreateTooltipTimer(); globalBitmapCache = new BitmapCache(); CreateFocusable(); }
/** * Creates a new ExpandableListItemAdapter with the specified list, or an empty list if * items == null. */ public MyExpandableListItemAdapter(Context context) : base(context, Resource.Layout.activity_expandablelistitem_card, Resource.Id.activity_expandablelistitem_card_title, Resource.Id.activity_expandablelistitem_card_content) { mContext = context; mMemoryCache = new BitmapCache(); for (int i = 0; i < 100; i++) { add(i); } }
private static Bitmap GetBitmap(Cache.CacheType cacheType, string name, IconGenerator.IconType type, int size, Color borderColor, float borderWidth, out Cache cache) { SetIconGeneratorSettings(type, size, borderColor, borderWidth); cache = CreateCache(cacheType, name); if (BitmapCache.ContainsKey(cache)) { return(BitmapCache[cache]); //Bitmap has been created already, return it. } //Bitmap has been created yet, so lets create it and cache it. return(BitmapCache[cache] = IconGenerator.GetIcon(name)); // All done, returning sprite. }
public CanvasView() { InitializeComponent(); ViewModel.Canvas = CanvasElement; ViewModel.TileSetCanvas = TileSetCanvas; ViewModel.PropertyChanged += ViewModelOnPropertyChanged; var cache = new BitmapCache(); TileSetCanvas.CacheMode = cache; CanvasElement.CacheMode = cache; Render(); }
private void chkCache_Click(object sender, RoutedEventArgs e) { if (chkCache.IsChecked == true) { BitmapCache bitmapChche = new BitmapCache(); pathBackground.CacheMode = new BitmapCache(); } else { pathBackground.CacheMode = null; } }
private void chkCache_Click(object sender, RoutedEventArgs e) { if (chkCache.IsChecked == true) { BitmapCache bitmapCache = new BitmapCache(); bitmapCache.RenderAtScale = 5; cmd.CacheMode = bitmapCache; } else { cmd.CacheMode = null; } }
/// <summary> /// 构造器 /// </summary> private ImageBank() : base() { _cache = new FsBitmapCache(); IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; if ( settings.Contains( CACHE_CLEAN_LAST ) ) { double lastCleanTime = Double.Parse( settings[CACHE_CLEAN_LAST].ToString() ); if ( DateTime.Now.Ticks / 10000 - lastCleanTime > CACHE_CLEAN_INTERVAL ) { _cache.Clear(); } } else { // 没有设置过清理缓存的时间,第一次启动或者不小心删掉了,重新设置 settings[CACHE_CLEAN_LAST] = ( DateTime.Now.Ticks / 10000 ).ToString(); } }
protected override void OnCreate(Bundle bundle) { Console.WriteLine("LockScreenActivity - OnCreate"); base.OnCreate(bundle); _playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>(); _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); // Create bitmap cache int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024); int cacheSize = maxMemory / 16; _bitmapCache = new BitmapCache(null, cacheSize, 800, 800); // Create layout and get controls _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); SetContentView(Resource.Layout.LockScreen); _lblArtistName = FindViewById<TextView>(Resource.Id.lockScreen_lblArtistName); _lblAlbumTitle = FindViewById<TextView>(Resource.Id.lockScreen_lblAlbumTitle); _lblSongTitle = FindViewById<TextView>(Resource.Id.lockScreen_lblSongTitle); _lblPosition = FindViewById<TextView>(Resource.Id.lockScreen_lblPosition); _lblLength = FindViewById<TextView>(Resource.Id.lockScreen_lblLength); _btnPrevious = FindViewById<ImageButton>(Resource.Id.lockScreen_btnPrevious); _btnPlayPause = FindViewById<ImageButton>(Resource.Id.lockScreen_btnPlayPause); _btnNext = FindViewById<ImageButton>(Resource.Id.lockScreen_btnNext); _btnShuffle = FindViewById<ImageButton>(Resource.Id.lockScreen_btnShuffle); _btnRepeat = FindViewById<ImageButton>(Resource.Id.lockScreen_btnRepeat); _btnClose = FindViewById<ImageButton>(Resource.Id.lockScreen_btnClose); _btnClose.SetOnTouchListener(this); _btnPlayPause.SetOnTouchListener(this); _btnPrevious.SetOnTouchListener(this); _btnNext.SetOnTouchListener(this); _btnRepeat.SetOnTouchListener(this); _btnShuffle.SetOnTouchListener(this); _imageAlbum = FindViewById<ImageView>(Resource.Id.lockScreen_imageAlbum); _seekBar = FindViewById<SeekBar>(Resource.Id.lockScreen_seekBar); _seekBar.StartTrackingTouch += SeekBarOnStartTrackingTouch; _seekBar.StopTrackingTouch += SeekBarOnStopTrackingTouch; _seekBar.ProgressChanged += SeekBarOnProgressChanged; _btnClose.Click += (sender, args) => Finish(); _btnPrevious.Click += (sender, args) => OnPlayerPrevious(); _btnPlayPause.Click += (sender, args) => OnPlayerPlayPause(); _btnNext.Click += (sender, args) => OnPlayerNext(); _btnShuffle.Click += (sender, args) => OnPlayerShuffle(); _btnRepeat.Click += (sender, args) => OnPlayerRepeat(); //_btnPlaylist.Click += (sender, args) => { // Intent intent = new Intent(this, typeof (PlaylistActivity)); // intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop); // StartActivity(intent); //}; _timerSongPosition = new Timer(); _timerSongPosition.Interval = 100; _timerSongPosition.Elapsed += (sender, args) => { if (_isPositionChanging) return; RunOnUiThread(() => { try { var position = _playerService.GetPosition(); //Console.WriteLine("LockScreenActivity - timerSongPosition - position: {0}", position); _lblPosition.Text = position.Position; float percentage = ((float)position.PositionBytes / (float)_playerService.CurrentPlaylistItem.LengthBytes) * 10000f; _seekBar.Progress = (int)percentage; } catch { // Just ignore exception. It's not really worth it to start/stop the timer when the player is playing. // TODO: In fact reuse the last position instead of returning 0. _lblPosition.Text = "0:00.000"; _seekBar.Progress = 0; } }); }; _timerSongPosition.Start(); // Since the onViewReady action could not be added to an intent, tell the NavMgr the view is ready ((AndroidNavigationManager)_navigationManager).SetLockScreenActivityInstance(this); }
private void Initialize() { Console.WriteLine("NotificationService - Initializing service..."); int maxMemory = (int) (Runtime.GetRuntime().MaxMemory()/1024); int cacheSize = maxMemory/16; _bitmapCache = new BitmapCache(null, cacheSize, 200, 200); _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); _playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>(); _messengerHub.Subscribe<PlayerPlaylistIndexChangedMessage>((message) => { Console.WriteLine("NotificationService - PlayerPlaylistIndexChangedMessage"); if (message.Data.AudioFileStarted != null) { _audioFile = message.Data.AudioFileStarted; //UpdateNotificationView(message.Data.AudioFileStarted, null); UpdateNotificationView(); GetAlbumArt(message.Data.AudioFileStarted); } }); _messengerHub.Subscribe<PlayerStatusMessage>((message) => { Console.WriteLine("NotificationService - PlayerStatusMessage - Status=" + message.Status.ToString()); _status = message.Status; UpdateNotificationView(); }); // Declare the service as foreground (i.e. the user is aware because of the audio) Console.WriteLine("NotificationService - Declaring service as foreground (API {0})...", (int) global::Android.OS.Build.VERSION.SdkInt); CreateNotificationView(); }
private void Initialize() { Console.WriteLine("WidgetService - Initializing service..."); int maxMemory = (int) (Runtime.GetRuntime().MaxMemory()/1024); int cacheSize = maxMemory/16; _bitmapCache = new BitmapCache(null, cacheSize, 200, 200); _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); _playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>(); _messengerHub.Subscribe<PlayerPlaylistIndexChangedMessage>((message) => { Console.WriteLine("WidgetService - PlayerPlaylistIndexChangedMessage"); if (message.Data.AudioFileStarted != null) { _audioFile = message.Data.AudioFileStarted; //UpdateNotificationView(message.Data.AudioFileStarted, null); UpdateWidgetView(); GetAlbumArt(message.Data.AudioFileStarted); } }); _messengerHub.Subscribe<PlayerStatusMessage>((message) => { Console.WriteLine("WidgetService - PlayerStatusMessage - Status=" + message.Status.ToString()); _status = message.Status; UpdateWidgetView(); }); }
protected override void OnCreate(Bundle bundle) { Console.WriteLine("PlayerActivity - OnCreate"); _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); base.OnCreate(bundle); SetContentView(Resource.Layout.Player); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); _fragments = new List<Fragment>(); _viewPager = FindViewById<ViewPager>(Resource.Id.player_pager); _viewPager.OffscreenPageLimit = 4; _viewPagerAdapter = new ViewPagerAdapter(FragmentManager, _fragments, _viewPager); _viewPagerAdapter.OnPageChanged += ViewPagerAdapterOnOnPageChanged; _viewPager.Adapter = _viewPagerAdapter; _viewPager.SetOnPageChangeListener(_viewPagerAdapter); _waveFormScrollView = FindViewById<WaveFormScrollView>(Resource.Id.player_waveFormScrollView); _imageViewAlbumArt = FindViewById<SquareImageView>(Resource.Id.player_imageViewAlbumArt); _lblPosition = FindViewById<TextView>(Resource.Id.player_lblPosition); _lblLength = FindViewById<TextView>(Resource.Id.player_lblLength); _btnPlayPause = FindViewById<ImageButton>(Resource.Id.player_btnPlayPause); _btnPrevious = FindViewById<ImageButton>(Resource.Id.player_btnPrevious); _btnNext = FindViewById<ImageButton>(Resource.Id.player_btnNext); _btnShuffle = FindViewById<ImageButton>(Resource.Id.player_btnShuffle); _btnRepeat = FindViewById<ImageButton>(Resource.Id.player_btnRepeat); _btnPlaylist = FindViewById<ImageButton>(Resource.Id.player_btnPlaylist); _seekBar = FindViewById<SeekBar>(Resource.Id.player_seekBar); _carrouselDot1 = FindViewById<Button>(Resource.Id.player_carrouselDot1); _carrouselDot2 = FindViewById<Button>(Resource.Id.player_carrouselDot2); _carrouselDot3 = FindViewById<Button>(Resource.Id.player_carrouselDot3); _carrouselDot4 = FindViewById<Button>(Resource.Id.player_carrouselDot4); _carrouselDot5 = FindViewById<Button>(Resource.Id.player_carrouselDot5); _btnPlayPause.Click += BtnPlayPauseOnClick; _btnPrevious.Click += BtnPreviousOnClick; _btnNext.Click += BtnNextOnClick; _btnPlaylist.Click += BtnPlaylistOnClick; _btnRepeat.Click += BtnRepeatOnClick; _btnShuffle.Click += BtnShuffleOnClick; _btnPlayPause.SetOnTouchListener(this); _btnPrevious.SetOnTouchListener(this); _btnNext.SetOnTouchListener(this); _btnPlaylist.SetOnTouchListener(this); _btnRepeat.SetOnTouchListener(this); _btnShuffle.SetOnTouchListener(this); _seekBar.StartTrackingTouch += SeekBarOnStartTrackingTouch; _seekBar.StopTrackingTouch += SeekBarOnStopTrackingTouch; _seekBar.ProgressChanged += SeekBarOnProgressChanged; // Get screen size Point size = new Point(); WindowManager.DefaultDisplay.GetSize(size); // Create bitmap cache int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024); int cacheSize = maxMemory / 12; _bitmapCache = new BitmapCache(this, cacheSize, size.X, size.X); // The album art takes the whole screen width // Match height with width (cannot do that in xml) //_imageViewAlbumArt.LayoutParameters = new ViewGroup.LayoutParams(_imageViewAlbumArt.Width, _imageViewAlbumArt.Width); if (bundle != null) { string state = bundle.GetString("key", "value"); Console.WriteLine("PlayerActivity - OnCreate - State is {0} - isInitialized: {1}", state, _isInitialized); } else { Console.WriteLine("PlayerActivity - OnCreate - State is null - isInitialized: {0}", _isInitialized); } // Don't try to check the bundle contents, if the activity wasn't destroyed, it will be null. //if (bundle != null) // Console.WriteLine("PlayerActivity - OnCreate - Bundle isn't null - value: {0}", bundle.GetString("key", "null")); //else // Console.WriteLine("PlayerActivity - OnCreate - Bundle is null!"); // When Android stops an activity, it recalls OnCreate after, even though the activity is not destroyed (OnDestroy). It actually goes through creating a new object (the ctor is called). //((AndroidNavigationManager)_navigationManager).SetPlayerActivityInstance(this); _navigationManager.BindPlayerView(MobileNavigationTabType.Playlists, this); // Activate lock screen if not already activated _messengerHub.PublishAsync<ActivateLockScreenMessage>(new ActivateLockScreenMessage(this, true)); _messengerHub.Subscribe<ApplicationCloseMessage>(message => { Console.WriteLine("PlayerActivity - Received ApplicationCloseMessage; closing activity of type {0}", this.GetType().FullName); }); }
private void drawSatValPanel(Canvas canvas) { /* * Draw time for this code without using bitmap cache and hardware acceleration was around 20ms. * Now with the bitmap cache and the ability to use hardware acceleration we are down at 1ms as long as the hue isn't changed. * If the hue is changed we the sat/val rectangle will be rendered in software and it takes around 10ms. * But since the rest of the view will be rendered in hardware the performance gain is big! */ RectF rect = mSatValRect; if (BORDER_WIDTH_PX > 0) { mBorderPaint.Color = new Color((int)mBorderColor); canvas.DrawRect(mDrawingRect.Left, mDrawingRect.Top, rect.Right + BORDER_WIDTH_PX, rect.Bottom + BORDER_WIDTH_PX, mBorderPaint); } if (mValShader == null) { //Black gradient has either not been created or the view has been resized. uint startColor = 0xFFFFFFFF; uint endColor = 0xFF000000; mValShader = new LinearGradient(rect.Left, rect.Top, rect.Left, rect.Bottom, new Color((int)startColor), new Color((int)endColor), Shader.TileMode.Clamp); } //If the hue has changed we need to recreate the cache. if (mSatValBackgroundCache == null || mSatValBackgroundCache.value != mHue) { if (mSatValBackgroundCache == null) { mSatValBackgroundCache = new BitmapCache(); } //We create our bitmap in the cache if it doesn't exist. if (mSatValBackgroundCache.bitmap == null) { mSatValBackgroundCache.bitmap = Bitmap.CreateBitmap((int)rect.Width(), (int)rect.Height(), Bitmap.Config.Argb8888); } //We create the canvas once so we can draw on our bitmap and the hold on to it. if (mSatValBackgroundCache.canvas == null) { mSatValBackgroundCache.canvas = new Canvas(mSatValBackgroundCache.bitmap); } int rgb = Color.HSVToColor(new float[] { mHue, 1f, 1f }); uint startColor = 0xFFFFFFFF; mSatShader = new LinearGradient(rect.Left, rect.Top, rect.Right, rect.Top, new Color((int)startColor), new Color(rgb), Shader.TileMode.Clamp); ComposeShader mShader = new ComposeShader(mValShader, mSatShader, PorterDuff.Mode.Multiply); mSatValPaint.SetShader(mShader); //ly we draw on our canvas, the result will be stored in our bitmap which is already in the cache. //Since this is drawn on a canvas not rendered on screen it will automatically not be using the hardware acceleration. //And this was the code that wasn't supported by hardware acceleration which mean there is no need to turn it of anymore. //The rest of the view will still be hardware accelerated!! mSatValBackgroundCache.canvas.DrawRect(0, 0, mSatValBackgroundCache.bitmap.Width, mSatValBackgroundCache.bitmap.Height, mSatValPaint); //We set the hue value in our cache to which hue it was drawn with, //then we know that if it hasn't changed we can reuse our cached bitmap. mSatValBackgroundCache.value = mHue; } //We draw our bitmap from the cached, if the hue has changed //then it was just recreated otherwise the old one will be used. canvas.DrawBitmap(mSatValBackgroundCache.bitmap, null, rect, null); Point p = satValToPoint(mSat, mVal); mSatValTrackerPaint.Color = Color.Black; canvas.DrawCircle(p.X, p.Y, PALETTE_CIRCLE_TRACKER_RADIUS - 1f * mDensity, mSatValTrackerPaint); mSatValTrackerPaint.Color = Color.LightGray; canvas.DrawCircle(p.X, p.Y, PALETTE_CIRCLE_TRACKER_RADIUS, mSatValTrackerPaint); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { float density = Resources.DisplayMetrics.Density; if (density == 3) density = 2; //Console.WriteLine("MLBFragment - OnCreateView"); _view = inflater.Inflate(Resource.Layout.MobileLibraryBrowser, container, false); // Get screen size Point size = new Point(); Activity.WindowManager.DefaultDisplay.GetSize(size); // Create bitmap cache int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024); BitmapCache = new BitmapCache(Activity, maxMemory / 8, size.X / 2, size.X / 2); // Max size = half the screen (grid has 2 columns) SmallBitmapCache = new BitmapCache(Activity, maxMemory / 16, 44 * (int)density, 44 * (int)density); _viewFlipper = _view.FindViewById<ViewFlipper>(Resource.Id.mobileLibraryBrowser_viewFlipper); _imageAlbum = _view.FindViewById<SquareImageView>(Resource.Id.mobileLibraryBrowser_imageAlbum); _lblBreadcrumb = _view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowser_lblBreadcrumb); _layoutAlbum = _view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowser_layoutAlbum); _layoutSongs = _view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowser_layoutSongs); _lblArtistName = _view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowser_lblArtistName); _lblAlbumTitle = _view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowser_lblAlbumTitle); _lblAlbumLength = _view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowser_lblAlbumLength); _lblAlbumSongCount = _view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowser_lblAlbumSongCount); _listViewArtists = _view.FindViewById<ListView>(Resource.Id.mobileLibraryBrowser_listViewArtists); _listViewSongs = _view.FindViewById<ListView>(Resource.Id.mobileLibraryBrowser_listViewSongs); _listViewPlaylists = _view.FindViewById<ListView>(Resource.Id.mobileLibraryBrowser_listViewPlaylists); _gridViewAlbums = _view.FindViewById<GridView>(Resource.Id.mobileLibraryBrowser_gridViewAlbums); _listAdapterArtists = new MobileLibraryBrowserListAdapter(Activity, this, _listViewArtists, _entities.ToList()); _listViewArtists.SetAdapter(_listAdapterArtists); _listViewArtists.ItemClick += ListViewOnItemClick; _listViewArtists.ItemLongClick += ListViewOnItemLongClick; _listAdapterSongs = new MobileLibraryBrowserListAdapter(Activity, this, _listViewSongs, _entities.ToList()); _listViewSongs.SetAdapter(_listAdapterSongs); _listViewSongs.ItemClick += ListViewOnItemClick; _listViewSongs.ItemLongClick += ListViewOnItemLongClick; _gridAdapter = new MobileLibraryBrowserGridAdapter(Activity, this, _gridViewAlbums, _entities.ToList()); _gridViewAlbums.SetAdapter(_gridAdapter); _gridViewAlbums.ItemClick += GridViewOnItemClick; _gridViewAlbums.ItemLongClick += GridViewOnItemLongClick; var navigationManager = (AndroidNavigationManager)Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); navigationManager.BindMobileLibraryBrowserView(this, _tabType, _browserType, _query); return _view; }
protected override void OnCreate(Bundle bundle) { Console.WriteLine("MainActivity - OnCreate"); base.OnCreate(bundle); _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); _messengerHub.Subscribe<MobileLibraryBrowserItemClickedMessage>(MobileLibraryBrowserItemClickedMessageReceived); RequestWindowFeature(WindowFeatures.ActionBar); SetContentView(Resource.Layout.Main); _actionBarSpinnerAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.action_list, Resource.Layout.actionbar_spinner_item); ActionBar.NavigationMode = ActionBarNavigationMode.List; ActionBar.Title = string.Empty; ActionBar.SetListNavigationCallbacks(_actionBarSpinnerAdapter, this); ActionBar.SetSelectedNavigationItem(1); _viewFlipper = FindViewById<ViewFlipper>(Resource.Id.main_viewflipper); _miniPlayer = FindViewById<LinearLayout>(Resource.Id.main_miniplayer); _miniPlaylist = FindViewById<LinearLayout>(Resource.Id.main_miniplaylist); _lblArtistName = FindViewById<TextView>(Resource.Id.main_miniplayer_lblArtistName); _lblAlbumTitle = FindViewById<TextView>(Resource.Id.main_miniplayer_lblAlbumTitle); _lblSongTitle = FindViewById<TextView>(Resource.Id.main_miniplayer_lblSongTitle); //_lblNextArtistName = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextArtistName); //_lblNextAlbumTitle = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextAlbumTitle); //_lblNextSongTitle = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextSongTitle); _lblPlaylistCount = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblPlaylistCount); _btnPrevious = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnPrevious); _btnPlayPause = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnPlayPause); _btnNext = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnNext); _btnPlaylist = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnPlaylist); _btnShuffle = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnShuffle); _btnRepeat = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnRepeat); _btnLeft = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnLeft); _cboPlaylist = FindViewById<Spinner>(Resource.Id.main_miniplaylist_cboPlaylist); _btnRight = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnRight); _imageAlbum = FindViewById<SquareImageView>(Resource.Id.main_miniplayer_imageAlbum); _miniPlayer.Click += (sender, args) => _messengerHub.PublishAsync<MobileNavigationManagerCommandMessage>(new MobileNavigationManagerCommandMessage(this, MobileNavigationManagerCommandMessageType.ShowPlayerView)); _btnLeft.SetOnTouchListener(this); _btnRight.SetOnTouchListener(this); _btnPrevious.SetOnTouchListener(this); _btnPlayPause.SetOnTouchListener(this); _btnNext.SetOnTouchListener(this); _btnPlaylist.SetOnTouchListener(this); _btnShuffle.SetOnTouchListener(this); _btnRepeat.SetOnTouchListener(this); _btnPrevious.Click += (sender, args) => OnPlayerPrevious(); _btnPlayPause.Click += (sender, args) => OnPlayerPlayPause(); _btnNext.Click += (sender, args) => OnPlayerNext(); _btnPlaylist.Click += (sender, args) => OnOpenPlaylist(); _btnShuffle.Click += (sender, args) => OnPlayerShuffle(); _btnRepeat.Click += (sender, args) => OnPlayerRepeat(); _btnLeft.Click += BtnLeftOnClick; _btnRight.Click += BtnRightOnClick; // Set initial view flipper item int realIndex = _viewFlipper.IndexOfChild(_miniPlayer); _viewFlipper.DisplayedChild = realIndex; // Create bitmap cache Point size = new Point(); WindowManager.DefaultDisplay.GetSize(size); int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024); int cacheSize = maxMemory / 16; BitmapCache = new BitmapCache(this, cacheSize, size.X / 6, size.X / 6); _playlistSpinnerAdapter = new ArrayAdapter<string>(this, Resource.Layout.playlist_spinner_item, new string[2] {"Hello", "World"}); _cboPlaylist.Adapter = _playlistSpinnerAdapter; _cboPlaylist.ItemSelected += CboPlaylistOnItemSelected; Console.WriteLine("MainActivity - OnCreate - Binding presenters..."); var navigationManager = (AndroidNavigationManager)Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); navigationManager.MainActivity = this; // Watch out, this can lead to memory leaks! navigationManager.BindOptionsMenuView(this); navigationManager.BindPlayerStatusView(this); navigationManager.BindMobileMainView(this); }