コード例 #1
0
 private void ShowScriptingButton(GridItem3D item)
 {
     if (grid.selectedItems.Count == 1 & item.isSelected & scriptableItems.Contains(item.classId))
     {
         ScriptingButton.Visibility = Visibility.Visible;
     }
 }
コード例 #2
0
        /*  ------------------------------------------------- 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();
            }
        }
コード例 #3
0
 private void OnScriptButtonClicked(object sender, System.Windows.RoutedEventArgs e)
 {
     if (grid.selectedItems.Count == 1)
     {
         GridItem3D item = grid.selectedItems[0];
         ShowScriptingWindow(item);
     }
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 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));
     }
 }
コード例 #6
0
        private void Tailback(String message)
        {
            int        simulationFactoryId = GetSelectedSimulationId();
            GridItem3D item = grid.GetItemByID(message);

            if (item != null)
            {
                grid.GetItemByID(message).tailback = true;
            }
        }
コード例 #7
0
        public void MoveItem(String instanceId, Point3D point)
        {
            GridItem3D item = GetItemByID(instanceId);

            if (item != null)
            {
                item.position = point;
                UpdateModel();
            }
        }
コード例 #8
0
 private void ShowConsumerEmptyButton(GridItem3D item)
 {
     if (grid.selectedItems.Count == 1 & item.isSelected)
     {
         if (grid.selectedItems[0].classId == 2)
         {
             ConsumerCanvas.Visibility = Visibility.Visible;
         }
     }
 }
コード例 #9
0
 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);
 }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        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();
        }
コード例 #13
0
        public void RemoveItem(string instanceId)
        {
            GridItem3D itemToBeRemoved = GetItemByID(instanceId);

            if (itemToBeRemoved != null)
            {
                Model.Children.Remove(itemToBeRemoved.model);
                modelList.Remove(itemToBeRemoved);

                ClearAndDeselectAllItems();
                UpdateModel();
            }
        }
コード例 #14
0
 /* ------------------------------------------ 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();
     }
 }
コード例 #15
0
        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 });
            }
        }
コード例 #16
0
 public void SelectItem(GridItem3D item)
 {
     if (!item.isSelected)
     {
         item.isSelected = true;
         selectedItems.Add(item);
         if (selectedItems.Count == 1)
         {
             SetGhost();
         }
         else
         {
             UnsetGhost();
         }
     }
     else
     {
         ClearAndDeselectAllItems();
     }
 }
コード例 #17
0
        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();
            }
        }
コード例 #18
0
        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);
                }
            }
        }
コード例 #19
0
        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();
        }
コード例 #20
0
 public void UnsetGhost()
 {
     HideGhost();
     ghostItem = null;
 }
コード例 #21
0
        /* ----------------------- GHOST METHODS --------------------------- */

        public void SetGhost()
        {
            GridItem3D item = selectedItems[0];

            ghostItem = item.Clone();
        }
コード例 #22
0
 private void AddItemToModel(GridItem3D item)
 {
     item.UpdateModelProperties(xOffset, yOffset);
     item.isSet = true;
     Model.Children.Add(item.model);
 }
コード例 #23
0
        /* --------------------- GUI-Methoden ---------------------------*/

        public void PlaceItem(GridItem3D item)
        {
            modelList.Add(item);
            UpdateModel();
        }