void SetColorOnControlButton(Color color) { var lightColor = ControlPaint.LightLight(color); ControlButton.OverrideDefault.Back.Color2 = color; ControlButton.OverrideDefault.Back.Color1 = lightColor; ControlButton.OverrideFocus.Back.Color2 = color; ControlButton.OverrideFocus.Back.Color1 = lightColor; ControlButton.StateCommon.Back.Color2 = color; ControlButton.StateCommon.Back.Color1 = lightColor; ControlButton.StateNormal.Back.Color2 = color; ControlButton.StateNormal.Back.Color1 = lightColor; ControlButton.StatePressed.Back.Color2 = color; ControlButton.StatePressed.Back.Color1 = lightColor; ControlButton.StateTracking.Back.Color2 = color; ControlButton.StateTracking.Back.Color1 = lightColor; ControlButton.StateCheckedNormal.Back.Color2 = color; ControlButton.StateCheckedNormal.Back.Color1 = lightColor; ControlButton.StateCheckedPressed.Back.Color2 = color; ControlButton.StateCheckedPressed.Back.Color1 = lightColor; ControlButton.StateCheckedTracking.Back.Color2 = color; ControlButton.StateCheckedTracking.Back.Color1 = lightColor; ControlButton.Update(); }
private void ExitToolStripButton_Click(object sender, EventArgs e) { // 当前状态如果不是已停止状态 if (State != Models.State.Waiting && State != Models.State.Stopped) { // 如果未勾选退出时停止,要求先点击停止按钮 if (!Global.Settings.StopWhenExited) { MessageBox.Show(Utils.i18N.Translate("Please press Stop button first"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); this.Visible = true; this.ShowInTaskbar = true; // 显示在系统任务栏 this.WindowState = FormWindowState.Normal; // 还原窗体 this.NotifyIcon.Visible = true; // 托盘图标隐藏 return; } // 否则自动点击停止按钮 else { ControlButton.PerformClick(); } } Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex; Global.Settings.ModeComboBoxSelectedIndex = ModeComboBox.SelectedIndex; Utils.Configuration.Save(); State = Models.State.Terminating; this.NotifyIcon.Visible = false; this.Close(); this.Dispose(); System.Environment.Exit(System.Environment.ExitCode); }
public LotusView(Context context, IAttributeSet attrs) : base(context, attrs) { Holder.AddCallback(this); var screenCenter = new PointVector { X = Resources.DisplayMetrics.WidthPixels / 2, Y = Resources.DisplayMetrics.HeightPixels / 2 }; var controlPadRadius = 225; var controlPad = new ControlPad(Resources, new PointVector { X = controlPadRadius, Y = screenCenter.Y * 2 - controlPadRadius }, controlPadRadius); var fireButtonRadius = 125; var fireButton = new ControlButton(Resources, new PointVector { X = screenCenter.X * 2 - fireButtonRadius, Y = screenCenter.Y * 2 - fireButtonRadius }, fireButtonRadius); var player = new Player(controlPad, fireButton); mDrawThread = new DrawThread(Holder, screenCenter, player); player.RegisterShip(new Ship(Resources, Resource.Drawable.t1, 600, 1200, 720)); player.RegisterWeapon(new Weapon(Resources, Resource.Drawable.t1, mDrawThread)); new StaticImage(Resources, Resource.Drawable.background); SetOnTouchListener(player); }
public void OnExited(object sender, EventArgs e) { if (State == Objects.State.Started) { ControlButton.PerformClick(); } }
protected override void Initialize() { new Eon.UIApi.Cursors.Cursor("Cursor", "Cursors/CenterCursor", 24); Vector2 initialPos = new Vector2(Common.TextureQuality.X, 10); foreach (string s in names) { ControlButton btn = new ControlButton(s, this, initialPos, new Vector2(6, 3), true); btn.TextColour = Color.Red; btn.OnClicked += new OnClickedEvent(OnClicked); initialPos.X -= btn.Bounds.Width; } txt = new TextItem(ID + "txt", 0, "Model Viewer", "Eon\\Fonts\\Arial23", new Vector2(13, 17), Color.Red, true); AttachComponent(txt); saveDia = new SaveFileDialog(); saveDia.InitialDirectory = @"C:\"; saveDia.Filter = InterOperations.ModelFileFilters; saveDia.Title = "Save file"; openDia = new OpenFileDialog(); openDia.InitialDirectory = @"C:\"; openDia.Filter = InterOperations.ModelFileFilters; openDia.Title = "Browze files"; base.Initialize(); }
private InputResponse CheckCommand(TrackCommand tc, ControlButton button) { if (tc.Type != button.Type) { FailedCommand(tc); return(InputResponse.TrackAndSwallow); } if (tc.Progress < this.EarlyGrace * 0.35f && tc.Progress > this.LateGrace * 0.35f) { Debug.Log("PERFECT HIT! " + tc.Progress); HitCommand(tc); } else if (tc.Progress < this.EarlyGrace && tc.Progress > this.LateGrace) { Debug.Log("Mistimed Hit " + tc.Progress); MistimedCommand(tc); } else { FailedCommand(tc); return(InputResponse.TrackAndSwallow); } return(InputResponse.None); }
private void CreateControlButtons() { // Create the the three control buttons: step, reset, and run // 680 is the "base position", from there each is offset by 80 // This is because DisassemblyListView ends at around 600 px. ButtonStep = new ControlButton() { Location = new Point(600 + 80 * 1, 450), Text = "Step", }; ButtonRun = new ControlButton() { Location = new Point(600 + 80 * 2, 450), Text = "Run", }; ButtonReset = new ControlButton() { Location = new Point(600 + 80 * 3, 450), Text = "Reset" }; // Register the correct events to the buttons. ButtonRun.Click += new EventHandler(VMContinue_ButtonEvent); ButtonStep.Click += new EventHandler(VMContinue_ButtonEvent); ButtonReset.Click += new EventHandler(Reset_Click); // This order does not matter. Controls.Add(ButtonStep); Controls.Add(ButtonRun); Controls.Add(ButtonReset); }
private void MainForm_Load(object sender, EventArgs e) { OnlyInstance.Called += OnCalled; // 计算 ComboBox绘制 目标宽度 _eWidth = ServerComboBox.Width / 10; Modes.Load(); ServerComboBox.DataSource = Global.Settings.Server; SaveSelectIndex = true; SelectLastMode(); SelectLastServer(); // 加载翻译 InitText(); // 隐藏 NatTypeStatusLabel NatTypeStatusText(); _sizeHeight = Size.Height; _configurationGroupBoxHeight = ConfigurationGroupBox.Height; _profileConfigurationHeight = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度 _profileGroupboxHeight = ProfileGroupBox.Height; // 加载快速配置 InitProfile(); // 打开软件时启动加速,产生开始按钮点击事件 if (Global.Settings.StartWhenOpened) { ControlButton.PerformClick(); } // 自动检测延迟 Task.Run(() => { while (true) { if (State == State.Waiting || State == State.Stopped) { TestServer(); Thread.Sleep(10000); } else { Thread.Sleep(200); } } }); Task.Run(() => { // 检查更新 if (Global.Settings.CheckUpdateWhenOpened) { CheckUpdate(); } }); }
private void MainForm_Load(object sender, EventArgs e) { AddAddServerToolStripMenuItems(); #region i18N Translations _mainFormText.Add(UninstallServiceToolStripMenuItem.Name, new[] { "Uninstall {0}", "NF Service" }); _mainFormText.Add(UninstallTapDriverToolStripMenuItem.Name, new[] { "Uninstall {0}", "TUN/TAP driver" }); #endregion OnlyInstance.Called += OnCalled; // 计算 ComboBox绘制 目标宽度 _eWidth = ServerComboBox.Width / 10; ModeHelper.Load(); InitMode(); InitServer(); _comboBoxInitialized = true; // 加载翻译 InitText(); // 隐藏 NatTypeStatusLabel NatTypeStatusText(); _configurationGroupBoxHeight = ConfigurationGroupBox.Height; _profileConfigurationHeight = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度 // 加载快速配置 InitProfile(); // 打开软件时启动加速,产生开始按钮点击事件 if (Global.Settings.StartWhenOpened) { ControlButton.PerformClick(); } Task.Run(() => { // 检查更新 if (Global.Settings.CheckUpdateWhenOpened) { CheckUpdate(); } }); Task.Run(async() => { // 检查订阅更新 if (Global.Settings.UpdateSubscribeatWhenOpened) { await UpdateServersFromSubscribe(); } }); }
private void MainForm_Load(object sender, EventArgs e) { // 加载服务器 InitServer(); // 加载模式 InitMode(); // 加载翻译 InitText(); // NatTypeStatusText(); // 加载快速配置 _sizeHeight = Size.Height; _controlHeight = ConfigurationGroupBox.Controls[0].Height / 3; _profileBoxHeight = ProfileGroupBox.Height; _configurationGroupBoxHeight = ConfigurationGroupBox.Height; InitProfile(); // 为 ComboBox绘制 收集宽度数据 _eWidth = ServerComboBox.Width / 10; // 自动检测延迟 Task.Run(() => { while (true) { if (State == State.Waiting || State == State.Stopped) { TestServer(); Thread.Sleep(10000); } else { Thread.Sleep(200); } } }); // 打开软件时启动加速,产生开始按钮点击事件 if (Global.Settings.StartWhenOpened) { ControlButton.PerformClick(); } // 检查更新 if (Global.Settings.CheckUpdateWhenOpened) { CheckUpdate(); } }
private IObservable <Unit> AnimateButtonAsync(ControlButton button) => button .ScaleTo(0.95, 100, Easing.CubicOut) .ToObservable() .ObserveOn(RxApp.MainThreadScheduler) .SelectMany( _ => button .ScaleTo(1, 150, Easing.CubicIn) .ToObservable()) .ToSignal() .FirstAsync();
public InputResponse OnButtonDown(ControlButton button) { Debug.Log(gameObject.name + " Button down: " + button.Type); if (this.IsUpperCase && !Input.GetKey(KeyCode.LeftShift)) { return(InputResponse.None); } else if (!this.IsUpperCase && Input.GetKey(KeyCode.LeftShift)) { return(InputResponse.None); } this.Bouncer.Bounce(); List <TrackCommand> eligibleCommands = new List <TrackCommand>(); for (int i = this.TrackCommands.Count - 1; i >= 0; i--) { TrackCommand tc = this.TrackCommands[i]; if (tc.Progress < this.Activatable) { eligibleCommands.Add(tc); } } TrackCommand nextCommand; nextCommand = null; float minProgress; minProgress = 1.0f; if (eligibleCommands.Count > 0) { foreach (TrackCommand command in eligibleCommands) { if (command.Progress < minProgress && command.Progress > this.LateGrace) { nextCommand = command; minProgress = nextCommand.Progress; } } } if (nextCommand != null) { return(CheckCommand(nextCommand, button)); } return(InputResponse.None); }
private void ProfileButton_Click(object sender, EventArgs e) { int index = ProfileButtons.IndexOf((Button)sender); //Utils.Logging.Info(String.Format("Button no.{0} clicked", index)); if (Control.ModifierKeys == Keys.Control) { SaveProfile(index); ProfileButtons[index].Text = ProfileNameText.Text; } else { try { ProfileNameText.Text = LoadProfile(index); // start the profile bool need2ndStart = true; if (State == Models.State.Waiting || State == Models.State.Stopped) { need2ndStart = false; } ControlButton.PerformClick(); if (need2ndStart) { Task.Run(() => { while (State != Models.State.Stopped) { Thread.Sleep(200); } ControlButton.PerformClick(); }); } } catch (Exception ee) { Task.Run(() => { Utils.Logging.Info(ee.Message); ProfileButtons[index].Text = Utils.i18N.Translate("Error"); Thread.Sleep(1200); ProfileButtons[index].Text = Utils.i18N.Translate("None"); }); } } }
private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ControlButton ctrl = d as ControlButton; if (ctrl.InnerEllipse != null) { ctrl.InnerEllipse.Fill = new SolidColorBrush() { Color = ctrl.Color } } ; } }
void Call_OnInfoChanged() { if (ControlButton.InvokeRequired) { ControlButton.BeginInvoke(_callOnInfoChanged); return; } if (_active) { RefreshUI(); } RefreshBackUI(); }
public void InitExtensionControl(ExtensionArgs args) { try { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(delegate { InitExtensionControl(args); })); return; } this.Controls.Clear(); int i = 0; int startIndex = (SystemInformation.PrimaryMonitorSize.Width - args.extensions.Count * 120) / 2; foreach (var app in args.extensions) { ControlButton btn = new ControlButton(); if (!string.IsNullOrEmpty(app.Icon)) { btn.PicImage = app.Icon; } btn.TitleName = app.ExtensText; btn.Size = new System.Drawing.Size(120, 80); btn.Location = new Point(startIndex + 119 * i, 0); i++; PictureBox pb = btn.Controls.Find("picLogo", false)[0] as PictureBox; pb.Tag = app; pb.Click += new EventHandler(btn_Click); this.Controls.Add(btn); } ///////////////////////////加载数据库状态图标///////////////////////////////////// PictureBox picDbStatus = new PictureBox(); picDbStatus.Size = new System.Drawing.Size(30, 30); picDbStatus.Name = "DBStatus"; picDbStatus.Image = new Bitmap(GlobalEnvironment.BasePath + @"\image\Signal.png"); picDbStatus.Location = new Point(SystemInformation.PrimaryMonitorSize.Width - 100, 30); this.Controls.Add(picDbStatus); //数据库连接状态 this.timerDBTesting.Stop(); this.timerDBTesting.Interval = 3000; this.timerDBTesting.Tick += new EventHandler(timerDBTesting_Tick); timerDBTesting.Start(); } catch (Exception ex) { LogHelper.Log.Error(ex.Message); } }
void Call_OnRemoved(CallRemoveReason reason) { if (ControlButton.InvokeRequired) { ControlButton.BeginInvoke(_callOnRemoved, reason); return; } if (Active && Call != null && Call.Number == _controlCallerNumber.Text) { _controlCallerNumber.Text = ""; } Call = null; RefreshBackUI(); }
void Call_OnStateChanged() { if (ControlButton.InvokeRequired) { ControlButton.BeginInvoke(_callOnStateChanged); return; } Trace.TraceInformation("New call state on MainFormPhoneLineControl" + ControlButton.Text + ", new state: " + SipHelper.SipCallStateDecode(_call?.State ?? CallState.NULL)); if (_active) { RefreshUI(); } RefreshBackUI(); }
private void _button_Click(object sender, EventArgs e) { ControlButton button = (ControlButton)sender; switch (button.Action) { case ControlAction.Back: { this.OnBack(EventArgs.Empty); break; } case ControlAction.Cancel: { this.OnCancel(EventArgs.Empty); break; } case ControlAction.CancelExport: { this.OnCancelExport(EventArgs.Empty); break; } case ControlAction.Close: { this.OnClose(EventArgs.Empty); break; } case ControlAction.Export: { this.OnExport(EventArgs.Empty); break; } case ControlAction.Next: { this.OnNext(EventArgs.Empty); break; } } }
void Call_OnDurationChanged() { if (!_active || _call == null) { return; } if (ControlButton.InvokeRequired) { ControlButton.BeginInvoke(_callOnDurationChanged); return; } if (_call.ActiveDuration > TimeSpan.Zero) { _controlDuration.Text = _call.ActiveDuration.ToFormattedString(); } else if (_call.Duration > TimeSpan.Zero) { _controlDuration.Text = _call.Duration.ToFormattedString(); } }
private void OnConfigControlButtonPressed(object sender, ControlButton controlButton) { AlignmentMethodListItem alignmentMethodListItem = (AlignmentMethodListItem)sender; switch (controlButton) { case ControlButton.Delete: DeleteMethod(alignmentMethodListItem); break; case ControlButton.MoveUp: MoveMethod(alignmentMethodListItem, true); break; case ControlButton.MoveDown: MoveMethod(alignmentMethodListItem, false); break; case ControlButton.Configure: AlignmentMethod alignmentMethod = AlignmentMethods[alignmentMethodListItem.listIndex]; ConfigureMethod(alignmentMethod); break; } }
private void OnConfigControlButtonPressed(object sender, ControlButton controlButton) { ConfigureDataListItem configListItem = (ConfigureDataListItem)sender; switch (controlButton) { case ControlButton.Delete: DeleteConfiguration(configListItem); break; case ControlButton.MoveUp: MoveConfiguration(configListItem, true); break; case ControlButton.MoveDown: MoveConfiguration(configListItem, false); break; case ControlButton.Configure: ConfigurationBase configuration = ConfigurationsManager.GetConfiguration(configListItem.ConfigName); ConfigureConfiguration(configuration); break; } }
private void MainForm_Load(object sender, EventArgs e) { // 加载配置 Utils.Configuration.Load(); // 加载服务器 InitServer(); // 加载模式 InitMode(); // 加载翻译 ServerToolStripMenuItem.Text = Utils.i18N.Translate(ServerToolStripMenuItem.Text); ImportServersFromClipboardToolStripMenuItem.Text = Utils.i18N.Translate(ImportServersFromClipboardToolStripMenuItem.Text); AddSocks5ServerToolStripMenuItem.Text = Utils.i18N.Translate(AddSocks5ServerToolStripMenuItem.Text); AddShadowsocksServerToolStripMenuItem.Text = Utils.i18N.Translate(AddShadowsocksServerToolStripMenuItem.Text); AddShadowsocksRServerToolStripMenuItem.Text = Utils.i18N.Translate(AddShadowsocksRServerToolStripMenuItem.Text); AddVMessServerToolStripMenuItem.Text = Utils.i18N.Translate(AddVMessServerToolStripMenuItem.Text); ModeToolStripMenuItem.Text = Utils.i18N.Translate(ModeToolStripMenuItem.Text); CreateProcessModeToolStripMenuItem.Text = Utils.i18N.Translate(CreateProcessModeToolStripMenuItem.Text); SubscribeToolStripMenuItem.Text = Utils.i18N.Translate(SubscribeToolStripMenuItem.Text); ManageSubscribeLinksToolStripMenuItem.Text = Utils.i18N.Translate(ManageSubscribeLinksToolStripMenuItem.Text); UpdateServersFromSubscribeLinksToolStripMenuItem.Text = Utils.i18N.Translate(UpdateServersFromSubscribeLinksToolStripMenuItem.Text); OptionsToolStripMenuItem.Text = Utils.i18N.Translate(OptionsToolStripMenuItem.Text); RestartServiceToolStripMenuItem.Text = Utils.i18N.Translate(RestartServiceToolStripMenuItem.Text); UninstallServiceToolStripMenuItem.Text = Utils.i18N.Translate(UninstallServiceToolStripMenuItem.Text); ReloadModesToolStripMenuItem.Text = Utils.i18N.Translate(ReloadModesToolStripMenuItem.Text); CleanDNSCacheToolStripMenuItem.Text = Utils.i18N.Translate(CleanDNSCacheToolStripMenuItem.Text); AboutToolStripButton.Text = Utils.i18N.Translate(AboutToolStripButton.Text); ConfigurationGroupBox.Text = Utils.i18N.Translate(ConfigurationGroupBox.Text); ServerLabel.Text = Utils.i18N.Translate(ServerLabel.Text); ModeLabel.Text = Utils.i18N.Translate(ModeLabel.Text); ProfileLabel.Text = Utils.i18N.Translate(ProfileLabel.Text); ProfileGroupBox.Text = Utils.i18N.Translate(ProfileGroupBox.Text); SettingsButton.Text = Utils.i18N.Translate(SettingsButton.Text); ControlButton.Text = Utils.i18N.Translate(ControlButton.Text); UsedBandwidthLabel.Text = $@"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}0 KB"; StatusLabel.Text = $@"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Waiting for command")}"; ShowMainFormToolStripButton.Text = Utils.i18N.Translate(ShowMainFormToolStripButton.Text); ExitToolStripButton.Text = Utils.i18N.Translate(ExitToolStripButton.Text); InitProfile(); // 自动检测延迟 Task.Run(() => { while (true) { if (State == Models.State.Waiting || State == Models.State.Stopped) { TestServer(); Thread.Sleep(10000); } else { Thread.Sleep(200); } } }); // 打开软件时启动加速,产生开始按钮点击事件 if (Global.Settings.StartWhenOpened) { ControlButton.PerformClick(); } // 检查更新 if (Global.Settings.CheckUpdateWhenOpened) { CheckUpdate(); } }
public LaunchpadCCKeyEventArgs(int _val, int _vol) { switch (_val) { case 104: val = ControlButton.UP; break; case 105: val = ControlButton.DOWN; break; case 106: val = ControlButton.LEFT; break; case 107: val = ControlButton.RIGHT; break; case 108: val = ControlButton.SESSION; break; case 109: val = ControlButton.USER1; break; case 110: val = ControlButton.USER2; break; case 111: val = ControlButton.MIXER; break; case 89: val = ControlButton.F0; break; case 79: val = ControlButton.F1; break; case 69: val = ControlButton.F2; break; case 59: val = ControlButton.F3; break; case 49: val = ControlButton.F4; break; case 39: val = ControlButton.F5; break; case 29: val = ControlButton.F6; break; case 19: val = ControlButton.F7; break; default: val = ControlButton.NONE; break; } if (_vol == 127) { press = true; } else { press = false; } }
private void ProfileButton_Click(object sender, EventArgs e) { var index = ProfileButtons.IndexOf((Button)sender); if (ModifierKeys == Keys.Control) { if (ServerComboBox.SelectedIndex == -1) { MessageBoxX.Show(i18N.Translate("Please select a server first")); } else if (ModeComboBox.SelectedIndex == -1) { MessageBoxX.Show(i18N.Translate("Please select an mode first")); } else if (ProfileNameText.Text == "") { MessageBoxX.Show(i18N.Translate("Please enter a profile name first")); } else { SaveProfile(index); ProfileButtons[index].Text = ProfileNameText.Text; } } else if (ModifierKeys == Keys.Shift) { if (MessageBoxX.Show(i18N.Translate("Remove this Profile?"), confirm: true) == DialogResult.OK) { RemoveProfile(index); ProfileButtons[index].Text = i18N.Translate("None"); MessageBoxX.Show(i18N.Translate("Profile Removed!")); } } else { if (Global.Settings.Profiles[index].IsDummy) { MessageBoxX.Show(i18N.Translate("No saved profile here. Save a profile first by Ctrl+Click on the button")); return; } try { ProfileNameText.Text = LoadProfile(index); // start the profile ControlFun(); if (State == State.Stopping || State == State.Stopped) { Task.Run(() => { while (State != State.Stopped) { Thread.Sleep(250); } ControlButton.PerformClick(); }); } } catch (Exception ee) { Task.Run(() => { Logging.Info(ee.Message); ProfileButtons[index].Text = i18N.Translate("Error"); Thread.Sleep(1200); ProfileButtons[index].Text = i18N.Translate("None"); }); } } }
public void OnButtonUp(ControlButton button) { }
public void setFireButtonControl(ControlButton arg) { buttonFire = arg; buttonFire.AddPressedDelegate(new OnPressedDelegate(this.OnFire)); }
public void setBoostButtonControl(ControlButton arg) { buttonBoost = arg; }
private static void UpdateTintColor(ControlButton element, UIImageView nativeView) { nativeView.TintColor = (element.IsEnabledEx ? element.EnabledTintColor : element.DisabledTintColor).ToUIColor(); nativeView.Image = nativeView.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); }
private void MainForm_Load(object sender, EventArgs e) { AddAddServerToolStripMenuItems(); OnlyInstance.Called += OnCalled; // 计算 ComboBox绘制 目标宽度 _eWidth = ServerComboBox.Width / 10; Modes.Load(); InitMode(); InitServer(); _comboBoxInitialized = true; // 加载翻译 InitText(); // 隐藏 NatTypeStatusLabel NatTypeStatusText(); _sizeHeight = Size.Height; _configurationGroupBoxHeight = ConfigurationGroupBox.Height; _profileConfigurationHeight = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度 _profileGroupboxHeight = ProfileGroupBox.Height; // 加载快速配置 InitProfile(); // 打开软件时启动加速,产生开始按钮点击事件 if (Global.Settings.StartWhenOpened) { ControlButton.PerformClick(); } // 自动检测延迟 Task.Run(() => { while (true) { if (State == State.Waiting || State == State.Stopped) { TestServer(); Thread.Sleep(10000); } else { Thread.Sleep(200); } } }); Task.Run(() => { // 检查更新 if (Global.Settings.CheckUpdateWhenOpened) { CheckUpdate(); } }); Task.Run(async() => { // 检查订阅更新 if (Global.Settings.UpdateSubscribeatWhenOpened) { await UpdateServersFromSubscribe(); } }); }
private void ControlButton_Click(object sender, EventArgs e) { if (ControlButton.Text.Contains("启动")) { if (v2rayServerAddressTextBox.Text != "" && v2rayServerPortTextBox.Text != "" && v2rayUserIDTextBox.Text != "" && v2rayAlterIDTextBox.Text != "" && TUNTAPAddressTextBox.Text != "" && TUNTAPGatewayTextBox.Text != "" && TUNTAPDNSTextBox.Text != "" && TUNTAPPointsTextBox.Text != "") { status = "启动中 ..."; ControlButton.Enabled = false; ControlButton.Text = "稍等 ..."; string adapterAddress = AdapterAddressComboBox.Text; string adapterGateway = AdapterGatewayComboBox.Text; string v2rayDefaultDNS = v2rayDefaultDNSTextBox.Text; string v2rayChinaDNS = v2rayChinaDNSTextBox.Text; string v2rayServerAddress = v2rayServerAddressTextBox.Text; string v2rayServerPort = v2rayServerPortTextBox.Text; string v2rayUserID = v2rayUserIDTextBox.Text; string v2rayAlterID = v2rayAlterIDTextBox.Text; string v2rayTransferMethod; switch (v2rayTransferMethodComboBox.Text) { case "TCP": v2rayTransferMethod = "tcp"; break; case "mKCP": v2rayTransferMethod = "kcp"; break; case "WebSockets": v2rayTransferMethod = "ws"; break; case "HTTP/2": v2rayTransferMethod = "http"; break; case "QUIC": v2rayTransferMethod = "quic"; break; default: v2rayTransferMethod = "ws"; break; } string v2rayTLSSecure = (v2rayTLSSecureCheckBox.Checked) ? "tls" : "none"; string v2rayPath = v2rayPathTextBox.Text; string TUNTAPGateway = TUNTAPGatewayTextBox.Text; string TUNTAPAddress = TUNTAPAddressTextBox.Text; string TUNTAPDNS = TUNTAPDNSTextBox.Text; string TUNTAPPoints = TUNTAPPointsTextBox.Text; Task.Factory.StartNew(() => { status = "正在生成 v2ray 配置文件 ..."; string config = Encoding.UTF8.GetString(Convert.FromBase64String(v2tap.config)); config = config.Replace("adapterIPAddress", adapterAddress); config = config.Replace("v2rayDefaultDNS", v2rayDefaultDNS); config = config.Replace("v2rayChinaDNS", v2rayChinaDNS); config = config.Replace("v2rayServerAddress", v2rayServerAddress); config = config.Replace("v2rayServerPort", v2rayServerPort); config = config.Replace("v2rayUserID", v2rayUserID); config = config.Replace("v2rayAlterID", v2rayAlterID); config = config.Replace("v2rayTransferMethod", v2rayTransferMethod); config = config.Replace("v2rayTLSSecure", v2rayTLSSecure); config = config.Replace("v2rayPath", v2rayPath); File.WriteAllText("config.json", config); Thread.Sleep(1000); status = "正在启动 v2ray 服务 ..."; Utils.SharedUtils.ExecuteCommand("wv2ray.exe -config config.json"); Thread.Sleep(1000); status = "正在启动 tun2socks 服务 ..."; Utils.SharedUtils.ExecuteCommand("RunHiddenConsole.exe tun2socks.exe -tun-gw " + TUNTAPGateway + " -tun-address " + TUNTAPAddress + " -tun-dns " + TUNTAPDNS + " -enable-dns-cache -public-only -local-socks-addr 127.0.0.1:1099"); Thread.Sleep(1000); status = "正在配置 路由表 ..."; Utils.SharedUtils.ExecuteCommand("ROUTE CHANGE 0.0.0.0 MASK 0.0.0.0 " + adapterGateway + " METRIC 1000"); Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + v2rayDefaultDNS + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10"); Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + v2rayChinaDNS + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10"); if (TUNTAPDNS.Contains(",")) { foreach (string IP in TUNTAPDNS.Split(",".ToCharArray())) { Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + IP + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10"); } } else { Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + TUNTAPDNS + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10"); } Utils.SharedUtils.ExecuteCommand("ROUTE ADD 0.0.0.0 MASK 0.0.0.0 " + TUNTAPGateway + " METRIC " + TUNTAPPoints); Thread.Sleep(1000); ControlButton.Invoke((MethodInvoker) delegate { ControlButton.Enabled = true; ControlButton.Text = "停止"; }); status = "启动完毕 ..."; try { File.Delete("config.json"); } catch { } }); } else { MessageBox.Show("配置信息不可为空", "配置错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { status = "停止中 ..."; ControlButton.Enabled = false; ControlButton.Text = "稍等 ..."; string v2rayDefaultDNS = v2rayDefaultDNSTextBox.Text; string v2rayChinaDNS = v2rayChinaDNSTextBox.Text; string TUNTAPDNS = TUNTAPDNSTextBox.Text; Task.Factory.StartNew(() => { Thread.Sleep(1000); status = "正在关闭 v2ray 服务 ..."; Utils.SharedUtils.ExecuteCommand("TASKKILL /F /T /IM wv2ray.exe"); Thread.Sleep(1000); status = "正在关闭 tun2socks 服务 ..."; Utils.SharedUtils.ExecuteCommand("TASKKILL /F /T /IM tun2socks.exe"); Thread.Sleep(1000); status = "正在重置 路由表 ..."; Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + v2rayDefaultDNS); Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + v2rayChinaDNS); if (TUNTAPDNS.Contains(",")) { foreach (string IP in TUNTAPDNS.Split(",".ToCharArray())) { Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + IP); } } else { Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + TUNTAPDNS); } Thread.Sleep(1000); ControlButton.Invoke((MethodInvoker) delegate { ControlButton.Enabled = true; ControlButton.Text = "启动"; }); status = "停止完毕 ..."; }); } }
private void ProfileButton_Click(object sender, EventArgs e) { var index = ProfileButtons.IndexOf((Button)sender); //Utils.Logging.Info(String.Format("Button no.{0} clicked", index)); if (ModifierKeys == Keys.Control) { if (ServerComboBox.SelectedIndex == -1) { MessageBoxX.Show(i18N.Translate("Please select a server first")); } else if (ModeComboBox.SelectedIndex == -1) { MessageBoxX.Show(i18N.Translate("Please select an mode first")); } else if (ProfileNameText.Text == "") { MessageBoxX.Show(i18N.Translate("Please enter a profile name first")); } else { SaveProfile(index); ProfileButtons[index].Text = ProfileNameText.Text; } } else { if (ProfileButtons[index].Text == i18N.Translate("Error") || ProfileButtons[index].Text == i18N.Translate("None")) { MessageBoxX.Show(i18N.Translate("No saved profile here. Save a profile first by Ctrl+Click on the button")); } try { ProfileNameText.Text = LoadProfile(index); // start the profile var need2ndStart = true; if (State == State.Waiting || State == State.Stopped) { need2ndStart = false; } ControlButton.PerformClick(); if (need2ndStart) { Task.Run(() => { while (State != State.Stopped) { Thread.Sleep(200); } ControlButton.PerformClick(); }); } } catch (Exception ee) { Task.Run(() => { Logging.Info(ee.Message); ProfileButtons[index].Text = i18N.Translate("Error"); Thread.Sleep(1200); ProfileButtons[index].Text = i18N.Translate("None"); }); } } }
public Player(ControlPad controlPad, ControlButton fireButton) { mControlPad = controlPad; mFireButton = fireButton; }
private static void UpdateTintColor(ControlButton element, Droid.ImageView nativeView) { nativeView.SetColorFilter((element.IsEnabledEx ? element.EnabledTintColor : element.DisabledTintColor).ToAndroid()); }
public void setAimButtonControl(ControlButton arg) { buttonAim = arg; }