Exemplo n.º 1
0
        public AvatarPicker(ImageList avatarImageList, PersonSetting personSetting)
        {
            _okToClose       = true;
            _avatarImageList = avatarImageList;
            _personSetting   = personSetting;
            InitializeComponent();
            emailTextbox.Text = personSetting.Email;
            if (personSetting.Email != null)
            {
                _gravatar.SetImage(personSetting, avatarImageList);
                tabControl1.SelectedIndex = 1;
            }
            if (personSetting.AvatarImageName != null)
            {
                _croppedCustom.ImageLocation = Path.Combine(SirenOfShameSettings.GetAvatarsFolder(),
                                                            personSetting.AvatarImageName);
                tabControl1.SelectedIndex = 2;
            }
            int avatarCount = SirenOfShameSettings.AVATAR_COUNT;

            for (int i = 0; i < avatarCount; i++)
            {
                Avatar avatar = new Avatar();
                avatar.SetImage(i, avatarImageList);
                avatar.Click += AvatarOnClick;
                flowLayoutPanel1.Controls.Add(avatar);
            }
        }
Exemplo n.º 2
0
        private void ImportFromAd()
        {
            var activeDirectoryService = new ActiveDirectoryService();
            var avatarsFolder          = SirenOfShameSettings.GetAvatarsFolder();

            foreach (var personSetting in _settings.People)
            {
                ImportPersonFromAdContinueOnError(personSetting, activeDirectoryService, avatarsFolder);
            }
            _settings.Save();
            _errorMessage.Visible = false;
        }
Exemplo n.º 3
0
        private void SaveCustomImage_Click(object sender, EventArgs e)
        {
            if (_croppedCustom.Image == null)
            {
                CloseAndDispose();
                return;
            }
            var avatarsFolder = SirenOfShameSettings.GetAvatarsFolder();
            var newFileName   = Guid.NewGuid() + ".png";
            var combine       = Path.Combine(avatarsFolder, newFileName);

            _croppedCustom.Image.Save(combine);
            _personSetting.AvatarImageName = newFileName;
            SelectAvatarAndClose(null);
        }
Exemplo n.º 4
0
        public int LoadAvatarFromFile(string avatarImageName, ImageList avatarImageList)
        {
            if (avatarImageList.Images.ContainsKey(avatarImageName))
            {
                return(avatarImageList.Images.IndexOfKey(avatarImageName));
            }

            try
            {
                var avatarsFolder = SirenOfShameSettings.GetAvatarsFolder();
                var imagePath     = Path.Combine(avatarsFolder, avatarImageName);
                var image         = Image.FromFile(imagePath);
                avatarImageList.Images.Add(avatarImageName, image);
                return(avatarImageList.Images.Count - 1);
            }
            catch (Exception ex)
            {
                _log.Error("Unable to retrieve avatar, defaulting to a random avatar", ex);
                return(new Random(avatarImageName.GetHashCode()).Next(0, 19));
            }
        }