コード例 #1
0
ファイル: Form.cs プロジェクト: liyanjie8712/BuildingBlocks
    private void Form_Load(object sender, EventArgs e)
    {
        var appIcon  = ConfigurationManager.AppSettings["AppIcon"] ?? "icon.ico";
        var iconPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, appIcon));

        if (File.Exists(iconPath))
        {
            var icon = new System.Drawing.Icon(iconPath);
            this.Icon            = icon;
            this.NotifyIcon.Icon = icon;
        }
        var appName = ConfigurationManager.AppSettings["AppName"];

        if (!string.IsNullOrEmpty(appName))
        {
            this.Text            = appName;
            this.NotifyIcon.Text = appName;
        }

        this.Visible      = false;
        this.FormClosing += Form_FormClosing;
        this.LogShowing  += Form_LogShowing;

        Task.Run(() => HostManager.Start());
        foreach (var url in HostManager.GetUrls().Reverse())
        {
            var item = new ToolStripMenuItem
            {
                Name = url,
                Text = $"    {url}",
                Size = new System.Drawing.Size(322, 38),
                Tag  = url,
            };
            item.Click += ToolStripMenuItem_Open_Click;
            this.ContextMenuStrip_NotifyIcon.Items.Insert(1, item);
        }
    }