Practical gadget developed by WPF-Quick floating menu

Practical gadget developed by WPF-Quick floating menu

This article was submitted by netizens and compiled by the Dotnet9 webmaster. The webmaster thinks this gadget is very practical, and the webmaster is also trying to use it at home and company.

最后更新 11/29/2020 10:50 PM
闫金华(闫驚鏵)
预计阅读 8 分钟
分类
WPF
专题
WPF Open Source Project
标签
.NET C# WPF WPF Open Source Project open source

This article was submitted by netizens and compiled by the Dotnet 9 webmaster. The webmaster thinks this gadget is very practical, and the webmaster is also trying to use it at home and company.

    • Text catalog: **
  1. What's the use of this tool?
  2. text
  3. Source code acquisition and application download experience
  4. Suggestions from the webmaster

1. What's the use of this tool?

Question: ** Where do applications installed in the operating system start? **

Answer:

  1. The operating system start menu in the lower left corner;
  2. Operating system taskbar;
  3. Operating system desktop shortcuts

If the answer is correct, give 10 points!

Everyone mainly looks for applications in these three places. Have you ever thought of concentrating shortcuts for these applications in one place? For whatever application you want, simply scroll the mouse and start it when you see the target application. See if the following operations are what you want?

Quickly find apps and launch them

快捷查找应用并启动

There are many similar software gadgets on the market, which may be more powerful, but who told us that we are programmers and don't make some gadgets we develop ourselves? How can we go out and talk about it? Hahaha, the following is the webmaster's reference to the author's open source project and extracted one of the styles (vs. 2019 +.net5, I only learned through recent exchanges that the author temporarily removed the horizontal menu and cried with laughter. I hope the author will add it later):

horizontal menu

水平菜单

2. text

preface

Looking at it's been relatively deserted recently (webmaster's note: WPF section of Blog Park), I'm here to warm up the scene.

2020-10-29

[New update]

  1. Add new trays.

  2. Add skin replacement.

  3. Transparency switches.

[Environment]

Visual Studio 2019,dotNet Framework 4.0 SDK

This project adopts the MVVM model and briefly introduces the functional code:

  1. Obtain the size of the working area on the main monitor.

  2. And set the height of the current main form, and set the Left and Top of the form to the rightmost.

private Rect desktopWorkingArea;       
desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
this.Height = desktopWorkingArea.Height / 2;
this.Left = desktopWorkingArea.Width - this.Width;
this.Top = desktopWorkingArea.Height / 2 - (this.Height / 2);
  1. The moving form only allows Y-axis movement, and Win32 's MoveWindow is called.
#region 移动窗体
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
    anchorPoint = e.GetPosition(this);
    inDrag = true;
    CaptureMouse();
    e.Handled = true;
}

protected override void OnMouseMove(MouseEventArgs e)
{
    try
    {
        if (inDrag)
        {
            System.Windows.Point currentPoint = e.GetPosition(this);
            var y = this.Top + currentPoint.Y - anchorPoint.Y;
            Win32Api.RECT rect;
            Win32Api.GetWindowRect(new WindowInteropHelper(this).Handle, out rect);
            var w = rect.right - rect.left;
            var h = rect.bottom - rect.top;
            int x = Convert.ToInt32(PrimaryScreen.DESKTOP.Width - w);

            Win32Api.MoveWindow(new WindowInteropHelper(this).Handle, x, (int)y, w, h, 1);
        }
    }
    catch (Exception ex)
    {
        Log.Error($"MainView.OnMouseMove{ex.Message}");
    }
}

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
    if (inDrag)
    {
        ReleaseMouseCapture();
        inDrag = false;
        e.Handled = true;
    }
}
#endregion
  1. Hide the current form when Tab + Alt switches.
WindowInteropHelper wndHelper = new WindowInteropHelper(this);

int exStyle = (int)Win32Api.GetWindowLong(wndHelper.Handle, (int)Win32Api.GetWindowLongFields.GWL_EXSTYLE);

exStyle |= (int)Win32Api.ExtendedWindowStyles.WS_EX_TOOLWINDOW;
Win32Api.SetWindowLong(wndHelper.Handle, (int)Win32Api.GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle);

Tab + Alt Hide the current form

Tab + Alt隐藏当前窗体

  1. After the form is loaded, go to the registry to read the installed application (as well as the system desktop), obtain the application path, extract the. ICO and convert it to. PNG and save it.

Read the installation application

读取安装应用

  1. The rest of the code is animation and auto-definition control code in wpf.

[Preview of renderings]

Vertical menu

竖直菜单

2020/11/09

[New update]

Scroll adds animation

[Preview of renderings]

Vertical scrolling animation

竖直滚动动画

Hidden vertical menu

竖直菜单隐藏

Vertical menu folding

竖直菜单折叠

Vertical menu switching

竖直菜单切换

2020/11/19

[New update]

  1. Add drag mobile.

Operation instructions: After right-clicking on the main page, a dotted border will appear and then the current application location can be modified, but it has not been saved. The sorting will still be default after the next startup.

  1. Modifying to find existing references will not find uninstall.

[Preview of renderings]

修改bug

2020/11/20

[New update]

  1. Add and remove apps.
  2. Buttons are not displayed during editing.
  3. Do not use animations during editing.

[Preview of renderings]

可删除

3. Source code acquisition and application download experience

源码下载地址:SoftWareHelper

SoftWareHelper

下载解压后体验:点击下载

Author submitted article:

4. webmaster advice

作者也是凭着一股热情,一直在更新该项目,大家有需要可以通过上面的链接进行下载、使用,觉得不错,不要忘了给个 star 哦:SoftWareHelper

SoftWareHelper仓库

Before receiving the author's proposal, the webmaster also paid attention to the first article published by the author in the blog park and downloaded the project to experience it. He felt that the shortcut menu was good, so he extracted it and revised it (a small number of ideas have been implemented, the rest will be completed later):

  • The menu is configured through configuration files, because the operating system may have too many applications installed and not all of them need to be loaded: Implemented
  • Support exe drag-and-drop (or system-generated shortcut drag-and-drop) addition: implemented
  • Support URL configuration (click to open the specified URL, similar to a webpage collection shortcut): Implemented
  • Support cmd command configuration (such as system application mstsc, remote desktop configuration of target IP and port, one-click opening connection, etc.): Implemented
  • Interface configuration menu provided: not implemented
  • Display icons and text: Not implemented
  • ... I'm still thinking about more ideas

If the author thinks the above ideas are okay, he may wish to consider adding them.

站长先不要脸的奉上基于作者开源项目的修改版,很简陋的一个版本:QuickApp

QuickApp

In addition to the webmaster's own magic revision ideas above, there are also the following suggestions, which I hope the author can consider on the original project:

  • Keep the original horizontal menu display method, and it is best to support top, bottom, left and right of the desktop (you can dynamically switch positions);
  • Currently, there are only two types of skin resurfacing: lignt and dark, which can be expanded appropriately later (it should be possible to change the background color);

Do you have any suggestions? Welcome to leave a message at the bottom of the article, or click on the original author's blog post above to brainstorm and create an interesting gadget together!!!

thank

Thank you for submitting your contribution

Everyone is welcome to submit articles to the webmaster, or recommend WPF projects or control libraries.

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 1/26/2025

WPF internationalizes with custom XML files

This article describes in detail the methods of using custom XML files to achieve internationalization in WPF programs, including installing the necessary NuGet package, dynamically obtaining language lists, dynamically switching languages, using translation strings in code and xaml interfaces, etc. It also provides source code links to help developers easily internationalize WPF applications.

继续阅读