Skip to content

Commit

Permalink
When OS is Windows 7, modify window sizing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lich426 committed Jul 6, 2020
1 parent 23a9285 commit 6eca6fb
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 98 deletions.
34 changes: 17 additions & 17 deletions ControlForm.Designer.cs

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

141 changes: 75 additions & 66 deletions ControlForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace FanCtrl
{
public partial class ControlForm : Form
{
private Size mLastSize = new Size(748, 414);
private Size mNormalLastSize = new Size(748, 414);
private Size mLastSize = new Size(940, 543);
private Size mNormalLastSize = new Size(940, 543);

private bool mIsUpdateGraph = true;
private bool mIsResize = false;
Expand Down Expand Up @@ -49,89 +49,98 @@ public ControlForm()
this.initControl();
this.initGraph();

this.SetStyle(ControlStyles.UserPaint |
// Can only resize windows with Windows 10
if (System.Environment.OSVersion.Version.Major >= 10)
{
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.SupportsTransparentBackColor, true);
this.Resize += (sender, e) =>
{
if (mIsResize == true)
return;
mIsResize = true;
this.Resize += (sender, e) =>
{
if (mIsResize == true)
return;
mIsResize = true;

//Console.WriteLine("Size : {0}, {1}", this.Width, this.Height);
//Console.WriteLine("Size : {0}, {1}", this.Width, this.Height);

int widthGap = this.Width - mLastSize.Width;
int heightGap = this.Height - mLastSize.Height;
int widthGap = this.Width - mLastSize.Width;
int heightGap = this.Height - mLastSize.Height;

//Console.WriteLine("Gap : {0}, {1}", widthGap, heightGap);

mFanGroupBox.Height = mFanGroupBox.Height + heightGap;
mFanListView.Height = mFanListView.Height + heightGap;
mRemoveButton.Top = mRemoveButton.Top + heightGap;

mModeGroupBox.Width = mModeGroupBox.Width + widthGap;
//Console.WriteLine("Gap : {0}, {1}", widthGap, heightGap);

mGraphGroupBox.Width = mGraphGroupBox.Width + widthGap;
mGraphGroupBox.Height = mGraphGroupBox.Height + heightGap;
mFanGroupBox.Height = mFanGroupBox.Height + heightGap;
mFanListView.Height = mFanListView.Height + heightGap;
mRemoveButton.Top = mRemoveButton.Top + heightGap;

mGraph.Width = mGraph.Width + widthGap;
mGraph.Height = mGraph.Height + heightGap;
mModeGroupBox.Width = mModeGroupBox.Width + widthGap;

mUnitLabel.Left = mUnitLabel.Left + widthGap;
mUnitComboBox.Left = mUnitComboBox.Left + widthGap;
mHysLabel.Left = mHysLabel.Left + widthGap;
mHysNumericUpDown.Left = mHysNumericUpDown.Left + widthGap;
mStepCheckBox.Left = mStepCheckBox.Left + widthGap;
mGraphGroupBox.Width = mGraphGroupBox.Width + widthGap;
mGraphGroupBox.Height = mGraphGroupBox.Height + heightGap;

mApplyButton.Left = mApplyButton.Left + widthGap;
mApplyButton.Top = mApplyButton.Top + heightGap;
mGraph.Width = mGraph.Width + widthGap;
mGraph.Height = mGraph.Height + heightGap;

mOKButton.Left = mOKButton.Left + widthGap;
mOKButton.Top = mOKButton.Top + heightGap;
mUnitLabel.Left = mUnitLabel.Left + widthGap;
mUnitComboBox.Left = mUnitComboBox.Left + widthGap;
mHysLabel.Left = mHysLabel.Left + widthGap;
mHysNumericUpDown.Left = mHysNumericUpDown.Left + widthGap;
mStepCheckBox.Left = mStepCheckBox.Left + widthGap;

mLastSize.Width = this.Width;
mLastSize.Height = this.Height;
mApplyButton.Left = mApplyButton.Left + widthGap;
mApplyButton.Top = mApplyButton.Top + heightGap;

if(this.WindowState != FormWindowState.Maximized)
{
mNormalLastSize.Width = this.Width;
mNormalLastSize.Height = this.Height;
}
mOKButton.Left = mOKButton.Left + widthGap;
mOKButton.Top = mOKButton.Top + heightGap;

mIsResize = false;
};
mLastSize.Width = this.Width;
mLastSize.Height = this.Height;

this.ResizeBegin += (s, e) =>
{
mIsUpdateGraph = false;
this.SuspendLayout();
};
this.ResizeEnd += (s, e) =>
{
this.ResumeLayout();
mIsUpdateGraph = true;
};
if (this.WindowState != FormWindowState.Maximized)
{
mNormalLastSize.Width = this.Width;
mNormalLastSize.Height = this.Height;
}

this.FormClosing += (s, e) =>
{
ControlManager.getInstance().Width = mNormalLastSize.Width;
ControlManager.getInstance().Height = mNormalLastSize.Height;
ControlManager.getInstance().IsMaximize = (this.WindowState == FormWindowState.Maximized);
ControlManager.getInstance().write();
};
mIsResize = false;
};

this.ResizeBegin += (s, e) =>
{
mIsUpdateGraph = false;
this.SuspendLayout();
};
this.ResizeEnd += (s, e) =>
{
this.ResumeLayout();
mIsUpdateGraph = true;
};

this.FormClosing += (s, e) =>
{
ControlManager.getInstance().Width = mNormalLastSize.Width;
ControlManager.getInstance().Height = mNormalLastSize.Height;
ControlManager.getInstance().IsMaximize = (this.WindowState == FormWindowState.Maximized);
ControlManager.getInstance().write();
};

if (ControlManager.getInstance().IsMaximize == true)
{
this.WindowState = FormWindowState.Maximized;
}

if (ControlManager.getInstance().IsMaximize == true)
this.Width = ControlManager.getInstance().Width;
this.Height = ControlManager.getInstance().Height;
mLastSize.Width = this.Width;
mLastSize.Height = this.Height;
mNormalLastSize.Width = this.Width;
mNormalLastSize.Height = this.Height;
}
else
{
this.WindowState = FormWindowState.Maximized;
this.MaximizeBox = false;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}

this.Width = ControlManager.getInstance().Width;
this.Height = ControlManager.getInstance().Height;
mLastSize.Width = this.Width;
mLastSize.Height = this.Height;
mNormalLastSize.Width = this.Width;
mNormalLastSize.Height = this.Height;
}

private void localizeComponent()
Expand Down
2 changes: 1 addition & 1 deletion FanCtrl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PublisherName>Lich</PublisherName>
<SuiteName>FanCtrl</SuiteName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.1.9.0</ApplicationVersion>
<ApplicationVersion>1.2.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
3 changes: 0 additions & 3 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ private void onOptionButtonClick(object sender, EventArgs e)
mFanIconTimer.Stop();
}
}
form.Dispose();
}

private void onFanControlButtonClick(object sender, EventArgs e)
Expand All @@ -622,7 +621,6 @@ private void onFanControlButtonClick(object sender, EventArgs e)
mControlForm.StartPosition = FormStartPosition.Manual;
mControlForm.Location = new Point(this.Location.X + 100, this.Location.Y + 100);
mControlForm.ShowDialog();
mControlForm.Dispose();
mControlForm = null;
}

Expand All @@ -640,7 +638,6 @@ private void onOSDButtonClick(object sender, EventArgs e)
mEnableOSDToolStripMenuItem.Checked = OSDManager.getInstance().IsEnable;
};
form.ShowDialog();
form.Dispose();
}


Expand Down
3 changes: 0 additions & 3 deletions OptionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,18 @@ private void onKrakenButtonClick(object sender, EventArgs e)
{
var form = new LightingForm(HardwareManager.getInstance().getKraken());
form.ShowDialog();
form.Dispose();
}

private void onCLCButtonClick(object sender, EventArgs e)
{
var form = new LightingForm(HardwareManager.getInstance().getCLC());
form.ShowDialog();
form.Dispose();
}

private void onRGBnFCButtonClick(object sender, EventArgs e)
{
var form = new LightingForm(HardwareManager.getInstance().getRGBnFC());
form.ShowDialog();
form.Dispose();
}
}
}
Binary file added Portable/FanCtrl_v1.2.0a.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
[assembly: AssemblyVersion("1.1.9")]
[assembly: AssemblyFileVersion("1.1.9")]
[assembly: AssemblyInformationalVersion("1.1.9")]
[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0")]
[assembly: AssemblyInformationalVersion("1.2.0a")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
10 changes: 5 additions & 5 deletions Properties/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
목록입니다. 해당 요소의 주석 처리를 제거하면 Windows에서
호환 가능성이 가장 큰 환경을 자동으로 선택합니다. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- 애플리케이션에서 DPI를 인식하며 높은 DPI에서는 Windows가 자동으로 크기를 조정하지
Expand Down

0 comments on commit 6eca6fb

Please sign in to comment.