private void btnSave_Click(object sender, System.EventArgs e) { // Add to the main category "All" PhotoInfo.AddImage2Cat(imageId, "All"); // Add to all other categories for (int i = 0; i < _categories.Items.Count; i++) { string cat = _categories.Items[i].ToString(); bool isChecked = _categories.GetItemChecked(i); bool isAdded = (bool)categories[cat]; if (isAdded != isChecked) { if (isAdded) { PhotoInfo.RemoveImageFromCat(imageId, cat); } else { PhotoInfo.AddImage2Cat(imageId, cat); } } } DialogResult = DialogResult.OK; this.Close(); }
private void btnSelect_Click(object sender, EventArgs e) { PhotoInfo.LogPhotoHit(SelectedItem.ImageId); DialogResult = DialogResult.OK; this.Close(); }
private void LoadPreviews(string category) { ArrayList al = new ArrayList(); // Load document string pathPreview = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\content\\PhotoCategories.xml"; XmlDocument xd = new XmlDocument(); xd.Load(pathPreview); // Read all the image for this category foreach (XmlNode xn in xd.DocumentElement.ChildNodes) { if (xn.Name == "Category" && xn.Attributes["name"] != null && xn.Attributes["name"].InnerText == category) { foreach (XmlNode xn1 in xn.ChildNodes) { PhotoInfo pi = new PhotoInfo(); pi.ImageId = int.Parse(xn1.Attributes["id"].InnerText); al.Add(pi); } } } // Sort the list based on frequency al.Sort(new ImageFreqComparer()); photoPreviewContainer1.LoadImages(al, category); }
private void btnLink_Click(object sender, EventArgs e) { if (ppiCurrent == null) { return; } AssignToCategory f = new AssignToCategory(ppiCurrent.PhotoInfo.ImageId, false); if (f.ShowDialog() == DialogResult.OK) { // Check if the current image got removed from the current category System.Collections.Hashtable h = PhotoInfo.GetCatListById(ppiCurrent.PhotoInfo.ImageId); if (!(bool)h[photoPreviewContainer1.CurrentCategory]) { photoPreviewContainer1.Controls.Remove(ppiCurrent); } // Check if category list needs to be refreshed if (f.needCategoryRefresh) { supressCatChanged = true; object selectedItem = _categories.SelectedItem; InternalLoadCategories(); _categories.SelectedItem = selectedItem; supressCatChanged = false; } } }
private void btnRenameCat_Click(object sender, EventArgs e) { if (ixItemSelected < 1) { return; } string catname = _categories.Items[ixItemSelected].ToString(); Prompt p = new Prompt(); p.Text = Loc.Get("Rename category"); p.lblPrompt.Text = Loc.Get("Please enter a new name for the category:"); if (p.ShowDialog() == DialogResult.OK) { string newname = p._input.Text; if (newname != "") { if (_categories.Items.Contains(newname)) { MessageBox.Show(Loc.Get("Name is already in use"), Loc.Get("Error")); return; } PhotoInfo.RenameCategory(catname, newname); LoadCategories(); // refresh the list // update the current category for the photo prevew container photoPreviewContainer1.CurrentCategory = newname; } } }
public void UpdateBackground(int imageId) { this.imageId = imageId; PhotoInfo pi = new PhotoInfo(); pi.ImageId = imageId; UpdateBackground(pi.FullSizeImage); }
public SongFormatter(DS.SongsRow row) { InitializeComponent(); currentRow = row; // accept changes if not new if (row.RowState == DataRowState.Detached) { this.Text = "Add a new song"; this.btnSave.Text = "Add"; } else { this.btnSave.Text = "Save"; row.AcceptChanges(); } dt = new EmpowerPresenter.DS.SongVersesDataTable(); // load song verses using (FBirdTask t = new FBirdTask()) { t.CommandText = "SELECT \"AutoNumber\", \"IsChorus\", \"Verse\", \"OrderNum\" " + "FROM \"SongVerses\" " + "WHERE \"AutoNumber\" = @AutoNumber " + "ORDER BY \"OrderNum\""; t.Parameters.Add("@AutoNumber", FbDbType.Integer); t.Parameters["@AutoNumber"].Value = row.AutoNumber; DS.SongVersesRow r; t.ExecuteReader(); while (t.DR.Read()) { r = dt.NewSongVersesRow(); r.AutoNumber = t.DR.GetInt32(0); r.IsChorus = t.DR.GetInt16(1) == 1 ? true : false; r.Verse = t.DR.GetString(2); r.OrderNum = t.DR.GetInt32(3); dt.AddSongVersesRow(r); } dt.AcceptChanges(); } dataView1.BeginInit(); dataView1.Table = dt; dataView1.EndInit(); // disect song SongNumber = currentRow.Number.ToString(); txtTitle.Text = currentRow.Title; txtChorus.Text = currentRow.Chorus; currentImage = new PhotoInfo(); currentImage.ImageId = currentRow.Image; button1_Click(null, null); gdbVerses.Model.Refresh(); }
private void btnCancel_Click(object sender, System.EventArgs e) { DialogResult = DialogResult.Cancel; if (newImg) { PhotoInfo.RemoveImage(imageId); } this.Close(); }
public void EnsureBackground() { if (graphicsContext.img == null) { PhotoInfo pi = new PhotoInfo(); pi.ImageId = Program.ConfigHelper.BibleImage; UpdateBackgroundImage(pi.FullSizeImage); // Set if not init } }
private void InternalLoadCategories() { _categories.Items.Clear(); // Load al the categories foreach (string name in PhotoInfo.GetCatList()) { _categories.Items.Add(name); } }
public void LoadData(AnouncementData ad) { bSaved = true; data = ad; // Update image PhotoInfo pi = new PhotoInfo(); pi.ImageId = imageId; ctx.img = pi.FullSizeImage; ctx.opacity = ad.opacity; }
private void BuildCategoryList() { _categories.Items.Clear(); categories = PhotoInfo.GetCatListById(imageId); foreach (string cat in categories.Keys) { if (cat == "All") { continue; // Do not allow the user to remove the image from the built in "All" category } _categories.Items.Add(cat, (bool)categories[cat]); } }
private void ChangeBackgroundImage() { #if DEMO new DemoVersionOnly("Changing background").ShowDialog(); #else ImageSelection images = new ImageSelection(); if (DialogResult.OK == images.ShowDialog()) { currentImage = images.SelectedItem; this.pbPhoto.Invalidate(); } #endif }
private void btnRemoveCat_Click(object sender, EventArgs e) { if (ixItemSelected < 1) { return; } string catname = _categories.Items[ixItemSelected].ToString(); string txt = Loc.Get("Are you sure you want to remove the selected category:") + " "; if (MessageBox.Show(this, txt + catname + "?", Loc.Get("Warning"), MessageBoxButtons.YesNo) == DialogResult.Yes) { PhotoInfo.RemoveCategory(catname); LoadCategories(); // refresh the list } }
private void btnUnlink_Click(object sender, EventArgs e) { if (ppiCurrent == null) { return; } string txt = Loc.Get("Are you sure you want to remove the image from the current category") + "?"; if (MessageBox.Show(this, txt, Loc.Get("Warning"), MessageBoxButtons.YesNo) == DialogResult.Yes) { PhotoInfo.RemoveImageFromCat(ppiCurrent.PhotoInfo.ImageId, photoPreviewContainer1.CurrentCategory); photoPreviewContainer1.Controls.Remove(ppiCurrent); } }
private void _OK_Click(object sender, System.EventArgs e) { string[] cats = PhotoInfo.GetCatList(); foreach (string cat in cats) { if (cat == _name.Text) { MessageBox.Show(this, Loc.Get("Category already exists"), Loc.Get("Error")); return; } } PhotoInfo.AddCategory(_name.Text); DialogResult = DialogResult.OK; this.Close(); }
public void RefreshData() { LoadData(currentSong); PrepareForDisplay(); // Update image settings graphicsContext.opacity = currentSong.Overlay; if (graphicsContext.opacity == 777) { graphicsContext.opacity = Program.ConfigHelper.SongDefaultOpacity; } PhotoInfo pi = new PhotoInfo(); pi.ImageId = currentSong.Image; UpdateBackgroundImage(pi.FullSizeImage); GotoSlide(currentSlideNum, true); }
private void LoadData(PresenterDataset.SongsRow currentSong) { // Clear songVerses.Clear(); // Populate songVerses LoadVerses(songVerses, currentSong.AutoNumber, false); // Load other data currentSong.Image = Data.Songs.GetSongBackground(currentSong.AutoNumber); copyright = EmpowerPresenter.Data.Songs.GetSongCopyright(currentSong.AutoNumber); songFont = PresenterFont.GetFontFromDatabase(currentSong.FontId); graphicsContext.opacity = currentSong.Overlay; if (graphicsContext.opacity == 777) { graphicsContext.opacity = Program.ConfigHelper.SongDefaultOpacity; } // Load img into context if (graphicsContext.img == null) { PhotoInfo pi = new PhotoInfo(); pi.ImageId = currentSong.Image; graphicsContext.img = pi.FullSizeImage; } // Load formatting settings string settings = currentSong.Settings; if (settings == null || settings == "") { settings = Program.ConfigHelper.SongDefaultFormat; } string[] sparts = settings.Split("|".ToCharArray()); if (sparts.Length == 2) { stripFormatting = bool.Parse(sparts[0]); includeVerseNumbers = bool.Parse(sparts[1]); } }
private void btnAddImage_Click(object sender, System.EventArgs e) { OpenFileDialog f = new OpenFileDialog(); Program.Presenter.BeginExKeyOwner(); f.Title = Loc.Get("Select image to add"); f.Filter = Loc.Get("Supported formats") + " | *.jpeg;*.jpg;*.png;*.bmp;*.gif | JPG | *.jpg | JPEG | *.jpeg | GIF | *.gif | PNG | *.png | BMP | *.bmp"; f.Multiselect = false; if (f.ShowDialog() == DialogResult.OK) { try { int id = PhotoInfo.AddImage(Image.FromFile(f.FileName)); AssignToCategory a2c = new AssignToCategory(id, true); if (a2c.ShowDialog() == DialogResult.OK) { LoadCategories(); photoPreviewContainer1.Controls.Clear(); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); } } Program.Presenter.EndExKeyOwner(); }
public int Compare(object x, object y) { PhotoInfo _x = (PhotoInfo)x; PhotoInfo _y = (PhotoInfo)y; bool xfound = frequencies.ContainsKey(_x.ImageId); bool yfound = frequencies.ContainsKey(_y.ImageId); if (!xfound && !yfound) { return(_x.ImageId.CompareTo(_y.ImageId)); } else if (xfound && !yfound) { return(1); } else if (yfound && !xfound) { return(-1); } else { return(frequencies[_x.ImageId].CompareTo(frequencies[_y.ImageId])); } }
// Song Information public void LoadSong(PresenterDataset.SongsRow row) { if (row == null) { this.Close(); return; } currentRow = row; // Accept changes if not new if (row.RowState == DataRowState.Detached) { this.Text = Loc.Get("Add a new song"); this.btnSave.Text = Loc.Get("Add"); // setup datatable InternalLoadSongFromDB(row, true); } else { this.btnSave.Text = Loc.Get("Save"); row.AcceptChanges(); // Load song verses from database InternalLoadSongFromDB(row, false); } // Set textboxes if (currentRow.Number != -1) { txtNumber.Text = currentRow.Number.ToString(); } else { txtNumber.Text = ""; } txtTitle.Text = currentRow.Title; txtChorus.Text = currentRow.Chorus; // Image and properties currentImage = new PhotoInfo(); if (currentRow.Image == -2) { currentImage.ImageId = Program.ConfigHelper.SongDefaultImage; } else { currentImage.ImageId = currentRow.Image; } sliderSuspendUpdate++; if (currentRow.Overlay == 777) { sliderOpacity.Value = 50; } else { sliderOpacity.Value = (int)(((double)currentRow.Overlay + 255) * 100 / 512); } sliderSuspendUpdate--; txtCopyright.Text = Data.Songs.GetSongCopyright(currentRow.AutoNumber); }
public void UpdateBackgroundImage(PhotoInfo photo) { UpdateBackgroundImage(photo.FullSizeImage); }
public ImageFreqComparer() { frequencies = PhotoInfo.GetPhotoFrequency(); }