Example #1
0
        private void BTNAddRoomSubtype_Click(object sender, RoutedEventArgs e)
        {
            WindowWithStringResult w = new WindowWithStringResult(
                (name) =>
            {
                InteriorObjectType typ = (sender as Button).DataContext as InteriorObjectType;

                if (typ.child.Count == 1 && typ.child[0].category == UIElementCategory.Undefined)
                {
                    var products = typ.child[0].products;
                    InteriorObjectSubtype subTyp = new InteriorObjectSubtype(string.IsNullOrEmpty(name) ? UIElementCategory.Undefined : UIElementCategory.ProductTypeType);
                    subTyp.products      = products;
                    subTyp.uidisplayname = name;
                    subTyp.id            = 0;
                    subTyp.parentid      = typ.id;

                    typ.child[0] = subTyp;
                }
                else
                {
                    InteriorObjectSubtype subTyp = new InteriorObjectSubtype(string.IsNullOrEmpty(name) ? UIElementCategory.Undefined : UIElementCategory.ProductTypeType);
                    subTyp.uidisplayname         = name;
                    subTyp.parentid = typ.id;
                    subTyp.id       = typ.child.Count > 0 ? typ.child.Max(x => x.id) + 1 : 0;

                    typ.child.Add(subTyp);
                }

                UpdateTree();
            });

            w.Owner = this;
            w.ShowDialog();
        }
Example #2
0
        private void BTNRemoveRoom_Click(object sender, RoutedEventArgs e)
        {
            RoomItem room    = (sender as Button).DataContext as RoomItem;
            int      roomIdx = json.elements.IndexOf(room);

            for (int i = roomIdx + 1; i < json.elements.Count; i++)
            {
                RoomItem r = json.elements[i];
                r.id--;
                for (int j = 0; j < r.child.Count; j++)
                {
                    InteriorObjectType t = r.child[j];
                    for (int k = 0; k < t.child.Count; k++)
                    {
                        InteriorObjectSubtype st = t.child[k];
                        for (int l = 0; l < st.products.Count; l++)
                        {
                            st.products[l].room = r.id;
                        }
                    }
                }
            }

            json.elements.RemoveAt(roomIdx);
            UpdateTree();
        }
Example #3
0
        private void BTNRenameType_Click(object sender, RoutedEventArgs e)
        {
            InteriorObjectType     room = (sender as Button).DataContext as InteriorObjectType;
            WindowWithStringResult w    = new WindowWithStringResult((name) =>
            {
                room.uidisplayname = name;
                UpdateTree();
            });

            w.ShowDialog();
        }
Example #4
0
        private void BTNAddRoomType_Click(object sender, RoutedEventArgs e)
        {
            WindowWithStringResult w = new WindowWithStringResult(
                (name) =>
            {
                RoomItem room = (sender as Button).DataContext as RoomItem;

                InteriorObjectType typ = new InteriorObjectType();
                typ.uidisplayname      = name;
                typ.id = room.child.Count > 0 ? room.child.Max(x => x.id) + 1 : 0;
                room.child.Add(typ);

                UpdateTree();
            });

            w.Owner = this;
            w.ShowDialog();
        }
Example #5
0
        private void BTNRemoveType_Click(object sender, RoutedEventArgs e)
        {
            InteriorObjectType type = (sender as Button).DataContext as InteriorObjectType;

            RoomItem parentRoom = null;

            foreach (var room in json.elements)
            {
                if (room.child.Contains(type))
                {
                    parentRoom = room;
                    break;
                }
            }
            if (parentRoom != null)
            {
                parentRoom.child.Remove(type);
            }

            UpdateTree();
        }
Example #6
0
        private void BTNRemoveSubType_Click(object sender, RoutedEventArgs e)
        {
            InteriorObjectSubtype subType    = (sender as Button).DataContext as InteriorObjectSubtype;
            InteriorObjectType    parentType = null;

            foreach (var room in json.elements)
            {
                foreach (var type in room.child)
                {
                    if (type.child.Contains(subType))
                    {
                        parentType = type;
                        break;
                    }
                }
            }
            if (parentType != null)
            {
                parentType.child.Remove(subType);
            }

            UpdateTree();
        }
        private void BTNAddRoomType_Click(object sender, RoutedEventArgs e)
        {
            WindowWithStringResult w = new WindowWithStringResult(
                (name) =>
                {
                    RoomItem room = (sender as Button).DataContext as RoomItem;

                    InteriorObjectType typ = new InteriorObjectType();
                    typ.uidisplayname = name;
                    typ.id = room.child.Count > 0 ? room.child.Max(x => x.id) + 1 : 0;
                    room.child.Add(typ);

                    UpdateTree();
                });
            w.Owner = this;
            w.ShowDialog();
        }