Exemple #1
0
 private Panel CreateMatchElement(XmlNode match,SteDragDrop dragDrop)
 {
     Grid matchGrid = new Grid();
     matchGrid.Height = 100;
     matchGrid.Width = 200;
     matchGrid.Background = Brushes.AliceBlue;
     matchGrid.PreviewMouseDown += dragDrop.MatchElementMouseDown;
     matchGrid.MouseUp += dragDrop.MatchElementMouseUp;
     matchGrid.MouseMove += dragDrop.MatchElementdMouseMove;
     
     ScrollViewer scroll=new ScrollViewer();
     matchGrid.Children.Add(scroll);
     
     WrapPanel panel;
     panel = CreateContentBlock(match);
     matchGrid.HorizontalAlignment = HorizontalAlignment.Left;
     matchGrid.VerticalAlignment = VerticalAlignment.Top;
     matchGrid.Children.Add(panel);
     
     return matchGrid;
 }
Exemple #2
0
        /// <summary>
        /// Создаем вопрос на совпадение из XML
        /// </summary>
        /// <param name="node">Узел в XML с соответствующим типом</param>
        /// <returns>Возвращаем описание вопроса в XAML</returns>
        public StackPanel CreateMatchingAnswerElement(XmlNode node)
        {
            StackPanel MatchingAnswerElement=new StackPanel();
            Grid gridPanel = new Grid();
            Panel currentPanel;
            SteDragDrop dragDrop=new SteDragDrop();
            dragDrop.steController = steController;
            double d = 0;
            double w = SystemParameters.PrimaryScreenWidth;
            Viewbox box = new Viewbox();
            box.Child = gridPanel;
            string slotName="";
            string matchName = "";
            foreach (XmlNode slot in node.LastChild.ChildNodes)
            {
                slotName = slot.Attributes.GetNamedItem("id").Value;
                currentPanel=CreateSlotElement(slot);
                currentPanel.Name = slotName;
                double top = currentPanel.Margin.Top;
                currentPanel.Margin = new Thickness(w-400, top + d, 0, 0);
                dragDrop.slots.Add(currentPanel);
                gridPanel.Children.Add(currentPanel);
                d = d+105;
            }

            d = 0;
            foreach (XmlNode match in node.FirstChild.ChildNodes)
            {
                matchName = match.Attributes.GetNamedItem("id").Value;
                currentPanel = CreateMatchElement(match, dragDrop);
                currentPanel.Name = matchName;
                double top = currentPanel.Margin.Top;
                currentPanel.Margin = new Thickness(0, top + d, 0, 0);
                gridPanel.Children.Add(currentPanel);
                d += 105;
               
            }
            gridPanel.MouseMove += dragDrop.MatchElementdMouseMove;
           
            MatchingAnswerElement.Children.Add(box);
            
            return MatchingAnswerElement;
        }