예제 #1
0
        private void ClippingForm_Load(object sender, EventArgs e)
        {
            SetAnchorControl();
            FixWindowSize();

            // フォームを強制的に再描画
            this.Update();

            try
            {
                StationList.ClippingPodcast(this);
            }
            catch (OutOfMemoryException)
            {
                MessageBox.Show("ファイルがダウンロードできませんでした", "警告");
            }
            catch (IOException)
            {
                MessageBox.Show("ファイルがダウンロードできませんでした", "警告");
            }
            catch (ArgumentException)
            {
                MessageBox.Show("ファイルがダウンロードできませんでした", "警告");
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("ファイルがダウンロードできませんでした", "警告");
            }
            catch (ClippingException ex)
            {
                MessageBox.Show("クリップできなかったPodcastがあります\n" + ex.Message, "警告");
            }

            this.Close();
        }
예제 #2
0
        /// <summary>
        /// チェックした番組をダウンロードし、RSSを作成する
        /// </summary>
        private void ClipPodcast()
        {
            // 選択された番組のリスト
            ArrayList alSelectedGlobalChannels = new ArrayList();

            // 選択された番組で未クリップの番組のリストを作る
            foreach (IChannel channel in StationList.GetUnclipedChannelsOfCurrentStation())
            {
                if (channel.Check == true)
                {
                    alSelectedGlobalChannels.Add(channel);
                }
            }

            // 選択された未クリップの番組がある場合のみ
            if (alSelectedGlobalChannels.Count != 0)
            {
                ClippingForm clippingForm = new ClippingForm();
                clippingForm.ShowDialog();
                clippingForm.Dispose();
            }
            // 選択された未クリップの番組が無い場合は警告を出す
            else
            {
                MessageBox.Show("未クリップの番組が選択されていません", "情報");
            }
        }
예제 #3
0
        private void StationsSettingForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // 放送局を追加し忘れていると思われる場合
            if (podcastUrlTextBox.Text.Trim().Length != 0)
            {
                // 追加するかを聞く
                DialogResult result = MessageBox.Show(
                    podcastUrlTextBox.Text.Trim() + "を追加しますか?\n(" + podcastUrlTextBox.Text.Trim() + "はまだ追加されていません)",
                    "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    CreateStation();
                }
            }

            // 設定の書き込み
            StationList.SetStationList((Station[])alStationList.ToArray(typeof(Station)));
            try
            {
                UserSetting.SaveSetting();
            }
            catch (IOException)
            {
                MessageBox.Show("設定ファイルが書き込めませんでした", "設定ファイル書き込みエラー");
            }
        }
예제 #4
0
        private void StationStartupSettingForm_Load(object sender, EventArgs e)
        {
            downloadNumNumericUpDown.Minimum     = Station.STARTUP_DOWNLOAD_NUM_MIN;
            deleteRemainDayNumericUpDown.Minimum = Station.STARTUP_DELETE_REMAIN_DAY_MIN;

            Station[] stations = StationList.GetStationList();
            stationStartupSettings = new StationStartupSetting[stations.Length];
            for (int i = 0; i < stations.Length; ++i)
            {
                stationStartupSettings[i] = new StationStartupSetting(stations[i]);
            }

            foreach (Station station in StationList.GetStationList())
            {
                stationListComboBox.Items.Add(station.Name);
            }

            if (stationListComboBox.Items.Count > 0)
            {
                stationListComboBox.SelectedIndex = 0;
            }
            else
            {
                stationListComboBox.Enabled          = false;
                startupDownloadCheckBox.Enabled      = false;
                downloadNumNumericUpDown.Enabled     = false;
                startupDeleteCheckBox.Enabled        = false;
                deleteRemainDayNumericUpDown.Enabled = false;
            }
        }
예제 #5
0
        /// <summary>
        /// チェックした番組を削除する
        /// </summary>
        private void DeletePodcast()
        {
            #region UI前処理

            // フォームをいったん選択不可にする
            this.Enabled = false;

            #endregion

            #region 削除処理

            // 選択された番組のリスト
            ArrayList alSelectedLocalChannels = new ArrayList();

            // 選択された番組でクリップ済みの番組のリストを作る
            foreach (IChannel channel in StationList.GetChannelsOfCurrentStationFromLocalHeadline())
            {
                if (channel.Check == true)
                {
                    alSelectedLocalChannels.Add(channel);
                }
            }

            // 選択された番組がある場合
            if (alSelectedLocalChannels.Count != 0)
            {
                foreach (IChannel channel in (IChannel[])alSelectedLocalChannels.ToArray(typeof(IChannel)))
                {
                    try
                    {
                        // ヘッドラインから自分を削除
                        channel.DeleteClipFile();
                    }
                    catch (FileNotFoundException)
                    {
                        ;
                    }
                    catch (IOException)
                    {
                        MessageBox.Show("ファイルが削除できませんでした。他のプログラムでファイルが使用されている可能性があります。", "ファイルエラー");
                    }
                }
            }

            // RSSを作成
            StationList.GenerateRssLocalHeadlines();

            #endregion

            #region UI後処理

            // フォームを選択可能に回復する
            this.Enabled = true;

            #endregion
        }
예제 #6
0
        /// <summary>
        /// 選択された番組からm3uファイルを作成し、それをメディアプレイヤーに渡して実行する
        /// </summary>
        private void PlayPodcast()
        {
            // 選択された番組のリスト
            ArrayList alSelectedLocalChannels = new ArrayList();

            // 選択された番組でクリップ済みの番組のリストを作る
            foreach (IChannel channel in StationList.GetChannelsOfCurrentStationFromLocalHeadline())
            {
                if (channel.Check == true)
                {
                    alSelectedLocalChannels.Add(channel);
                }
            }

            // 選択されたクリップ済みの番組が無い場合は警告を出して終了
            if (alSelectedLocalChannels.Count == 0)
            {
                MessageBox.Show("クリップ済みの番組が選択されていません", "情報");

                return;
            }

            // すでにあるm3uファイルを削除
            if (File.Exists(UserSetting.M3uFilePath))
            {
                File.Delete(UserSetting.M3uFilePath);
            }

            try
            {
                // ディレクトリを作成する
                if (Directory.Exists(UserSetting.PodcastClipDirectoryPath) == false)
                {
                    Directory.CreateDirectory(UserSetting.PodcastClipDirectoryPath);
                }

                using (StreamWriter sw = new StreamWriter(UserSetting.M3uFilePath, false, Encoding.Default))
                {
                    foreach (IChannel channel in (IChannel[])alSelectedLocalChannels.ToArray(typeof(IChannel)))
                    {
                        sw.WriteLine(channel.GetPlayUrl().LocalPath);
                    }
                }
            }
            catch (IOException) { }

            try
            {
                PodcasCoUtility.PlayStreaming(UserSetting.M3uFilePath);
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("メディアプレイヤーが見つかりません", "警告");
            }
        }
예제 #7
0
        private void StationsSettingForm_Load(object sender, EventArgs e)
        {
            SetAnchorControl();
            FixWindowSize();
            ButtonsEnable();

            // 放送局情報の読み込み
            foreach (Station station in StationList.GetStationList())
            {
                alStationList.Add(station);
                stationListBox.Items.Add(station.DisplayName);
            }
        }
예제 #8
0
        /// <summary>
        /// 切り替えボックスの追加
        /// </summary>
        private void AddStationFilterComboBoxItem()
        {
            // フォームをいったん選択不可にする
            this.Enabled = false;
            // 各放送局の切り替えボックスをいったんクリアする
            this.stationFilterComboBox.Items.Clear();
            // 切り替えボックスの先頭に"All"を追加
            this.stationFilterComboBox.Items.Add("All");
            // 各放送局の切り替えボックスの追加
            foreach (Station station in StationList.GetStationList())
            {
                this.stationFilterComboBox.Items.Add(station.DisplayName);
            }
            // 切り替えボックスが追加し終わったので、フォームを選択可能にする
            this.Enabled = true;

            // 放送局が選択されておらず、かつ放送局がある場合
            if (this.stationFilterComboBox.SelectedIndex == -1 && this.stationFilterComboBox.Items.Count > 0)
            {
                // トップの放送局を選択
                this.stationFilterComboBox.SelectedIndex = 0;
            }
        }
예제 #9
0
        private void SettingForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // 設定の書き込み
            UserSetting.PodcastClipDirectoryPath = podcastClipDirectoryPathTextBox.Text.Trim();
            UserSetting.MediaPlayerPath          = mediaPlayerPathTextBox.Text.Trim();
            UserSetting.BrowserPath = browserPathTextBox.Text.Trim();
            if (proxyUnuseRadioButton.Checked == true)
            {
                UserSetting.ProxyUse = UserSetting.ProxyConnect.Unuse;
            }
            else if (proxyUseOsSettingRadioButton.Checked == true)
            {
                UserSetting.ProxyUse = UserSetting.ProxyConnect.OsSetting;
            }
            else if (proxyUseOriginalSettingRadioButton.Checked == true)
            {
                UserSetting.ProxyUse = UserSetting.ProxyConnect.OriginalSetting;
            }
            else
            {
                // ここに到達することはあり得ない
                Trace.Assert(false, "想定外の動作のため、終了します");
            }
            UserSetting.ProxyServer = proxyServerTextBox.Text.Trim();
            try
            {
                UserSetting.ProxyPort = int.Parse(proxyPortTextBox.Text.Trim());
            }
            catch (ArgumentException)
            {
                ;
            }
            catch (FormatException)
            {
                ;
            }
            catch (OverflowException)
            {
                ;
            }

            try
            {
                UserSetting.SaveSetting();
            }
            catch (IOException)
            {
                MessageBox.Show("設定ファイルが書き込めませんでした", "設定ファイル書き込みエラー");
            }

            if (podcastClipDirectoryPathTextBox.Modified == true)
            {
                // 「Podcastをクリップするフォルダ」にローカルヘッドラインが格納されるために、
                // 「Podcastをクリップするフォルダ」の場所が変わったので、ローカルヘッドラインの
                // URLを作り直す
                foreach (Station station in StationList.GetStationList())
                {
                    // ローカルヘッドラインのURLの作り直し
                    station.LocalHeadline.SetUrl(
                        new Uri(UserSetting.PodcastClipDirectoryPath + @"\"
                                + station.LocalHeadline.GetId() + @"\" + PodcasCoInfo.LocalRssFile));
                    // ローカルヘッドラインの番組を破棄する
                    station.LocalHeadline.ClearChannels();
                    // ローカルヘッドラインの内容が書き換わったので設定を保存する
                    station.LocalHeadline.SaveSetting();
                }
            }
        }
예제 #10
0
        /// <summary>
        /// 設定をファイルに保存
        /// </summary>
        public static void SaveSetting()
        {
            FileStream    fs     = null;
            XmlTextWriter writer = null;

            try
            {
                fs     = new FileStream(SettingPath, FileMode.Create, FileAccess.Write);
                writer = new XmlTextWriter(fs, Encoding.GetEncoding("utf-8"));

                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument(true);

                writer.WriteStartElement("Setting");

                writer.WriteStartElement("Header");

                writer.WriteStartElement("Name");
                writer.WriteAttributeString("name", PodcasCoInfo.ApplicationName);
                writer.WriteEndElement(); // End of Name.
                writer.WriteStartElement("Version");
                writer.WriteAttributeString("version", PodcasCoInfo.VersionNumber);
                writer.WriteEndElement(); // End of Version.

                writer.WriteStartElement("Date");
                writer.WriteAttributeString("date", DateTime.Now.ToString());
                writer.WriteEndElement(); // End of Date.

                writer.WriteEndElement(); // End of Header.

                writer.WriteStartElement("Content");

                writer.WriteStartElement("StationList");
                foreach (Station station in StationList.GetStationList())
                {
                    writer.WriteStartElement("Station");
                    writer.WriteAttributeString("id", station.Id);
                    writer.WriteAttributeString("name", station.Name);
                    writer.WriteAttributeString("kind", station.Kind.ToString());
                    writer.WriteAttributeString("startupDownload", station.StartupDownload.ToString());
                    writer.WriteAttributeString("startupDownloadNum", station.StartupDownloadNum.ToString());
                    writer.WriteAttributeString("startupDelete", station.StartupDelete.ToString());
                    writer.WriteAttributeString("startupDeleteRemainDay", station.StartupDeleteRemainDay.ToString());
                    writer.WriteEndElement(); // End of Station
                }
                writer.WriteEndElement();     // End of StationList

                writer.WriteStartElement("PodcastClipDirectoryPath");
                writer.WriteAttributeString("path", PodcastClipDirectoryPath);
                writer.WriteEndElement(); // End of PodcastClipDirectoryPath

                writer.WriteStartElement("MediaPlayerPath");
                writer.WriteAttributeString("path", MediaPlayerPath);
                writer.WriteEndElement(); // End of MediaPlayerPath

                writer.WriteStartElement("BrowserPath");
                writer.WriteAttributeString("path", BrowserPath);
                writer.WriteEndElement(); // End of BrowserPath

                writer.WriteStartElement("Proxy");
                writer.WriteAttributeString("use", ProxyUse.ToString());
                writer.WriteAttributeString("server", ProxyServer);
                writer.WriteAttributeString("port", ProxyPort.ToString());
                writer.WriteEndElement(); // End of Porxy

                writer.WriteStartElement("ChannelSort");
                writer.WriteAttributeString("sort", ChannelSort.ToString());
                writer.WriteEndElement(); // End of ChannelSort

                writer.WriteEndElement(); // End of Content.

                writer.WriteEndElement(); // End of Setting.

                writer.WriteEndDocument();
            }
            finally
            {
                writer.Close();
                fs.Close();
            }
        }
예제 #11
0
        /// <summary>
        /// 設定をファイルから読み込む
        /// </summary>
        public static void LoadSetting()
        {
            if (File.Exists(SettingPath))
            {
                FileStream    fs     = null;
                XmlTextReader reader = null;

                try
                {
                    fs     = new FileStream(SettingPath, FileMode.Open, FileAccess.Read);
                    reader = new XmlTextReader(fs);

                    ArrayList alStation = new ArrayList();

                    // StationListタグの中にいるか
                    bool inStationListFlag = false;

                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.LocalName == "StationList")
                            {
                                inStationListFlag = true;
                            } // End of StationList
                            // StationListタグの中にいる場合
                            else if (inStationListFlag == true)
                            {
                                if (reader.LocalName == "Station")
                                {
                                    string id   = string.Empty;
                                    string name = string.Empty;
                                    Station.StationKind stationKind = Station.StationKind.RssPodcast;
                                    bool startupDownload            = false;
                                    int  startupDownloadNum         = Station.STARTUP_DOWNLOAD_NUM_MIN;
                                    bool startupDelete          = false;
                                    int  startupDeleteRemainDay = Station.STARTUP_DELETE_REMAIN_DAY_MIN;

                                    if (reader.MoveToFirstAttribute())
                                    {
                                        id   = reader.GetAttribute("id");
                                        name = reader.GetAttribute("name");

                                        string kind = reader.GetAttribute("kind");
                                        if (kind == Station.StationKind.RssPodcast.ToString())
                                        {
                                            stationKind = Station.StationKind.RssPodcast;
                                        }
                                        else
                                        {
                                            // ここに到達することはあり得ない
                                            Trace.Assert(false, "想定外の動作のため、終了します");
                                        }

                                        string startupDownloadString = reader.GetAttribute("startupDownload");
                                        if (startupDownloadString == true.ToString())
                                        {
                                            startupDownload = true;
                                        }
                                        else
                                        {
                                            startupDownload = false;
                                        }

                                        string startupDownloadNumString = reader.GetAttribute("startupDownloadNum");
                                        if (startupDownloadNumString != null)
                                        {
                                            try
                                            {
                                                startupDownloadNum = int.Parse(startupDownloadNumString);
                                            }
                                            catch (ArgumentException)
                                            {
                                                ;
                                            }
                                            catch (FormatException)
                                            {
                                                ;
                                            }
                                            catch (OverflowException)
                                            {
                                                ;
                                            }
                                        }
                                        if (startupDownloadNum < Station.STARTUP_DOWNLOAD_NUM_MIN)
                                        {
                                            startupDownloadNum = Station.STARTUP_DOWNLOAD_NUM_MIN;
                                        }

                                        string startupDeleteString = reader.GetAttribute("startupDelete");
                                        if (startupDeleteString == true.ToString())
                                        {
                                            startupDelete = true;
                                        }
                                        else
                                        {
                                            startupDelete = false;
                                        }

                                        string startupDeleteRemainDayString = reader.GetAttribute("startupDeleteRemainDay");
                                        if (startupDeleteRemainDayString != null)
                                        {
                                            try
                                            {
                                                startupDeleteRemainDay = int.Parse(startupDeleteRemainDayString);
                                            }
                                            catch (ArgumentException)
                                            {
                                                ;
                                            }
                                            catch (FormatException)
                                            {
                                                ;
                                            }
                                            catch (OverflowException)
                                            {
                                                ;
                                            }
                                        }

                                        #region Version 0.7 〜 Version 0.8 TestRelease5互換
                                        string startupDeleteDayString = reader.GetAttribute("startupDeleteDay");
                                        if (startupDeleteDayString != null)
                                        {
                                            try
                                            {
                                                startupDeleteRemainDay = int.Parse(startupDeleteDayString) + 1;
                                            }
                                            catch (ArgumentException)
                                            {
                                                ;
                                            }
                                            catch (FormatException)
                                            {
                                                ;
                                            }
                                            catch (OverflowException)
                                            {
                                                ;
                                            }
                                        }
                                        #endregion // Version 0.7 〜 Version 0.8 TestRelease5互換

                                        if (startupDeleteRemainDay < Station.STARTUP_DELETE_REMAIN_DAY_MIN)
                                        {
                                            startupDeleteRemainDay = Station.STARTUP_DELETE_REMAIN_DAY_MIN;
                                        }

                                        try
                                        {
                                            Station station = new Station(id, name, stationKind);
                                            station.StartupDownload        = startupDownload;
                                            station.StartupDownloadNum     = startupDownloadNum;
                                            station.StartupDelete          = startupDelete;
                                            station.StartupDeleteRemainDay = startupDeleteRemainDay;
                                            alStation.Add(station);
                                        }
                                        // ローカルヘッドラインの解析が失敗した場合は、そのヘッドラインを無視する
                                        catch (XmlException)
                                        {
                                            ;
                                        }
                                        catch (IOException)
                                        {
                                            ;
                                        }
                                    }
                                } // End of Station
                            }     // End of StationListタグの中にいる場合
                            else if (reader.LocalName == "PodcastClipDirectoryPath")
                            {
                                string path = reader.GetAttribute("path");
                                if (path.Length > 0)
                                {
                                    PodcastClipDirectoryPath = path;
                                }
                            } // End of PodcastClipDirectory
                            else if (reader.LocalName == "MediaPlayerPath")
                            {
                                MediaPlayerPath = reader.GetAttribute("path");
                            } // End of MediaPlayerPath
                            else if (reader.LocalName == "BrowserPath")
                            {
                                BrowserPath = reader.GetAttribute("path");
                            } // End of BrowserPath
                            else if (reader.LocalName == "Proxy")
                            {
                                if (reader.MoveToFirstAttribute())
                                {
                                    string use = reader.GetAttribute("use");
                                    if (use == ProxyConnect.Unuse.ToString())
                                    {
                                        ProxyUse = ProxyConnect.Unuse;
                                    }
                                    else if (use == ProxyConnect.OsSetting.ToString())
                                    {
                                        ProxyUse = ProxyConnect.OsSetting;
                                    }
                                    else if (use == ProxyConnect.OriginalSetting.ToString())
                                    {
                                        ProxyUse = ProxyConnect.OriginalSetting;
                                    }

                                    ProxyServer = reader.GetAttribute("server");

                                    try
                                    {
                                        string port = reader.GetAttribute("port");
                                        ProxyPort = int.Parse(port);
                                    }
                                    catch (ArgumentException)
                                    {
                                        ;
                                    }
                                    catch (FormatException)
                                    {
                                        ;
                                    }
                                    catch (OverflowException)
                                    {
                                        ;
                                    }
                                }
                            } // End of Proxy
                            else if (reader.LocalName == "DownloadBuffer")
                            {
                                if (reader.MoveToFirstAttribute())
                                {
                                    try
                                    {
                                        string size = reader.GetAttribute("size");
                                        DownLoadBufferSize = long.Parse(size);
                                    }
                                    catch (ArgumentException)
                                    {
                                        ;
                                    }
                                    catch (FormatException)
                                    {
                                        ;
                                    }
                                    catch (OverflowException)
                                    {
                                        ;
                                    }
                                }
                            } // End of DownloadBuffer
                            else if (reader.LocalName == "ChannelSort")
                            {
                                string sort = reader.GetAttribute("sort");
                                if (sort == ChannelSorts.None.ToString())
                                {
                                    ChannelSort = ChannelSorts.None;
                                }
                                else if (sort == ChannelSorts.DateNewer.ToString())
                                {
                                    ChannelSort = ChannelSorts.DateNewer;
                                }
                                else if (sort == ChannelSorts.DateOlder.ToString())
                                {
                                    ChannelSort = ChannelSorts.DateOlder;
                                }
                            } // End of ChannelSort
                        }
                        else if (reader.NodeType == XmlNodeType.EndElement)
                        {
                            if (reader.LocalName == "StationList")
                            {
                                inStationListFlag = false;
                                StationList.SetStationList((Station[])alStation.ToArray(typeof(Station)));
                            }
                        }
                    }
                }
                finally
                {
                    reader.Close();
                    fs.Close();
                }
            }
        }
예제 #12
0
        /// <summary>
        /// 番組をクリップする
        /// </summary>
        /// <param name="clippingForm">ClippingForm</param>
        public static void ClippingPodcast(ClippingForm clippingForm)
        {
            // すでにクリップした番組
            int alreadyClippingFiles = 0;

            // クリップできない番組があったか
            bool cannotCliped = false;

            // クリップできなかった番組の情報
            string cannotClipedString = string.Empty;

            // 選択された番組のリスト
            ArrayList alSelectedGlobalChannels = new ArrayList();

            // 選択された番組で未クリップの番組のリストを作る
            foreach (IChannel channel in GetUnclipedChannelsOfCurrentStation())
            {
                if (channel.Check == true)
                {
                    alSelectedGlobalChannels.Add(channel);
                }
            }

            if (clippingForm != null)
            {
                clippingForm.OnFile(new FileEventArgs(0, alSelectedGlobalChannels.Count));
            }

            foreach (IChannel channel in (IChannel[])alSelectedGlobalChannels.ToArray(typeof(IChannel)))
            {
                try
                {
                    // URLがnullの場合に対処
                    if (channel.GetPlayUrl() == null)
                    {
                        throw new WebException();
                    }

                    string directoryName = UserSetting.PodcastClipDirectoryPath
                                           + @"\" + channel.ParentHeadline.ParentStation.LocalHeadline.GetId();

                    if (Directory.Exists(directoryName) == false)
                    {
                        Directory.CreateDirectory(directoryName);
                    }

                    string generateFilePath = directoryName + @"\"
                                              + Path.GetFileNameWithoutExtension(channel.GetPlayUrl().LocalPath)
                                              + "-" + channel.GetHash().ToString("x")
                                              + Path.GetExtension(channel.GetPlayUrl().LocalPath);

                    PodcasCoUtility.FetchFile(channel.GetPlayUrl(), generateFilePath,
                                              new FetchEventHandler(clippingForm.ClipReceiver),
                                              new FetchEventHandler(clippingForm.ClippingReceiver),
                                              null);

                    // 番組をローカルヘッドラインに加える
                    IChannel localChannel = (IChannel)channel.Clone(channel.ParentHeadline.ParentStation.LocalHeadline);
                    localChannel.SetPlayUrl(new Uri(generateFilePath));
                    localChannel.ParentHeadline.ParentStation.LocalHeadline.AddChannel(localChannel);

                    // ダウンロードした番組の元のグローバル番組からはチェックを外す
                    channel.Check = false;
                }
                catch (WebException)
                {
                    cannotCliped        = true;
                    cannotClipedString += channel.ParentHeadline.ParentStation.Name + " - " + channel.GetTitle() + "\n";
                }
                catch (UriFormatException)
                {
                    cannotCliped        = true;
                    cannotClipedString += channel.ParentHeadline.ParentStation.Name + " - " + channel.GetTitle() + "\n";
                }
                catch (SocketException)
                {
                    cannotCliped        = true;
                    cannotClipedString += channel.ParentHeadline.ParentStation.Name + " - " + channel.GetTitle() + "\n";
                }

                if (clippingForm != null)
                {
                    clippingForm.OnFiling(new FileEventArgs(++alreadyClippingFiles, alSelectedGlobalChannels.Count));
                }
            }

            // RSSを作成
            StationList.GenerateRssLocalHeadlines();

            if (cannotCliped == true)
            {
                throw new ClippingException(cannotClipedString);
            }
        }
예제 #13
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // 起動時のチェック
                PodcasCoSpecificProcess.StartUpCheck();
            }
            catch (DllNotFoundException ex)
            {
                MessageBox.Show(ex.Message);
                Application.Exit();

                return;
            }

            try
            {
                // 起動時の初期化
                PodcasCoSpecificProcess.StartUpInitialize();

                StationList.StationListChanged += new EventHandler(StationList_StationListChanged);

                AddStationFilterComboBoxItem();

                // 起動直後には放送局切り替えボックスで"All"を選択する
                stationFilterComboBox.SelectedIndex = 0;

                // 放送局リストがある場合
                if (StationList.GetStationList().Length > 0)
                {
                    // ローカルヘッドラインのみの番組表をチェックする
                    CheckHeadlines(CheckHeadlinesOption.LocalOnly);
                }
            }
            catch (XmlException)
            {
                MessageBox.Show("設定ファイルが読み込めませんでした", "設定ファイルの解析エラー");
            }
            catch (IOException)
            {
                MessageBox.Show("設定ファイルが読み込めませんでした", "設定ファイルの読み込みエラー");
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("設定ファイルが読み込めませんでした", "設定ファイルの読み込みエラー");
            }

            StationList.HeadlineFetching  += new FetchEventHandler(StationList_HeadlineFetching);
            StationList.HeadlineAnalyzing += new HeadlineAnalyzeEventHandler(StationList_HeadlineAnalyzing);

            #region 起動時自動ダウンロード

            // クリップする番組の数をカウントする
            int clipCount = 0;

            foreach (Station station in StationList.GetStationList())
            {
                // 現在の放送局を設定する
                StationList.ChangeCurrentStation(station);

                // 指定の個数の番組を自動ダウンロードし、指定の日数より古い番組を自動削除する
                if (station.StartupDownload == true && station.StartupDelete == true)
                {
                    // 指定の個数の番組を自動ダウンロードする
                    if (station.StartupDownloadNum > 0)
                    {
                        // グローバルヘッドラインを取得する
                        station.GlobalHeadline.FetchHeadline();
                        // グローバル・ローカルの両方の番組
                        IChannel[] channels = StationList.GetChannelsOfCurrentStationFromAllHeadline();
                        // 日付で降順ソートする
                        Array.Sort(channels, 0, channels.Length, (IComparer) new ChannelDateComparer());
                        Array.Reverse(channels, 0, channels.Length);

                        // これより古い日付のものはダウンロードしない
                        DateTime undownloadDate = DateTime.Today.Subtract(new TimeSpan(station.StartupDeleteRemainDay - 1, 0, 0, 0));

                        for (int i = 0; i < station.StartupDownloadNum && i < channels.Length; ++i)
                        {
                            if (station.ContainLocalHeadline(channels[i]) == false && channels[i].GetDate() > undownloadDate)
                            {
                                // チェックを立てる
                                channels[i].Check = true;
                                ++clipCount;
                            }
                        }
                    }
                }
                else if (station.StartupDownload == true && station.StartupDelete == false)
                {
                    // 指定の個数の番組を自動ダウンロードする
                    if (station.StartupDownloadNum > 0)
                    {
                        // グローバルヘッドラインを取得する
                        station.GlobalHeadline.FetchHeadline();
                        // グローバル・ローカルの両方の番組
                        IChannel[] channels = StationList.GetChannelsOfCurrentStationFromAllHeadline();
                        // 日付で降順ソートする
                        Array.Sort(channels, 0, channels.Length, (IComparer) new ChannelDateComparer());
                        Array.Reverse(channels, 0, channels.Length);

                        for (int i = 0; i < station.StartupDownloadNum && i < channels.Length; ++i)
                        {
                            if (station.ContainLocalHeadline(channels[i]) == false)
                            {
                                // チェックを立てる
                                channels[i].Check = true;
                                ++clipCount;
                            }
                        }
                    }
                }
            }

            // 現在の放送局を全放送局に戻す
            StationList.ChangeCurrentStationAt(-1);

            // ダウンロードする番組が存在する場合
            if (clipCount > 0)
            {
                // チェックのある番組をダウンロードする
                ClipPodcast();
            }

            #endregion // 起動時自動ダウンロード

            #region 起動時自動削除

            // クリップする番組の数をカウントする
            int deleteCount = 0;

            foreach (Station station in StationList.GetStationList())
            {
                // 指定の日数より古い番組を自動削除する
                if (station.StartupDelete == true)
                {
                    // これより古い日付のものは削除する
                    DateTime deleteDate = DateTime.Today.Subtract(new TimeSpan(station.StartupDeleteRemainDay - 1, 0, 0, 0));
                    foreach (IChannel channel in station.LocalHeadline.GetChannels())
                    {
                        if (channel.GetDate() <= deleteDate)
                        {
                            channel.Check = true;
                            ++deleteCount;
                        }
                    }
                }
            }

            // 削除する番組が存在する場合
            if (deleteCount > 0)
            {
                // チェックのある番組を削除する
                DeletePodcast();
            }

            #endregion // 起動時自動削除

            // 番組リストを更新する
            UpdateChannelList();

            SetAnchorControl();
            FixWindowSize();
        }
예제 #14
0
        /// <summary>
        /// 番組リストの更新処理
        /// </summary>
        private void UpdateChannelList()
        {
            #region UI前処理

            // フォームををいったん選択不可にする
            this.Enabled = false;

            #endregion

            #region フィルタリング処理

            // 放送局切り替えボックス Allが選択されている場合
            if (stationFilterComboBox.SelectedIndex == 0)
            {
                // 全放送局を対象とする
                StationList.ChangeCurrentStationAt(-1);
            }
            else
            {
                /*
                 * 放送局切り替えボックスに対して、StationList配列の並びは-1となるため、-1を指定
                 * stationListComboBox => ALL, Station1, Station2 ...
                 * StationList => Station1, Station2 ...
                 */
                StationList.ChangeCurrentStationAt(stationFilterComboBox.SelectedIndex - 1);
            }

            // クリップ ALLが選択されている場合
            if (allClipRadioButton.Checked == true)
            {
                currentChannels = StationList.GetChannelsOfCurrentStationFromAllHeadline();
            }
            // クリップ Clipedが選択されている場合
            else if (clipedRadioButton.Checked == true)
            {
                currentChannels = StationList.GetChannelsOfCurrentStationFromLocalHeadline();
            }
            // クリップ Unclipedが選択されている場合
            else if (unclipedRadioButton.Checked == true)
            {
                currentChannels = StationList.GetUnclipedChannelsOfCurrentStation();
            }
            else
            {
                // ここに到達することはあり得ない
                Trace.Assert(false, "想定外の動作のため、終了します");
            }

            switch (UserSetting.ChannelSort)
            {
            case UserSetting.ChannelSorts.DateOlder:
                Array.Sort(currentChannels, 0, currentChannels.Length, new DateOlderComparer());
                break;

            case UserSetting.ChannelSorts.DateNewer:
                Array.Sort(currentChannels, 0, currentChannels.Length, new DateNewerComparer());
                break;

            default:
                break;
            }

            DrawChannelList(currentChannels);

            mainStatusBar.Text = "Last " + DateTime.Now.ToString()
                                 + " - A:" + StationList.GetChannelsOfCurrentStationFromAllHeadline().Length
                                 + " C:" + StationList.GetChannelsOfCurrentStationFromLocalHeadline().Length
                                 + " U:" + StationList.GetUnclipedChannelsOfCurrentStation().Length;

            #endregion

            #region UI後処理

            AutoResizeColumnListView(channelListView);

            // フォームを選択可能に回復する
            this.Enabled = true;

            #endregion
        }
예제 #15
0
        /// <summary>
        /// ヘッドラインを取得、表示する
        /// </summary>
        /// <param name="option">オプション。CheckHeadlinesOption.LocalOnlyの場合はローカルのヘッドラインのみが対象となる。</param>
        private void CheckHeadlines(CheckHeadlinesOption option)
        {
            try
            {
                #region UI前処理

                // フォームをいったん選択不可にする
                this.Enabled = false;

                #endregion

                mainStatusBar.Text = "接続中...";
                mainStatusBar.Refresh();

                #region 番組取得処理

                if (option == CheckHeadlinesOption.GlobalAndLocal)
                {
                    // 番組を取得する(グローバル・ローカル)
                    StationList.FetchGlobalHeadlineOfCurrentStation();
                    StationList.FetchLocalHeadlineOnStations();
                }
                else if (option == CheckHeadlinesOption.LocalOnly)
                {
                    // 番組を取得する(ローカル)
                    StationList.FetchLocalHeadlineOnStations();
                }
                else
                {
                    // ここに到達することはあり得ない
                    Trace.Assert(false, "想定外の動作のため、終了します");
                }

                #endregion

                // 番組リストを更新する
                UpdateChannelList();
            }
            catch (WebException)
            {
                MessageBox.Show("番組表を取得できませんでした", "接続エラー");
            }
            catch (OutOfMemoryException)
            {
                MessageBox.Show("メモリが足りません", "メモリエラー");
            }
            catch (IOException)
            {
                MessageBox.Show("記録デバイスが何らかのエラーです", "デバイスエラー");
            }
            catch (UriFormatException)
            {
                MessageBox.Show(StationList.StationNameOfCurrentStation + "のURLが不正です", "URLエラー");
            }
            catch (SocketException)
            {
                MessageBox.Show("番組表を取得できませんでした", "ネットワークエラー");
            }
            catch (NotSupportedException)
            {
                MessageBox.Show(StationList.StationNameOfCurrentStation + "のURLが不正です", "URLエラー");
            }
            catch (XmlException)
            {
                MessageBox.Show("XML形式のヘッドラインが正常に処理できませんでした", "XMLエラー");
            }
            catch (ArgumentException)
            {
                MessageBox.Show(StationList.StationNameOfCurrentStation + "のURLが不正です", "URLエラー");
            }
            finally
            {
                #region UI後処理

                // フォームを選択可能に回復する
                this.Enabled = true;

                #endregion
            }
        }