Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
otomad authored Dec 19, 2021
1 parent 562d1eb commit 5d49186
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 20 deletions.
34 changes: 18 additions & 16 deletions otomad_helper/WinForm/Form1.Designer.cs

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

60 changes: 58 additions & 2 deletions otomad_helper/WinForm/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,27 @@ public ConfigForm(/* EntryPoint entryPoint */) {
string configIniName = "otomad_helper.ini";
configIni = new IniFile(Path.r(vegas.GetApplicationDataPath(Environment.SpecialFolder.ApplicationData), configIniName).FullPath, this);
ReadIni();
#else
VideoEffectLbl.Click += (sender, e) => {
StaffVisualizerConfigCheck.Checked = !StaffVisualizerConfigCheck.Checked;
bool isStaff = StaffVisualizerConfigCheck.Checked;
VideoEffectInitialValueCombo.Visible = VideoEffectInitialValueLbl.Visible = !isStaff;
VideoEffectCombo.DropDownStyle = isStaff ? ComboBoxStyle.DropDown : ComboBoxStyle.DropDownList;
if (isStaff) VideoEffectCombo.Text = "五线谱";
VideoEffectCombo.Enabled = !isStaff;
};
#endif

#endregion

#region 程序图标
#if VEGAS_ENVIRONMENT
#if VEGAS_ENVIRONMENT
string iconName = "otomad_helper.ico";
try {
Icon = Icon.ExtractAssociatedIcon(Path.r(vegas.InstallationDirectory, "Script Menu", iconName).FullPath);
icon = Icon;
} catch (Exception) { } // 如果路径不存在则不受影响
#endif
#endif
#endregion
}

Expand Down Expand Up @@ -719,6 +729,52 @@ private void TrackLegatoBtn_MouseDown(object sender, MouseEventArgs e) {
private void TrackLegatoMenuItems_Click(object sender, EventArgs e) {
TrackLegatoBtn.Enabled = false;
}

/*[StructLayout(LayoutKind.Sequential)]
public struct CompositionMargins {
public int Left;
public int Right;
public int Top;
public int Bottom;
}
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref CompositionMargins margins);
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern bool DwmIsCompositionEnabled();
protected override void OnLoad(EventArgs e) {
if (DwmIsCompositionEnabled()) {
CompositionMargins margins = new CompositionMargins();
margins.Right = margins.Left = margins.Top = margins.Bottom = Width + Height;
DwmExtendFrameIntoClientArea(Handle, ref margins);
}
base.OnLoad(e);
}
protected override void OnPaintBackground(PaintEventArgs e) {
base.OnPaintBackground(e);
if (DwmIsCompositionEnabled())
e.Graphics.Clear(Color.Black);
}*/

/*protected override void OnHandleCreated(EventArgs e) {
// Use e.g. Color.FromArgb(128, Color.Lime) for a 50% opacity green tint.
WindowUtils.EnableAcrylic(this, Color.Transparent);
base.OnHandleCreated(e);
}
protected override void OnPaintBackground(PaintEventArgs e) {
e.Graphics.Clear(Color.Transparent);
}*/

[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize);

protected override void OnHandleCreated(EventArgs e) {
DwmSetWindowAttribute(Handle, 20, new[] { 1 }, 4);
}
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions otomad_helper/WinForm/IntegerTrackWithBox.Designer.cs

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

5 changes: 5 additions & 0 deletions otomad_helper/WinForm/VegasScript.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<StartupObject>VegasScript.Program</StartupObject>
Expand All @@ -44,6 +46,7 @@
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -54,6 +57,7 @@
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="NAudio">
Expand Down Expand Up @@ -146,6 +150,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Windows10StyledContextMenuStripRenderer.cs" />
<Compile Include="WindowUtils.cs" />
<EmbeddedResource Include="AutoLayoutTracksBox3dForm.resx">
<DependentUpon>AutoLayoutTracksBox3dForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down
68 changes: 68 additions & 0 deletions otomad_helper/WinForm/WindowUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public static class WindowUtils {
public static void EnableAcrylic(IWin32Window window, Color blurColor) {
if (window is null) throw new ArgumentNullException(nameof(window));

var accentPolicy = new AccentPolicy {
AccentState = ACCENT.ENABLE_ACRYLICBLURBEHIND,
GradientColor = ToAbgr(blurColor)
};

unsafe {
SetWindowCompositionAttribute(
new HandleRef(window, window.Handle),
new WindowCompositionAttributeData {
Attribute = WCA.ACCENT_POLICY,
Data = &accentPolicy,
DataLength = Marshal.SizeOf<AccentPolicy>()
});
}
}

private static uint ToAbgr(Color color) {
return ((uint)color.A << 24)
| ((uint)color.B << 16)
| ((uint)color.G << 8)
| color.R;
}

// ReSharper disable InconsistentNaming, UnusedMember.Local, NotAccessedField.Local
#pragma warning disable 649

// Discovered via:
// https://withinrafael.com/2015/07/08/adding-the-aero-glass-blur-to-your-windows-10-apps/
// https://github.com/riverar/sample-win32-acrylicblur/blob/917adc277c7258307799327d12262ebd47fd0308/MainWindow.xaml.cs

[DllImport("user32.dll")]
private static extern int SetWindowCompositionAttribute(HandleRef hWnd, in WindowCompositionAttributeData data);

private unsafe struct WindowCompositionAttributeData {
public WCA Attribute;
public void* Data;
public int DataLength;
}

private enum WCA {
ACCENT_POLICY = 19
}

private enum ACCENT {
DISABLED = 0,
ENABLE_GRADIENT = 1,
ENABLE_TRANSPARENTGRADIENT = 2,
ENABLE_BLURBEHIND = 3,
ENABLE_ACRYLICBLURBEHIND = 4,
INVALID_STATE = 5
}

private struct AccentPolicy {
public ACCENT AccentState;
public uint AccentFlags;
public uint GradientColor;
public uint AnimationId;
}
}

0 comments on commit 5d49186

Please sign in to comment.