private void ShowScriptingButton(GridItem3D item) { if (grid.selectedItems.Count == 1 & item.isSelected & scriptableItems.Contains(item.classId)) { ScriptingButton.Visibility = Visibility.Visible; } }
/* ------------------------------------------------- EVENTS -------------------------------------------------- */ private void OnClick(object sender, MouseButtonEventArgs e) { if (!csu.isSimulation) { HideScriptingButton(); HideConsumerEmptyButton(); var position = GetPosition(e.GetPosition(view)); GridItem3D item = grid.GetItemAtPosition(position); if (item != null) // Wenn auf Position Item liegt - ITEM SELECT { SelectItem(item); SetItemInformations(item); } else // Wenn Feld frei ist -> immer deselektieren und evtl Item setzen { grid.ClearAndDeselectAllItems(); MachinePositionXBox.Text = ""; MachinePositionYBox.Text = ""; LoadTextBox.Text = ""; int id = toolbox.GetSelectedClassID(); if (id > 0 && id < 6) { grid.CreateItemOnServer(position, id); } } ShowSelectedItems(); } }
private void OnScriptButtonClicked(object sender, System.Windows.RoutedEventArgs e) { if (grid.selectedItems.Count == 1) { GridItem3D item = grid.selectedItems[0]; ShowScriptingWindow(item); } }
private GridItem3D GetItem3DFromID(string instId) { GridItem3D it = null; grid.Model.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => it = (from item in grid.modelList where item.instanceId.Equals(instId) select item).First() )); return(it); }
public void MoveItemOnServer(Point3D position) { if (selectedItems.Count > 0) { GridItem3D item = selectedItems[0]; Point3D serverPosition = TransformClientToServerCoords(position); item.MoveItemOnServer(new Point3D(serverPosition.X, serverPosition.Y, 0)); } }
private void Tailback(String message) { int simulationFactoryId = GetSelectedSimulationId(); GridItem3D item = grid.GetItemByID(message); if (item != null) { grid.GetItemByID(message).tailback = true; } }
public void MoveItem(String instanceId, Point3D point) { GridItem3D item = GetItemByID(instanceId); if (item != null) { item.position = point; UpdateModel(); } }
private void ShowConsumerEmptyButton(GridItem3D item) { if (grid.selectedItems.Count == 1 & item.isSelected) { if (grid.selectedItems[0].classId == 2) { ConsumerCanvas.Visibility = Visibility.Visible; } } }
private void SelectItem(GridItem3D item) { if (!CtrlPressed()) // Wenn STRG nicht gedrückt und mehrere markiert sind { grid.DeselectItem(item); MachinePositionXBox.Text = ""; MachinePositionYBox.Text = ""; } grid.SelectItem(item); }
private void ShowScriptingWindow(GridItem3D item) { string script = item.GetScriptFromServer(); ScriptingWindow scriptingWindow = new ScriptingWindow(script); DialogResult result = scriptingWindow.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { item.ScriptObjectOnServer(scriptingWindow.script); } }
private void SetItemInformations(GridItem3D item) { ShowScriptingButton(item); ShowConsumerEmptyButton(item); Point3D point = grid.TransformClientToServerCoords(item.position); SetMaschinePositionBoxValue(point); if (grid.selectedItems.Count > 0) { SetMachineCapacityTextbox(grid.selectedItems[0].instanceId); } }
private void MouseReleased(object sender, MouseButtonEventArgs e) { var position = GetPosition(e.GetPosition(view)); GridItem3D item = grid.GetItemAtPosition(position); if (grid.IsSetGhost()) // Item verschieben { grid.MoveItemOnServer(position); grid.UnsetGhost(); } ShowSelectedItems(); }
public void RemoveItem(string instanceId) { GridItem3D itemToBeRemoved = GetItemByID(instanceId); if (itemToBeRemoved != null) { Model.Children.Remove(itemToBeRemoved.model); modelList.Remove(itemToBeRemoved); ClearAndDeselectAllItems(); UpdateModel(); } }
/* ------------------------------------------ Hilfs-Methoden - Item Selektieren ----------------------------------------------*/ internal void DeselectItem(GridItem3D item) { if (selectedItems.Count() == 1) { if (selectedItems[0] != item) { ClearAndDeselectAllItems(); } UnsetGhost(); } else if (selectedItems.Count() > 1) { ClearAndDeselectAllItems(); } }
private void CreateUIElement3D(string itemId) { position p = csu.GetPosition(itemId); if (p != null) { Point3D point = grid.TransformServerToClientCoords(new Point3D(p.x, p.y, 0)); String direction = p.direction.ToString(); int classID = HelperFunctions.GetClassIdFromItemId(itemId); GridItem3D it = grid.Model.Dispatcher.Invoke(new GetGridItem3DDelegate(grid.CreateGridItem3D), new object[] { classID, point, direction }) as GridItem3D; it.instanceId = itemId; grid.Model.Dispatcher.BeginInvoke(new CreateUIElement3DDelegate(grid.PlaceItem), new object[] { it }); } }
public void SelectItem(GridItem3D item) { if (!item.isSelected) { item.isSelected = true; selectedItems.Add(item); if (selectedItems.Count == 1) { SetGhost(); } else { UnsetGhost(); } } else { ClearAndDeselectAllItems(); } }
public void RotateItem(string itemId, string dir) { ClientServerUtil csu = ClientServerUtil.getInstance(); position p = csu.GetPosition(itemId); if (p != null) { GridItem3D item = GetItemByID(itemId); if (dir == "right") { item.rotateRight(); } else { item.rotateLeft(); } UpdateModel(); } }
private void OnPositionChangeClick(object sender, System.Windows.RoutedEventArgs e) { if (grid.selectedItems.Count == 1) { GridItem3D item = grid.selectedItems[0]; try { double x = Convert.ToDouble(MachinePositionXBox.Text); double y = Convert.ToDouble(MachinePositionYBox.Text); Point3D point = new Point3D(x, y, 0); item.MoveItemOnServer(point); } catch (FormatException) { Point3D point = grid.TransformClientToServerCoords(item.position); SetMaschinePositionBoxValue(point); } } }
public void InitSimulationGrid(Sim.machineMap machines) { ClearAndDeselectAllItems(); ClearGrid(); if (machines == null || machines.map == null) { return; } foreach (Sim.machineMapEntry machine in machines.map) { string instanceID = machine.key; int classID = HelperFunctions.GetClassIdFromItemId(instanceID); Sim.position pos = machine.value; Point3D point = TransformServerToClientCoords(new Point3D(pos.x, pos.y, 0)); GridItem3D newItem = CreateGridItem3D(classID, point, pos.direction.ToString()); newItem.instanceId = instanceID; PlaceItem(newItem); } SetItemOffset(); }
public void UnsetGhost() { HideGhost(); ghostItem = null; }
/* ----------------------- GHOST METHODS --------------------------- */ public void SetGhost() { GridItem3D item = selectedItems[0]; ghostItem = item.Clone(); }
private void AddItemToModel(GridItem3D item) { item.UpdateModelProperties(xOffset, yOffset); item.isSet = true; Model.Children.Add(item.model); }
/* --------------------- GUI-Methoden ---------------------------*/ public void PlaceItem(GridItem3D item) { modelList.Add(item); UpdateModel(); }