Exemplo n.º 1
0
        void _school_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            // get clicked school name
            var _object = sender as TextBlock;
            string _selectedSchoolName = _object.Name;

            // query this school's pubs in years
            SchoolPubsInYears _tempSchoolPubInYears = new SchoolPubsInYears();
            _tempSchoolPubInYears.SchoolName = _selectedSchoolName;
            foreach (string _year in pubData.PubYears)
            {
                _tempSchoolPubInYears.Years.Add(_year);
                _tempSchoolPubInYears.Pubs.Add(pubData.PubCountSchoolPubInYear(_selectedSchoolName, _year));
            }

            //-> generate data image
            pubMap.GenerateTerrains(_tempSchoolPubInYears);//-> pubMap.TextureImage
            scene.Update(pubMap.DepthImage, pubMap.TextureImage, state);

            //debug info
            //DebugShow(pubMap.TextureImage);
            Debug.WriteLine("!!!right click ->" + _object.Name);
        }
Exemplo n.º 2
0
        void _school_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //if ctrl button down
            ModifierKeys _keys = Keyboard.Modifiers;
            bool _ctrlkey = (_keys & ModifierKeys.Control) != 0;
            if (true == _ctrlkey)
            {
                //debug info
                Debug.WriteLine("!!!control key down.");

                //->get selected school's name
                var _object = sender as TextBlock;
                string _selectedSchoolName = _object.Name;

                //update UI
                schoolConnectionSlider.Visibility = System.Windows.Visibility.Collapsed;

                //->load this school's all stuffs with r t e data
                //schStuffData.StaffCountSchoolStuffs(_selectedSchoolName) -> list<dataset>
                schStuffMap.GenerateTerrains(schStuffData.StaffCountSchoolStuffs(_selectedSchoolName), 1);  //->schStuffMap.DepthImage schStuffMap.TextureImage
                scene.Update(schStuffMap.DepthImage, schStuffMap.TextureImage, state);
            }
            else
            {
                //loading
                loading.Visibility = System.Windows.Visibility.Visible;
                schoolConnectionSlider.Visibility = System.Windows.Visibility.Visible;

                //change color
                var _object = sender as TextBlock;
                if (_object.Tag == "active")
                {
                    _object.Foreground = new SolidColorBrush(Colors.Gray);
                    _object.Tag = "inactive";
                }
                else
                {
                    _object.Foreground = new SolidColorBrush(Colors.Black);
                    _object.Tag = "active";
                }

                //update date
                // get active school list
                List<TextBlock> _activeSchools = new List<TextBlock>();
                foreach (TextBlock _sch in stackPanelSchools.Children)
                {
                    if (_sch.Tag == "active")
                    {
                        _activeSchools.Add(_sch); //Debug.WriteLine(_sch.Name);
                    }
                }

                // get active schools' data
                List<SchoolPubsInYears> _schPubsInYears = new List<SchoolPubsInYears>();
                foreach (TextBlock _sch in _activeSchools)
                {
                    SchoolPubsInYears _tempSchPubsInYears = new SchoolPubsInYears();
                    _tempSchPubsInYears.SchoolName = _sch.Name;

                    //
                    List<string> _tempYears = new List<string>();
                    List<int> _tempPubs = new List<int>();
                    foreach (string _y in pubData.PubYears)
                    {
                        _tempYears.Add(_y);
                        _tempPubs.Add(pubData.PubCountSchoolPubInYear(_sch.Name, _y));

                        //debug info
                        //Debug.WriteLine("school:{0}, year:{1}, pubs:{2}", _sch.Name, _y.ToString(), pubData.PubCountSchoolPubInYear(_sch.Name, _y));
                    }
                    _tempSchPubsInYears.Years = _tempYears;
                    _tempSchPubsInYears.Pubs = _tempPubs;

                    //add to _schPubInYears
                    _schPubsInYears.Add(_tempSchPubsInYears);
                }

                //-> send data to dataimage
                pubMap.GenerateTerrains(_schPubsInYears, (int)schoolConnectionSlider.Value);//-> pubMap.TextureImage
                scene.Update(pubMap.DepthImage, pubMap.TextureImage, state);

                //debug info
                //DebugShow(pubMap.TextureImage);

                //loading
                loading.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Exemplo n.º 3
0
        private void schoolConnection_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            var _object = sender as Slider;

            //update dataimage
            //get active school names
            List<string> _activeSchoolNames = new List<string>();
            foreach (TextBlock _sch in stackPanelSchools.Children)
            {
                if (_sch.Tag == "active") _activeSchoolNames.Add(_sch.Name);
            }

            //get data
            List<SchoolPubsInYears> _schPubsInYears = new List<SchoolPubsInYears>();
            foreach (string sch in _activeSchoolNames)
            {
                SchoolPubsInYears _tempSchoolPubsInYears = new SchoolPubsInYears();
                _tempSchoolPubsInYears.SchoolName = sch;

                //
                List<string> _tempYears = new List<string>();
                List<int> _tempPubs = new List<int>();
                foreach (string _year in pubData.PubYears)
                {
                    _tempYears.Add(_year);
                    _tempPubs.Add(pubData.PubCountSchoolPubInYear(sch, _year));
                }
                _tempSchoolPubsInYears.Years = _tempYears;
                _tempSchoolPubsInYears.Pubs = _tempPubs;

                //add to _schPubsInYears
                _schPubsInYears.Add(_tempSchoolPubsInYears);
            }

            //send data to dataimage
            pubMap.GenerateTerrains(_schPubsInYears, (int)_object.Value);
            scene.Update(pubMap.DepthImage, pubMap.TextureImage, state);
        }
Exemplo n.º 4
0
        private void subPanel_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var _subLabel = sender as TextBlock;
            //
            switch (_subLabel.Name)
            {
                case "labelResearchOutput":
                    textInfo.Text = _subLabel.Name;

                    //update UI
                    researchOutputSlider.Visibility = researchEnvironmentSlider.Visibility = researchImpactSlider.Visibility = System.Windows.Visibility.Collapsed;
                    stackPanelSchools.Visibility = System.Windows.Visibility.Visible;
                    if (labelResearchOutput.Tag == "inactive")
                    {
                        //show slider for connection strength
                        schoolConnectionSlider.Visibility = System.Windows.Visibility.Visible;

                        //show school textblocks
                        foreach (var sch in pubData.PubSchoolPubs)
                        {
                            TextBlock _school = new TextBlock();
                            _school.Height = 25; _school.Width = 80;
                            _school.TextAlignment = TextAlignment.Center;
                            _school.Tag = "active";
                            _school.Name = sch.schName;
                            _school.Text = sch.schName;
                            _school.MouseRightButtonDown += new MouseButtonEventHandler(_school_MouseRightButtonDown);
                            _school.MouseLeftButtonUp += new MouseButtonEventHandler(_school_MouseLeftButtonDown);

                            stackPanelSchools.Children.Add(_school);
                        }

                        //mark panel state
                        labelResearchOutput.Tag = "active";

                        //update data
                        //get active school list -> pubData.PubSchoolNames
                        //get active school data
                        List<SchoolPubsInYears> _schPubsInYears = new List<SchoolPubsInYears>();
                        foreach (string sch in pubData.PubSchoolNames)
                        {
                            SchoolPubsInYears _tempSchoolPubsInYears = new SchoolPubsInYears();
                            _tempSchoolPubsInYears.SchoolName = sch;

                            //
                            List<string> _tempYears = new List<string>();
                            List<int> _tempPubs = new List<int>();
                            foreach (string _year in pubData.PubYears)
                            {
                                _tempYears.Add(_year);
                                _tempPubs.Add(pubData.PubCountSchoolPubInYear(sch, _year));
                            }
                            _tempSchoolPubsInYears.Years = _tempYears;
                            _tempSchoolPubsInYears.Pubs = _tempPubs;

                            //add to _schPubsInYears
                            _schPubsInYears.Add(_tempSchoolPubsInYears);
                        }

                        //send data to dataimage
                        pubMap.GenerateTerrains(_schPubsInYears);
                        scene.Update(pubMap.DepthImage, pubMap.TextureImage, state);
                    }
                    else
                    {
                        schoolConnectionSlider.Visibility = System.Windows.Visibility.Collapsed;
                        stackPanelSchools.Children.Clear();
                        labelResearchOutput.Tag = "inactive";
                    }

                    break;
                case "labelResearchEnvironment":
                    textInfo.Text = _subLabel.Name;

                    //update UI
                    stackPanelSchools.Visibility = stackPanelResearchImpact.Visibility = System.Windows.Visibility.Collapsed;
                    stackPanelResearchEnvironment.Visibility = System.Windows.Visibility.Visible;

                    break;
                case "labelResearchImpact":
                    textInfo.Text = _subLabel.Name;

                    //update UI
                    stackPanelSchools.Visibility = stackPanelResearchEnvironment.Visibility = System.Windows.Visibility.Collapsed;
                    stackPanelResearchImpact.Visibility = System.Windows.Visibility.Visible;

                    break;
                case "labelTeachingCourse":
                    textInfo.Text = _subLabel.Name;
                    break;
                case "labelTeachingTime":
                    textInfo.Text = _subLabel.Name;
                    break;
                case "labelTeachingStudent":
                    textInfo.Text = _subLabel.Name;
                    break;
                case "labelEnterprisingOutput":
                    textInfo.Text = _subLabel.Name;
                    break;
                case "labelEnterprisingFund":
                    textInfo.Text = _subLabel.Name;
                    break;
                case "labelEnterprisingImpact":
                    textInfo.Text = _subLabel.Name;
                    break;
            }
        }
Exemplo n.º 5
0
        public void GenerateTerrains(SchoolPubsInYears _inputData)
        {
            //set up canvas
            canvas.Children.Clear();
            canvas.Background = transparent;

            //draw data shapes - terrain
            int _max = _inputData.Pubs.Max();
            for (int i = 0; i < _inputData.Years.Count; i++)
            {
                byte _r = (byte)(((float)_inputData.Pubs[i] / _max) * 255);
                byte _g = _r;
                byte _b = (byte)(255 - _r);
                System.Windows.Shapes.Path _circle = DrawArcPaths(
                    new SolidColorBrush(Color.FromArgb(255, _r, _g, _b)),
                    transparent,
                    15,
                    0,
                    359.999d,
                    (i * 30 + 10) / 2,
                    new Point(256, 256)
                    );

                canvas.Children.Add(_circle);
            }

            //generate writeablebitmap
            textureImage = new WriteableBitmap(canvas, null);
            depthImage = textureImage;
        }