Ejemplo n.º 1
0
        private void AddNewDeviceFromWizardDataStore(Wizard wizard)
        {
            CompatibleDevice device          = (CompatibleDevice)wizard.DataStore[WizardDataStoreKeys.DEVICE];
            String           name            = (String)wizard.DataStore[WizardDataStoreKeys.NAME];
            bool             openDevicePanel = (bool)wizard.DataStore[WizardDataStoreKeys.OPEN_PLAYLIST_PANEL];

            DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices");

            if (deviceCollection.GetDeviceWithIdentifier(device.Identifier) != null)
            {
                MessageBox.Show(this, "The device you are adding has already been added. You can only "
                                + "add a device once.\n\nIf you want several playlists synchronized to the same "
                                + "device, use the Playlists view to assign more playlists to your device.",
                                "Device already added", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }

            Device newDevice = new Device();

            newDevice.Identifier = device.Identifier;
            newDevice.Name       = name;

            deviceCollection.Devices.Add(newDevice);
            FlushDeviceConfigurationToFile();

            RefreshDevicesList();

            if (openDevicePanel)
            {
                mainForm.SwithcToMyDevicesPanel();
            }
        }
Ejemplo n.º 2
0
 protected virtual void OnDeviceRemoved(CompatibleDevice device)
 {
     if (DeviceRemoved != null)
     {
         DeviceRemoved(device);
     }
 }
Ejemplo n.º 3
0
        public void RefreshDevicesList()
        {
            DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices");

            lvDevices.Items.Clear();

            foreach (Device device in deviceCollection.Devices)
            {
                ListViewItem item = new ListViewItem();
                item.Text = device.Name;
                item.Name = device.Identifier;

                CompatibleDevice connectedDevice = supportedDevicesManager.GetConnectedDevice(device.Identifier);
                if (connectedDevice == null)
                {
                    item.SubItems.Add(Resources.StrDeviceStatusOffline);
                }
                else
                {
                    item.SubItems.Add(Resources.StrDeviceStatusOnline);
                }
                item.SubItems.Add("Unknown");
                item.SubItems.Add("Never");
                lvDevices.Items.Add(item);
            }

            lvDevices.Invalidate();
        }
Ejemplo n.º 4
0
 protected virtual void OnNewDeviceConnected(CompatibleDevice device)
 {
     if (NewDeviceConnected != null)
     {
         NewDeviceConnected(device);
     }
 }
Ejemplo n.º 5
0
        void BtnBrowseClick(object sender, EventArgs e)
        {
            Device selectedDevice = (Device)DataStore[WizardDataStoreKeys.PLAYLIST_ASSOCIATION_SELECTEDDEVICE];

            FolderBrowserDialog folderBrowser = new FolderBrowserDialog();

            folderBrowser.RootFolder = Environment.SpecialFolder.MyComputer;

            // TODO Need to set root folder of the browser to the root of the selected device.

            DialogResult result = folderBrowser.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                CompatibleDevice device = devicesManager.GetConnectedDevice(selectedDevice.Identifier);
                bool             folderExistsOnDevice = device.CheckPath(folderBrowser.SelectedPath);

                if (!folderExistsOnDevice)
                {
                    MessageBox.Show(this, String.Format("The folder you selected ({0}) was not found on the device '{1}'. Are you sure you browsed the correct device?",
                                                        folderBrowser.SelectedPath, selectedDevice.Name), "Unable to verify folder location",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                this.DataStore[WizardDataStoreKeys.PLAYLIST_ASSOCIATION_SELECTEDPATH] = folderBrowser.SelectedPath;
                lblSelectedDestination.Text = String.Format("{0}:\n{1}", Resources.StrPlaylistAssociationCurrentlySelected, folderBrowser.SelectedPath);
            }
        }
Ejemplo n.º 6
0
        public void NewDeviceConnectedEventHandler(CompatibleDevice connectedDevice)
        {
            DevicesPanel devicesPanel = GetDevicesPanel();
            devicesPanel.RefreshDevicesList();

            trayIcon.ShowBalloonTip(2000, "New device connected", connectedDevice.Name
                                    + " has been connected and is ready to be synchronized.", ToolTipIcon.Info);
        }
Ejemplo n.º 7
0
        public void DeviceRemovedEventHandler(CompatibleDevice removedDevice)
        {
            DevicesPanel devicesPanel = GetDevicesPanel();
            devicesPanel.RefreshDevicesList();

            trayIcon.ShowBalloonTip(2000, "Device removed", removedDevice.Name
                                    + " has been removed from the system.", ToolTipIcon.Info);
        }
Ejemplo n.º 8
0
        public void NewDeviceConnectedEventHandler(CompatibleDevice connectedDevice)
        {
            DevicesPanel devicesPanel = GetDevicesPanel();

            devicesPanel.RefreshDevicesList();

            trayIcon.ShowBalloonTip(2000, "New device connected", connectedDevice.Name
                                    + " has been connected and is ready to be synchronized.", ToolTipIcon.Info);
        }
Ejemplo n.º 9
0
        public void DeviceRemovedEventHandler(CompatibleDevice removedDevice)
        {
            DevicesPanel devicesPanel = GetDevicesPanel();

            devicesPanel.RefreshDevicesList();

            trayIcon.ShowBalloonTip(2000, "Device removed", removedDevice.Name
                                    + " has been removed from the system.", ToolTipIcon.Info);
        }
Ejemplo n.º 10
0
        public override void Populate()
        {
            String deviceName = (String)DataStore[WizardDataStoreKeys.NAME];

            if (deviceName != null)
            {
                textDeviceName.Text = deviceName;
            }
            else
            {
                CompatibleDevice selecteDevice = (CompatibleDevice)DataStore[WizardDataStoreKeys.DEVICE];
                textDeviceName.Text = "My " + selecteDevice.Name;
            }
        }
        public override void Populate()
        {
            CompatibleDevice selectedDevice = (CompatibleDevice)DataStore[WizardDataStoreKeys.DEVICE];

            listWPDDevices.Items.Clear();

            string[] deviceIds = devicesService.GetDeviceIds();
            foreach (string deviceId in deviceIds)
            {
                CompatibleDevice device = devicesService.GetDeviceById(deviceId);
                device.Connect();
                device.Disconnect();
                listWPDDevices.Items.Add(device);

                if (selectedDevice != null && selectedDevice.Identifier == device.Identifier)
                {
                    listWPDDevices.SelectedItem = device;
                }
            }
        }
Ejemplo n.º 12
0
        public void CheckForNewDevices()
        {
            string[] idsOfConnectedDevices = portableDevicesService.GetDeviceIds();
            foreach (string id in idsOfConnectedDevices)
            {
                if (CheckIfDeviceAlreadyRecognized(id))
                {
                    continue;
                }

                IEnumerable <Device> recognizedList = from c in configuredDevices.Devices where c.Identifier == id select c;
                if (recognizedList.Count() == 0)
                {
                    continue;
                }

                CompatibleDevice compatibleDevice = portableDevicesService.GetDeviceById(id);
                compatibleDevice.Connect();

                connectedDevices.Add(compatibleDevice);
                OnNewDeviceConnected(compatibleDevice);
            }
        }
Ejemplo n.º 13
0
 protected virtual void OnNewDeviceConnected(CompatibleDevice device)
 {
     if(NewDeviceConnected != null)
     {
         NewDeviceConnected(device);
     }
 }
Ejemplo n.º 14
0
 protected virtual void OnDeviceRemoved(CompatibleDevice device)
 {
     if(DeviceRemoved != null)
     {
         DeviceRemoved(device);
     }
 }