Skip to content

Commit

Permalink
ビューアのタブを閉じてもメモリが解放されない不具合を修正
Browse files Browse the repository at this point in the history
youtubeもビューアで開くように修正
  • Loading branch information
ggslyman committed Mar 21, 2014
1 parent b399d56 commit ef1e221
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@

##更新履歴

* 14/03/10 2.0.1 Rev.7
- ビューアのタブを閉じてもメモリが解放されない不具合を修正
- youtubeもビューアで開く様に変更

* 14/03/10 2.0.1 Rev.6
- https、ttpsでもリンクをはる様に修正
- イメージビューアを仮実装
Expand Down
25 changes: 20 additions & 5 deletions SpeechCast/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public FormMain()
void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
string url = e.Url.AbsoluteUri;

if (url.StartsWith(Response.AnchorUrl))
{
e.Cancel = true;
Expand All @@ -86,7 +85,13 @@ void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
else if (url.EndsWith("jpg") || url.EndsWith("png") || url.EndsWith("gif"))
{
e.Cancel = true;
oepnFormViewNewtab(url);
oepnFormViewNewtabImg(url);
}
else if (url.IndexOf("youtube.com/watch?v=")>0)
{
e.Cancel = true;
var id = url.Split('=');
oepnFormViewNewtabYoutube(id[1]);
}
else if (url.StartsWith("http:"))
{
Expand Down Expand Up @@ -2100,19 +2105,29 @@ private static string MatchKanaEvaluator(System.Text.RegularExpressions.Match m)

private void toolStripButton19_Click(object sender, EventArgs e)
{
oepnFormViewNewtab("http://peercasket.s3.amazonaws.com/2014s/title/d348fc17-c842-412f-bfe4-37af265905cd");
oepnFormViewNewtabImg("http://peercasket.s3.amazonaws.com/2014s/title/d348fc17-c842-412f-bfe4-37af265905cd");
}

// イメージビューア起動
public FormViewResource formViewResource = null;
private void oepnFormViewNewtab(string url)
private void oepnFormViewNewtabImg(string url)
{
if ((formViewResource == null) || formViewResource.IsDisposed)
{
formViewResource = new FormViewResource(UserConfig.FormViewToRect);
formViewResource.Show();
}
formViewResource.addTabImg(url);
formViewResource.Activate();
}
private void oepnFormViewNewtabYoutube(string id)
{
if ((formViewResource == null) || formViewResource.IsDisposed)
{
formViewResource = new FormViewResource(UserConfig.FormViewToRect);
formViewResource.Show();
}
formViewResource.addTab(url);
formViewResource.addTabYoutube(id);
formViewResource.Activate();
}
// ビューア位置の保存
Expand Down
20 changes: 18 additions & 2 deletions SpeechCast/FormViewResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class FormViewResource : Form
static public FormViewResource Instance;
private ImageList imgList = new ImageList();
public Rectangle rect;
public FormViewResource(Rectangle loadRect)
public FormViewResource(Rectangle loadRect)
{
rect = loadRect;
InitializeComponent();
Expand All @@ -35,7 +35,20 @@ private void FormViewResouce_Load(object sender, EventArgs e)
this.Height = rect.Height;
}

public void addTab(string url)
public void addTabYoutube(string id)
{
string widgetCode = "<iframe width=\"480\" height=\"360\" src=\"https://www.youtube.com/embed/" + id + "\" frameborder=\"0\" allowfullscreen></iframe>";
// コンテンツ格納用のWebブラウザを作成
WebBrowser wb = new WebBrowser();
wb.Dock = DockStyle.Fill;
wb.DocumentText = "<body>" + widgetCode + "</body>";

// タブを追加
TabPage tp = new TabPage();
tp.Controls.Add(wb);
this.tabControlContainer.TabPages.Add(tp);
}
public void addTabImg(string url)
{
// コンテンツ格納用のWebブラウザを作成
WebBrowser wb = new WebBrowser();
Expand Down Expand Up @@ -65,7 +78,10 @@ private void tabControlContainer_MouseDown(object sender, MouseEventArgs e)
//タブとマウス位置を比較し、クリックしたタブを選択
if (this.tabControlContainer.GetTabRect(i).Contains(e.X, e.Y))
{
TabPage rmPage = this.tabControlContainer.TabPages[i];
this.tabControlContainer.TabPages.Remove(this.tabControlContainer.TabPages[i]);
// タブを消しただけだとページがメモリ上に残るのでdisposeする
rmPage.Dispose();
// タブが無くなったらフォーム自体を閉じる
if (this.tabControlContainer.TabCount == 0)this.Close();
break;
Expand Down
4 changes: 2 additions & 2 deletions SpeechCast/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1.6")]
[assembly: AssemblyFileVersion("2.0.1.6")]
[assembly: AssemblyVersion("2.0.1.7")]
[assembly: AssemblyFileVersion("2.0.1.7")]

0 comments on commit ef1e221

Please sign in to comment.