/// <summary> /// /// </summary> /// <param name="OldValue"></param> /// <param name="NewValue"></param> protected virtual void OnColorChanged(Color OldValue, Color NewValue) { if (OldValue != NewValue) { if (SelectedComponent != null) { if (ColorChangeSource == ColorChangeSourceType.ColorPropertySet) { UpdatePlane(SelectedComponent.GetValue(NewValue).Round().ToInt32()); SelectionPoint = SelectedComponent.PointFromColor(NewValue); SelectionTransform.X = SelectionPoint.X - (SelectionPane.PixelWidth / 2.0); SelectionTransform.Y = SelectionPoint.Y - (SelectionPane.PixelHeight / 2.0); PART_Slider.Value = SelectedComponent.GetValue(NewValue); if (!SelectedComponent.IsUniform) { SelectedComponent.UpdateSlider(NormalPane, NewValue); } } if (SelectionRing == ColorSelectorRing.BlackOrWhite) { AdjustRing(NewValue); } } PART_AlphaSlider.Alpha = NewValue.A; ColorChanged?.Invoke(this, new EventArgs <Color>(NewValue)); } }
public void StartNewComponent() { SelectedComponent.ClearSelection(); SelectedComponent.ID = Guid.NewGuid().ToString(); SelectedComponent.Name = "NewComponent"; ComponentAbilitySDs.Clear(); }
public void HandleComponentProperties() { const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance; FieldInfo[] fields = SelectedComponent.GetType().GetFields(flags); PropertyInfo[] properties = SelectedComponent.GetType().GetProperties(flags); int numFields = fields.Length + properties.Length; VariableOptionStrings = new string[numFields]; TypesOfVariableOptions = new Type[numFields]; for (int i = 0; i < numFields; i++) { if (i < fields.Length) { TypesOfVariableOptions[i] = fields[i].FieldType; VariableOptionStrings[i] = fields[i].Name; } else { TypesOfVariableOptions[i] = properties[i - fields.Length].PropertyType; VariableOptionStrings[i] = properties[i - fields.Length].Name; } } }
protected override void MouseUp(System.Windows.Forms.MouseEventArgs e) { if (SelectedComponent != null) { SelectedComponent.MouseUp(e); this.View.Invalidate(); } }
void UpdatePlane(int ComponentValue) { if (LastComponentValue != ComponentValue || LastComponentHashCode != SelectedComponent.GetHashCode()) { SelectedComponent.UpdatePlane(SelectionPane, ComponentValue); LastComponentValue = ComponentValue; LastComponentHashCode = SelectedComponent.GetHashCode(); } }
public DalSelectedComponent MapToDal(SelectedComponent entity) { return(new DalSelectedComponent { Id = entity.id, ComponentLib_id = entity.componentLib_id, Component_id = entity.component_id }); }
//SelectableComponentModel void OnSliderChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { ColorChangeSource = ColorChangeSourceType.SliderMove; if (ProcessSliderEvents) { ProcessSliderEvents = false; Color = SelectedComponent.ColorAtPoint(SelectionPoint, (int)e.NewValue).WithAlpha(PART_AlphaSlider.Alpha); UpdatePlane(SelectedComponent.GetValue(Color).Round().ToInt32()); ProcessSliderEvents = true; } ColorChangeSource = ColorChangeSourceType.ColorPropertySet; }
private void Components_SelectionChangedEvent(int oldSelection, int newSelection) { if (newSelection == -1) //if newindex is not a valid selection { return; } SelectedComponent.SetDesignSD(Components.GetKey());// = mainTemplateVM; ComponentAbilitySDs.Clear(); var tmp = new List <ComponentAbilityTemplateVM>(); foreach (var item in Components.GetKey().ComponentAbilitySDs) { var vm = new ComponentAbilityTemplateVM(this, item, ComponentAbilitySDs, _staticData); tmp.Add(vm); } ComponentAbilitySDs.AddRange(tmp); }
protected override void MouseDown(System.Windows.Forms.MouseEventArgs e) { if (SelectedComponent != null) { if (SelectedComponent.HitTest(e.X, e.Y)) { if ((Control.ModifierKeys & Keys.Shift) != Keys.None) { SaveInstance(); LoadInstance(); BaseComponent addedCmp = SelectedComponent; if (addedCmp.HitTest(e.X, e.Y)) { OnSelect(addedCmp); addedCmp.MouseDown(e); } return; } else { SelectedComponent.MouseDown(e); return; } } else { OnSelect(null); } } foreach (BaseComponent x in Model.Items) { x.MouseState = Entities.MouseState.None; x.IsSelected = false; if (x.HitTest(e.X, e.Y)) { OnSelect(x); x.MouseDown(e); break; } } this.View.Invalidate(); }
protected override void MouseMove(System.Windows.Forms.MouseEventArgs e) { if (SelectedComponent != null) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (SelectedComponent.MouseState == MouseState.Resize) { SelectedComponent.MouseMove(e); this.View.Invalidate(); } else if (SelectedComponent.MouseState == MouseState.Move) { SelectedComponent.Move(e); this.View.Invalidate(); } } } }
private void AddItem() { if (CheckNumbers() && SelectedComponent != null) { var type = ""; if (SelectedComponent.GetType().Name.Equals("MotherBoard")) { type = "Motherboard"; } else { type = SelectedComponent.GetType().Name; } StockComponent component = new StockComponent { Count = Int32.Parse(Count), PhysicalLocation = Location, Type = type }; Component cmp = SelectedComponent; cmp.Id = new Guid(); component.M_Component = cmp; ConnectionService.Instance.proxy.AddComponent(cmp); component.Id = new Guid(); RuntimeContext.addedStockComponent = ConnectionService.Instance.proxy.AddStockComponent(component); RuntimeContext.msgLabel = "New stock item added to db."; RuntimeContext.commands.Add("added"); LogService.Instance.LogInformation("New stock component added to db."); MainWindowViewModel.Instance.OnNav("data"); } else { LogService.Instance.LogError("Wrong parameters."); MsgLabel = "Wrong number input."; return; } }
void OnPlaneMouseDown(Point selectionPoint) { if (SelectedComponent != null) { SelectionPoint = selectionPoint; double w = PART_ColorPlane.ActualWidth / 2, h = PART_ColorPlane.ActualHeight / 2; SelectionTransform.X = (SelectionPoint.X - w).Coerce(w, -w); SelectionTransform.Y = (SelectionPoint.Y - h).Coerce(h, -h); SelectionPoint = new Point(SelectionPoint.X.Coerce(255d), SelectionPoint.Y.Coerce(255d)); var NewColor = SelectedComponent.ColorAtPoint(SelectionPoint, (int)PART_Slider.Value); if (!SelectedComponent.IsUniform) { SelectedComponent.UpdateSlider(NormalPane, NewColor); } Color = NewColor.WithAlpha(PART_AlphaSlider.Alpha); } }
public void SelectComponent(Point location) { Component selected = components .Where(c => c.Select(location, this)) .OrderBy(c => c.ID) .LastOrDefault(); if (SelectedComponent == selected) { DeselectComponent(selected); } else { DeselectComponent(SelectedComponent); SelectedComponent = selected; if (SelectedComponent != null) { SelectedComponent.ChangeColor(Color.Orange); } } Draw(true); }
public ComponentDetailsViewModel() { SelectedComponent = new SelectedComponent(); }
private void SaveInstance() { System.Windows.Forms.Clipboard.SetText(Util.GetJSONString(SelectedComponent.GetComponent())); }
public void KeyStroke(Key key, Point mouseLocation) { Point closest = Grid.SnapToGrid(mouseLocation); if (!WirePlacementMode) { switch (key) { case Key.T: AddComponent(new Switch(this, closest)); break; case Key.L: AddComponent(new Light(this, closest)); break; case Key.Q: AddComponent(new ANDGate(this, closest)); break; case Key.W: AddComponent(new NOTGate(this, closest)); break; case Key.E: AddComponent(new ORGate(this, closest)); break; case Key.R: AddComponent(new XORGate(this, closest)); break; case Key.Y: AddComponent(new Clock(this, closest)); break; case Key.Plus: Scale(0.25f); break; case Key.Minus: Scale(-0.25f); break; case Key.Up: if (SelectedComponent != null && !(SelectedComponent is Wire)) { SelectedComponent.Translate(this, Direction.Up, 1); } else { TranslateScene(Direction.Down); } break; case Key.Down: if (SelectedComponent != null && !(SelectedComponent is Wire)) { SelectedComponent.Translate(this, Direction.Down, 1); } else { TranslateScene(Direction.Up); } break; case Key.Right: if (SelectedComponent != null && !(SelectedComponent is Wire)) { SelectedComponent.Translate(this, Direction.Right, 1); } else { TranslateScene(Direction.Left); } break; case Key.Left: if (SelectedComponent != null && !(SelectedComponent is Wire)) { SelectedComponent.Translate(this, Direction.Left, 1); } else { TranslateScene(Direction.Right); } break; case Key.Delete: if (SelectedComponent != null) { RemoveComponent(SelectedComponent); } break; } } }
/// <summary> /// /// </summary> /// <param name="Value"></param> protected virtual void OnIlluminantChanged(Illuminant Value) { UpdatePlane(SelectedComponent.GetValue(Color).Round().ToInt32()); SelectedComponent.UpdateSlider(NormalPane, Color); }