Ejemplo n.º 1
0
 /// <summary>
 /// добавление в таблицу
 /// </summary>
 private void insertStripButton_Click(object sender, EventArgs e)
 {
     // альбома нет - добавляется просто в таблицу песен
     if (_album == null)
     {
         var f = new SongEditor(_database);
         f.ShowDialog();
         if (f.DialogResult != DialogResult.OK)
         {
             return;
         }
         _database.Insert(f.Song);
     }
     // альбом есть - добавляется в таблицу песен и в таблицу альбомы-песни
     else
     {
         var d = new AlbumSongEditor(_database, _album);
         d.ShowDialog();
         if (d.DialogResult == DialogResult.OK)
         {
             var s = d.Song;
             _database.Insert(new AlbumSong(s, _album));
         }
     }
     selectStripButton_Click(sender, EventArgs.Empty);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// изменение записи в таблице
        /// </summary>
        private void updateToolStripButton_Click(object sender, EventArgs e)
        {
            var f = gridView1.GetFocusedRow() as Song;

            _focusIndex = gridView1.GetFocusedDataSourceRowIndex();
            if (f == null)
            {
                return;
            }
            var songEditorForm = new SongEditor(_database)
            {
                Song = f
            };

            songEditorForm.ShowDialog();
            if (songEditorForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            _database.Update(songEditorForm.Song);
            gridView1.FocusedRowHandle = _focusIndex;
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            DateTime startTime = DateTime.Now;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Update settings from previous version
            if (Settings.Default.UpgradeRequired)
            {
                Settings.Default.Upgrade();
                Settings.Default.UpgradeRequired = false;
                Settings.Default.Save();
            }

            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Settings.Default.SelectedCulture);
            log.Debug("Set culture to " + Thread.CurrentThread.CurrentUICulture);

            // code to ensure that only one copy of the software is running.
            Mutex          mutex;
            string         strLoc    = Assembly.GetExecutingAssembly().Location;
            FileSystemInfo fileInfo  = new FileInfo(strLoc);
            string         sExeName  = fileInfo.Name;
            string         mutexName = "Global\\" + sExeName;

            try
            {
                mutex = Mutex.OpenExisting(mutexName);

                //since it hasn’t thrown an exception, then we already have one copy of the app open.
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                String   appTitle   = ((AssemblyProductAttribute)attributes[0]).Product;

                MessageBox.Show(StringResources.ProgramInstanceAlreadyRunning, appTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Environment.Exit(0);
            }
            catch
            {
                //since we didn’t find a mutex with that name, create one
                mutex = new Mutex(true, mutexName);
            }

            // Check Data directory
            if (SettingsUtil.SetDefaultDataDirIfEmpty(Settings.Default))
            {
                Settings.Default.Save();
            }

            SongManager songManager = new SongManager(SettingsUtil.GetSongDirPath(Settings.Default));

            ImageManager imgManager = new ImageManager(SettingsUtil.GetImageDirPath(Settings.Default), SettingsUtil.GetThumbDirPath(Settings.Default))
            {
                DefaultThumbSize  = Settings.Default.ThumbSize,
                DefaultEmptyColor = Settings.Default.ProjectionBackColor
            };

            BibleManager bibleManager = new BibleManager(SettingsUtil.GetBibleDirPath(Settings.Default));

            if (Settings.Default.ShowLoadingScreen)
            {
                LoadingScreen ldg = new LoadingScreen(songManager, imgManager);
                ldg.SetLabel("PraiseBase Presenter wird gestartet...");
                ldg.Show();

                ldg.SetLabel("Prüfe Miniaturbilder...");
                imgManager.CheckThumbs(false);

                ldg.SetLabel("Lade Liederdatenbank...");
                songManager.Reload();

                GC.Collect();
                ldg.Close();
                ldg.Dispose();
            }
            else
            {
                imgManager.CheckThumbs(false);
                songManager.Reload();
                GC.Collect();
            }

            log.Debug(@"Loading took " + (DateTime.Now - startTime).TotalSeconds + @" seconds!");

            string setlistFile = null;
            string songFile    = null;

            // Detect if program is called with a setlist file as argument
            if (args.Length == 1)
            {
                if (File.Exists((args[0])))
                {
                    string ext = Path.GetExtension(args[0]);
                    if (ext == "." + SetlistWriter.FileExtension)
                    {
                        setlistFile = args[0];
                    }
                    else
                    {
                        songFile = args[0];
                    }
                }
            }

            Form mw;

            if (songFile != null)
            {
                mw = new SongEditor(Settings.Default, imgManager, songFile);
            }
            else
            {
                mw = new MainWindow(songManager, imgManager, bibleManager, setlistFile);
            }
            Application.Run(mw);
            GC.KeepAlive(mutex);
        }
Ejemplo n.º 4
0
 // Use this for initialization
 public void Awake()
 {
     instance = this;
     ReadData();
 }