public override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); switch (requestCode) { case 2: if (resultCode == Result.Ok && data != null) { Android.Net.Uri uri = data.Data; try { BackgroundFactory background = new BackgroundFactory(); background.SaveImagePath(uri); background = null; Log.Info("tag", "Path sent to BackgroundFactory"); } catch { } } else { Log.Info("LiveDisplay", "Data was null"); using (ConfigurationManager configurationManager = new ConfigurationManager(sharedPreferences)) { configurationManager.SaveAValue(ConfigurationParameters.ChangeWallpaper, "0"); } } break; } }
public List <BackgroundModel> GetAllBackgrounds() { List <BackgroundModel> backgrounds = new List <BackgroundModel>(); using (SQLiteConnection db = new SQLiteConnection(dbArgs)) { db.Open(); using (SQLiteDataReader reader = new SQLiteCommand("SELECT * from backgrounds", db).ExecuteReader()) { while (reader.Read()) { backgrounds.Add(BackgroundFactory.NewBackgroundModel( reader.GetInt32(0), reader.GetString(1), reader.GetString(2), (BaseDirectoryType)reader.GetInt32(3), Convert.ToBoolean(reader.GetInt32(4)), (ScreenLayoutType)reader.GetInt32(5))); } reader.Close(); } db.Close(); } return(backgrounds); }
public void Execute() { string fileName = Path.GetFileName(args.FilePath); if (File.Exists(Path.Combine(locationModel.LocalDirectoryBackgrounds, fileName))) { fileName = GetUnusedName(locationModel.LocalDirectoryBackgrounds, fileName); } string destinationFileName = $"{Path.GetFileNameWithoutExtension(fileName)}.jpg"; string destinationPath = Path.Combine(locationModel.LocalDirectoryBackgrounds, destinationFileName); BitmapImage originalBitmap = new BitmapImage(new Uri(args.FilePath)); if (!args.CropArea.IsEmpty) { SaveJpeg(CropBitmap(originalBitmap, args.CropArea), destinationPath); } else { SaveJpeg(originalBitmap, destinationPath); } BackgroundModel background = BackgroundFactory.NewBackgroundModel(args.Name, destinationFileName, BaseDirectoryType.BACKGROUNDS_DIRECTORY, false, args.Layout); database.AddBackground(background); collection.Add(background); screenModel.SetBackground(background); Injector.ExecuteCommand <ValidatePlaceholderCollectionCommand>(new CollectionEventArgs <PlaceholderModel>(0, placeholderCollection, placeholderCollection.Items.ToArray())); }
public static GameObject CheckBackgroundObjects(Entity entity) { switch (entity.Type) { case "SmallHill": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.SmallHill)); case "BigHill": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.BigHill)); case "SmallBush": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.SmallBush)); case "BigBush": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.BigBush)); case "SmallCloud": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.SmallCloud)); case "BigCloud": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.BigCloud)); case "SmallTree": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.SmallTree)); case "BigTree": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.BigTree)); case "Black": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.BlackBackground)); case "Castle": return(new BackgroundObject(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), BackgroundTypes.Castle)); case "Flag": return(new Flag(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y))); case "Flag Segment 1": return(new FlagSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), 200)); case "Flag Segment 2": return(new FlagSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), 400)); case "Flag Segment 3": return(new FlagSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), 600)); case "Flag Segment 4": return(new FlagSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), 800)); case "Flag Segment 5": return(new FlagSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), 1000)); case "Flag Segment 6": return(new FlagSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), 1200)); default: return(null); } }
void CreateBackGround() { if (BackgroundFactory != null) { var background = BackgroundFactory.Create(this); SetCameraPosition(background.Center); } }
public static GameObject CheckBlocks(Entity entity) { switch (entity.Type) { case "BrickBlock": return(new BrickBlock(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "FloorBlock": return(new FloorBlock(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "HiddenBlock": GameObject block = new QuestionBlock(BlockFactory.GetInstance(), new Point(entity.X, entity.Y)); return(new HiddenBlock((Block)block)); case "PyramidBlock": return(new PyramidBlock(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "QuestionBlock": return(new QuestionBlock(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "Pipe": return(new SmallPipe(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), new Vector2())); case "CopperPipe": GameObject obj = new SmallPipe(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), new Vector2()); obj.Sprite = BackgroundFactory.GetInstance().CreateProduct(BackgroundTypes.CopperPipe); return(obj); case "MediumPipe": return(new MediumPipe(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), new Vector2())); case "PipeSegment": return(new PipeSegment(BackgroundFactory.GetInstance(), new Point(entity.X, entity.Y), new Vector2())); case "Win Block": return(new WinBlock(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "Gate": return(new Gate(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "Button": return(new Button(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "InvertedButton": return(new Button(true, BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); case "CompanionCube": return(new CompanionCube(BlockFactory.GetInstance(), new Point(entity.X, entity.Y))); default: return(null); } }
public override void Draw(SpriteBatch spriteBatch) { if (!this.ShouldUpdate) { spriteBatch.Begin(samplerState: SamplerState.PointClamp); ISprite background = BackgroundFactory.GetInstance().CreateProduct(BackgroundTypes.BlackBackground); background.Draw(spriteBatch, new Color(100, 100, 100, 175), Point.Zero); int x = (VirtualWidth - pausedTexture.Width) / 2; int y = (VirtualHeight - pausedTexture.Height) / 5; spriteBatch.Draw(pausedTexture, new Rectangle(x, y, pausedTexture.Width, pausedTexture.Height), Color.White); Texture2D staticMario = ((Sprite) FireMarioFactory.GetInstance().CreateProduct(MarioTypes.IdleRight)).GetTexture(); spriteBatch.Draw(staticMario, new Vector2((float)((VirtualWidth - 96) * 0.5), (float)((VirtualHeight - 200) * 0.6)), new Rectangle(new Point(384, 161), new Point(47, 80)), Color.White, 0, Vector2.Zero, new Vector2(2, 2), SpriteEffects.None, 0f); SpriteFont font = this.Game.Content.Load<SpriteFont>("Font/Mario Game HUD Text"); string name = CostumeChanger.GetInstance().CurrentName(); Texture2D leftButton = Game.Content.Load<Texture2D>("Textures/Left"); Texture2D rightButton = Game.Content.Load<Texture2D>("Textures/Right"); spriteBatch.Draw(leftButton, new Vector2(125, 250), Color.White); spriteBatch.Draw(rightButton, new Vector2(325, 250), Color.White); Vector2 strSize = font.MeasureString(name); int strWidth = (int) Math.Round(strSize.X); int strHeight = (int)Math.Round(strSize.Y); Vector2 position = new Vector2 { X = ((float)(VirtualWidth - strWidth) / 2), Y = ((float)(VirtualHeight - strHeight) / 2) + 125 }; spriteBatch.DrawString(font, string.Format(name), position, Color.White); spriteBatch.End(); } }
public void Execute() { List <BackgroundModel> backgrounds = database.GetAllBackgrounds(); if (backgrounds.Count == 0) { BackgroundModel defaultBackground = BackgroundFactory.NewBackgroundModel("Default", "background.png", BaseDirectoryType.GRAPHICAL_ASSETS, true, ScreenLayoutType.SINGLE); backgroundCollection.AddRange(new List <BackgroundModel>(new BackgroundModel[] { defaultBackground })); database.AddBackground(defaultBackground); screenModel.SetBackground(defaultBackground); } else { backgroundCollection.AddRange(backgrounds); screenModel.SetBackground(backgrounds[0]); } }
private void UnbindViews() { linearLayout = null; recycler = null; tvTitulo = null; tvTexto = null; v = null; wallpaperManager = null; papelTapiz = null; layoutManager = null; lockScreenInstance = null; backgroundFactory = null; fecha = null; dia = null; mes = null; notificationAction = null; }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { if (resultCode == Result.Ok && data != null) { Android.Net.Uri uri = data.Data; try { BackgroundFactory background = new BackgroundFactory(); background.SaveImagePath(uri); background = null; Log.Info("tag", "Path sent to BackgroundFactory"); var imagePath = configurationManager.RetrieveAValue(ConfigurationParameters.ImagePath, ""); if (imagePath != "") { ThreadPool.QueueUserWorkItem(m => { Bitmap bitmap = BitmapFactory.DecodeFile(configurationManager.RetrieveAValue(ConfigurationParameters.ImagePath, imagePath)); defaultBlurLevel = configurationManager.RetrieveAValue(ConfigurationParameters.BlurLevel, 1); defaultOpacityLevel = configurationManager.RetrieveAValue(ConfigurationParameters.OpacityLevel, 255); BlurImage blurImage = new BlurImage(Application.Context); blurImage.Load(bitmap).Intensity(defaultBlurLevel); Drawable drawable = new BitmapDrawable(Resources, blurImage.GetImageBlur()); RunOnUiThread(() => { wallpaperPreview.Background = drawable; wallpaperPreview.Background.Alpha = defaultBlurLevel; } ); }); } } catch { configurationManager.SaveAValue(ConfigurationParameters.ChangeWallpaper, "0"); //Black wallpaper. } } else { Log.Info("LiveDisplay", "Data was null"); configurationManager.SaveAValue(ConfigurationParameters.ChangeWallpaper, "0"); //Black wallpaper. } base.OnActivityResult(requestCode, resultCode, data); }
private void InicializarValores() { //Propiedades de la ventana: Barra de estado odulta y de Navegación traslúcida Window.AddFlags(WindowManagerFlags.TranslucentNavigation); Window.AddFlags(WindowManagerFlags.Fullscreen); wallpaperManager = WallpaperManager.GetInstance(this); papelTapiz = wallpaperManager.Drawable; backgroundFactory = new BackgroundFactory(); linearLayout.Background = backgroundFactory.Difuminar(papelTapiz); layoutManager = new LinearLayoutManager(this); recycler.SetLayoutManager(layoutManager); RunOnUiThread(() => recycler.SetAdapter(Catcher.adapter)); fecha = Calendar.GetInstance(Locale.Default); dia = fecha.Get(CalendarField.DayOfMonth).ToString(); mes = fecha.GetDisplayName(2, 2, Locale.Default); tvFecha.Text = string.Format(dia + ", " + mes); lockScreenInstance = this; }
Captcha(bool createBuilder, Config config) { // the createBuilder is false when the object has been created from the builder // and true when a public constructor is used instead if (createBuilder) { if (config == null) { throw new ArgumentNullException("config", "Configuration object can't be null"); } new Builder(this) .Background(BackgroundFactory.Create(config)) .Keygen(KeygenFactory.Create(config)) .Drawer(DrawerFactory.Create(config)) .Filters(FilterFactory.Create(config)) .Build(); } }
private void Awake() { m_bgFactory = GetComponentInChildren <BackgroundFactory>(); }