コード例 #1
0
        //Tải các Task lên ,tham so gom:
        //  streams: chứa dữ liệu xml (file xml dưới dạng binary).
        //  types: chứa loại bài tập của task đó là gì.
        public void AddPractices(List<Stream> streams,List<int> types)
        {
            if (streams == null)
                return;

            ResetAll();

            SelectionPartControl control = new SelectionPartControl();
            Stream stream;

            for (int i = 0; i < streams.Count; ++i)
            {
                stream = streams[i];

                switch (types[0])
                {
                    case 0:
                        {
                            control = new SelectionPartControl();

                            control.LoadContentFromStream(stream);

                            cnvMain.Children.Add(control);
                            break;
                        }
                }
            }
            spcList.Add(control);  
        }
コード例 #2
0
        //Tải các Task lên ,tham so gom:
        //  streams: chứa dữ liệu xml (file xml dưới dạng binary).
        //  types: chứa loại bài tập của task đó là gì.
        public void AddPractices(List <Stream> streams, List <int> types)
        {
            if (streams == null)
            {
                return;
            }

            ResetAll();

            SelectionPartControl control = new SelectionPartControl();
            Stream stream;

            for (int i = 0; i < streams.Count; ++i)
            {
                stream = streams[i];

                switch (types[0])
                {
                case 0:
                {
                    control = new SelectionPartControl();

                    control.LoadContentFromStream(stream);

                    cnvMain.Children.Add(control);
                    break;
                }
                }
            }
            spcList.Add(control);
        }
コード例 #3
0
        //Tải các Task lên ,tham so gom:
        //  streams: chứa dữ liệu xml (file xml dưới dạng binary).dùng trực tiếp xml để biết loại bài tập
        public void AddPractices(List<Stream> streams)
        {
            if (streams == null)
                return;

            ResetAll();

            
            Stream stream;
            XmlReader reader;
            int type;

            for (int i = 0; i < streams.Count; ++i)
            {
                stream = streams[i];

                //Lấy type từ xml stream
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.CloseInput = false;

                reader = XmlReader.Create(stream,settings);
                if(reader == null)continue;
                if (!reader.ReadToFollowing("Type"))
                    continue;
                type = reader.ReadElementContentAsInt();
                reader.Close();
                stream.Seek(0, SeekOrigin.Begin);

                switch (type)
                {
                        //trac nghiem
                    case 0:
                        {
                            SelectionPartControl control = new SelectionPartControl();
                            control = new SelectionPartControl();

                            control.LoadContentFromStream(stream);

                            cnvMain.Children.Add(control);
                            spcList.Add(control);
                            break;                            
                        }

                        //dien tu
                    case 1:
                        {
                            FillInBlankControl control = new FillInBlankControl();
                            control.LoadContentFromStream(stream);
                            control.Tag = type;
                            fbcList.Add(control);
                            break;
                        }
                }

                stream.Dispose();
            }            
        }
コード例 #4
0
        //Tải các Task lên ,tham so gom:
        //  streams: chứa dữ liệu xml (file xml dưới dạng binary).dùng trực tiếp xml để biết loại bài tập
        public void AddPractices(List <Stream> streams)
        {
            if (streams == null)
            {
                return;
            }

            ResetAll();


            Stream    stream;
            XmlReader reader;
            int       type;

            for (int i = 0; i < streams.Count; ++i)
            {
                stream = streams[i];

                //Lấy type từ xml stream
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.CloseInput = false;

                reader = XmlReader.Create(stream, settings);
                if (reader == null)
                {
                    continue;
                }
                if (!reader.ReadToFollowing("Type"))
                {
                    continue;
                }
                type = reader.ReadElementContentAsInt();
                reader.Close();
                stream.Seek(0, SeekOrigin.Begin);

                switch (type)
                {
                //trac nghiem
                case 0:
                {
                    SelectionPartControl control = new SelectionPartControl();
                    control = new SelectionPartControl();

                    control.LoadContentFromStream(stream);

                    cnvMain.Children.Add(control);
                    spcList.Add(control);
                    break;
                }

                //dien tu
                case 1:
                {
                    FillInBlankControl control = new FillInBlankControl();
                    control.LoadContentFromStream(stream);
                    control.Tag = type;
                    fbcList.Add(control);
                    break;
                }
                }

                stream.Dispose();
            }
        }