Пример #1
0
        public void PerformSynchronize()
        {
            Dictionary <String, HashSet <Device> > deviceinfo = connectedDevices.GetConnectedDevicesWithDrives();
            IDictionaryEnumerator keys = deviceinfo.GetEnumerator();

            try
            {
                // Create synchronizer and form.
                ISynchronizer synchronizer = new StandardSynchronizer();
                synchronizer.Form = syncForm;

                while (keys.MoveNext())
                {
                    string drive = ((string)keys.Key).Substring(0, 3);

                    HashSet <Device> devices = (HashSet <Device>)keys.Value;
                    foreach (Device device in devices)
                    {
                        if (configuration.ConfirmMusicLocation && !GetMusicLocationConfirmation(drive + device.MediaRoot))
                        {
                            syncForm.CloseSafe();
                            syncForm     = null;
                            synchronizer = null;
                            return;
                        }

                        IITPlaylist playlist = PlaylistExists(device);
                        if (playlist == null)
                        {
                            MessageBox.Show("I could not synchronize '" + device.Name + "' because "
                                            + "the playlist does not exist! Try reconnecting the device. If the problem continues"
                                            + " please report the problem to the Notpod developers at http://www.sourceforge.net/projects/ita.",
                                            "Internal synchronization error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            continue;
                        }

                        synchronizer.Configuration         = deviceConfiguration;
                        synchronizer.SynchronizeError     += new SynchronizeErrorEventHandler(OnSynchronizeError);
                        synchronizer.SynchronizeComplete  += new SynchronizeCompleteEventHandler(OnSynchronizeComplete);
                        synchronizer.SynchronizeCancelled += new SynchronizeCancelledEventHandler(OnSynchronizeCancelled);
                        synchronizer.SynchronizeDevice((IITUserPlaylist)playlist, drive, device);
                    }
                }
            }
            catch (Exception ex)
            {
                l.Error(ex);

                string message = "I encountered an unexpected error while synchronizing your device(s). "
                                 + "\n\nPlease make sure your devices are properly "
                                 + "connected and try again.";

                itaTray.ShowBalloonTip(7, "Synchronize error", message, ToolTipIcon.Error);
            }

            if (syncForm != null && configuration.CloseSyncWindowOnSuccess)
            {
                syncForm.CloseSafe();
            }
        }
Пример #2
0
        private void ctxTraySynchronize_Click(object sender, EventArgs e)
        {
            // There are no devices connected.
            if (connectedDevices.GetConnectedDevices().Count == 0)
            {
                if (configuration.ShowNotificationPopups)
                {
                    itaTray.ShowBalloonTip(3, "No devices", "There are no connected devices to synchronize.", ToolTipIcon.Info);
                }

                return;
            }

            if (configuration.WarnOnSystemDrives && !PerformDeviceCheck())
            {
                return;
            }

            syncForm = new StandardSynchronizerForm();
            syncForm.Show();
            Thread thread = new Thread(new ThreadStart(PerformSynchronize));

            thread.Start();
        }
Пример #3
0
        public void PerformSynchronize()
        {


            Hashtable deviceinfo = connectedDevices.GetConnectedDevicesWithDrives();
            IEnumerator keys = deviceinfo.Keys.GetEnumerator();
            try
            {
                // Create synchronizer and form.
                ISynchronizer synchronizer = new StandardSynchronizer();                
                synchronizer.Form = syncForm;                

                while (keys.MoveNext())
                {
                    
                    string drive = (string)keys.Current;
                    Device device = (Device)deviceinfo[keys.Current];

                    if (configuration.ConfirmMusicLocation && !GetMusicLocationConfirmation(drive + device.MediaRoot))
                    {
                        syncForm.CloseSafe();
                        syncForm = null;
                        synchronizer = null;
                        return;
                    }

                    List<IITPlaylist> playlist = PlaylistExists(device);
                    if (playlist == null)
                    {
                        MessageBox.Show("I could not synchronize '" + device.Name + "' because "
                            + "the playlist does not exist! Try reconnecting the device. If the problem continues"
                            + " please report the problem to the Notpod developers at http://www.sourceforge.net/projects/ita.",
                            "Internal synchronization error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }

                    synchronizer.Configuration = deviceConfiguration;
                    synchronizer.SynchronizeError += new SynchronizeErrorEventHandler(OnSynchronizeError);
                    synchronizer.SynchronizeComplete += new SynchronizeCompleteEventHandler(OnSynchronizeComplete);
                    synchronizer.SynchronizeCancelled += new SynchronizeCancelledEventHandler(OnSynchronizeCancelled);
                    synchronizer.SynchronizeDevice(playlist, drive, device);

                }
                                
            }
            catch (Exception ex)
            {
                l.Error(ex);

                string message = "I encountered an unexpected error while synchronizing your device(s). "
                    + "\n\nPlease make sure your devices are properly "
                    + "connected and try again.";

                itaTray.ShowBalloonTip(7, "Synchronize error", message, ToolTipIcon.Error);
            }

            if (syncForm != null && configuration.CloseSyncWindowOnSuccess)
                syncForm.CloseSafe();
        }
Пример #4
0
        private void ctxTraySynchronize_Click(object sender, EventArgs e)
        {

            // There are no devices connected.
            if (connectedDevices.GetConnectedDevices().Count == 0)
            {
                if (configuration.ShowNotificationPopups)
                    itaTray.ShowBalloonTip(3, "No devices", "There are no connected devices to synchronize.", ToolTipIcon.Info);

                return;
            }

            if (configuration.WarnOnSystemDrives && !PerformDeviceCheck())
            {
                return;
            }

            syncForm = new StandardSynchronizerForm();
            syncForm.Show();
            Thread thread = new Thread(new ThreadStart(PerformSynchronize));
            thread.Start();
        }