예제 #1
0
        ContextMenu CreateMenu()
        {
            return(new ContextMenu(new MenuItem[] {
                new MenuItem(I18N("Log"), (s, a) => serverItem.ShowLogForm()),
                new MenuItem(I18N("Edit"), (s, a) => {
                    var item = this.serverItem;
                    var config = item.config;
                    new Views.FormConfiger(this.serverItem.config);
                }),
                new MenuItem(I18N("Delete"), (s, a) => {
                    if (!Lib.UI.Confirm(I18N("ConfirmDeleteControl")))
                    {
                        return;
                    }
                    Cleanup();
                    serverItem.DeleteSelf();
                }),
                new MenuItem("-"),
                new MenuItem(I18N("Copy"), new MenuItem[] {
                    new MenuItem(I18N("VmessLink"), (s, a) => {
                        MessageBox.Show(
                            Lib.Utils.CopyToClipboard(
                                Lib.Utils.Vmess2VmessLink(
                                    Lib.Utils.ConfigString2Vmess(
                                        this.serverItem.config)))?
                            I18N("LinksCopied") :
                            I18N("CopyFail"));
                    }),
                    new MenuItem(I18N("V2RayLink"), (s, a) => {
                        MessageBox.Show(
                            Lib.Utils.CopyToClipboard(
                                Lib.Utils.AddLinkPrefix(
                                    Lib.Utils.Base64Encode(this.serverItem.config),
                                    Model.Data.Enum.LinkTypes.v2ray)) ?
                            I18N("LinksCopied") :
                            I18N("CopyFail"));
                    }),
                }),
                new MenuItem(I18N("SpeedTest"), (s, a) => {
                    Task.Factory.StartNew(
                        () => serverItem.DoSpeedTestThen());
                }),
                new MenuItem(I18N("SetAsSysProxy"), (s, a) => {
                    if (cboxInbound.SelectedIndex != (int)Model.Data.Enum.ProxyTypes.HTTP)
                    {
                        MessageBox.Show(I18N("SysProxyRequireHTTPServer"));
                        return;
                    }

                    Service.Setting.Instance.SetSystemProxy(
                        string.Format("{0}:{1}",
                                      this.tboxInboundIP.Text,
                                      this.tboxInboundPort.Text));

                    MessageBox.Show(I18N("Done"));
                }),
            }));
        }
예제 #2
0
 private void logOfThisServerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     serverItem.ShowLogForm();
 }