internal Fb2EPubTextConverterV2(IEPubCommonSettings commonSettings, ImageManager images, HRefManagerV2 referencesManager, ulong maxSize) { _commonSettings = commonSettings; _images = images; _referencesManager = referencesManager; _maxSize = maxSize; }
public Cube(int blocktype, ImageManager imageManager) : base(imageManager) { this.imageManager = imageManager; Sprite = new Sprite(imageManager.GetImage("tileset")); setType(blocktype); }
public Fb2EPubTextConverterV3(IEPubCommonSettings commonSettings, ImageManager images, HRefManagerV3 referencesManager,IEPubV3Settings v3Settings) { _commonSettings = commonSettings; _images = images; _referencesManager = referencesManager; _v3Settings = v3Settings; _notesManager = new FBNotesManager(v3Settings,images,referencesManager); }
void Start() { root = GameObject.Find("UI Root"); ps = transform.GetComponent<PanelSwitch>(); tm = transform.GetComponent<TextManager>(); im = transform.GetComponent<ImageManager>(); playerdata = new UserData(); for(int i = 0; i < 7; i++) { girl[i] = new GirlData(i); } }
public World(ImageManager imageManager) { this.imageManager = imageManager; playerList = new List<Player>(); cubeLists = new List<List<Cube>>(); quadTrees = new List<QuadTree>(); for (int i = 0; i < LAYERNBR; i++) { cubeLists.Add(new List<Cube>()); quadTrees.Add(new QuadTree(10, new Vector2f(90, 90))); } }
public Player(World world, ImageManager imageManager) : base(imageManager) { this.world = world; Sprite = new Sprite(imageManager.GetImage("player")); size = new Vector2f(sprite.Width - 2, sprite.Height); offset = new Vector2f(-1, 0); leftPupil = new Sprite(imageManager.GetImage("pupil")); rightPupil = new Sprite(imageManager.GetImage("pupil")); colorMask = new Sprite(imageManager.GetImage("colorMask")); Random randomiser = new Random(); byte[] rgb = new byte[3]; randomiser.NextBytes(rgb); colorMask.Color = new Color(rgb[0], rgb[1], rgb[2]); leftPupilOrigin = new Vector2f(5, 9); rightPupilOrigin = new Vector2f(20, 9); leftPupilPosition = leftPupilOrigin; rightPupilPosition = rightPupilOrigin; }
/// <summary> /// Set the Image to be used for the mouse cursor when a drag operation is /// in progress. /// <para> /// This method may be used during a drag operation to update the current mouse /// cursor image. /// </para> /// </summary> /// <param name="name"> /// Image to be used as the mouse cursor when dragging. /// </param> /// <exception cref="UnknownObjectException"> /// thrown if Image \name is unknown. /// </exception> public void SetDragCursorImage(string name) { SetDragCursorImage(ImageManager.GetSingleton().Get(name)); }
public static Image GFXItem(uint GID) { var id = RuntimeHelpers.GetObjectValue(ObjectDataManager.Instance.Get <Item>(GID).IconId); return(ImageManager.GetImage(Convert.ToInt32(id))); }
public void PreviousImage(object param) { viewModel.Image = ImageManager.GetPreviousImage(); }
public ActionResult AddGaleryImage(GaleryImageModel model) { if (ModelState.IsValid) { if (model.GaleryImg.ContentLength > 0) { var image = model.GaleryImg; var fileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(image.FileName); var imageDirectory = Server.MapPath("~/Content/Images/uploads/Galery/" + model.Galery.Id); var imageDirectorySmall = Server.MapPath("~/Content/Images/uploads/Galery/" + model.Galery.Id + "/Small"); var imageDirectoryMiddle = Server.MapPath("~/Content/Images/uploads/Galery/" + model.Galery.Id + "/Middle"); var imageDirectoryBig = Server.MapPath("~/Content/Images/uploads/Galery/" + model.Galery.Id + "/Big"); // dizin yoksa oluştur. if (!Directory.Exists(imageDirectory)) { Directory.CreateDirectory(imageDirectory); Directory.CreateDirectory(imageDirectorySmall); Directory.CreateDirectory(imageDirectoryMiddle); Directory.CreateDirectory(imageDirectoryBig); } // resmi sunucuya kaydet image.SaveAs(Path.Combine(imageDirectory, fileName)); // resmi küçük boyutta kaydet ImageManager.SaveResizedImage(Image.FromFile(Path.Combine(imageDirectory, fileName)), new Size(180, 180), imageDirectorySmall, fileName); ImageManager.SaveResizedImage(Image.FromFile(Path.Combine(imageDirectory, fileName)), new Size(360, 360), imageDirectoryMiddle, fileName); ImageManager.SaveResizedImage(Image.FromFile(Path.Combine(imageDirectory, fileName)), new Size(720, 720), imageDirectoryBig, fileName); var galeryImage = new GaleryImage(); galeryImage.ContentSize = image.ContentLength; galeryImage.ContentType = image.ContentType; galeryImage.FileName = fileName; galeryImage.GaleryId = model.Galery.Id; galeryImage.InsertDate = DateTime.Now; galeryImage.InsertUserId = CustomMembership.CurrentUser().Id; galeryImage.IsActive = true; galeryImage.Order = model.Order; galeryImage.ImgUrl = Path.Combine("Content/Images/uploads/Galery/" + model.Galery.Id, fileName); galeryImage.ImgUrlSmall = Path.Combine("Content/Images/uploads/Galery/" + model.Galery.Id + "/Small", fileName); galeryImage.ImgUrlMiddle = Path.Combine("Content/Images/uploads/Galery/" + model.Galery.Id + "/Middle", fileName); galeryImage.ImgUrlBig = Path.Combine("Content/Images/uploads/Galery/" + model.Galery.Id + "/Big", fileName); try { _galeryService.Insert(galeryImage); _uow.SaveChanges(); messagesForView.Clear(); messagesForView.Add("İşlemi başarılı!"); Success(messagesForView); } catch (Exception ex) { messagesForView.Clear(); messagesForView.Add("İşlem başarısız!"); messagesForView.Add(ex.Message); messagesForView.Add(ex.InnerException.Message); Error(messagesForView); } } } return(RedirectToAction("GaleryImages", new { galeryId = model.Galery.Id })); }
//public async Task<IActionResult> Details(int? id) public async Task <IActionResult> Details(int?id, bool disableHotShot) { if (id == null) { return(NotFound()); } var product = await _context.Products .Include(p => p.Brand) .Include(p => p.Category) .ThenInclude(d => d.Section) .Include(p => p.Gallery) .FirstOrDefaultAsync(m => m.ProductId == id); var isHotShot = _context.HotShots.Any(d => d.StartDate <DateTime.Now && d.EndDate> DateTime.Now && d.Quantity > d.ItemsSold && d.ProductId == product.ProductId); if (disableHotShot) { isHotShot = false; } HotShot hotShot = null; if (isHotShot) { hotShot = await _context.HotShots.Include(d => d.Product.Gallery.ImageGalleries) .ThenInclude(d => d.Image) .FirstOrDefaultAsync(d => d.StartDate <DateTime.Now && d.EndDate> DateTime.Now); } if (product == null) { return(NotFound()); } var ratings = _context.Ratings.Where(d => d.ProductId == product.ProductId); var sum = await ratings.SumAsync(d => d.Value); var ratingCount = await ratings.CountAsync(); var avg = 0; if (ratingCount > 0) { avg = sum / ratingCount; } //formattedEndDate = hotShot.EndDate.ToString("yyyy-MM-dd HH:mm:ss"); var model = new ProductDetailsViewModel() { Product = product, Tags = await TagManager.GetTagNameWithValues(_context, product), Images = await ImageManager.GetImagesForProduct(_context, (int)id), IsHotShot = isHotShot, HotShot = hotShot, FormattedDate = hotShot?.EndDate.ToString("yyyy-MM-dd HH:mm:ss"), Ratings = avg, RatingsCount = ratingCount }; return(View(model)); }
/// <summary> /// Initializes the static fields of <see cref="RawImageManager"/> /// </summary> static RawImageManager() { Instance = new RawImageManager(); }
void Awake() { DontDestroyOnLoad(gameObject); if (instance != null && instance != this) { Destroy(gameObject); return; } else { instance = this; } }
public HomeController(ImageManager imageManager) { this._imageManager = imageManager; }
private void InitializeInstanceFields() { mImageSaver = new ImageSaver(this, this); mImageManager = new ImageManager(this, this); }
/// <summary> /// Given a list of post this gets the images and puts them into file cache. /// </summary> /// <param name="posts"></param> /// <param name="isLockScreen"></param> /// <returns></returns> private async void GetImagesFromPosts(List <Post> posts, UpdateTypes type) { // First, remove all of the existing images try { await DeleteAllCacheImages(type); } catch (Exception e) { m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "FailedToDeleteCacheImages", e); } // Setup the vars if (type == UpdateTypes.LockScreen) { m_lockScreenRequestCount = 0; m_lockScreenDoneCount = 0; } else if (type == UpdateTypes.Band) { m_bandRequestCount = 0; m_bandDoneCount = 0; } else { m_desktopRequestCount = 0; m_desktopDoneCount = 0; } // Figure out all of the images we need to request. List <Tuple <string, string> > imageRequestList = new List <Tuple <string, string> >(); foreach (Post post in posts) { string imageUrl = ImageManager.GetImageUrl(post.Url); if (!String.IsNullOrWhiteSpace(imageUrl)) { imageRequestList.Add(new Tuple <string, string>(imageUrl, post.Id)); } if (imageRequestList.Count > c_maxImageCacheCount) { break; } } // Now set our request counts before we start requesting. We must do this to ensure // the numbers are correct when the request come back. if (type == UpdateTypes.LockScreen) { m_lockScreenRequestCount = imageRequestList.Count; } else if (type == UpdateTypes.Band) { m_bandRequestCount = imageRequestList.Count; } else { m_desktopRequestCount = imageRequestList.Count; } // Now make all of the request. foreach (Tuple <string, string> request in imageRequestList) { // Make the request ImageManager.ImageManagerRequest imageRequst = new ImageManager.ImageManagerRequest() { Url = request.Item1, ImageId = request.Item2, Context = type }; imageRequst.OnRequestComplete += OnRequestComplete; m_baconMan.ImageMan.QueueImageRequest(imageRequst); } // If we have nothing to request this is the end of the line for this type. if (imageRequestList.Count == 0) { // And kill the deferral ReleaseDeferral(type); // And set us to stopped. UnSetIsRunningIfDone(); } }
public IActionResult AddAdvertisementSubmit(Advertisement myAdvertisement, int mySponsorId, String adSize, IFormFile imgFile) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } ImageManager imageManager = new ImageManager(environment, "images"); if (!ModelState.IsValid) { return(RedirectToAction("AddAdvertisement")); } //submit new ad to db if (adSize == "full") { myAdvertisement.adSize = "full"; } else if (adSize == "half") { myAdvertisement.adSize = "half"; } else if (adSize == "quarter") { myAdvertisement.adSize = "quarter"; } myAdvertisement.date = DateTime.Now; int result = imageManager.uploadImage(imgFile); switch (result) { case 1: Console.WriteLine("\n\n\n*** Wrong File Type! ***"); ViewData["feedback"] = "Wrong File Type"; return(RedirectToAction("AddAdvertisement")); case 2: Console.WriteLine("\n\n\n*** File Too Large! ***"); ViewData["feedback"] = "File Too Large"; return(RedirectToAction("AddAdvertisement")); case 3: Console.WriteLine("\n\n\n*** File Name Too Long! ***"); ViewData["feedback"] = "File Name Too Long"; return(RedirectToAction("AddAdvertisement")); case 4: Console.WriteLine("\n\n\n*** Error Saving File! ***"); ViewData["feedback"] = "Error Saving File"; return(RedirectToAction("AddAdvertisement")); case 5: ViewData["feedback"] = "Success"; myAdvertisement.imgFile = imageManager.fileName; revenueManager.Add(myAdvertisement); revenueManager.SaveChanges(); //build rel with sponsor AdvertRelations rel = new AdvertRelations(); rel.sponsorId = mySponsorId; rel.adId = revenueManager.newAdId(); revenueManager.Add(rel); revenueManager.SaveChanges(); return(RedirectToAction("ViewAdvertisements")); default: Console.WriteLine("\n\n\n*** No File Selected! ***"); ViewData["feedback"] = "No File Selected"; return(RedirectToAction("AddAdvertisement")); } }
/// <summary> /// Set image manager implementation to use. /// </summary> /// <param name="impl">Implementation to use.</param> public static void SetImplementation(ImageManager impl) { implementation = impl; }
/// <summary> /// Initializes the static fields of <see cref="WinFormsImageManager"/> /// </summary> static WinFormsImageManager() { Instance = new WinFormsImageManager(); }
/// <summary> /// Fired when an image request is done. /// </summary> /// <param name="sender"></param> /// <param name="response"></param> public async void OnRequestComplete(object sender, ImageManager.ImageManagerResponseEventArgs response) { // Remove event listener ImageManager.ImageManagerRequest request = (ImageManager.ImageManagerRequest)sender; request.OnRequestComplete -= OnRequestComplete; UpdateTypes type = (UpdateTypes)response.Request.Context; // Make sure we were successfully. if (response.Success) { try { // Get the target size Size targetImageSize = LastKnownScreenResoultion; if (type == UpdateTypes.Band) { if(m_baconMan.BackgroundMan.BandMan.BandVersion == BandVersions.V1) { targetImageSize = new Size(310, 102); } else { targetImageSize = new Size(310, 128); } } else if(type == UpdateTypes.Desktop && DeviceHelper.CurrentDevice() == DeviceTypes.Mobile) { // If we are desktop on mobile we want to do a bit larger than the screen res because // there is a sliding image animation when you switch to all apps. Lets make the width 30% larger. targetImageSize.Width *= 1.3; } // Resize the image to fit nicely InMemoryRandomAccessStream image = await ResizeImage(response.ImageStream, targetImageSize); // Write the file await WriteImageToFile(image, type); } catch (Exception e) { m_baconMan.MessageMan.DebugDia("Failed to write background image", e); m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "Failed to write background image", e); } } // Indicate that this image is done. bool isDone = false; lock (m_getImageLock) { if(type == UpdateTypes.LockScreen) { m_lockScreenDoneCount++; isDone = m_lockScreenDoneCount >= m_lockScreenRequestCount; } else if(type == UpdateTypes.Band) { m_bandDoneCount++; isDone = m_bandDoneCount >= m_bandRequestCount; } else { m_desktopDoneCount++; isDone = m_desktopDoneCount >= m_desktopRequestCount; } } // if we are done done then tell the images to rotate and clean up. if(isDone) { // Set this high so we roll over. if(type == UpdateTypes.LockScreen) { CurrentLockScreenRotationIndex = 99; } else if (type == UpdateTypes.Band) { CurrentBandRotationIndex = 99; } else { CurrentDesktopRotationIndex = 99; } // Do the rotate await DoImageRotation(type); // If this is a lock screen update this might also be a desktop update. This happens when the lock screen and desktop // share the same subreddit, they share the same images. if (type == UpdateTypes.LockScreen && IsDeskopEnabled && LockScreenSubredditName.Equals(DesktopSubredditName)) { // Off set the two so they don't show the same image CurrentDesktopRotationIndex = 1; // We also need to update the desktop. await DoImageRotation(UpdateTypes.Desktop); } // We are done, set the last update time LastFullUpdate = DateTime.Now; // And kill the deferral ReleaseDeferral(type); // And set us to stopped. UnSetIsRunningIfDone(); } }
/// <summary> /// Sets the posts to the UI. /// </summary> /// <param name="startingPos"></param> /// <param name="newPosts"></param> private async void SetPosts(int startingPos, List <Post> newPosts, bool isFreshUpdate) { // Dispatch to the UI thread await global::Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Setup the insert int insertIndex = startingPos; // Lock the list lock (m_postsLists) { // Set up the objects for the UI foreach (Post post in newPosts) { // Check if we are adding or inserting. bool isReplace = insertIndex < m_postsLists.Count; // If this is a replace and the urls are the same just set the image if (isReplace && post.Url == m_postsLists[insertIndex].Url) { post.Image = m_postsLists[insertIndex].Image; post.ImageVisibility = m_postsLists[insertIndex].ImageVisibility; } else { // Request the image if there is one if (ImageManager.IsThumbnailImage(post.Thumbnail)) { ImageManager.ImageManagerRequest request = new ImageManager.ImageManagerRequest() { Url = post.Thumbnail, ImageId = post.Id }; request.OnRequestComplete += OnRequestComplete; App.BaconMan.ImageMan.QueueImageRequest(request); } } if (isReplace) { if (m_postsLists[insertIndex].Id.Equals(post.Id)) { // If the post is the same, just update the UI vars. // If we replace the entire post the UI freaks out. m_postsLists[insertIndex].Score = post.Score; m_postsLists[insertIndex].TitleTextColor = post.TitleTextColor; m_postsLists[insertIndex].Title = post.Title; m_postsLists[insertIndex].Likes = post.Likes; m_postsLists[insertIndex].SubTextLine1 = post.SubTextLine1; m_postsLists[insertIndex].NewCommentText = post.NewCommentText; m_postsLists[insertIndex].SubTextLine2PartOne = post.SubTextLine2PartOne; m_postsLists[insertIndex].SubTextLine2PartTwo = post.SubTextLine2PartTwo; } else { // Replace the current item m_postsLists[insertIndex] = post; } } else { // Add it to the end m_postsLists.Add(post); } insertIndex++; } // If it was a fresh update, remove anything past the last story sent. while (isFreshUpdate && m_postsLists.Count > newPosts.Count) { m_postsLists.RemoveAt(m_postsLists.Count - 1); } } }); }
public async void OnRequestComplete(ImageManager.ImageManagerResponse response) { // Make sure we were successfully. if (!response.Success) { return; } // Get a unique name for this image int imageCount = 0; lock(m_getImageLock) { imageCount = m_imageReturnCount; m_imageReturnCount++; } // Get the file name string imageFileName = imageCount + ".jpg"; try { // Write the file await WriteImageToFile(response.ImageStream, imageFileName, m_isCurrentImageRequestLockScreen); } catch(Exception e) { m_baconMan.MessageMan.DebugDia("Failed to write background image", e); m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "Failed to write background image", e); } // Add the file to the list lock (m_getImageLock) { // Report we are done m_imageDoneCount++; // Check to see if we were last if(m_imageDoneCount == c_maxImageCacheCount) { m_autoReset.Set(); } } }
public ImageManagerTests() { ImageManager = new ImageManager(); }
public void Upload(int chartID, int type, string imageData) { try { // base.LogExceptionOnly(Session["CurrentUserID"] == null ? "IMAGEPROCESSOR SERVICE -- SESSION IS NULL" : string.Format("IMAGEPROCESSOR SERVICE -- SESSION == {0}", Session["CurrentUserID"])); int currentUserID = UserSessionWrapper.CurrentUserID; if (currentUserID == -1) { throw new Exception("App Timeout"); } else { // we only check to see if it is "In Process" and if it is not -- default to published OrganizationChartTypeViews selectedChartView = (type == (int)OrganizationChartTypeViews.InProcess) ? OrganizationChartTypeViews.InProcess : OrganizationChartTypeViews.Published; byte[] imageByteData = Convert.FromBase64String(imageData); // convert from base64 using (MemoryStream ms = new MemoryStream(imageByteData)) { //////------------------------------------------------------------------------------ ////// FOR TESTING PURPOSES ONLY: Temporarily save image for offline review ////using (Image chartImage = Image.FromStream(ms)) ////{ //// // save image to generated directory //// chartImage.Save(@"C:\HCMS\HCMS.OrgChart\Processing\Generated\" + string.Format("testImage_{0}_{1}_{2}.png", chartImage.Width, chartImage.Height, chartImage.PixelFormat.ToString())); ////} //////------------------------------------------------------------------------------ using (Bitmap bmp = new Bitmap(ms)) { PixelFormat selectedPixelFormat = PixelFormat.Format32bppArgb; using (Bitmap trimmedBMP = ImageManager.CropWhitespaceAndAlpha(bmp, selectedPixelFormat)) { byte[] trimmedByteData = ImageManager.ConvertToByteArray(trimmedBMP, ImageFormat.Png); // store in database -- cleaner than file system // allows it to work in load-balanced environments with no issues TemporaryDocument newDocument = new TemporaryDocument() { UserID = currentUserID, DocumentData = trimmedByteData }; Guid newGuidValue = TemporaryDocumentRepository.Instance.Save(newDocument); ChartGenerationParametersSessionWrapper.Parameters = new ChartGenerationParameters() { ID = chartID, ChartType = selectedChartView, DocumentID = newGuidValue }; } } } // Normally, we would allow garbage collection to happen as dictated by the sytem // We need to call it now due to the vast amount of memory used in the previous operation // Test and monitor the following GC.Collect(); } } catch (Exception ex) { if (!(ex is ThreadAbortException)) { if (ex is OutOfMemoryException) { throw new Exception("MemoryException"); } else { if (ex.Message == "App Timeout") { throw ex; } else { if (ex.InnerException == null) { base.LogExceptionOnly(ex); } else { base.LogExceptionOnly(ex.InnerException); } // throw new Exception("We've encountered an error while processing your request. Please contact the system administrator."); throw; } } } } }
static ImageTestProgram() { ImageManager.SetImplementation(WinFormsImageManager.Instance); }
public ImagesApiController(ImageManager imageMgr) { this.imageMgr = imageMgr; }
public void NextImage(object param) { viewModel.Image = ImageManager.GetNextImage(); }
public Knife(ImageManager manager) { image_manager = manager; Initialize(); }
/// <summary> /// Survient lorsque le formulaire devient visible /// </summary> public void InitializeDBSystem() { //Code de chargement Project = GameCore.Instance.Game.Project.Clone(); //Désactiver events rscMainMenuMusic.ValueChanged -= new EventHandler(rscMainMenuMusic_ValueChanged); rscGameOverMusic.ValueChanged -= new EventHandler(rscGameOverMusic_ValueChanged); rscChoiceButtonSound.ValueChanged -= new EventHandler(rscChoiceButtonSound_ValueChanged); rscMovementButtonSound.ValueChanged -= new EventHandler(rscMovementButtonSound_ValueChanged); rscLifeBar.ValueChanged -= new EventHandler(rscLifeBar_ValueChanged); rscLifeBarDeco.ValueChanged -= new EventHandler(rscLifeBarDeco_ValueChanged); txtTitle.TextChanged -= new EventHandler(txtTitle_TextChanged); rscSystemGUI.ValueChanged -= new EventHandler(rscSystemGUI_ValueChanged); txtAuthor.TextChanged -= new EventHandler(txtAuthor_TextChanged); crdLifeBar.ValueChanged -= new EventHandler(crdLifeBar_ValueChanged); radMov4.CheckedChanged -= new EventHandler(radMov4_CheckedChanged); //Bind des infos dans les contrôles LoadLists(); ScriptManager.LoadScript(Project.GameOver); rscMainMenuMusic.ResourceString = Project.MainMenuMusic.Filename; rscGameOverMusic.ResourceString = Project.GameOverMusic.Filename; rscChoiceButtonSound.ResourceString = Project.ChoiceButtonSound; rscMovementButtonSound.ResourceString = Project.MovementButtonSound; rscLifeBar.ResourceString = Project.LifeBarResource; rscLifeBarDeco.ResourceString = Project.LifeBarBackground; rscSystemGUI.ResourceString = Project.GuiResource; txtResolution.Text = Project.Resolution.Title; txtTitle.Text = Project.Title; if (File.Exists(PathTools.GetProjectPath(Enums.ProjectPath.Menus) + Project.LifeBarResource)) { Image pic = ImageManager.GetImageResource(PathTools.GetProjectPath(Enums.ProjectPath.Menus) + Project.LifeBarResource); crdLifeBar.Coords = new Rectangle(Project.LifeBarCoords, pic.Size); } else { crdLifeBar.Coords = new Rectangle(Project.LifeBarCoords, new Size(0, 0)); } crdLifeBar.SourceResolution = new Size(Project.Resolution.Width, Project.Resolution.Height); if (Project.SplashScreenAnimation != new Guid()) { AnimLoading.LoadAnimation(Project.SplashScreenAnimation); AnimLoading.Start(); } else { AnimLoading.LoadAnimation(new Guid()); } radMov4.Checked = false; radMov8.Checked = false; if (Project.MovementDirections == 4) { radMov4.Checked = true; } else if (Project.MovementDirections == 8) { radMov8.Checked = true; } //Désactiver events rscMainMenuMusic.ValueChanged += new EventHandler(rscMainMenuMusic_ValueChanged); rscGameOverMusic.ValueChanged += new EventHandler(rscGameOverMusic_ValueChanged); rscChoiceButtonSound.ValueChanged += new EventHandler(rscChoiceButtonSound_ValueChanged); rscMovementButtonSound.ValueChanged += new EventHandler(rscMovementButtonSound_ValueChanged); rscLifeBar.ValueChanged += new EventHandler(rscLifeBar_ValueChanged); rscLifeBarDeco.ValueChanged += new EventHandler(rscLifeBarDeco_ValueChanged); rscSystemGUI.ValueChanged += new EventHandler(rscSystemGUI_ValueChanged); txtTitle.TextChanged += new EventHandler(txtTitle_TextChanged); txtAuthor.TextChanged += new EventHandler(txtAuthor_TextChanged); crdLifeBar.ValueChanged += new EventHandler(crdLifeBar_ValueChanged); radMov4.CheckedChanged += new EventHandler(radMov4_CheckedChanged); }
protected void ddlPhoto_SelectedIndexChanged(object sender, EventArgs e) { images.PhotoID = ddlPhoto.SelectedValue; imgPhoto.ImageUrl = ImageManager.findImageByPhotoID(images).Photo; }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Resource.Style.AppThemeClearStatusBar); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_camera); //CrashLytics Fabric.Fabric.With(this, new Crashlytics.Crashlytics()); Crashlytics.Crashlytics.HandleManagedExceptions(); RequestPermissions(permissions, 0); if (Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape) { RequestedOrientation = ScreenOrientation.Portrait; } toggleFlashButton = FindViewById <ImageButton>(Resource.Id.toggleFlashButton); takePictureButton = FindViewById <Button>(Resource.Id.takePictureButton); openGalleryButton = FindViewById <ImageButton>(Resource.Id.openGalleryButton); openDefaultCameraButton = FindViewById <ImageButton>(Resource.Id.openDefaultCamera); cameraPreview = FindViewById <FrameLayout>(Resource.Id.cameraView); imageManager = new ImageManager(); imageManager.AddOnImageResultListener(delegate(Bitmap bitmap, string path, Exception ex) { if (path != null) { StopCamera(); Intent intent = new Intent(this, typeof(MainViewActivity)); intent.PutExtra("image", path); StartActivity(intent); } else if (ex != null) { Toast.MakeText(Application.Context, ex.Message, ToastLength.Short).Show(); StartCamera(); } else { StartCamera(); } }); //Выбор режима activity на весь экран if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat) { Window w = Window; w.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); } takePictureButton.Click += delegate { TakePicture(); }; toggleFlashButton.Click += delegate { ToggleFlash(); }; openGalleryButton.Click += delegate { imageManager.PickPhoto(); }; openDefaultCameraButton.Click += delegate { StopCamera(); imageManager.TakePhoto(); }; //Отслеживание смены угла экрана orientationListener = new OrientationListener(this, delegate(int angle) { if (lastAngle != angle) { if (lastAngle == -90 && angle == 180) { angle = -180; } toggleFlashButton.Animate().Rotation(angle).Start(); openGalleryButton.Animate().Rotation(angle).Start(); openDefaultCameraButton.Animate().Rotation(angle).Start(); if (angle == -180) { lastAngle = 180; } else { lastAngle = angle; } } }); }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty) { Response.Write("<script language=javascript>alert('版主名不能为空!')</script>"); } else { host.HostName = txtName.Text; host = HostManager.FindHostByHostName(host); if (host.HostName != null) { Response.Write("<script language=javascript>alert('该版主已经存在!')</script>"); txtName.Text = string.Empty; txtName.Focus(); } else { try { module.ModuleName = ddlModule.SelectedValue; host.ModuleID = ModuleManager.findModuleByName(module).ModuleID; } catch { Response.Write("<script language=javascript>alert('请先填写版块信息!')</script>"); return; } host.HostPwd = txtPwd.Text; host.TName = txtTName.Text; if (ddlSex.SelectedIndex == 0) { host.Sex = true; } if (ddlSex.SelectedIndex == 1) { host.Sex = false; } host.Birthday = DateTime.Parse(txtBirthday.Text); host.Tel = txtTel.Text; host.Mobile = txtMobile.Text; try { host.QQ = Int32.Parse(txtQQ.Text); } catch { txtQQ.Text = string.Empty; Response.Write("<script language=javascript>alert('QQ号码输入错误!')</script>"); return; } images.PhotoID = ddlPhoto.SelectedValue; host.Photo = ImageManager.findImageByPhotoID(images).Photo; host.Email = txtEmail.Text; host.FAddress = txtHAddress.Text; host.RAddress = txtRAddress.Text; host.Index = txtIndex.Text; HostManager.addHost(host); Response.Write("<script language=javascript>alert('版主添加成功!')</script>"); txtName.Text = txtPwd.Text = txtSPwd.Text = txtTName.Text = txtBirthday.Text = txtTel.Text = txtMobile.Text = txtQQ.Text = txtEmail.Text = txtHAddress.Text = txtRAddress.Text = txtIndex.Text = string.Empty; } } }
void Awake() { _instance = this; }
private BitmapImage GetDefaultCurrentImage() { return(!CurrentFrameSize.IsEmpty ? ImageManager.ConvertFrameworkElementToBitmapImage(new ThumbnailBox(), CurrentFrameSize) : ImageManager.ConvertFrameworkElementToBitmapImage(new ThumbnailBox(), CurrentImageWidth)); }
public IActionResult EditAdvertisementSubmit(Advertisement ad, int mySponsorId, String adSize, IFormFile newImgFile) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } ImageManager imageManager = new ImageManager(environment, "images"); if (!ModelState.IsValid) { return(RedirectToAction("EditAdvertisement", ad.adId)); } //check if sponsor is changed try { AdvertRelations oldRel = new AdvertRelations(); oldRel = revenueManager.getAdvertRelations(ad.adId); if (oldRel.sponsorId != mySponsorId) { revenueManager.Remove(oldRel); revenueManager.SaveChanges(); AdvertRelations newRel = new AdvertRelations(); newRel.sponsorId = mySponsorId; newRel.adId = ad.adId; revenueManager.Add(newRel); revenueManager.SaveChanges(); } } catch {} //change adSize if (adSize == "full") { ad.adSize = "full"; } else if (adSize == "half") { ad.adSize = "half"; } else if (adSize == "quarter") { ad.adSize = "quarter"; } //upload new image if changed Console.WriteLine("\n\n\n***Image file of ad, currently: " + ad.imgFile); if ((newImgFile != null) && (newImgFile.FileName != "") && (ad.imgFile != newImgFile.FileName)) { bool delete = imageManager.deleteImage(ad.imgFile); if (delete) { int result = imageManager.uploadImage(newImgFile); switch (result) { case 1: ViewData["feedback"] = "Wrong File Type"; return(RedirectToAction("EditAdvertisement", ad.adId)); case 2: ViewData["feedback"] = "File Too Large"; return(RedirectToAction("EditAdvertisement", ad.adId)); case 3: ViewData["feedback"] = "File Name Too Long"; return(RedirectToAction("EditAdvertisement", ad.adId)); case 4: ViewData["feedback"] = "Error Saving File"; return(RedirectToAction("EditAdvertisement", ad.adId)); case 5: //image has been replaced ViewData["feedback"] = "Success"; Console.WriteLine("\n\n\n***Successfully uploaded image to server!***"); ad.imgFile = imageManager.fileName; revenueManager.Update(ad); revenueManager.SaveChanges(); return(RedirectToAction("ViewAdvertisements")); default: ViewData["feedback"] = "No File Selected"; return(RedirectToAction("EditAdvertisement", ad.adId)); } } else { Console.WriteLine("\n\n\n***There has been an error deleting old image file!***"); return(RedirectToAction("EditAdvertisement", ad.adId)); } } else { //image not changed -> save changes to ad revenueManager.Update(ad); revenueManager.SaveChanges(); return(RedirectToAction("ViewAdvertisements")); } }
public StepThreePage(string calledfrom) { InitializeComponent(); CalledFrom = calledfrom; BindingContext = ViewModels = new StepThreeViewModel(CalledFrom); ViewModels.NoRegisterCall += () => ShowResult(); ViewModels.VerifyProfile += async() => await GoToLoginAsync(); switch (CalledFrom) { case "ForUserPic": coments = Translator.getText("UserPhoto"); CamTitle.Text = Translator.getText("UserPhoto"); break; case "ForIdPics": coments = Translator.getText("IdPhoto"); CamTitle.Text = Translator.getText("TextIdents"); break; case "ForProductPic": coments = Translator.getText("ProductPhoto"); CamTitle.Text = Translator.getText("ProductPhoto"); break; case "ForIdTrav": coments = Translator.getText("IdPhoto"); CamTitle.Text = Translator.getText("IdPhoto"); break; } TakePicture.Clicked += async(sender, args) => { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", ":( No camera available.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Sample", Name = "test.jpg", PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small, CompressionQuality = 90, AllowCropping = true }); if (file == null) { return; } using (UserDialogs.Instance.Loading(Translator.getText("Loading"), null, null, true, MaskType.Black)) { idInfo = new IdInfo { comments = coments, Image = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }), ImageByte = ImageManager.ConvertToBytes(file.Path), }; } createImage(file.Path, idInfo); }; SelectPicture.Clicked += async(sender, args) => { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsPickPhotoSupported) { await DisplayAlert("No Camera", ":( No camera available.", "OK"); return; } var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium, CompressionQuality = 90, }); if (file == null) { return; } //await DisplayAlert("File Location", file.Path, "OK"); using (UserDialogs.Instance.Loading(Translator.getText("Loading"), null, null, true, MaskType.Black)) { idInfo = new IdInfo { comments = coments, Image = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }), ImageByte = ImageManager.ConvertToBytes(file.Path), }; } createImage(file.Path, idInfo); }; lb_BackFunc(); void lb_BackFunc() { try { Back.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(async() => { Navigation.PopModalAsync(); } ) }); } catch (Exception ex) { Debug.WriteLine(ex); } } }
static void Main(string[] args) { var image = ImageManager.GetSampleImage("tiger"); ImageManager.SaveImage(ApplyGreenScaleFilter(image), Assembly.GetExecutingAssembly()); }
void SurfMatch(Bitmap img1, Bitmap img2) { Stopwatch watch = Stopwatch.StartNew(); ////主线程 //List<IPoint2> ipts1 = GetFtPntList(img1, thread);//图片1的特征点 //List<IPoint2> ipts2 = GetFtPntList(img2, thread);//图片2的特征点 //List<IPoint2>[] matches = Utils.getMatches(ipts1, ipts2); //多线程且对图像进行分割 ImageManager imgM = new ImageManager(img1, img2, thread, thread, cutSize); List <IPoint2>[] matches = imgM.GetMatchPoint(); IntPoint[] correlationPoints1 = new IntPoint[matches[0].Count]; IntPoint[] correlationPoints2 = new IntPoint[matches[1].Count]; List <IPoint2> list1 = matches[0]; int num = 0; foreach (IPoint2 kv in list1) { correlationPoints1[num] = new IntPoint { X = (int)kv.x, Y = (int)kv.y }; num++; } int num1 = 0; List <IPoint2> list2 = matches[1]; foreach (IPoint2 kv in list2) { correlationPoints2[num1] = new IntPoint { X = (int)kv.x, Y = (int)kv.y }; num1++; } if (correlationPoints1.Length > 0) { RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99); MatrixH homography = ransac.Estimate(correlationPoints1, correlationPoints2); Blend blend = new Blend(homography, img1); pictureBox.Image = blend.Apply(img2); //计算时间 long matchTime = watch.ElapsedMilliseconds; this.Invoke(new Action(delegate() { if (matchTime < 1000) { this.label1.Text = "完成!耗时 " + matchTime.ToString() + " 毫秒!"; } else { this.label1.Text = "完成!耗时 " + (matchTime / 1000.0).ToString() + " 秒!"; } this.btnSave.Visible = true; this.btnBlend.Enabled = true; })); } else { //计算时间 long matchTime = watch.ElapsedMilliseconds; this.Invoke(new Action(delegate() { this.label1.Text = "没有找到相同点!耗时 " + matchTime.ToString() + " 毫秒!"; })); } watch.Stop(); thd.Abort(); }
void OnGUI() { // Need to catch 'Stack empty' error on linux try { if (showLoadingIndicatorOverlay) { GUI.enabled = false; } Color defaultColor = GUI.contentColor; if (!EditorGUIUtility.isProSkin) { GUI.contentColor = Styles.Colors.DarkGray; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); searchTxt = searchfield.OnToolbarGUI(searchTxt); if (EditorGUI.EndChangeCheck()) { PrepareData(false); } GUILayout.FlexibleSpace(); EditorGUIUtility.SetIconSize(new Vector2(14.0f, 14.0f)); GUIContent watcherContent = (entryAccessor.IsMonitoring()) ? new GUIContent(ImageManager.Watching, "Watching changes") : new GUIContent(ImageManager.NotWatching, "Not watching changes"); if (GUILayout.Button(watcherContent, EditorStyles.toolbarButton)) { monitoring = !monitoring; EditorPrefs.SetBool("BGTools.PlayerPrefsEditor.WatchingForChanges", monitoring); if (monitoring) { entryAccessor.StartMonitoring(); } else { entryAccessor.StopMonitoring(); } Repaint(); } if (GUILayout.Button(new GUIContent(ImageManager.Refresh, "Refresh"), EditorStyles.toolbarButton)) { PlayerPrefs.Save(); PrepareData(); } if (GUILayout.Button(new GUIContent(ImageManager.Trash, "Delete all"), EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete ALL entries from PlayerPrefs?\n\nUse with caution! Unity defined keys are affected too.", "Yes", "No")) { PlayerPrefs.DeleteAll(); PrepareData(); GUIUtility.ExitGUI(); } } EditorGUIUtility.SetIconSize(new Vector2(0.0f, 0.0f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Box(ImageManager.GetOsIcon(), Styles.icon); GUILayout.TextField(platformPathPrefix + Path.DirectorySeparatorChar + pathToPrefs, GUILayout.MinWidth(200)); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos); serializedObject.Update(); userDefList.DoLayoutList(); serializedObject.ApplyModifiedProperties(); GUILayout.FlexibleSpace(); showSystemGroup = EditorGUILayout.Foldout(showSystemGroup, new GUIContent("Show System")); if (showSystemGroup) { unityDefList.DoLayoutList(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.enabled = true; if (showLoadingIndicatorOverlay) { GUILayout.BeginArea(new Rect(position.size.x * 0.5f - 30, position.size.y * 0.5f - 25, 60, 50), GUI.skin.box); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Box(ImageManager.SpinWheelIcons[loadingSpinnerFrame], Styles.icon); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Loading"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndArea(); } GUI.contentColor = defaultColor; } catch (InvalidOperationException) { } }
public override void Deregister(ImageManager imgManager) { base.Deregister(imgManager); ValueManager.DeregisterValue(ID.Bot); }
public BitmapProvider() { //ImageManager.SetImplementation(new WPFImageManager()); ImageManager.SetImplementation(new WinFormsImageManager()); }
public void GetImage_Returns_Null_If_Absent(ImageType type) { var imageManager = new ImageManager <Entity>(null, null, null); Assert.Null(imageManager.GetImage(type)); }
//----------------------//------------------------// public override void LoadContent() { base.LoadContent(); var viewportSize = SceneManager.Instance.VirtualSize; // Camera init _camera = new Camera2D(SceneManager.Instance.ViewportAdapter); // Player init _player = new Player(ImageManager.loadCharacter("Player")); // Projectiles init _projectilesTextures = new Dictionary <string, Texture2D>() { { "snowball", ImageManager.loadProjectile("Snowball") }, }; _projectiles = new List <GameProjectile>(); _projectilesColliderTexture = new Texture2D(SceneManager.Instance.GraphicsDevice, 1, 1); _projectilesColliderTexture.SetData(new Color[] { Color.Orange }); // Enemies init _enemies = new List <EnemyBase>(); var ghostTexture = ImageManager.loadCharacter("Ghost"); var birdTexture = ImageManager.loadCharacter("Bird"); _ghost = new Ghost(ghostTexture); _bird = new Bird(birdTexture); // Background init _backgroundTexture = ImageManager.loadScene("sceneMap", "Background"); // Hud init _gameHud = new GameHud(); // Particles init var particleTexture = new Texture2D(SceneManager.Instance.GraphicsDevice, 1, 1); particleTexture.SetData(new[] { Color.White }); ParticlesInit(new TextureRegion2D(particleTexture)); _blizzardTriggerPosition = new Vector2(viewportSize.X / 2 - 50.0f, -50.0f); // Spawn Manager init _enemiesSpawnManager = new EnemiesSpawnManager(); _enemiesSpawnManager.Start(); // Load the map LoadMap(MapManager.FirstMap); // Crystal init var mapSize = new Vector2(MapManager.Instance.MapWidth, MapManager.Instance.MapHeight); var crystalPosition = new Vector2(mapSize.X / 2 - 48, 96); _crystal = new GameCrystal(crystalPosition, ImageManager.loadCharacter("Crystal")); // Wave Clear init var textWidth = SceneManager.Instance.GameFontBig.MeasureString(WaveClearText).Width; var x = (viewportSize.X - textWidth) / 2; _waveClearInitialPosition = new Vector2(x, viewportSize.Y / 2 - 70); _waveClearPosition = _waveClearInitialPosition; // SE init var ambienceSe = SoundManager.LoadSe("Ambience"); _ambienceSei = ambienceSe.CreateInstance(); _ambienceSei.IsLooped = true; _ambienceSei.Play(); SoundManager.StartBgm(SoundManager.BGMType.Default); }
public void RemoveSetOrUpdateValue_Throws_Exception_If_No_Target_Image() { var imageManager = new ImageManager <Entity>(null, null, null); Assert.Throws <InvalidPluginExecutionException>(() => imageManager.RemoveSetOrUpdateValue(FieldName)); }
public Entity(ImageManager imageManager) { Sprite = new Sprite(imageManager.GetImage("cube")); offset = new Vector2f(0, 0); position = new Vector2f(0, 0); }