/// <summary> /// Contructor of the main form /// </summary> public Form1() { InitializeComponent(); SdkInfoStruct sdkInfo = SeekwareDevice.GetSdkInfo(); sdkVersionTextBox.Text = string.Format("{0}.{1}", sdkInfo.sdk_version_major, sdkInfo.sdk_version_minor); // populate device list combo box mSeekDeviceList = SeekwareDevice.GetDeviceList(); foreach (var dev in mSeekDeviceList) { selectCameraComboBox.Items.Add(dev.SerialNumber); } // populate temperature units combo box tempUnitsComboBox.DataSource = Enum.GetValues(typeof(SeekwareDevice.SwTemperatureUnits)); tempUnitsComboBox.SelectedItem = SeekwareDevice.SwTemperatureUnits.Celsius; // populate the display lut lutComboBox.DataSource = Enum.GetValues(typeof(SeekwareDevice.SwDisplayLut)); lutComboBox.SelectedItem = SeekwareDevice.SwDisplayLut.Spectra; // set the initial state and start the find devices timer State = ControlStates.Closed; findDevicesTimer.Enabled = true; }
/// <summary> /// /// This will coninuously grab images and update the pictureBox image until /// signaled to stop /// </summary> private void LiveCapture() { this.BeginInvoke(new Action(() => State = ControlStates.OpenPlaying)); while (!mStopImageGrab) { if (mActiveDevice == null || !mActiveDevice.IsOpen) { break; } Bitmap bitmap = null; float[] thermImage = null; if (mActiveDevice.GetImage(out bitmap, out thermImage)) { mLastThermImage = thermImage; if (bitmap != null) { lock (mTimerLockObject) { mFrameCounter++; mFrameTimeList.Add(DateTime.Now); } pictureBox1.Image = bitmap; } this.BeginInvoke(new Action(() => UpdatePixelValueStrip())); } } this.BeginInvoke(new Action(() => State = ControlStates.OpenStopped)); }
/// <summary> /// Gets an apperance defined by this theme from the <paramref name="state" /> parameter. /// </summary> /// <param name="state">The state to check.</param> /// <returns>A cell appearance.</returns> public Cell GetStateAppearance(ControlStates state) { if (Helpers.HasFlag((int)state, (int)ControlStates.Disabled)) { return(Disabled); } if (Helpers.HasFlag((int)state, (int)ControlStates.MouseLeftButtonDown) || Helpers.HasFlag((int)state, (int)ControlStates.MouseRightButtonDown)) { return(MouseDown); } if (Helpers.HasFlag((int)state, (int)ControlStates.MouseOver)) { return(MouseOver); } if (Helpers.HasFlag((int)state, (int)ControlStates.Focused)) { return(Focused); } if (Helpers.HasFlag((int)state, (int)ControlStates.Selected)) { return(Selected); } return(Normal); }
/// <summary> /// Open a SeekwareDevice. /// </summary> /// <param name="seekDev"></param> private void Open(SeekwareDevice seekDev) { if (seekDev.Open()) { // setup device whith current settings seekDev.TemperatureUnits = (SeekwareDevice.SwTemperatureUnits)tempUnitsComboBox.SelectedItem; seekDev.DisplayLUT = (SeekwareDevice.SwDisplayLut)lutComboBox.SelectedItem; // get info from device and fill in form items mImageSize = new Size(seekDev.ImageWidth, seekDev.ImageHeight); serialNumberTextBox.Text = seekDev.SerialNumber; firmwareVersionTextBox.Text = seekDev.FirmwareVersion; frameDimTextBox.Text = string.Format("Width={0}, Height={1}", mImageSize.Width, mImageSize.Height); errorToolStripStatusLabel.Text = "Open"; // set state this.BeginInvoke(new Action(() => State = ControlStates.OpenStopped)); } else { // Open failed, clear form data serialNumberTextBox.Text = string.Empty; firmwareVersionTextBox.Text = string.Empty; frameDimTextBox.Text = string.Empty; errorToolStripStatusLabel.Text = "Open Failed"; // set state this.BeginInvoke(new Action(() => State = ControlStates.Closed)); } }
private void CheckClick() { if (!Input.GetMouseButton(0)) { return; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { //var hitObj = hit.collider.gameObject.transform.parent.GetComponent<PlayerPathFollower>(); var hitObj = hit.collider.GetComponentInParent <PlayerPathFollower>(); if (hitObj) { _path = new Queue <Vector2>(); _path.Enqueue(hitObj.transform.position); _pathFollower = hitObj; _pathFollower.OnPathResolve += Reset; ControlState = ControlStates.DRAGGING; _pathDrawer.StartPath(Input.mousePosition); } } }
// default constructor for a control is a neutral/released state. public ControlStateMetadata() { this.state = ControlStates.Released; this.inputTimer = 0; this.heldTimer = 0; this.doubleInputCooldown = 0; }
private void OnViewControlState(View obj, ControlStates state) { if (null != obj && null != GetValue(state)) { obj.SetValue(targetBindableProperty, GetValue(state)); } }
public T GetValue(ControlStates state) { if (All != null) { return(All); } switch (state) { case ControlStates.Normal: return(Normal != null? Normal : Other); case ControlStates.Focused: return(Focused != null? Focused : Other); case ControlStates.Pressed: return(Pressed != null? Pressed : Other); case ControlStates.Disabled: return(Disabled != null? Disabled : Other); case ControlStates.Selected: return(Selected != null? Selected : Other); case ControlStates.DisabledFocused: return(DisabledFocused != null? DisabledFocused : Other); case ControlStates.DisabledSelected: return(DisabledSelected != null? DisabledSelected : Other); default: return(Other); } }
// default constructor for a control is a neutral/released state. public ControlStateMetadata(ControlStates initState, int initInputTimer, int initHeldTimer, int doubleInputCooldown) { this.state = initState; this.inputTimer = initInputTimer; this.heldTimer = initHeldTimer; this.doubleInputCooldown = doubleInputCooldown; }
private void Reset() { if (_pathFollower) { _pathFollower.OnPathResolve -= Reset; } ControlState = ControlStates.START; }
private void StateChange(ControlStates state, Action <Button> func, Button b) { if (_controlState != state) { _previousState = _controlState; _controlState = state; func(b); } }
private void StateChange(ControlStates state, Action func) { if (_controlState != state && _controlsEnabled) { _previousState = _controlState; _controlState = state; func(); } }
/// <summary> /// Cette methode envoit les instructions à executé par le robot /// </summary> public void setCommand(ControlStates state) { String command = ((int)state).ToString(); if ((int)state < 10) { command = "0" + command; } this.comPort.Write(command); }
public void AssignControl(object controlledObject, FieldPropertyListInfo fieldPropertyInfo, byte assignmentButton) { if (ControlStates.ContainsKey(assignmentButton)) { var controlState = ControlStates[assignmentButton]; controlState.ControlledObject = controlledObject; controlState.FieldPropertyInfo = fieldPropertyInfo; // See if it's a vector and assign subsequent controls if it is. byte vectorSize = 1; if (fieldPropertyInfo.FieldPropertyType == typeof(Vector2) || fieldPropertyInfo.FieldPropertyType == typeof(Xna.Vector2)) { vectorSize = 2; } else if (fieldPropertyInfo.FieldPropertyType == typeof(Vector3) || fieldPropertyInfo.FieldPropertyType == typeof(Xna.Vector3)) { vectorSize = 3; } else if (fieldPropertyInfo.FieldPropertyType == typeof(Vector4) || fieldPropertyInfo.FieldPropertyType == typeof(Xna.Vector4)) { vectorSize = 4; } if (vectorSize > 1) { controlState.IsVector = true; controlState.VectorIndex = 0; for (byte i = 1; i < vectorSize; i++) { byte vectorAssignmentButton = (byte)(assignmentButton + i); if (AssignToControlMapping.ContainsKey(vectorAssignmentButton) && AssignToControlMapping[vectorAssignmentButton].Type == AssignToControlMapping[assignmentButton].Type) // So long as this control is still the same control type { var vectorControlState = ControlStates[vectorAssignmentButton]; vectorControlState.ControlledObject = controlledObject; vectorControlState.FieldPropertyInfo = fieldPropertyInfo; vectorControlState.IsVector = true; vectorControlState.VectorIndex = i; ControlStates[vectorAssignmentButton] = vectorControlState; } else { break; } } } ControlStates[assignmentButton] = controlState; } Assigning = false; }
public List <MidiAssignments> SaveState() { List <MidiAssignments> midiAssignments = new List <MidiAssignments>(); foreach (var pair in ControlStates.Where(pair => pair.Value.ControlledObject != null && (!pair.Value.IsVector || pair.Value.VectorIndex == 0))) { midiAssignments.Add(new MidiAssignments(pair.Key, pair.Value.ControlledObject, pair.Value.FieldPropertyInfo.Name)); } return(midiAssignments); }
void IMetricsProvider.GetContentAdjustment(ref UIOperationContext context, ControlStates state, out Vector2 offset, out Vector2 scale) { if (GetContentAdjustment != null) { GetContentAdjustment(context, state, out offset, out scale); } else { offset = Vector2.Zero; scale = Vector2.One; } }
bool IMetricsProvider.GetTextSettings(ref UIOperationContext context, ControlStates state, out Material material, ref Color?color, out Vector4 userData) { if (GetTextSettings != null) { return(GetTextSettings(context, state, out material, ref color, out userData)); } else { material = default; userData = default; return(false); } }
protected void UpdateState() { ControlStates sourceState = ControlState; ControlStates targetState; if (isEnabled) { if (isPressed) { // Pressed targetState = ControlStates.Pressed; } else { // Normal targetState = ControlStates.Normal; // Selected targetState |= (IsSelected ? ControlStates.Selected : 0); // Focused, SelectedFocused targetState |= (IsFocused ? ControlStates.Focused : 0); } } else { // Disabled targetState = ControlStates.Disabled; // DisabledSelected, DisabledFocused targetState |= (IsSelected ? ControlStates.Selected : (IsFocused ? ControlStates.Focused : 0)); } if (sourceState != targetState) { ControlState = targetState; OnUpdate(); StateChangedEventArgs e = new StateChangedEventArgs { PreviousState = sourceState, CurrentState = targetState }; stateChangeHander?.Invoke(this, e); Extension?.OnControlStateChanged(this, new ControlStateChangedEventArgs(sourceState, targetState)); } }
public override void UpdateAndDraw(TextBox control, TimeSpan time) { if (control.Surface.Effects.Count != 0) { control.Surface.Update(time); control.IsDirty = true; } if (!control.IsDirty) { return; } Cell appearance = GetStateAppearance(control.State); if (control.IsFocused && !control.DisableKeyboard) { if (!control.IsCaretVisible) { _oldCaretPosition = control.CaretPosition; _oldState = control.State; _editingText = control.EditingText; control.Surface.Fill(appearance.Foreground, appearance.Background, 0, SpriteEffects.None); control.Surface.Print(0, 0, control.EditingText.Substring(control.LeftDrawOffset)); control.Surface.SetEffect(control.Surface[control.CaretPosition - control.LeftDrawOffset, 0], CaretEffect); control.IsCaretVisible = true; } else if (_oldCaretPosition != control.CaretPosition || _oldState != control.State || _editingText != control.EditingText) { control.Surface.Effects.RemoveAll(); control.Surface.Fill(appearance.Foreground, appearance.Background, 0, SpriteEffects.None); control.Surface.Print(0, 0, control.EditingText.Substring(control.LeftDrawOffset)); control.Surface.SetEffect(control.Surface[control.CaretPosition - control.LeftDrawOffset, 0], CaretEffect); _oldCaretPosition = control.CaretPosition; _oldState = control.State; _editingText = control.EditingText; } } else { control.Surface.Effects.RemoveAll(); control.Surface.Fill(appearance.Foreground, appearance.Background, appearance.Glyph, appearance.Mirror); control.IsCaretVisible = false; control.Surface.Print(0, 0, control.Text.Align(control.TextAlignment, control.Width)); } control.IsDirty = false; }
/// <summary> /// Close a SeekwareDevice /// </summary> /// <param name="seekDev"></param> private void Close(SeekwareDevice seekDev) { if (seekDev.IsOpen) { StopLiveCapture(); seekDev.Close(); } // clear form data serialNumberTextBox.Text = string.Empty; firmwareVersionTextBox.Text = string.Empty; frameDimTextBox.Text = string.Empty; errorToolStripStatusLabel.Text = "Closed"; // set state this.BeginInvoke(new Action(() => State = ControlStates.Closed)); }
public ProductManagementPresentationModel(Model modelData) { _model = modelData; this.CurrentSelectedProductChanged += UpdateSaveButton; this.IsValidProductInfoChanged += UpdateSaveButton; this.IsEditedProductInfoChanged += UpdateSaveButton; this.StateChanged += UpdateSaveButton; // UI _saveButton = new ControlStates(); // Initial states SetCurrentSelectedProduct(null); SetIsValidProductInfo(false); SetIsEditedProductInfo(false); SetState(State.EditProduct); }
/// <summary> /// The method invoked when all inputs are ready. /// The method is only invoked once pr. clock cycle /// </summary> protected override void OnTick() { switch (m_state) { case ControlStates.WaitWrite: Output.OutputValid = true; Output.OutputReady = false; // Wait for output to be consumed if (Input.InputReady) { Output.OutputValid = false; m_state = ControlStates.Init; } break; case ControlStates.Compute: m_write_value = m_read_value << 16 | m_read_value >> 16; Output.OutputValid = true; Output.OutputReady = false; m_state = ControlStates.WaitWrite; break; case ControlStates.WaitRead: Output.OutputValid = false; Output.OutputReady = true; // Wait for input to arrive if (Input.InputValid) { m_read_value = Input.Value; Output.OutputReady = false; m_state = ControlStates.Compute; } break; case ControlStates.Init: default: Output.OutputValid = false; Output.OutputReady = true; m_state = ControlStates.WaitRead; break; } Output.Value = m_write_value; }
void changeGroupInfo(object data) { var groupName = (((object[])data)[0] as string); var isPrivate = (bool)((object[])data)[1]; var isChat = (bool)((object[])data)[2]; bool update = false; //Validate data if (ValidateUserData.ValidateUserName(groupName, false) != null) { ChangeGroupInfoErrorMessage = "Wrong group name"; FieldState = ControlStates.UserNameError; return; } else { if (groupName == null) { groupName = GroupInfo.Name; } else { update = true; } } if (IsPrivate != isPrivate) { update = true; } if (IsChat != isChat) { update = true; } if (update) { UnitOfWork.ChangeGroupInfo(new Group(isPrivate, groupName, !isChat, GroupInfo.Image, GroupInfo.Id, GroupInfo.AdminsIdList, GroupInfo.MembersIdList, GroupInfo.UsersOnline)); } ChangeGroupInfoErrorMessage = ""; FieldState = ControlStates.NormalGray; }
public OrderPresentationModel(OrderModel orderModelData, Model modelData) { _orderModel = orderModelData; _model = modelData; // Observers _model.OrderAdded += (orderItem) => UpdateAddButtonIfCurrentSelectedProductIsAddedToOrRemovedFromOrder(orderItem.Product); _model.OrderRemoved += (orderItemIndex, removedProduct) => UpdateAddButtonIfCurrentSelectedProductIsAddedToOrRemovedFromOrder(removedProduct); _model.ProductStorageQuantityChanged += UpdateProductStorageQuantityAndAddButtonIfChangedCurrentSelectedProductStorageQuantity; // UI _productNameAndDescription = new ControlStates(); _productStorageQuantity = new ControlStates(); _productPrice = new ControlStates(); _addButton = new ControlStates(); _pageLabel = new ControlStates(); _leftArrowButton = new ControlStates(); _rightArrowButton = new ControlStates(); }
public OrderPresentationModel(Model modelData) { _model = modelData; _currentSelectedProduct = null; // Observers _model.OrderCleared += UpdateAddButtonByCurrentSelectedProduct; _model.OrderAdded += HandleModelOrderAdded; _model.OrderRemoved += HandleModelOrderRemoved; _model.ProductStorageQuantityChanged += UpdateCurrentProductInfoAndAddButtonIfChangedCurrentSelectedProductStorageQuantity; // UI _productNameAndDescription = new ControlStates(); _productStorageQuantity = new ControlStates(); _productPrice = new ControlStates(); _addButton = new ControlStates(); _pageLabel = new ControlStates(); _leftArrowButton = new ControlStates(); _rightArrowButton = new ControlStates(); }
public RogueskivMenuInputHandler( UxContext uxContext, RogueskivMenu game, IGameRenderer gameRenderer ) : base( uxContext, game, gameRenderer, controlsByKeys: new Dictionary <int, int> { { (int)SDL_Keycode.SDLK_ESCAPE, (int)Controls.QUIT }, { (int)SDL_Keycode.SDLK_q, (int)Controls.QUIT }, { (int)SDL_Keycode.SDLK_UP, (int)Controls.UP }, { (int)SDL_Keycode.SDLK_DOWN, (int)Controls.DOWN }, { (int)SDL_Keycode.SDLK_LEFT, (int)Controls.LEFT }, { (int)SDL_Keycode.SDLK_RIGHT, (int)Controls.RIGHT }, { (int)SDL_Keycode.SDLK_w, (int)Controls.UP }, { (int)SDL_Keycode.SDLK_s, (int)Controls.DOWN }, { (int)SDL_Keycode.SDLK_a, (int)Controls.LEFT }, { (int)SDL_Keycode.SDLK_d, (int)Controls.RIGHT }, { (int)SDL_Keycode.SDLK_KP_8, (int)Controls.UP }, { (int)SDL_Keycode.SDLK_KP_2, (int)Controls.DOWN }, { (int)SDL_Keycode.SDLK_KP_4, (int)Controls.LEFT }, { (int)SDL_Keycode.SDLK_KP_6, (int)Controls.RIGHT }, { (int)SDL_Keycode.SDLK_RETURN, (int)Controls.ENTER }, { (int)SDL_Keycode.SDLK_RETURN2, (int)Controls.ENTER }, { (int)SDL_Keycode.SDLK_KP_ENTER, (int)Controls.ENTER }, { (int)SDL_Keycode.SDLK_BACKSPACE, (int)Controls.BACKSPACE }, { (int)SDL_Keycode.SDLK_m, (int)Controls.TOGGLE_MUSIC }, }, closeWindowControl: (int)Controls.CLOSE_WINDOW, toggleMusicControl: (int)Controls.TOGGLE_MUSIC, allowRepeats: true ) { Game = game; ControlStates.Add((int)Controls.COPY, false); ControlStates.Add((int)Controls.PASTE, false); }
public override void OnControlStateChanged(Button button, ControlStates previousState, Touch touchInfo) { if (button.ControlState != ControlStates.Pressed) { return; } var overlayImage = button.GetCurrentOverlayImage(this); if (overlayImage == null) { return; } if (null == PressAnimation) { var keyFrames = new KeyFrames(); keyFrames.Add(0.0f, 0.0f); keyFrames.Add(0.25f, 1.0f, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear)); keyFrames.Add(1.0f, 0.0f, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut)); PressAnimation = new Animation(600); PressAnimation.EndAction = Animation.EndActions.StopFinal; PressAnimation.AnimateBetween(overlayImage, "Opacity", keyFrames); PressAnimation.AnimateTo(overlayImage, "Scale", new Vector3(1, 1, 1), 0, 600, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut)); } if (PressAnimation.State == Animation.States.Playing) { PressAnimation.Stop(); overlayImage.Hide(); } overlayImage.Opacity = 0.0f; overlayImage.CornerRadius = button.CornerRadius; overlayImage.Background = button.Background; overlayImage.Size = button.Size; overlayImage.Scale = new Vector3(0.80f, 0.80f, 1); overlayImage.Show(); PressAnimation.Play(); }
public virtual void Draw(CellSurface surface, Rectangle area, object item, ControlStates itemState) { string value = item.ToString(); if (value.Length < area.Width) { value += new string(' ', area.Width - value.Length); } else if (value.Length > area.Width) { value = value.Substring(0, area.Width); } if (Helpers.HasFlag(itemState, ControlStates.Selected) && !Helpers.HasFlag(itemState, ControlStates.MouseOver)) { surface.Print(area.Left, area.Top, value, Selected); } else { surface.Print(area.Left, area.Top, value, GetStateAppearance(itemState)); } }
private void Drag() { if (Input.GetMouseButtonUp(0)) { ControlState = ControlStates.MOVING; _pathFollower.EngagePath(_path); _pathDrawer.ClearPath(); return; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Physics.Raycast(ray, out RaycastHit hit, _layerMask); var mousepos = hit.point; mousepos.z = 2; _path.Enqueue(mousepos); _pathDrawer.PushPath(Input.mousePosition); }
public override void Draw(CellSurface surface, Rectangle area, object item, ControlStates itemState) { if (item is Color || item is Tuple <Color, Color, string> ) { string value = new string(' ', area.Width - 2); Cell cellLook = GetStateAppearance(itemState).Clone(); surface.Print(area.Left + 1, area.Top, value, cellLook); surface.Print(area.Left, area.Top, " ", cellLook); surface.Print(area.Left + area.Width - 1, area.Top, " ", cellLook); if (item is Color color) { cellLook.Background = color; surface.Print(area.Left + 1, area.Top, value, cellLook); } else { cellLook.Foreground = ((Tuple <Color, Color, string>)item).Item2; cellLook.Background = ((Tuple <Color, Color, string>)item).Item1; value = ((Tuple <Color, Color, string>)item).Item3.Align(HorizontalAlignment.Left, area.Width - 2); surface.Print(area.Left + 1, area.Top, value, cellLook); } if (itemState.HasFlag(ControlStates.Selected)) { surface.SetGlyph(area.Left, area.Top, 16); surface.SetGlyph(area.Left + area.Width - 1, area.Top, 17); } } else { base.Draw(surface, area, item, itemState); } }
/// <summary> /// Gets the property name for the specified control state. /// For example, to generate code for a SetStateAction on a TreeItem like: - /// myTreeItem.Expanded = true; /// this method should return "Expanded" as property name and true as the stateValue. /// Otherwise, if this returns null, then the generated code will look like - /// myEdit.SetProperty("State", ControlStates.Expanded); /// </summary> /// <param name="uiTestControl">The control for which the state property name is required.</param> /// <param name="uiState">The state for which the property names are required.</param> /// <param name="stateValues">The values for the properties returned.</param> /// <returns>The writable property names for the state or null if no property exists.</returns> public override string[] GetPropertyForControlState(UITestControl uiTestControl, ControlStates uiState, out bool[] stateValues) { stateValues = null; return null; }