Skip to content

Commit

Permalink
Merge pull request #16 from DigitalPlatform/master
Browse files Browse the repository at this point in the history
同步源
  • Loading branch information
renyh1013 committed Apr 22, 2016
2 parents 07a3fc3 + 4b0be14 commit aa94cff
Show file tree
Hide file tree
Showing 29 changed files with 183 additions and 108 deletions.
73 changes: 1 addition & 72 deletions DigitalPlatform.CommonControl/ControlExtentions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,6 @@

namespace DigitalPlatform.CommonControl
{
/// <summary>
/// Control 的扩展方法
/// </summary>
public static class ControlExtention
{
#region 不会被自动 Dispose 的 子 Control,放在这里托管,避免内存泄漏

public static void AddFreeControl(List<Control> controls,
Control control)
{
if (controls.IndexOf(control) == -1)
controls.Add(control);
}

public static void RemoveFreeControl(List<Control> controls,
Control control)
{
controls.Remove(control);
}

public static void DisposeFreeControls(List<Control> controls)
{
foreach (Control control in controls)
{
control.Dispose();
}
controls.Clear();
}

#endregion

// 清除控件集合。使用这个函数便于 Dispose() 所清除的控件对象
public static void ClearControls(this Control parent,
bool bDispose = false)
{
if (parent.Controls.Count == 0)
return;

List<Control> controls = new List<Control>();
foreach (Control control in parent.Controls)
{
controls.Add(control);
}

parent.Controls.Clear();
if (bDispose)
{
foreach (Control control in controls)
{
control.Dispose();
}
}
}

}

/// <summary>
/// ScrollableControl 的扩展方法
/// </summary>
public static class ScrollableControlExtention
{
public static void SetAutoScrollPosition(this ScrollableControl control, Point p)
{
if (p.Y + control.ClientSize.Height > control.DisplayRectangle.Height)
p.Y = control.DisplayRectangle.Height - control.ClientSize.Height;
if (p.X + control.ClientSize.Width > control.DisplayRectangle.Width)
p.X = control.DisplayRectangle.Width - control.ClientSize.Width;
control.AutoScrollPosition = new Point(p.X, p.Y);
}
}

/// <summary>
/// TableLayoutPanel 扩展方法
/// </summary>
Expand Down Expand Up @@ -120,6 +49,6 @@ public static Control GetAnyControlAt(this TableLayoutPanel panel, int column, i
}
return null;
}

}

}
17 changes: 15 additions & 2 deletions DigitalPlatform.CommonControl/DpTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@ public void InvalidateCell(DpCell cell)
Rectangle rect = Rectangle.Ceiling(cell.GetViewRect());
rect.Inflate(1, 1);
this.Invalidate(rect);
return;
}

public void InvalidateCellIcon(DpCell cell)
Expand Down Expand Up @@ -2773,7 +2774,6 @@ public bool EnsureVisible(RectangleF rectCell,
{
long lDelta = (long)rectCell.Y;


if (lDelta + rectCaret.Height >= this.ClientSize.Height)
{
if (rectCaret.Height >= this.ClientSize.Height)
Expand Down Expand Up @@ -2804,7 +2804,6 @@ public bool EnsureVisible(RectangleF rectCell,

lDelta = (long)rectCell.X;


if (lDelta + rectCaret.Width >= this.ClientSize.Width)
{
if (rectCaret.Width >= this.ClientSize.Width)
Expand Down Expand Up @@ -3917,9 +3916,23 @@ public string Text
if (this.Container != null
&& this.Container.Control != null)
{
long lOldHeight = this.Container.Control.DocumentHeight;
// 重新初始化行的高度
if (this.Container.UpdateLineHeight() == false) // == false表示没有Invalid当前行
this.Container.Control.InvalidateCell(this);

// 2016/4/21
long lDelta = this.Container.Control.DocumentHeight - lOldHeight;
if (lDelta != 0)
{
RectangleF rect = this.GetViewRect();
Debug.WriteLine("rect.Bottom = " + rect.Bottom + ", DocumentOrgY=" + this.Container.Control.DocumentOrgY);
if (rect.Bottom < 0)
{
// 行高度发生改变。如果此行在当前可见范围以上,则要把可见窗口下移 delta 高度,以让可见区域显示稳定
this.Container.Control.DocumentOrgY -= lDelta;
}
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions DigitalPlatform.CommonControl/WindowsUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ void AppendString(string strText)

void ScrollToEnd()
{
#if NO
this.webBrowser1.Document.Window.ScrollTo(
0,
this.webBrowser1.Document.Body.ScrollRectangle.Height);
#endif
this.webBrowser1.ScrollToEnd();
}

#endregion
Expand Down
3 changes: 2 additions & 1 deletion DigitalPlatform.EasyMarc/EasyMarcControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public bool HideIndicator
if (line is FieldLine)
{
FieldLine field = line as FieldLine;
if (field.IsControlField == false)
if (field.IsControlField == false
&& field.Visible == true)
field.textBox_content.Visible = !value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion DigitalPlatform.LibraryClient/LibraryChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ public static int CrashReport(
{
long lRet = channel.Login("public",
"",
"",
"client=crashReport|0.01",
out strError);
if (lRet != 1)
return -1;
Expand Down
94 changes: 94 additions & 0 deletions DigitalPlatform/4.0/ControlExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DigitalPlatform
{
/// <summary>
/// Control 的扩展方法
/// </summary>
public static class ControlExtention
{
#region 不会被自动 Dispose 的 子 Control,放在这里托管,避免内存泄漏

public static void AddFreeControl(List<Control> controls,
Control control)
{
if (controls.IndexOf(control) == -1)
controls.Add(control);
}

public static void RemoveFreeControl(List<Control> controls,
Control control)
{
controls.Remove(control);
}

public static void DisposeFreeControls(List<Control> controls)
{
foreach (Control control in controls)
{
control.Dispose();
}
controls.Clear();
}

#endregion

// 清除控件集合。使用这个函数便于 Dispose() 所清除的控件对象
public static void ClearControls(this Control parent,
bool bDispose = false)
{
if (parent.Controls.Count == 0)
return;

List<Control> controls = new List<Control>();
foreach (Control control in parent.Controls)
{
controls.Add(control);
}

parent.Controls.Clear();
if (bDispose)
{
foreach (Control control in controls)
{
control.Dispose();
}
}
}

}

/// <summary>
/// ScrollableControl 的扩展方法
/// </summary>
public static class ScrollableControlExtention
{
public static void SetAutoScrollPosition(this ScrollableControl control, Point p)
{
if (p.Y + control.ClientSize.Height > control.DisplayRectangle.Height)
p.Y = control.DisplayRectangle.Height - control.ClientSize.Height;
if (p.X + control.ClientSize.Width > control.DisplayRectangle.Width)
p.X = control.DisplayRectangle.Width - control.ClientSize.Width;
control.AutoScrollPosition = new Point(p.X, p.Y);
}
}

public static class WebBrowserExtension
{
public static void ScrollToEnd(this WebBrowser webBrowser1)
{
if (webBrowser1.Document != null
&& webBrowser1.Document.Window != null
&& webBrowser1.Document.Body != null)
webBrowser1.Document.Window.ScrollTo(
0,
webBrowser1.Document.Body.ScrollRectangle.Height);
}
}

}
1 change: 1 addition & 0 deletions DigitalPlatform/4.0/DigitalPlatform.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<Compile Include="ConfirmSupervisorDialog.Designer.cs">
<DependentUpon>ConfirmSupervisorDialog.cs</DependentUpon>
</Compile>
<Compile Include="ControlExtensions.cs" />
<EmbeddedResource Include="..\AutoCloseMessageBox.resx">
<DependentUpon>AutoCloseMessageBox.cs</DependentUpon>
<SubType>Designer</SubType>
Expand Down
2 changes: 1 addition & 1 deletion dp2Catalog/dp2/ChangePasswordForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private void button_dp2library_changePassword_Click(object sender, EventArgs e)
// 1 登录成功
lRet = Channel.Login(this.textBox_dp2library_userName.Text,
this.textBox_dp2library_oldPassword.Text,
"location=dp2Catalog,type=worker",
"location=dp2Catalog,type=worker,client=dp2catalog|" + Program.ClientVersion,
/*
"",
false,
Expand Down
2 changes: 1 addition & 1 deletion dp2Catalog/dp2Catalog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<SuiteName>dp2 V2</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>7</ApplicationRevision>
<ApplicationRevision>8</ApplicationRevision>
<ApplicationVersion>2.5.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
4 changes: 4 additions & 0 deletions dp2Circulation/BatchTaskForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using DigitalPlatform.Xml;
using DigitalPlatform.IO;
using DigitalPlatform.LibraryClient.localhost;
using DigitalPlatform.CommonControl;

namespace dp2Circulation
{
Expand Down Expand Up @@ -697,8 +698,11 @@ private void timer_monitorTask_Tick(object sender, EventArgs e)

void ScrollToEnd()
{
#if NO
this.webBrowser_info.Document.Window.ScrollTo(0,
this.webBrowser_info.Document.Body.ScrollRectangle.Height);
#endif
this.webBrowser_info.ScrollToEnd();
}

// *** 已经删除
Expand Down
2 changes: 1 addition & 1 deletion dp2Circulation/CfgDlg.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions dp2Circulation/Charging/UrgentChargingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void UrgentChargingForm_FormClosing(object sender, FormClosingEventArgs

private void UrgentChargingForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (this.MainForm != null)
if (this.MainForm != null)
this.MainForm.Urgent = false;
}

Expand Down Expand Up @@ -193,8 +193,6 @@ int WriteLogFile(string strFunc,
Global.WriteHtml(this.webBrowser_operationInfo,
strLine);
Global.ScrollToEnd(this.webBrowser_operationInfo);


return 0;
}

Expand Down Expand Up @@ -503,8 +501,6 @@ int LoadLogFileContentToBrowser(out string strError)

// Global.ScrollToEnd(this.webBrowser_operationInfo);
API.PostMessage(this.Handle, WM_SCROLLTOEND, 0, 0);


return 0;
}

Expand Down Expand Up @@ -729,7 +725,6 @@ public void Recover()
strLine + "\r\n");
CONTINUE_1:
Global.ScrollToEnd(this.webBrowser_operationInfo);

nLineCount++;
}
}
Expand Down Expand Up @@ -759,7 +754,6 @@ public void Recover()
"注意打开数据目录,改名保存 " + this.LogFileName + " 文件,避免将来不小心重复恢复。\r\n");

API.PostMessage(this.Handle, WM_SCROLLTOEND, 0, 0);

return;
ERROR1:
MessageBox.Show(this, strError);
Expand Down
2 changes: 2 additions & 0 deletions dp2Circulation/Comment/CommentViewerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;

using DigitalPlatform;
using DigitalPlatform.CommonControl;

namespace dp2Circulation
Expand Down
Loading

0 comments on commit aa94cff

Please sign in to comment.