Beispiel #1
0
        private void removeAllUncheckedToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            // Gather IDs
            ArrayList modelIds = new ArrayList();

            for (int i = 0; i < modelsBox.Items.Count; i++)
            {
                if (modelsBox.GetItemCheckState(i) == CheckState.Unchecked)
                {
                    modelIds.Add(i);
                }
            }

            // Reverse so we start at the end, or as we remove elements the indexes will be incorrect
            modelIds.Reverse();

            // Batch remove
            foreach (int id in modelIds)
            {
                string modelName = modelsBox.Items[id].ToString();

                // Fetching process
                IDownloaderProcess listener = _manager[modelName];

                // Initiating termination
                listener.Terminate();

                // Removing listener from lists
                if (_manager.RemoveModel(modelName))
                {
                    modelsBox.Items.RemoveAt(id);
                    Logger.Log(modelName, "Remove all unchecked");
                }
            }
        }
Beispiel #2
0
        private void removeMenuItem_Click(object sender, EventArgs e)
        {
            int idx = modelsBox.SelectedIndex;

            // Validating item
            if (idx == -1)
            {
                return;
            }

            string modelName = modelsBox.Items[idx].ToString();

            // Fetching process
            IDownloaderProcess listener = _manager[modelName];

            // Initiating termination
            listener.Terminate();

            // Removing listener from lists
            if (_manager.RemoveModel(modelName))
            {
                modelsBox.Items.RemoveAt(idx);
                Logger.Log(modelName, "Remove");
            }
            else
            {
                Logger.Log(modelName, "Remove failed");
            }
        }
Beispiel #3
0
        private void restartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string modelName = GetSelectedModelName();

            if (modelName == null)
            {
                return;
            }

            // Fetching process
            IDownloaderProcess listener = _manager[modelName];

            // Cancel restart if the listener is already running
            if (listener.IsRunning())
            {
                return;
            }

            // Otherwise, continue with the manual start
            listener.Start(true);
            Logger.Log(modelName, "Manual restart");
        }
Beispiel #4
0
        public void Stop()
        {
            // Stop thread
            if (Running)
            {
                _thread.Abort();
            }

            // Stop all downloader processes
            foreach (KeyValuePair <string, IDownloaderProcess> valuePair in _listeners)
            {
                string             modelName = valuePair.Key;
                IDownloaderProcess listener  = valuePair.Value;

                // Initiate termination
                listener.Terminate();

                // Remove listener from list
                IDownloaderProcess output;
                _listeners.TryRemove(modelName, out output);
            }
        }