Example #1
0
        private void SideWindowElem_Drop(object sender, DragEventArgs e)
        {
            if (sender is ListBoxItem)
            {
                Term source = e.Data.GetData(typeof(Term)) as Term;
                Term target = ((ListBoxItem)sender).DataContext as Term;

                var source_parent = getParentOC(source);
                var target_parent = getParentOC(target);

                int sourceIndex = SideList.IndexOf(source);
                int targetIndex = SideList.IndexOf(target);

                if (source_parent.Equals(target_parent))
                {
                    SideList.RemoveAt(sourceIndex);
                    SideList.Insert(targetIndex, source);
                }
                else
                {
                    sourceIndex = source_parent.IndexOf(source);
                    source_parent.RemoveAt(sourceIndex);
                    source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                    source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                    source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                    SideList.Insert(targetIndex, source);
                    unassignedTerms.Add(source);
                }
            }
        }
Example #2
0
        private void SideWindow_Drop(object sender, DragEventArgs e)
        {
            if (sender is ListBox)
            {
                Term source = e.Data.GetData(typeof(Term)) as Term;

                if (source.SubjectId == "")
                {
                    e.Handled = true;
                    return;
                }
                var source_parent = getParentOC(source);

                if (source_parent.Equals(SideList))
                {
                    e.Handled = true;
                    return;
                }

                int sourceIndex = source_parent.IndexOf(source);

                source_parent.RemoveAt(sourceIndex);
                source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                SideList.Add(source);
                unassignedTerms.Add(source);
            }
        }
Example #3
0
        public static void removeTermBySubject(string sub_id)
        {
            List <int> remove_elements = new List <int>();

            foreach (var week in classroomsWeek)
            {
                foreach (var dayModel in week.Value)
                {
                    remove_elements.Clear();
                    foreach (Term t in dayModel)
                    {
                        if (t.SubjectId == sub_id)
                        {
                            int index = dayModel.IndexOf(t);
                            remove_elements.Add(index);
                        }
                    }
                    for (int i = remove_elements.Count - 1; i > -1; i--)
                    {
                        dayModel.RemoveAt(remove_elements[i]);
                        dayModel.Insert(remove_elements[i], new Term("", "", "", "", 0));
                        dayModel.Insert(remove_elements[i], new Term("", "", "", "", 0));
                        dayModel.Insert(remove_elements[i], new Term("", "", "", "", 0));
                    }
                }
            }
            for (int i = SideList.Count - 1; i > -1; i--)
            {
                if (SideList[i].SubjectId == sub_id)
                {
                    SideList.RemoveAt(i);
                }
            }
        }
Example #4
0
        private void MainWindow_Drop(object sender, DragEventArgs e)
        {
            if (sender is ListBoxItem)
            {
                Term source        = e.Data.GetData(typeof(Term)) as Term;
                Term target        = ((ListBoxItem)sender).DataContext as Term;
                var  target_parent = getParentOC(target);
                var  source_parent = getParentOC(source);

                int sourceIndex = source_parent.IndexOf(source);
                int targetIndex = target_parent.IndexOf(target);

                if (source_parent.Equals(target_parent))
                {
                    source_parent.RemoveAt(sourceIndex);
                    source_parent.Insert(targetIndex, source);
                }
                else if (source_parent.Equals(SideList))
                {
                    sourceIndex = SideList.IndexOf(source);

                    if ((targetIndex = getStartIndex(target_parent, targetIndex)) != -1)
                    {
                        target_parent.RemoveAt(targetIndex);
                        target_parent.RemoveAt(targetIndex);
                        target_parent.RemoveAt(targetIndex);
                        target_parent.Insert(targetIndex, source);
                        unassignedTerms.RemoveAt(unassignedTerms.IndexOf(source));
                        SideList.RemoveAt(sourceIndex);
                    }
                    else
                    {
                        MessageBox.Show("Moguće je premeštanje samo na 3 spojena polja od 15 minuta!", "Greška", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    if (source.SubjectId == "")
                    {
                        MessageBox.Show("Premeštanje pauza između dana nije moguce!", "Greška", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        if ((targetIndex = getStartIndex(target_parent, targetIndex)) != -1)
                        {
                            target_parent.RemoveAt(targetIndex);
                            target_parent.RemoveAt(targetIndex);
                            target_parent.RemoveAt(targetIndex);
                            target_parent.Insert(targetIndex, source);
                            source_parent.RemoveAt(sourceIndex);
                            source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                            source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                            source_parent.Insert(sourceIndex, new Term("", "", "", "", 0));
                        }
                    }
                }
            }
        }
Example #5
0
        public void AddSide(string name)
        {
            int index = SideList.ToList().FindIndex(f => f.GetName() == name);

            if (index == -1)
            {
                RigItemBool new_bool = new RigItemBool(name);
                SideList.Add(new_bool);
                RaisePropertyChanged("SideList");
            }
        }
Example #6
0
 public static void fillSideList(string classroomId)
 {
     SideList.Clear();
     if (classroomId == null)
     {
         return;
     }
     foreach (var term in unassignedTerms)
     {
         if (checkTermClassroom(term, classroomId))
         {
             SideList.Add(term);
         }
     }
 }
Example #7
0
        public void DoTriangulation()
        {
            SideList sides;
            int      triIndex;
            Triangle t;

            // Añade el triángulo de base a la lista de triángulos
            Vector2  p1  = new Vector2(-2000, -2000);
            Vector2  p2  = new Vector2(2000, -2000);
            Vector2  p3  = new Vector2(0, 2000);
            Triangle tri = new Triangle(p1, p2, p3);

            tris = new List <Triangle> (numPoints / 2);
            tris.Add(tri);

            for (int v = 0; v < numPoints; v++)
            {
                // por cada vértice (punto) comprobar si está contenido en uno o más triángulos
                Vector2 vertex = data [v];
                triIndex = 0;
                sides    = new SideList();
                while (triIndex < tris.Count)
                {
                    t = tris [triIndex];
                    if (t.ContainsInCircle(vertex))
                    {
                        sides.AddSide(t.l1);
                        sides.AddSide(t.l2);
                        sides.AddSide(t.l3);
                        tris.Remove(t);
                    }
                    else
                    {
                        triIndex++;
                    }
                }
                // Agrega un triángulo nuevo por cada lado
                for (int k = 0; k < sides.sideList.Count; k++)
                {
                    Line side = sides.sideList [k];
                    tris.Add(new Triangle(side.p, side.q, vertex));
                }
            }

            // Elimina los triángulos conexos con el inicial
            triIndex = 0;
            while (triIndex < tris.Count)
            {
                t = tris [triIndex];
                if (t.p1 == tri.p1 || t.p1 == tri.p2 || t.p1 == tri.p3 ||
                    t.p2 == tri.p1 || t.p2 == tri.p2 || t.p2 == tri.p3 ||
                    t.p3 == tri.p1 || t.p3 == tri.p2 || t.p3 == tri.p3)
                {
                    tris.Remove(t);
                }
                else
                {
                    triIndex++;
                }
            }
        }
Example #8
0
        /// <summary>
        /// Handles filtering on search and filter post request.
        /// </summary>
        public void OnPost()
        {
            Menu = new Menu();

            ComboList  = Menu.AvailableCombos;
            EntreeList = Menu.AvailableEntrees;
            SideList   = Menu.AvailableSides;
            DrinkList  = Menu.AvailableDrinks;

            if (search != null)
            {
                ComboList = ComboList.Where(item =>
                                            (item as CretaceousCombo).Description.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                            (item as CretaceousCombo).Side.Description.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                            (item as CretaceousCombo).Drink.Description.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                            (item as CretaceousCombo).Ingredients.Contains(search, StringComparer.OrdinalIgnoreCase));

                EntreeList = EntreeList.Where(item =>
                                              (item as IOrderItem).Description.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                              item.Ingredients.Contains(search, StringComparer.OrdinalIgnoreCase));

                SideList = SideList.Where(item =>
                                          (item as IOrderItem).Description.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                          item.Ingredients.Contains(search, StringComparer.OrdinalIgnoreCase));

                DrinkList = DrinkList.Where(item =>
                                            (item as IOrderItem).Description.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                            item.Ingredients.Contains(search, StringComparer.OrdinalIgnoreCase));
            }

            if (menuCategory.Count > 0)
            {
                ComboList  = ComboList.Where(item => menuCategory.Contains("Combo"));
                EntreeList = EntreeList.Where(item => menuCategory.Contains("Entree"));
                SideList   = SideList.Where(item => menuCategory.Contains("Side"));
                DrinkList  = DrinkList.Where(item => menuCategory.Contains("Drink"));
            }

            if (minimumPrice is float minP)
            {
                ComboList  = ComboList.Where(item => item.Price > minP);
                EntreeList = EntreeList.Where(item => item.Price > minP);
                SideList   = SideList.Where(item => item.Price > minP);
                DrinkList  = DrinkList.Where(item => item.Price > minP);
            }

            if (maximumPrice is float maxP)
            {
                ComboList  = ComboList.Where(item => item.Price < maxP);
                EntreeList = EntreeList.Where(item => item.Price < maxP);
                SideList   = SideList.Where(item => item.Price < maxP);
                DrinkList  = DrinkList.Where(item => item.Price < maxP);
            }

            if (excludedIngredients.Count > 0)
            {
                ComboList = ComboList.Where(item =>
                {
                    bool contains = false;

                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient, StringComparer.OrdinalIgnoreCase))
                        {
                            contains = true;
                        }
                    }

                    return(!contains);
                });

                EntreeList = EntreeList.Where(item =>
                {
                    bool contains = false;

                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient, StringComparer.OrdinalIgnoreCase))
                        {
                            contains = true;
                        }
                    }

                    return(!contains);
                });

                SideList = SideList.Where(item =>
                {
                    bool contains = false;

                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient, StringComparer.OrdinalIgnoreCase))
                        {
                            contains = true;
                        }
                    }

                    return(!contains);
                });

                DrinkList = DrinkList.Where(item =>
                {
                    bool contains = false;

                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient, StringComparer.OrdinalIgnoreCase))
                        {
                            contains = true;
                        }
                    }

                    return(!contains);
                });
            }
        }