public ControlState controlState; //get and set the control state #endregion #region constructor/load public TacticalBattle(List<Piece> player1Army, List<Piece> player2Army, TacMap map, ContentManager content) { //p1Avatar = player1; //p2Avatar = player2; this.player1Army = player1Army; this.player2Army = player2Army; isPlayer1Turn = true; this.map = map; battleOver = false; gridOn = false; mouseVisible = true; controlState = ControlState.selectUnit; selectedUnit = null; status = "Combat begins"; selectionTiles = new List<Tile>(); unitInfo = ""; //load interface items TODO confirmation = content.Load<Texture2D>("confirmationPopup"); background = content.Load<Texture2D>("TerrainSprites/battle"); statusFont = content.Load<SpriteFont>("Arial"); playerFont = content.Load<SpriteFont>("playerFont"); infoFont = content.Load<SpriteFont>("infoFont"); moveBox = content.Load<Texture2D>("TerrainSprites/move"); targetBox = content.Load<Texture2D>("TerrainSprites/target"); selectedBox = content.Load<Texture2D>("TerrainSprites/selected"); horizontal = content.Load<Texture2D>("TerrainSprites/horizontal"); vertical = content.Load<Texture2D>("TerrainSprites/vertical"); winBox = content.Load<Texture2D>("Menu/Win message"); //set units to starting positions startingPositions(); }
// Update is called once per frame void Update() { switch(controlState){ case ControlState.DEBUG: Vector2 mouse = Input.mousePosition; float h = mouse.x / cam.pixelWidth; float v = (cam.pixelHeight - mouse.y)/cam.pixelHeight ; //Script used for detecting if controller should be used transform.rotation = Quaternion.Euler(v * verticalRotationAmount + verticalRotationOffset,h * horizontalRotationAmount + horizontalRotationOffset,0); break; case ControlState.NVR: controllerRotX += (Input.GetAxis("ViewY") * turnSpeed * Time.deltaTime); controllerRotY += (Input.GetAxis("ViewX") * turnSpeed * Time.deltaTime); controllerRotX = Mathf.Clamp(controllerRotX,-90,90); transform.rotation = Quaternion.Euler(controllerRotX,controllerRotY + cartOffsetRotY,0); break; case ControlState.VR: transform.rotation = Quaternion.Euler(0,cartOffsetRotY - 180,0); break; } if(Input.GetKeyDown("c")){ if((int)++controlState % 3 == 0) controlState = ControlState.DEBUG; Console.Instance.AddMessage("ControlState: " + controlState); Debug.Log("ControlState: " + controlState); } }
public void LoadEditor(IImageUploadSettingsEditorContext context) { _loadedState = ControlState.Loading; _context = context; LoadEditor(); _loadedState = ControlState.Loaded; }
public void LoadEditor(IProperties imageServiceSettings) { _loadedState = ControlState.Loading; _imageServiceSettings = imageServiceSettings; LoadEditor(); _loadedState = ControlState.Loaded; }
public PaintScrollBarThumbEventArgs(System.Drawing.Graphics graphics, Rectangle thumbRect, ControlState controlState, System.Windows.Forms.Orientation orientation, bool enabled) { this._graphics = graphics; this._thumbRect = thumbRect; this._controlState = controlState; this._orientation = orientation; this._enabled = enabled; }
public void Update(TimeSpan elapsedTime, ControlState controlState) { var leftRight = this.helpSteer(controlState).Clamped(-1, 1); this.updateMovement(elapsedTime, controlState.Acceleration, leftRight); this.update(); }
public ColorValue[] States; // Modulate colors for all possible control states #endregion Fields #region Methods /// <summary>Blend the colors together</summary> public void Blend(ControlState state, float elapsedTime, float rate) { if ((States == null) || (States.Length == 0) ) return; // Nothing to do ColorValue destColor = States[(int)state]; Current = ColorOperator.Lerp(Current, destColor, 1.0f - (float)Math.Pow(rate, 30 * elapsedTime) ); }
public PaintScrollBarThumbEventArgs( Graphics graphics, Rectangle thumbRect, ControlState controlState, Orientation orientation) : this(graphics, thumbRect, controlState, orientation, true) { }
protected override void OnMouseEnter(EventArgs e) { if (state != ControlState.Down) { state = ControlState.Hover; ; } this.Invalidate(); base.OnMouseEnter(e); }
public PaintScrollBarArrowEventArgs(System.Drawing.Graphics graphics, Rectangle arrowRect, ControlState controlState, System.Windows.Forms.ArrowDirection arrowDirection, System.Windows.Forms.Orientation orientation, bool enabled) { this._graphics = graphics; this._arrowRect = arrowRect; this._controlState = controlState; this._arrowDirection = arrowDirection; this._orientation = orientation; this._enabled = enabled; }
public void LoadEditor(ImageDecoratorEditorContext context, object state, IImageTargetEditor imageTargetEditor) { _loadedState = ControlState.Loading; _context = context; _state = state; _imageTargetEditor = imageTargetEditor; LoadEditor(); _loadedState = ControlState.Loaded; OnEditorLoaded(); }
public MainEngine() { commandList = CommandSingleton.Instance(); controlState = new CommandState(); SetupSpeechRecognition(); EventSingleton.Instance().fixationEvent += sharedData_fixationEvent; }
public PaintScrollBarThumbEventArgs( Graphics graphics, Rectangle thumbRect, ControlState controlState, Orientation orientation, bool enabled) { _graphics = graphics; _thumbRect = thumbRect; _controlState = controlState; _orientation = orientation; _enabled = enabled; }
public PaintScrollBarArrowEventArgs( Graphics graphics, Rectangle arrowRect, ControlState controlState, ArrowDirection arrowDirection, Orientation orientation) : this(graphics, arrowRect, controlState, arrowDirection, orientation, true) { }
public StateHotspot(ControlState representedState, Rectangle hotspotRect, bool selected, Image activeImage, Image inactiveImage) { //Setting what state the hotspot represents this.representedState = representedState; //Setting if it is currently selected this.selected = selected; //Setting the size and position of the hotspot this.hotspotRect = hotspotRect; //Setting the images it will use to display if it is active this.activeImage = activeImage; this.inactiveImage = inactiveImage; }
public PaintScrollBarArrowEventArgs( Graphics graphics, Rectangle arrowRect, ControlState controlState, ArrowDirection arrowDirection, Orientation orientation, bool enabled) { _graphics = graphics; _arrowRect = arrowRect; _controlState = controlState; _arrowDirection = arrowDirection; _orientation = orientation; _enabled = enabled; }
private void SetControlState(ControlState state) { switch (state) { case ControlState.TimerStopped: this.groupBoxStartTimers.Enabled = true; this.groupBoxControls.Enabled = false; break; case ControlState.TimerRunning: this.groupBoxStartTimers.Enabled = false; this.groupBoxControls.Enabled = true; break; default: break; } }
private float helpSteer(ControlState controlState) { var leftRight = ( controlState.LeftRight * 2f ).Clamped(-1, 1); var rayAngle = Angle.FromRadians(0.7f); var rayLength = 2.5.U(); var vVector = this.Direction.Vector; leftRight += this.modifySteering(rayAngle, rayLength, vVector); leftRight -= this.modifySteering(-rayAngle, rayLength, vVector); return leftRight; }
public void Update () { if (stateChanged) { stateChanged = false; return; } if (_state == ControlState.Starting) { _state = ControlState.Active; } if (_state == ControlState.Ending) { _state = ControlState.Inactive; } }
/// <summary> /// 图片按钮的背景图是4个,根据状态获取其中背景图 /// </summary> /// <param name="name">图片名称</param> /// <param name="state">状态</param> /// <returns></returns> public static Bitmap GetResWithState(String name, ControlState state) { Bitmap bitmap = (Bitmap)GetResAsImage(name); if (bitmap == null) { return null; } int block = 0; switch (state) { case ControlState.Normal: block = 0; break; case ControlState.MouseOver: block = 1; break; case ControlState.MouseDown: block = 2; break; case ControlState.Disable: block = 3; break; } int width = bitmap.Width / 4; Rectangle rect = new Rectangle(block * width, 0, width, bitmap.Height); return bitmap.Clone(rect, bitmap.PixelFormat); }
public XbmcHandler(XbmcJsonRpcConnection xbmc, DisplayHandler display) { if (xbmc == null) { throw new ArgumentNullException("xbmc"); } if (display == null) { throw new ArgumentNullException("display"); } this.xbmc = xbmc; this.display = display; this.xbmc.Connected += this.xbmcConnected; this.xbmc.Aborted += this.xbmcAborted; this.xbmc.Player.PlaybackStarted += this.xbmcPlaybackStarted; this.xbmc.Player.PlaybackPaused += this.xbmcPlaybackPaused; this.xbmc.Player.PlaybackResumed += this.xbmcPlaybackResumed; this.xbmc.Player.PlaybackStopped += this.xbmcPlaybackStopped; this.xbmc.Player.PlaybackEnded += this.xbmcPlaybackEnded; this.xbmc.Player.PlaybackSeek += this.xbmcPlaybackSeek; this.xbmc.Player.PlaybackSeekChapter += this.xbmcPlaybackSeek; this.xbmc.Player.PlaybackSpeedChanged += this.xbmcPlaybackSpeedChanged; this.progressTimer = new System.Timers.Timer(); this.progressTimer.Interval = ProgressUpdateInterval; this.progressTimer.Elapsed += progressTimerUpdate; this.progressTimer.AutoReset = true; this.WorkerReportsProgress = false; this.WorkerSupportsCancellation = true; this.controlModeState = new ControlState(); this.controlModeTimer = new System.Timers.Timer(); this.controlModeTimer.Interval = ControlModeUpdateInterval; this.controlModeTimer.Elapsed += controlModeTimerUpdate; this.controlModeTimer.AutoReset = true; this.semReady = new Semaphore(0, 1); this.semWork = new Semaphore(0, 1); }
/// <summary> /// Set state of control /// </summary> /// <param name="controlState"></param> public void SetControlState(ControlState controlState) { switch (controlState) { case ControlState.NewFee: { this.txtCode.Enabled = true; this.txtDescription.Enabled = true; this.txtAmount.Enabled = true; break; } case ControlState.ViewFee: { this.txtCode.Enabled = false; this.txtDescription.Enabled = false; this.txtAmount.Enabled = false; break; } } }
/// <summary> /// Определяет текущее состояние пользователя. /// </summary> protected virtual void DefineCurrentState() { SLService.SLService service = new SLService.SLService(); IList<WorkEvent> mainAndLastWorkEvent = service.GetMainWorkAndLastEvent(Page.CurrentUser.ID.Value); WorkEvent TodayWorkEvent = mainAndLastWorkEvent[0]; WorkEvent LastEvent = mainAndLastWorkEvent[1]; if (TodayWorkEvent == null || (TodayWorkEvent.BeginTime != TodayWorkEvent.EndTime)) { State = ControlState.WorkFinished; return; } switch (LastEvent.EventType) { case WorkEventType.MainWork: State = ControlState.WorkGoes; break; case WorkEventType.TimeOff: State = LastEvent.BeginTime == LastEvent.EndTime ? ControlState.Absent : ControlState.WorkGoes; break; case WorkEventType.LanchTime: State = LastEvent.BeginTime == LastEvent.EndTime ? ControlState.Feeding : ControlState.WorkGoes; break; case WorkEventType.StudyEnglish: State = LastEvent.BeginTime == LastEvent.EndTime ? ControlState.EnglishLesson : ControlState.WorkGoes; break; } }
// ----------------- public SpriteConfig GetStateSpriteConfig(ControlState state) { switch (state) { case ControlState.Neutral: return(this.spriteNeutral); case ControlState.RawPress: return(this.spriteRawPress); case ControlState.NormalPress: return(this.spriteNormalPress); case ControlState.LongPress: return(this.spriteLongPress); case ControlState.Tap: return(this.spriteTap); case ControlState.DoubleTap: return(this.spriteDoubleTap); case ControlState.LongTap: return(this.spriteLongTap); case ControlState.NormalScrollU: return(this.spriteNormalScrollU); case ControlState.NormalScrollR: return(this.spriteNormalScrollR); case ControlState.NormalScrollD: return(this.spriteNormalScrollD); case ControlState.NormalScrollL: return(this.spriteNormalScrollL); case ControlState.LongScrollU: return(this.spriteLongScrollU); case ControlState.LongScrollR: return(this.spriteLongScrollR); case ControlState.LongScrollD: return(this.spriteLongScrollD); case ControlState.LongScrollL: return(this.spriteLongScrollL); } return(null); }
/// <summary> /// Switch screens in this connection config view /// </summary> /// <param name="state"></param> private async void ChangeStates(ControlState state) { VMConfig.Avatar = AzureDevOps.Avatar; VMConfig.DisplayName = AzureDevOps.DisplayName; VMConfig.Email = AzureDevOps.Email; VMConfig.State = state; if (state == ControlState.EditingServer) { // Load the team project list, show progress animation try { ToggleLoading(true); Dispatcher.Invoke(projects.Clear); var newProjectList = await UpdateTeamProjects().ConfigureAwait(true); // need to come back to original UI thread. newProjectList.ForEach(p => projects.Add(p)); ToggleLoading(false); Dispatcher.Invoke(() => serverTreeview.ItemsSource = projects); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); Dispatcher.Invoke(() => MessageDialog.Show("Error when retrieving team projects")); ToggleLoading(false); disconnectButton_Click(null, null); } #pragma warning restore CA1031 // Do not catch general exception types FireAsyncContentLoadedEvent(AsyncContentLoadedState.Completed); } else if (state == ControlState.HasServer) { Dispatcher.Invoke(() => selectedTeamText.Text = AzureDevOps.Configuration.SavedConnection.ToString()); } }
/// <summary> /// Update ViewItem State. /// </summary> internal void UpdateState() { if (!styleApplied) { return; } ControlState sourceState = ControlState; ControlState targetState; // Normal, Disabled targetState = IsEnabled ? ControlState.Normal : ControlState.Disabled; // Selected, DisabledSelected if (IsSelected) { targetState += ControlState.Selected; } // Pressed, PressedSelected if (IsPressed) { targetState += ControlState.Pressed; } // Focused, FocusedPressed, FocusedPressedSelected, DisabledFocused, DisabledSelectedFocused if (IsFocused) { targetState += ControlState.Focused; } if (sourceState != targetState) { ControlState = targetState; OnUpdate(); } }
/// <summary> /// 控件状态改变时方法。 /// </summary> /// <param name="state">控件状态。</param> private void OnAfterStateChanged(ControlState state) { switch (state) { case ControlState.Empty: toolbarSave.Enabled = false; toolbarDelete.Enabled = false; toolbarStatus.Enabled = false; this.teActionName.Text = string.Empty; this.teEDCName.Text = string.Empty; this.teEquipmentKey.Text = string.Empty; this.teEquipmentKey.EditValue = string.Empty; this.teSPName.Text = string.Empty; this.tePartName.Text = string.Empty; this.teOperationName.Text = string.Empty; this.txtPartType.Text = string.Empty; this.meDesc.Text = string.Empty; this.txtRoute.Text = string.Empty; this.lciIsMustInputLotNo.Visibility = LayoutVisibility.Never; this.chkIsMustInputLotNo.Checked = false; this.teEquipmentKey.Properties.ReadOnly = true; grdEDCPoint.DataSource = null; BindEquipmentData(); break; case ControlState.Edit: case ControlState.New: toolbarSave.Enabled = true; toolbarDelete.Enabled = true; toolbarStatus.Enabled = true; this.teEquipmentKey.Properties.ReadOnly = false; this.lciIsMustInputLotNo.Visibility = LayoutVisibility.Never; this.chkIsMustInputLotNo.Checked = false; BindEquipmentData(); break; } }
public static ControlStates FromControlStateClass(ControlState controlState) { if (controlState == ControlState.Normal) { return(ControlStates.Normal); } if (controlState == ControlState.Focused) { return(ControlStates.Focused); } if (controlState == ControlState.Disabled) { return(ControlStates.Disabled); } if (controlState == ControlState.Selected) { return(ControlStates.Selected); } if (controlState == ControlState.Pressed) { return(ControlStates.Pressed); } if (controlState == ControlState.DisabledFocused) { return(ControlStates.DisabledFocused); } if (controlState == ControlState.SelectedFocused) { return(ControlStates.SelectedFocused); } if (controlState == ControlState.DisabledSelected) { return(ControlStates.DisabledSelected); } return(ControlStates.Normal); }
public void BeforeWrite(BlockNode control) { var groupControls = GetGroupControlChildren(control); if (!groupControls.Any()) { return; } foreach (var groupControl in groupControls) { var groupControlName = groupControl.Name.Identifier; if (!_editorStateStore.TryGetControlState(groupControlName, out var groupControlState)) { // There may not be editorstate present for this. Create a fake state to use groupControlState = new ControlState() { StyleName = "", ParentIndex = -1, IsGroupControl = true, ExtensionData = ControlInfoJson.Item.CreateDefaultExtensionData() }; } var groupedControlNames = groupControl.Children .Select(child => child.Name.Identifier) .OrderBy(childName => _entropy.GetGroupControlOrder(groupControlName, childName)); // Add the group controls to the parent's children instead foreach (var child in groupControl.Children) { control.Children.Add(child); } groupControl.Children = new List <BlockNode>(); groupControlState.GroupedControlsKey = groupedControlNames.ToList(); } }
// Use this for initialization void Start() { curentState = ControlState.WaitingForAnchorStore; ttsMgr = GetComponent <TextToSpeechManager>(); if (ttsMgr == null) { Debug.LogError("TextToSpeechManager Required"); } anchorManager = WorldAnchorManager.Instance; if (anchorManager == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } spatialMappingManager = SpatialMappingManager.Instance; if (spatialMappingManager == null) { Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene."); } WorldAnchorStore.GetAsync(AnchorStoreReady); }
/// <summary> /// 画Tab标签上的close图标 /// </summary> /// <param name="g"></param> private void DrawTabCloseImage(Graphics g, Rectangle rec) { ControlState state = ControlState.Normal; Rectangle closeTabRec = GetCloseTabRec(rec); Point pt = PointToClient(Control.MousePosition); if (closeTabRec.Contains(pt)) { state = _closeTabState; } if (state == ControlState.Normal && _closeTabNormalImage != null) { g.DrawImage(_closeTabNormalImage, closeTabRec); } else if (state == ControlState.Hover && _closeTabHoverImage != null) { g.DrawImage(_closeTabHoverImage, closeTabRec); } else if (state == ControlState.Pressed && _closeTabPressImage != null) { g.DrawImage(_closeTabPressImage, closeTabRec); } }
protected override void OnClick(EventArgs e) { if (Enabled) { Point p = PointToClient(MousePosition); if (BACK_BUTTON_RECT.Contains(p.X, p.Y) && BackButtonState != ControlState.Disabled) { MoveBack(); } else if (FORWARD_BUTTON_RECT.Contains(p.X, p.Y) && ForwardButtonState != ControlState.Disabled) { MoveForward(); } else if (DROPDOWN_ARROW_RECT.Contains(p.X, p.Y) && DropDownArrowState != ControlState.Disabled) { DropDownArrowState = ControlState.Pressed; } Invalidate(); } base.OnClick(e); }
public void AddStep(string text, object data) { int oldindex = HistoryIndex; bool IsExist = false; for (int i = 0; i < DropDownMenu.MenuItems.Count; i++) { if (DropDownMenu.MenuItems[i].Text == text && DropDownMenu.MenuItems[i].Tag == data) { HistoryIndex = i; IsExist = true; break; } } if (oldindex == HistoryIndex && !IsExist) { MenuItem mi = new MenuItem(text); mi.Tag = data; mi.Click += MenuClicked; DropDownMenu.MenuItems.Add(mi); if (DropDownMenu.MenuItems.Count > MaxStep) { DropDownMenu.MenuItems.RemoveAt(0); } HistoryIndex = DropDownMenu.MenuItems.Count - 1; } if (HistoryIndex >= 0) { DropDownArrowState = ControlState.Normal; } MoveTo(HistoryIndex); }
private void ReleaseControl() { controlState = ControlState.None; cam.transform.parent = null; curUnit.ResetTarget(); isAttacking = false; StopAllCoroutines(); Cursor.visible = true; Cursor.lockState = CursorLockMode.None; movedir = Vector3.zero; SelectedTime = 0; bool endTurn = true; foreach (Unit unit in currentTeam == Team.Red ? redUnits : blueUnits) { if (unit.isControllable) { endTurn = false; } } doEndTurn = endTurn; }
void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.tag == "explosion") { if (collider.gameObject.GetComponent <TimedObjectDestructor>().currentTime < 0.5f) //Only the first half second of the explosion the player will be able to jump from it { rigidbody2D.AddForce(transform.up * (jumpForce * 4) * Time.deltaTime); } } else if (collider.gameObject.tag == "goal") { //Player made it to the goal! if (!GoalManager.Instance.CheckForGoal()) { GoalManager.Instance.DisplayMessage(); if (charaType != CharacterType.Ghost) { LeaveCharacter(true); //ghost leave enemy, but be disabled } controlState = ControlState.Disabled; StopMoving(); } } }
private Action <ViewStyle, string> GenBackgroundSelectorAction(ControlState state) { return((ViewStyle viewStyle, string stringInput) => { var imageUrl = TryConvertToResourcePath(stringInput); if (imageUrl != null) { if (selectorData == null || (selectorData as Selector <string> == null)) { selectorData = new Selector <string>(); } ((Selector <string>)selectorData).AddWithoutDuplicationCheck(state, imageUrl); } else if (ParseXamlStringToObject <Color>(stringInput) is Color color) { if (selectorData == null || (selectorData as Selector <Color> == null)) { selectorData = new Selector <Color>(); } ((Selector <Color>)selectorData).AddWithoutDuplicationCheck(state, color); } }); }
void NewGame() { for (int i = 0; i < 5; ++i) { seeds[i] = Utily.Next(); Utily.ChangeSeed(seeds[i]); MapForPiсk[i] = new Map(); } numPickCave = 0; numDiff = 1; MiniGameEnd = true; minigame = new MiniGame(Width, Height); player = new Player(); score = new Scores(Width, Height); score.active = ScoreState.Achievements; CheckDanger = false; IsWin = false; StoryMiniGame = StoryMG.Empty; view.UpdateImage(); view.ClearConsole(); seed = ""; state = ControlState.PickCave; UseMiniGame = false; }
private void btnCancel_Click(object sender, EventArgs e) { this.CtrlState = ControlState.ReadOnly; }
private void btSave_Click(object sender, EventArgs e) { DataTable dtPlan = gcPlan.DataSource as DataTable; DataTable dtPlan_Update = dtPlan.GetChanges(DataRowState.Modified); DataTable dtPlan_Insert = dtPlan.GetChanges(DataRowState.Added); DataSet dsPlan = new DataSet(); if (dtPlan_Update != null && dtPlan_Update.Rows.Count > 0) { DataTable dtUpdate = dtPlan_Update.Clone(); foreach (DataRow dr in dtPlan_Update.Rows) { DataRow[] drUpdates = dtPlan.Select(string.Format(RPT_PLAN_AIM.FIELDS_PLANID + "='{0}'", dr[RPT_PLAN_AIM.FIELDS_PLANID].ToString())); DataRow drNew = dtUpdate.NewRow(); for (int i = 0; i < dtUpdate.Columns.Count; i++) { drNew[i] = drUpdates[0][i]; } dtUpdate.Rows.Add(drNew); } dtUpdate.TableName = RPT_PLAN_AIM.DATABASE_TABLE_FORUPDATE; dsPlan.Merge(dtUpdate, true, MissingSchemaAction.Add); } if (dtPlan_Insert != null && dtPlan_Insert.Rows.Count > 0) { DataTable dtInsert = dtPlan_Insert.Clone(); foreach (DataRow dr in dtPlan_Insert.Rows) { DataRow[] drUpdates = dtPlan.Select(string.Format(RPT_PLAN_AIM.FIELDS_PLANID + "='{0}'", dr[RPT_PLAN_AIM.FIELDS_PLANID].ToString())); DataRow drNew = dtInsert.NewRow(); for (int i = 0; i < dtInsert.Columns.Count; i++) { drNew[i] = drUpdates[0][i]; } dtInsert.Rows.Add(drNew); } dtInsert.TableName = RPT_PLAN_AIM.DATABASE_TABLE_FORINSERT; dsPlan.Merge(dtInsert, true, MissingSchemaAction.Add); } if (dsPlan.Tables.Count > 0) { bool bl_Bak = _rptEntity.SaveRptPlanAimData(dsPlan); if (!bl_Bak) { //MessageService.ShowMessage("保存失败!"); MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WorkOrderProductSetting.msg.0004}")); } else { //MessageService.ShowMessage("保存成功!"); MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WorkOrderProductSetting.msg.0005}")); this.CtrlState = ControlState.ReadOnly; } } }
public void update() //gathers input, updates positions, and handles combat { //update inputs oldMouse = mouseState; mouseState = Mouse.GetState(); oldKeyboardState = keyboardState; keyboardState = Keyboard.GetState(); Rectangle endTurn = new Rectangle(918, 818, 268, 69); Rectangle toggleGrid = new Rectangle(1076, 70, 115, 20); Rectangle mouse = new Rectangle(mouseState.X, mouseState.Y, 1, 1); //TODO find unspent unit //click toggle grid button if (mouse.Intersects(toggleGrid) && mouseState.LeftButton == ButtonState.Pressed && oldMouse.LeftButton != ButtonState.Pressed) gridOn = !gridOn; if (controlState == ControlState.selectUnit) { //change scroll-over display based on mouse coordinates scrolledOver = mouseOverTile(); //if click and scrolled over friendly unit set unit to selected and change state to choose option if (mouseState.LeftButton == ButtonState.Pressed) { if (mouse.Intersects(endTurn) && oldMouse.LeftButton != ButtonState.Pressed) { //if end turn is clicked then refresh armies and switch players controlState = ControlState.endTurn; } else { if (mouseState.X < 900 && mouseState.Y < 900 && scrolledOver != null && !scrolledOver.isEmpty()) { if((scrolledOver.getResident().getFaction().Equals("RED") && isPlayer1Turn) || (scrolledOver.getResident().getFaction().Equals("BLUE") && !isPlayer1Turn)) { if (!scrolledOver.getResident().hasPieceAttacked()) { selectedTile = scrolledOver; selectedUnit = scrolledOver.getResident(); selectionTiles = map.getValidMoves(); controlState = ControlState.chooseOption; //hide mouse mouseVisible = false; } else status = "Unit is spent for this turn"; } } } } if (keyboardState.IsKeyDown(Keys.K)) //test win screen { status = "Nobody wins! YAY!"; controlState = ControlState.endGame; } } else if (controlState == ControlState.chooseOption) { //if keyboardState has a button pressed coressponding to the options then change state and show mouse TODO if (keyboardState.IsKeyDown(Keys.W) && !selectedUnit.hasPieceMoved()) //move { mouseVisible = true; selectionTiles = map.findValidMoves(selectedUnit); controlState = ControlState.move; } else if (keyboardState.IsKeyDown(Keys.A) && !selectedUnit.hasPieceAttacked()) //attack { mouseVisible = true; currentAbility = new Attack(selectedUnit); selectionTiles = map.checkRange(selectedTile, currentAbility, currentAbility.getRange(), selectedUnit); //if no targets in range status "says so" and don't change state controlState = ControlState.selectTarget; } else if (keyboardState.IsKeyDown(Keys.T)) //end turn { //selectedUnit.move(); selectedUnit.attack(); //TODO mouseVisible = true; controlState = ControlState.selectUnit; } else if (keyboardState.IsKeyDown(Keys.Space) && !oldKeyboardState.IsKeyDown(Keys.Space)) { mouseVisible = true; controlState = ControlState.selectUnit; } //space = cancel, go back to selectUnit } else if (controlState == ControlState.move) { //change scroll-over display based on mouse coordinates scrolledOver = mouseOverTile(); //if click and mouse XY corresponds to valid tile then move unit and return to chooseoption TODO if (selectionTiles.Contains(mouseOverTile()) && mouseState.LeftButton == ButtonState.Pressed) { map.movePiece(selectedTile, scrolledOver, selectedUnit); selectedTile = scrolledOver; selectedUnit.move(); status = selectedUnit.getName() + " has moved."; mouseVisible = false; controlState = ControlState.chooseOption; } else if (keyboardState.IsKeyDown(Keys.Space) && !oldKeyboardState.IsKeyDown(Keys.Space)) { mouseVisible = false; controlState = ControlState.chooseOption; } //space = cancel, go back to chooseOption } else if (controlState == ControlState.selectTarget) { //change scroll-over display based on mouse coordinates scrolledOver = mouseOverTile(); //if click and tile is in target list than initiate combat between selected unit and target, show mouse, return to select unit TODO if (mouseState.LeftButton == ButtonState.Pressed) { //if scrolled over tile is within targetTiles then initiate combat if(selectionTiles.Contains(scrolledOver)) { //change status to combat result string status = currentAbility.execute(selectedUnit, scrolledOver.getResident()); selectedUnit.attack(); //remove dead units if (selectedUnit.getHealth() < 1) selectedTile.removePiece(); if (scrolledOver.getResident().getHealth() < 1) scrolledOver.removePiece(); controlState = ControlState.selectUnit; //status = "attack"; } } else if (keyboardState.IsKeyDown(Keys.Space) && !oldKeyboardState.IsKeyDown(Keys.Space)) { currentAbility = null; mouseVisible = false; controlState = ControlState.chooseOption; } //space = cancel, go back to chooseOption } else if (controlState == ControlState.endTurn) { if (keyboardState.IsKeyDown(Keys.Y)) { refreshArmy(); isPlayer1Turn = !isPlayer1Turn; //refreshArmy(); status = "Turn ended, next player's turn begins"; controlState = ControlState.selectUnit; } else if (keyboardState.IsKeyDown(Keys.Space)) { controlState = ControlState.selectUnit; } } else if(controlState == ControlState.endGame) { //continue if (keyboardState.IsKeyDown(Keys.Space)) { endBattle(); } } if (isArmyDead(player1Army)) { status = "Blue Player 2 Wins!"; } else if (isArmyDead(player2Army)) { status = "Red Player 1 Wins!"; } }
private void btnAdd_Click(object sender, EventArgs e) { this.CtrlState = ControlState.New; }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, ControlState state) { Color c = Color.White; Color oc = Color.White; int i = 0; int oi = -1; SkinLayer l = layer; if (state == ControlState.Hovered && (layer.States.Hovered.Index != -1)) { c = l.States.Hovered.Color; i = l.States.Hovered.Index; if (l.States.Hovered.Overlay) { oc = l.Overlays.Hovered.Color; oi = l.Overlays.Hovered.Index; } } else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1)) { c = l.States.Focused.Color; i = l.States.Focused.Index; if (l.States.Focused.Overlay) { oc = l.Overlays.Focused.Color; oi = l.Overlays.Focused.Index; } } else if (state == ControlState.Pressed) { c = l.States.Pressed.Color; i = l.States.Pressed.Index; if (l.States.Pressed.Overlay) { oc = l.Overlays.Pressed.Color; oi = l.Overlays.Pressed.Index; } } else if (state == ControlState.Disabled) { c = l.States.Disabled.Color; i = l.States.Disabled.Index; if (l.States.Disabled.Overlay) { oc = l.Overlays.Disabled.Color; oi = l.Overlays.Disabled.Index; } } else { c = l.States.Enabled.Color; i = l.States.Enabled.Index; if (l.States.Enabled.Overlay) { oc = l.Overlays.Enabled.Color; oi = l.Overlays.Enabled.Index; } } if (control.Color != Control.UndefinedColor) c = control.Color * (control.Color.A / 255f); DrawLayer(l, rect, c, i); if (oi != -1) { DrawLayer(l, rect, oc, oi); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy) { DrawString(control, layer, text, rect, state, margins, ox, oy, true); }
public static int DrawMessage(Graphics g, Message msg, Message prevMsg, Font fnt, ControlState state, int y = 0, int width = 500, int cHeight = 400, MouseState mouse = default(MouseState)) { if (msg == null) { return(y); } int height = 0; const int padding = 10; const int avatarSz = 48; int hWidth = width - avatarSz - 3 * padding; int msgWidth = width / 100 * 80; User usr = msg.Author; if (usr == null) { return(y); } Size hSize = Size.Empty; if (prevMsg == null || prevMsg.Author != usr) { int aX = padding; if (msg.Out) { aX = width - padding - avatarSz; } Bitmap p = usr.GetPhoto(); if (p != null && y > -avatarSz) { g.DrawImage(p, new Rectangle(aX, y, avatarSz, avatarSz)); } hSize = Size.Ceiling(g.MeasureString(usr.FullName, fnt, hWidth)); int hX = 2 * padding + avatarSz; if (msg.Out) { hX = width - 2 * padding - avatarSz - hSize.Width; } if (y > -hSize.Height) { DrawString(g, usr.FullName, fnt, Brushes.DimGray, new Rectangle(new Point(hX, y), hSize)); } } height += padding / 2 + hSize.Height; Size msgSize = Size.Ceiling(g.MeasureString(msg.Body, fnt, msgWidth)); Size msgRectSize = Size.Add(msgSize, new Size(2 * padding, 2 * padding)); int rX = 2 * padding + avatarSz + 5; if (msg.Out) { rX = width - 2 * padding - avatarSz - msgRectSize.Width - 5; } int rY = y + padding / 2 + hSize.Height; if (msg.Attachments != null && msg.Attachments.Length > 0) { int ax = 0, ay = 0; int mw = 0, mh = 0; foreach (Attachment a in msg.Attachments) { Size asz = a.Measure(g, fnt, msgWidth - ax, true); if (mh < asz.Height) { mh = asz.Height; } if (ax + asz.Width > msgWidth) { ax = 0; ay += mh + padding; mh = 0; } else { ax += asz.Width + padding; } if (mw < ax) { mw = ax; } } msgRectSize = new Size(Math.Max(msgSize.Width, mw) + padding, msgSize.Height + ay + mh + 2 * padding); rX = 2 * padding + avatarSz + 5; if (msg.Out) { rX = width - 2 * padding - avatarSz - msgRectSize.Width - 5; } rY = y + padding / 2 + hSize.Height; } Color msgRectColor = Color.White; if (msg.Crypted) { msgRectColor = Color.Lime; } if (!msg.Read) { msgRectColor = Color.DodgerBlue; if (msg.Crypted) { msgRectColor = Color.LimeGreen; } } Brush msgRectBrush = new SolidBrush(Color.FromArgb(128, msgRectColor)); if (rY > -msgRectSize.Height && rY < cHeight) { g.FillRoundRectangle(msgRectBrush, new Rectangle(new Point(rX, rY), msgRectSize), padding / 2); } int tX = rX; int tY = rY + padding; if (msg.Out) { tX = rX + msgRectSize.Width; } g.FillPolygon(msgRectBrush, new[] { new Point(tX, tY), new Point(tX, tY + 16), new Point(((msg.Out) ? tX + 10 : tX - 10), tY + 8) }); if (y + padding + padding / 2 + hSize.Height > -msgSize.Height && y < cHeight) { Rectangle msgRectangle = new Rectangle(new Point(rX + padding, y + padding + padding / 2 + hSize.Height), msgSize); /*if (msg.Body.Length > 256) * { * DrawString(g, msg.Body, fnt, Brushes.Black, msgRectangle, StringAlignment.Near); * } * else * {*/ List <TextBlock> blocks; if (msg.RuntimeData.ContainsKey("TextBlocks")) { blocks = (List <TextBlock>)msg.RuntimeData["TextBlocks"]; } else { blocks = new List <TextBlock>(); int blkend = 0; MatchCollection matches = _URL.Matches(msg.Body); if (matches.Count > 0) { foreach (Match m in matches) { String url = m.ToString(); int idx = msg.Body.IndexOf(url, StringComparison.Ordinal); if (idx > blkend) { blocks.Add(new TextBlock(msg.Body, blkend, idx - blkend)); } TextBlock blk = new TextBlock(msg.Body, idx, url.Length, TextStyle.Link); blocks.Add(blk); blkend = blk.End; } } if (msg.Body.Length > blkend) { blocks.Add(new TextBlock(msg.Body, blkend, msg.Body.Length - blkend)); } if (Emoji.FindEmojis(msg.Body).Count > 0) { List <TextBlock> nbl = new List <TextBlock>(); foreach (TextBlock b in blocks) { foreach (String em in Emoji.FindEmojis(b.Fragment)) { int idx = b.Fragment.IndexOf(em, StringComparison.Ordinal); if (idx > 0) { nbl.Add(new TextBlock(msg.Body, b.Start, idx, b.Style, b.State)); } nbl.Add(new EmojiBlock(msg.Body, b.Start + idx, em.Length, b.State)); if (idx + em.Length < b.Length) { nbl.Add(new TextBlock(msg.Body, b.Start + idx + em.Length, b.Length - idx - em.Length, b.Style, b.State)); } } } blocks = nbl; } Console.WriteLine(((msg.Body.Length > 32) ? msg.Body.Substring(0, 32) + "..." : msg.Body) + ": " + blocks.Count + " block(s)"); blocks.Sort((blk, blk2) => blk.Start.CompareTo(blk2.Start)); msg.RuntimeData.Add("TextBlocks", blocks); } if (blocks.Count > 16) { DrawString(g, msg.Body, fnt, Brushes.Black, msgRectangle, StringAlignment.Near); } else { int sX = rX + padding, sY = y + padding + padding / 2 + hSize.Height, eX = msgSize.Width, eY = msgSize.Height; int cX = 0, cY = 0, cH = 0; CharacterRange[] ranges = { new CharacterRange(0, 1) }; String _c; Rectangle charRect = Rectangle.Empty; int cP = 0; using (StringFormat stringFormat = new StringFormat()) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; foreach (TextBlock blk in blocks) { blk.StartPoint = new Point(cX, cY); if (blk is EmojiBlock) { Bitmap e = ((EmojiBlock)blk).Emoji; if (e != null) { g.DrawImage(e, new Rectangle(new Point(sX + cX + 2, sY + cY), new Size(16, 16))); if (cH < 16) { cH = 16; } cX += 20; if (cX > eX) { cX = 0; cY += cH; } } cP += blk.Length; } else { while (cP >= blk.Start && cP < blk.End) { ranges[0].First = cP; stringFormat.SetMeasurableCharacterRanges(ranges); _c = msg.Body.Substring(cP, 1); charRect = Rectangle.Round( g.MeasureCharacterRanges(msg.Body, fnt, msgRectangle, stringFormat)[0] .GetBounds(g)); if (cH < charRect.Height) { cH = charRect.Height; } Color c = Color.Black; if (blk.Style == TextStyle.Link) { c = Color.Blue; if (mouse != null) { int mpX = mouse.Position.X; int mpY = mouse.Position.Y; if (mpY >= sY + blk.StartPoint.Y && mpY <= sY + blk.EndPoint.Y && mpX >= sX + blk.StartPoint.X && mpX <= sX + blk.EndPoint.X) { blk.State = ControlState.Hover; if (mouse.Clicked) { blk.State = ControlState.Pressed; mouse.Clicked = false; } } else { blk.State = ControlState.Idle; } if (blk.State != ControlState.Idle) { if (blk.State == ControlState.Hover) { c = Color.DarkOrange; } if (blk.State == ControlState.Pressed) { c = Color.Red; App.Platform.OpenUrl(msg.Body.Substring(blk.Start, blk.Length)); } g.FillRectangle(Brushes.White, charRect); } } else { blk.State = ControlState.Idle; c = Color.Blue; } } g.DrawString(_c, fnt, new SolidBrush(c), sX + cX, sY + cY); if (blk.Style == TextStyle.Link) { g.DrawLine(new Pen(c), sX + cX + 2, sY + cY + cH, sX + cX + charRect.Width + 2, sY + cY + cH); } cX += charRect.Width; if (cX > eX || _c == "\n") { cX = 0; cY += cH; if (_c != "\n") { cH = 0; } } cP++; } } blk.EndPoint = new Point(cX + charRect.Width + 2, cY + cH); } } } } height += msgRectSize.Height + padding; if (msg.Attachments != null && msg.Attachments.Length > 0) { int ax = 0, ay = 0; int mh = 0; foreach (Attachment a in msg.Attachments) { Size asz = a.Measure(g, fnt, msgWidth - ax, true); Rectangle aRect = new Rectangle(new Point(rX + padding + ax, rY + msgSize.Height + padding + ay), asz); bool aHover = false, aClick = false; if (mouse != null && aRect.Contains(mouse.Position)) { aHover = true; if (mouse.Clicked) { aClick = true; mouse.Clicked = false; } } a.Draw(g, aRect, fnt, true, aHover, aClick); if (mh < asz.Height) { mh = asz.Height; } if (ax + asz.Width > msgWidth) { ax = 0; ay += mh + padding; mh = 0; } else { ax += asz.Width + padding; } } } return(height); }
public ControlChange(Control control, ControlState state) { Control = control; State = state; }
private void Update() { #if UNITY_EDITOR if (Input.GetMouseButton(0)) { ProcessPlayerClick(Input.mousePosition); } #endif if (_ctrlState == ControlState.Pan && _drags.Count == 1) { // Pan PointerEventData t = _drags.ElementAt(0).Value; Vector3 currentPos = _mainXform.position; _mainXform.Translate(Vector3.up * t.delta.y * panSensitivity * -1f); _mainXform.Translate(Vector3.right * t.delta.x * panSensitivity * -1f); _panVelocity = _mainXform.position - currentPos; } else if (_ctrlState == ControlState.Zoom && _drags.Count == 2) { // Zoom PointerEventData t0 = _drags.ElementAt(0).Value; PointerEventData t1 = _drags.ElementAt(1).Value; // Find the position in the previous frame of each touch. Vector2 touchZeroPrevPos = t0.position - t0.delta; Vector2 touchOnePrevPos = t1.position - t1.delta; // Find the magnitude of the vector (the distance) between the touches in each frame. float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude; float touchDeltaMag = (t0.position - t1.position).magnitude; // Find the difference in the distances between each frame. float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag; float currentSize = _main.orthographicSize; // ... change the orthographic size based on the change in distance between the touches. _main.orthographicSize += deltaMagnitudeDiff * orthoZoomSpeed; //clamp _main.orthographicSize = Mathf.Min(_main.orthographicSize, maxSize); _main.orthographicSize = Mathf.Max(_main.orthographicSize, minSize); _zoomVelocity = _main.orthographicSize - currentSize; } else { _ctrlState = ControlState.Default; if (_panVelocity.x > 0.1f || _panVelocity.y > 0.1f) { _mainXform.Translate(_panVelocity); _panVelocity = _panVelocity * 0.01f; } if (_zoomVelocity > 0.1f || _zoomVelocity < -0.1f) { _main.orthographicSize += _zoomVelocity; _zoomVelocity = _zoomVelocity * 0.01f; } } }
private void RenderConboBoxDropDownButton( Graphics g, Rectangle buttonRect, ControlState state) { Color baseColor = Color.FromArgb(160, 250, 250, 250); Color backColor = Color.FromArgb(160, 250, 250, 250); Color borderColor = base.Enabled ? _borderColor : SystemColors.ControlDarkDark; Color arrowColor = base.Enabled ? _arrowColor : SystemColors.ControlDarkDark; Rectangle rect = buttonRect; if (base.Enabled) { if (_officeColorTable == null) { _officeColorTable = StyleBuilderFactory.GetOffice2007ColorTable(_style); } switch (state) { case ControlState.Hover: //baseColor = RenderHelper.GetColor(_baseColor, 0, -33, -22, -13); baseColor = _officeColorTable.ComboBoxHoverColor; borderColor = _officeColorTable.ComboBoxBorderHoverColor; break; case ControlState.Pressed: baseColor = _officeColorTable.ComboBoxPressColor; borderColor = _officeColorTable.ComboBoxBorderPressColor; break; default: baseColor = _officeColorTable.ComboBoxBaseColor; borderColor = _officeColorTable.ComboBoxBorderColor; break; } } else { baseColor = SystemColors.ControlDark; } rect.Inflate(-1, -1); RenderScrollBarArrowInternal( g, rect, baseColor, borderColor, backColor, arrowColor, RoundStyle.All, true, false, ArrowDirection.Down, LinearGradientMode.Vertical); }
public static bool Translation(Controls.Type type, ControlState state, int playerNum) { //Debug.Log(type + ", " + state + ", " + Time.time); //playerNum is ignored, as it's defunct switch (state) { case ControlState.Constant: switch (type) { //Platforming case Controls.Type.Jump: return(ReInput.players.GetPlayer(0).GetButton("Jump")); case Controls.Type.Ability1: return(ReInput.players.GetPlayer(0).GetButton("Ability1")); case Controls.Type.MoveRight: return(ReInput.players.GetPlayer(0).GetButton("Move Right")); case Controls.Type.MoveLeft: return(ReInput.players.GetPlayer(0).GetButton("Move Left")); case Controls.Type.MoveDown: return(ReInput.players.GetPlayer(0).GetButton("Move Down")); case Controls.Type.FPSForward: return(ReInput.players.GetPlayer(0).GetButton("FPS Forward")); case Controls.Type.FPSBackward: return(ReInput.players.GetPlayer(0).GetButton("FPS Backwards")); case Controls.Type.FPSRight: return(ReInput.players.GetPlayer(0).GetButton("FPS Right")); case Controls.Type.FPSLeft: return(ReInput.players.GetPlayer(0).GetButton("FPS Left")); //case Controls.Type.FPSForward: return GetAxis("FPS Forward", true); //case Controls.Type.FPSBackward: return GetAxis("FPS Forward", false); //case Controls.Type.FPSRight: return GetAxis("FPS Strafe", true); //case Controls.Type.FPSLeft: return GetAxis("FPS Strafe", false); case Controls.Type.FPSLookUp: return(GetAxis("FPS Look Vertical", true)); case Controls.Type.FPSLookDown: return(GetAxis("FPS Look Vertical", false)); case Controls.Type.FPSLookRight: return(GetAxis("FPS Look Horizontal", true)); case Controls.Type.FPSLookLeft: return(GetAxis("FPS Look Horizontal", false)); } return(false); case ControlState.Down: switch (type) { //Platforming case Controls.Type.Jump: return(ReInput.players.GetPlayer(0).GetButtonDown("Jump")); case Controls.Type.Ability1: return(ReInput.players.GetPlayer(0).GetButtonDown("Ability1")); case Controls.Type.MoveDown: return(ReInput.players.GetPlayer(0).GetButtonDown("Move Down")); case Controls.Type.MoveRight: return(ReInput.players.GetPlayer(0).GetButtonDown("Move Right")); case Controls.Type.MoveLeft: return(ReInput.players.GetPlayer(0).GetButtonDown("Move Left")); case Controls.Type.Respawn: return(ReInput.players.GetPlayer(0).GetButtonDown("Respawn")); case Controls.Type.Restart: return(ReInput.players.GetPlayer(0).GetButtonDown("Restart")); //menu case Controls.Type.MenuSelect: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Select")); case Controls.Type.OpenMenu: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Escape")); case Controls.Type.MenuUp: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Up")); case Controls.Type.MenuDown: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Down")); case Controls.Type.MenuRight: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Right")); case Controls.Type.MenuLeft: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Left")); //FPS case Controls.Type.FPSFire: return(ReInput.players.GetPlayer(0).GetButtonDown("FPS Fire")); case Controls.Type.FPSCycleWeapon: return(ReInput.players.GetPlayer(0).GetButtonDown("FPS Cycle")); } return(false); case ControlState.Up: switch (type) { //Platforming case Controls.Type.Jump: return(ReInput.players.GetPlayer(0).GetButtonUp("Jump")); case Controls.Type.Ability1: return(ReInput.players.GetPlayer(0).GetButtonUp("Ability1")); case Controls.Type.MoveRight: return(ReInput.players.GetPlayer(0).GetButtonUp("Move Right")); case Controls.Type.MoveLeft: return(ReInput.players.GetPlayer(0).GetButtonUp("Move Left")); } return(false); } return(false); }
private void DrawScrollBar( IntPtr maskHWnd, Rectangle bounds, Rectangle trackRect, Rectangle topLeftArrowRect, Rectangle bottomRightArrowRect, Rectangle thumbRect, ControlState topLeftArrowState, ControlState bottomRightArrowState, ControlState thumbState, Orientation direction) { bool bHorizontal = direction == Orientation.Horizontal; ArrowDirection arrowDirection; bool bEnabled = _owner.Enabled; IScrollBarPaint paint = _owner as IScrollBarPaint; if (paint == null) { return; } ImageDc tempDc = new ImageDc(bounds.Width, bounds.Height); IntPtr hdc = NativeMethods.GetDC(maskHWnd); try { using (Graphics g = Graphics.FromHdc(tempDc.Hdc)) { using (PaintScrollBarTrackEventArgs te = new PaintScrollBarTrackEventArgs( g, trackRect, direction, bEnabled)) { Graphics ge = te.Graphics; Rectangle rect = te.TrackRectangle; Color baseColor = GetGray(Color.Blue); ControlPaintEx.DrawScrollBarTrack( ge, rect, baseColor, Color.White, te.Orientation); //paint.OnPaintScrollBarTrack(te); } arrowDirection = bHorizontal ? ArrowDirection.Left : ArrowDirection.Up; using (PaintScrollBarArrowEventArgs te = new PaintScrollBarArrowEventArgs( g, topLeftArrowRect, topLeftArrowState, arrowDirection, direction, bEnabled)) { paint.OnPaintScrollBarArrow(te); } arrowDirection = bHorizontal ? ArrowDirection.Right : ArrowDirection.Down; using (PaintScrollBarArrowEventArgs te = new PaintScrollBarArrowEventArgs( g, bottomRightArrowRect, bottomRightArrowState, arrowDirection, direction, bEnabled)) { paint.OnPaintScrollBarArrow(te); } using (PaintScrollBarThumbEventArgs te = new PaintScrollBarThumbEventArgs( g, thumbRect, thumbState, direction, bEnabled)) { paint.OnPaintScrollBarThumb(te); } } NativeMethods.BitBlt( hdc, 0, 0, bounds.Width, bounds.Height, tempDc.Hdc, 0, 0, TernaryRasterOperations.SRCCOPY); } finally { NativeMethods.ReleaseDC(maskHWnd, hdc); tempDc.Dispose(); } }
public static void ServerInitialize(SmallShip smallShip, Vector2 position, Vector2 velocity, ControlState controller1, ControlState controller4) { Ship.ServerInitialize(smallShip, position, velocity, 0, 40, 800, 1800, 1f, controller1); Turret t3 = new Turret(smallShip.Game); Turret.ServerInitialize(t3, smallShip, new Vector2(25, 25) - TextureLoader.GetTexture("Enemy").CenterOfMass, (float)(0), (float)(Math.PI * 3), controller4); smallShip.Game.GameObjectCollection.Add(t3); }
internal virtual void UnloadRecursive(bool dispose) { Page page = Page; if (page != null && page.RequiresControlState(this)) { page.UnregisterRequiresControlState(this); RareFieldsEnsured.RequiredControlState = true; } // Remove the generated ID so it will be assigned a different ID next time. if (flags[useGeneratedID]) { _id = null; flags.Clear(useGeneratedID); } if (_controls != null) { string oldmsg = _controls.SetCollectionReadOnly(SR.Parent_collections_readonly); int controlCount = _controls.Count; for (int i = 0; i < controlCount; i++) _controls[i].UnloadRecursive(dispose); _controls.SetCollectionReadOnly(oldmsg); } if (AdapterInternal != null) { AdapterInternal.OnUnload(EventArgs.Empty); } else { OnUnload(EventArgs.Empty); } // if (dispose) Dispose(); // VSWhidbey 244999: Everett behavior doesn't reset the control state. // But for control which requires its OnInit method to be called again // to properly initialize when the control is removed and added back // to Page's control tree, the control can override IsReloadable // to true so the control state is reset. e.g. Validator, see bug if (IsReloadable) { _controlState = ControlState.Constructed; } }
public TextBlock(String str, int start, int len, TextStyle style = TextStyle.Text, ControlState state = ControlState.Idle) { this.Start = start; this.Length = len; this.End = start + len; this.Style = style; this.State = state; this.Fragment = str.Substring(start, len); }
// Same as PreRenderRecursive, but has an async point after the call to this.OnPreRender. internal async Task PreRenderRecursiveInternalAsync(Page page) { // Call Visible property and cache value in !flags[invisible] to allow Visible to be overridden. // This avoids unnecessary virtual property calls in SaveViewState and Render. bool visible = Visible; if (!visible) { flags.Set(invisible); } else { flags.Clear(invisible); EnsureChildControls(); using (page.Context.SyncContext.AllowVoidAsyncOperationsBlock()) { if (AdapterInternal != null) { AdapterInternal.OnPreRender(EventArgs.Empty); } else { OnPreRender(EventArgs.Empty); } await page.GetWaitForPreviousStepCompletionAwaitable(); } if (_controls != null) { string oldmsg = _controls.SetCollectionReadOnly(SR.Parent_collections_readonly); int controlCount = _controls.Count; for (int i = 0; i < controlCount; i++) { _controls[i].PreRenderRecursiveInternal(); } _controls.SetCollectionReadOnly(oldmsg); } } _controlState = ControlState.PreRendered; }
public EmojiBlock(String str, int start, int len, ControlState state = ControlState.Idle) : base(str, start, len, TextStyle.Emoji, state) { this.Emoji = LibEmoji.Emoji.ResolveEmoji(this.Fragment); }
public override void Interact(Entity entity, EntityUniverseFacade facade, ControlState main, ControlState alt) { if (alt.DownClick) { GoalCount = 0; } }
public override void Interact(Entity entity, EntityUniverseFacade facade, ControlState main, ControlState alt) { if (!alt.DownClick) { return; } if (!IsClaimed()) { var player = entity.PlayerEntityLogic; player.ShowNotification(GameContext.NotificationDatabase.CreateNotificationFromCode(Component.NotClaimedNotification, entity.Step, NotificationParams.EmptyParams)); return; } if (!Totem.IsReady()) { var player = entity.PlayerEntityLogic; player.ShowNotification(GameContext.NotificationDatabase.CreateNotificationFromCode(Component.NotReadyNotification, entity.Step, NotificationParams.EmptyParams)); return; } if (Totem.CanStartNewGame()) { Totem.ResetGame(); PrepareReset(facade.Step); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state) { DrawString(control, layer, text, rect, state, true, 0, 0, true); }
private void btnModify_Click(object sender, EventArgs e) { this.CtrlState = ControlState.Edit; }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy, bool ellipsis) { Color col = Color.White; if (layer.Text != null) { if (margins) { Margins m = layer.ContentMargins; rect = new Rectangle(rect.Left + m.Left, rect.Top + m.Top, rect.Width - m.Horizontal, rect.Height - m.Vertical); } if (state == ControlState.Hovered && (layer.States.Hovered.Index != -1)) { col = layer.Text.Colors.Hovered; } else if (state == ControlState.Pressed) { col = layer.Text.Colors.Pressed; } else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1)) { col = layer.Text.Colors.Focused; } else if (state == ControlState.Disabled) { col = layer.Text.Colors.Disabled; } else { col = layer.Text.Colors.Enabled; } if (text != null && text != "") { SkinText font = layer.Text; if (control.TextColor != Control.UndefinedColor && control.ControlState != ControlState.Disabled) col = control.TextColor; if(control.Font != null) DrawString(control.Font, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis); else DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis); } } }
public PaintThumbEventArgs( Graphics g, Rectangle clipRect, ControlState state) : base(g, clipRect) { _controlState = state; }