public void Create(City_E main_city, Canvas canvas) { c1 = canvas; maincity = main_city; canvas.Children.Add(ordinate); canvas.Children.Add(absscisse); ordinate.X1 = 1; ordinate.X2 = 2; ordinate.Y1 = 1; ordinate.Y2 = 2; absscisse.X1 = 1; absscisse.X2 = 2; absscisse.Y1 = 1; absscisse.Y2 = 2; ordinate.StrokeThickness = 3; ordinate.Stroke= new SolidColorBrush(Colors.White); absscisse.StrokeThickness = 3; absscisse.Stroke = new SolidColorBrush(Colors.White); absscisse.Opacity = 0; ordinate.Opacity = 0; }
public void update_message(City_E ce) { citye=ce; tb_cityname.Content = citye.city_name; tb_rank.Text = "规模等级"+citye.rank.ToString(); tb_roaddis.Text = "驾车前往所需时间:"+citye.distance_road+"小时"; tb_raildis.Text = "火车前往所需时间:" + citye.distance_railway + "小时"; tb_airdis.Text = "飞机前往所需时间:" + citye.distance_air + "小时"; tb_describe.Text = citye.describe; tb_population.Text = citye.population.ToString() + "万"; tb_landscape.Text = citye.landscape1; tb_landscape2.Text = citye.landscape2; tb_landscape3.Text = citye.landscape3; bu1.Content = "查找酒店信息"; bu2.Content = "小吃信息"; bu3.Content = "感兴趣!"; // stackpanel.MaxWidth = 1; // stackpanel.MaxHeight = 1; }
public void set(City_E main_city) { maincity = main_city; }
//is being used public void set_ellipse_fillbrushcolor(City_E citye) { RadialGradientBrush brush = new RadialGradientBrush(); int[] c = { 0, 0, 0 }; if (now_set_color_number >= cities_number) now_set_color_number = 0; now_set_color_number++; px+=((double)6/(double)cities_number)*way; if(px>0.9) way=-1; else if(px<0.1) way=1; double bili =px; // now_set_color_number++; // now_set_color_number++; int paichu = random.Next(3); if (now_set_color_number <= (cities_number / 3)) paichu = 2; else if (now_set_color_number < (cities_number * 2) / 3) paichu = 0; else paichu = 1; int left; int right; c[paichu] = 0; if (paichu == 0) { left = 1; right = 2; } else if (paichu == 1) { left = 0; right = 2; } else { left = 0; right = 1; } bili = px; if (paichu == 2 || paichu == 0) { if (way == 1){ c[left] = (int)(255 * 0.2); c[right] = (int)(255 * bili * 0.2); } else { c[right] = (int)(255 * bili * 0.2); c[left] = (int)(255 * 0.2); } } else { if (way == 1){ c[right] = (int)(255 * bili * 0.2); c[left] = (int)(255 * 0.2); } else { c[left] = (int)(255 * 0.2); c[right]=(int)(255*bili*0.2); } } int a = c[right]; int b = c[left]; GradientStop gs=new GradientStop(); gs.Color = Color.FromArgb((byte)0, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0; gs = new GradientStop(); brush.GradientStops.Add(gs); //deep gs.Color = Color.FromArgb((byte)0, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.4; gs = new GradientStop(); brush.GradientStops.Add(gs);//deep c[right] = (int)(c[right] / 0.3); c[left] = (int)(c[left] / 0.3); gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.41; brush.GradientStops.Add(gs);//middle gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.49; brush.GradientStops.Add(gs);//middle c[left] = b; c[right] = a; gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.5; brush.GradientStops.Add(gs);//deep gs = new GradientStop(); gs.Offset=0.52; brush.GradientStops.Add(gs);//deep gs = new GradientStop(); c[left] = (int)(b / 0.2); c[right] = (int)(a / 0.2); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.53; brush.GradientStops.Add(gs);//lighgt gs = new GradientStop(); gs.Offset=1; gs.Color = Color.FromArgb((byte)0, (byte)c[0], (byte)c[1], (byte)c[2]); brush.GradientStops.Add(gs); //nothing citye.ellipse.Fill = brush; citye.line_brush.Color = Color.FromArgb((byte)175, (byte)c[0], (byte)c[1], (byte)c[2]); }
//set ellipse color at random public void set_citye_brushcolor(City_E city_e) { city_e.radialgradientbrush = new RadialGradientBrush(); // city_e.radialgradientbrush.GradientOrigin = new Point(0.5, 0.5); // city_e.radialgradientbrush.Center = new Point(0.5, 0.5); RadialGradientBrush brush = new RadialGradientBrush(); int []c={0,0,0}; double bili = random.NextDouble(); int paichu = random.Next(3); int left; int right; c[paichu] = 0; if (paichu == 0) { left = 1; right = 2; } else if (paichu == 1) { left = 0; right = 2; } else { left = 0; right = 1; } c[right] = (int)(255 * bili*0.2); c[left] = (int)(255 * 0.2); int a = c[right]; int b = c[left]; GradientStop gs=new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0; city_e.radialgradientbrush.GradientStops.Add(gs); //deep gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.6; city_e.radialgradientbrush.GradientStops.Add(gs);//deep c[right] = (int)(c[right] / 0.3); c[left] = (int)(c[left] / 0.3); gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.61; city_e.radialgradientbrush.GradientStops.Add(gs);//middle gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.69; city_e.radialgradientbrush.GradientStops.Add(gs);//middle c[left] = b; c[right] = a; gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.7; city_e.radialgradientbrush.GradientStops.Add(gs);//deep gs = new GradientStop(); gs.Offset=0.72; city_e.radialgradientbrush.GradientStops.Add(gs);//deep c[left] = (int)(b / 0.2); c[right] = (int)(a / 0.2); gs = new GradientStop(); gs.Color = Color.FromArgb((byte)255, (byte)c[0], (byte)c[1], (byte)c[2]); gs.Offset = 0.73; city_e.radialgradientbrush.GradientStops.Add(gs);//lighgt gs = new GradientStop(); gs.Offset=1; gs.Color = Color.FromArgb((byte)0, (byte)c[0], (byte)c[1], (byte)c[2]); city_e.radialgradientbrush.GradientStops.Add(gs); //nothing brush.GradientStops.Add(gs); city_e.ellipse.Fill = brush; city_e.line_brush.Color = Color.FromArgb((byte)10, (byte)c[0], (byte)c[1], (byte)c[2]); }
// set the city as if mouse down on it public int Control_Display_FindCityAsTargetCity(string city_name) { if (maincity_e.city_name.Equals(city_name)) return 0; if (moveanimation.isrunning == true) { moveanimation.stop_animation_CTN(); // biggersmalleranimation.stop_animation_bigger(); } if (last_citynumber >= 0) { cities_EL[last_citynumber].line_entity.StrokeThickness = 1.5; SolidColorBrush scb1 = cities_EL[last_citynumber].line_brush; cities_EL[last_citynumber].line_brush.Color = Color.FromArgb((byte)150, (byte)scb1.Color.R, (byte)scb1.Color.G, (byte)scb1.Color.B); cities_EL[last_citynumber].ellipse.Width = cities_EL[last_citynumber].r; cities_EL[last_citynumber].ellipse.Height = cities_EL[last_citynumber].r; cities_EL[last_citynumber].stop_twikling(); // cities_EL[last_citynumber]. } bu_change.disapear(); panel_info.disappear(); int i = 0; for (i = 0; i < cities_EL.Count; i++) { if (cities_EL[i].city_name.Equals(city_name)) break; } if (cities_EL[i].twinkling == 0) { cities_EL[i].start_twikling(); chosencity = cities_EL[i]; } if (bu_change.isShowing == false) { // bu_change.isShowing = true; bu_change.showbutton(cities_EL[i].x_center+40, cities_EL[i].y_center + 40); } if (panel_info.isShowing == false) { panel_info.update_message(cities_EL[i]); panel_info.show(cities_EL[i].x_center + 40, cities_EL[i].y_center - 80); } SolidColorBrush scb = cities_EL[i].line_brush; cities_EL[i].line_brush.Color = Color.FromArgb((byte)255, (byte)scb.Color.R, (byte)scb.Color.G, (byte)scb.Color.B); cities_EL[i].line_entity.StrokeThickness = 2.5; // cities_EL[i].ellipse.Width =cities_EL[i].r+10; // cities_EL[i].ellipse.Height = cities_EL[i].r + 10; last_citynumber = i; //set time circle time_circle.reset(maincity_e.x_center, maincity_e.y_center, position_compute.ratio_road, cities_EL[i].get_chosen_distance()); return 0; }
private void get_to_new_condition(City_E newmaincity) { List<City_E> Oldlist = cities_EL; maincity_e.is_centralcity = false; newmaincity.is_centralcity = true; // maincity_e = newmaincity; City_E oldmaincity=maincity_e; time_circle.tc_e.MouseLeftButtonDown -= tc_e_MouseLeftButtonDown; time_circle.tc_e.MouseMove -= ellipse_MouseMove; time_circle.tc_e.MouseLeftButtonUp -= ellipse_MouseLeftButtonUp; canvas1.MouseWheel-= canvas1_MouseWheel; canvas1.MouseLeftButtonDown -= canvas1_MouseLeftButtonDown; canvas1.MouseMove -= canvas1_MouseMove; canvas1.MouseLeftButtonUp -= canvas1_MouseLeftButtonUp; bu_change.button.Click -= changebutton_MouseLeftButtonDown; for (int i = 0; i < cities_EL.Count; i++) { // if (cities_EL[i] != chosencity) { canvas1.Children.Remove(cities_EL[i].ellipse); canvas1.Children.Remove(cities_EL[i].line_entity); canvas1.Children.Remove(cities_EL[i].textblock); cities_EL[i].ellipse.MouseEnter -= city_e_MouseEnter; cities_EL[i].ellipse.MouseLeave -= ellipse_e_MouseLeave; cities_EL[i].ellipse.MouseLeftButtonDown -= ellipse_MouseLeftButtonDown; cities_EL[i].ellipse.MouseMove -= ellipse_MouseMove; cities_EL[i].ellipse.MouseLeftButtonUp -= ellipse_MouseLeftButtonUp; } } cities_EL = new List<City_E>(); position_compute.angle_set = 0; position_compute.now_set_color_number = 0; for (int i = 0; i < Oldlist.Count; i++) { cities_EL.Add(Oldlist[i]); if (cities_EL[i].is_centralcity == true)//set new maincity maincity_e = cities_EL[i]; // cities_EL[i].create_linetomaincity(10, 10, canvas1); cities_EL[i].create_ellipse_oncavas(canvas1, cities_EL[i].x_center, cities_EL[i].y_center); position_compute.set_ellipse_fillbrushcolor(cities_EL[i]); } //animation sb = new Storyboard(); maincity_e.addellipse_to_storyBoard(sb, oldmaincity.x_center, oldmaincity.y_center); sb.Begin(); //make the maincity to center for (int i = 0; i < cities_EL.Count; i++) { random_set_citytime_value(cities_EL[i]); } cities_EL.Reverse(); Storyboard sb1 = new Storyboard(); position_compute.angle_set = 0; position_compute.cities_number = cities_EL.Count; for (int i = 0; i < cities_EL.Count; i++) { if (cities_EL[i] != maincity_e) { double angle1 = position_compute.angle_compute(); cities_EL[i].angle_remember = angle1; double dx1 = position_compute.compute_x_relatetomaincity(cities_EL[i].actual_distance[cities_EL[i].which_distance], maincity_e.x_center, angle1); double dy1 = position_compute.compute_Y_relateto_maincity(cities_EL[i].actual_distance[cities_EL[i].which_distance], maincity_e.y_center, angle1); cities_EL[i].angle_remember = angle1; cities_EL[i].addellipse_to_storyBoard(sb1, dx1, dy1); //cities_EL[i].set_line_position(maincity_e.x_center, maincity_e.y_center, dx1 + 12.5, dy1 + 12.5); } } sb1.BeginTime=TimeSpan.FromSeconds(0.65); sb1.Begin(); //set line Storyboard sb2 = new Storyboard(); for (int i = 0; i < cities_EL.Count; i++) { cities_EL[i].create_linetomaincity(maincity_e.x_center, maincity_e.y_center, canvas1); cities_EL[i].line_entity.X1 = maincity_e.x_center; cities_EL[i].line_entity.X2 = maincity_e.x_center; cities_EL[i].line_entity.Y1 = maincity_e.y_center; cities_EL[i].line_entity.Y2 = maincity_e.y_center; cities_EL[i].line_entity.Opacity=0; if(cities_EL[i].is_centralcity==false) cities_EL[i].set_line_position(maincity_e.x_center, maincity_e.y_center, cities_EL[i].x_center, cities_EL[i].y_center); cities_EL[i].ellipse.MouseEnter += new MouseEventHandler(city_e_MouseEnter); cities_EL[i].ellipse.MouseLeave += new MouseEventHandler(ellipse_e_MouseLeave); cities_EL[i].ellipse.MouseLeftButtonDown += new MouseButtonEventHandler(ellipse_MouseLeftButtonDown); cities_EL[i].ellipse.MouseMove += new MouseEventHandler(ellipse_MouseMove); cities_EL[i].ellipse.MouseLeftButtonUp += new MouseButtonEventHandler(ellipse_MouseLeftButtonUp); if(cities_EL[i]!=maincity_e) cities_EL[i].is_centralcity = false; cities_EL[i].add_line_storyboard(sb2); } sb2.BeginTime=TimeSpan.FromSeconds(1.4); sb2.Begin(); time_circle.tc_e.MouseLeftButtonDown += new MouseButtonEventHandler(tc_e_MouseLeftButtonDown); time_circle.tc_e.MouseMove += new MouseEventHandler(ellipse_MouseMove); time_circle.tc_e.MouseLeftButtonUp += new MouseButtonEventHandler(ellipse_MouseLeftButtonUp); canvas1.MouseWheel += new MouseWheelEventHandler(canvas1_MouseWheel); canvas1.MouseLeftButtonDown += new MouseButtonEventHandler(canvas1_MouseLeftButtonDown); canvas1.MouseMove += new MouseEventHandler(canvas1_MouseMove); canvas1.MouseLeftButtonUp += new MouseButtonEventHandler(canvas1_MouseLeftButtonUp); bu_change.button.Click += new RoutedEventHandler(changebutton_MouseLeftButtonDown); moveanimation.listtargetcities = cities_EL; moveanimation.target_circle = time_circle; canvas1.Children.Remove(panel_info.stackpanel); canvas1.Children.Remove(panel_info.stackpanel2); canvas1.Children.Add(panel_info.stackpanel); canvas1.Children.Add(panel_info.stackpanel2); showway_flag = 0; lineway_support.disappear(); panel_info.disappear(); bu_change.disapear(); }
void ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // Search_cityClient client = new Search_cityClient(); // client.search_cityCompleted += new EventHandler<search_cityCompletedEventArgs>(client_search_cityCompleted); // maincity_e.textblock.Text += "+"; // client.search_cityAsync("杭州", 52); // if (tempp == 52) // tempp = 5; // for (int u = 0; u < City_list.Count; u++) // { // maincity_e.textblock.Text += City_list[u].city_name; // } // Control_Display_Time(r23.Next(40)); if (moveanimation.isrunning == true) { moveanimation.stop_animation_CTN(); // biggersmalleranimation.stop_animation_bigger(); } ismousedown = true; ismousedownfromellipse = true; mouse_beginx = e.GetPosition(null).X; mouse_beginy = e.GetPosition(null).Y; int i=0; // first clean the last used city_entity if (maincity_e.ellipse != (sender as Ellipse)) { if (last_citynumber >= 0) { cities_EL[last_citynumber].line_entity.StrokeThickness = 1.5; SolidColorBrush scb1 = cities_EL[last_citynumber].line_brush; cities_EL[last_citynumber].line_brush.Color = Color.FromArgb((byte)150, (byte)scb1.Color.R, (byte)scb1.Color.G, (byte)scb1.Color.B); cities_EL[last_citynumber].ellipse.Width = cities_EL[last_citynumber].r; cities_EL[last_citynumber].ellipse.Height = cities_EL[last_citynumber].r; cities_EL[last_citynumber].stop_twikling(); // cities_EL[last_citynumber]. } bu_change.disapear(); panel_info.disappear(); for (i = 0; i < cities_EL.Count; i++) { if (cities_EL[i].ellipse == (sender as Ellipse)) break; } // biggersmalleranimation.stop_animation_bigger(); // client.search_cityAsync("上海",52); if (cities_EL[i].twinkling == 0) { cities_EL[i].start_twikling(); chosencity = cities_EL[i]; } if (bu_change.isShowing == false) { // bu_change.isShowing = true; bu_change.showbutton(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y + 20); } if (panel_info.isShowing == false) { panel_info.update_message(cities_EL[i]); panel_info.show(cities_EL[i].x_center +40, cities_EL[i].y_center -80); } SolidColorBrush scb = cities_EL[i].line_brush; cities_EL[i].line_brush.Color = Color.FromArgb((byte)255, (byte)scb.Color.R, (byte)scb.Color.G, (byte)scb.Color.B); cities_EL[i].line_entity.StrokeThickness = 2.5; // cities_EL[i].ellipse.Width =cities_EL[i].r+10; // cities_EL[i].ellipse.Height = cities_EL[i].r + 10; last_citynumber = i; //set time circle time_circle.reset(maincity_e.x_center, maincity_e.y_center, position_compute.ratio_road, cities_EL[i].get_chosen_distance()); } }
//void client_search_cityCompleted(object sender, search_cityCompletedEventArgs e) //{ // List<city_info> list = e.Result; // textBlock1.Text = list[0].city_name; //} private void Canvas_Loaded(object sender, RoutedEventArgs e) { cities_EL.Add(new City_E("上海", 1, 3.5, 2, 1)); cities_EL.Add(new City_E("南京", 1, 3.5, 1, 0.5)); cities_EL.Add(new City_E("江苏", 1, 2.5, 1, 0.5)); cities_EL.Add(new City_E("重庆", 1, 48, 30, 2)); String[] str_cityname = { "台北", "福州", "广州", "南宁", "南昌", "长沙", "武汉", "成都", "沈阳", "长春", "哈尔滨", "呼和浩特", "石家庄", "郑州", "香港", "澳门", "银川", "海口", "长春", "昆明", "兰州" }; Random ran=new Random(); for (int i = 4; i <= 24; i++) { cities_EL.Add(new City_E(str_cityname[i-4], 1,7+ran.Next(30), 19, 1)); } // set main city maincity_e = cities_EL[0]; maincity_e.is_centralcity = true; time_circle = new Time_circle(240, 200, canvas1); for (int i = 0; i < cities_EL.Count; i++) { //set line cities_EL[i].create_linetomaincity(10, 10, canvas1); cities_EL[i].create_ellipse_oncavas(canvas1, 240-i*20 , 200);//2 position_compute.set_ellipse_fillbrushcolor(cities_EL[i]); cities_EL[i].update(); cities_EL[i].ellipse.MouseEnter += new MouseEventHandler(city_e_MouseEnter); cities_EL[i].ellipse.MouseLeave += new MouseEventHandler(ellipse_e_MouseLeave); cities_EL[i].ellipse.MouseLeftButtonDown += new MouseButtonEventHandler(ellipse_MouseLeftButtonDown); cities_EL[i].ellipse.MouseMove += new MouseEventHandler(ellipse_MouseMove); cities_EL[i].ellipse.MouseLeftButtonUp += new MouseButtonEventHandler(ellipse_MouseLeftButtonUp); } for (int i = 1; i < cities_EL.Count; i++) { cities_EL[i].set_line_position(maincity_e.x_center, maincity_e.y_center, cities_EL[i].x_center, cities_EL[i].y_center); } double maincityx = (double)maincity_e.ellipse.RenderTransform.GetValue(TranslateTransform.XProperty) + maincity_e.ellipse.Width / 2; double maincityy = (double)maincity_e.ellipse.RenderTransform.GetValue(TranslateTransform.YProperty) + maincity_e.ellipse.Height / 2; sb=new Storyboard(); Random r1 = new Random(); //set animation for (int i = 1; i < cities_EL.Count; i++) { double angle1 = position_compute.angle_compute(); double dx1 = position_compute.compute_x_relatetomaincity(cities_EL[i].distance_road, maincityx, angle1); double dy1 = position_compute.compute_Y_relateto_maincity(cities_EL[i].distance_road, maincityy, angle1); cities_EL[i].angle_remember = angle1; cities_EL[i].addall_to_StoryBoard(sb, dx1, dy1, maincityx, maincityy); cities_EL[i].set_line_position(maincityx, maincityy, dx1 + 12.5,dy1+12.5); } sb.Begin(); time_circle.tc_e.MouseLeftButtonDown += new MouseButtonEventHandler(tc_e_MouseLeftButtonDown); time_circle.tc_e.MouseMove += new MouseEventHandler(ellipse_MouseMove); time_circle.tc_e.MouseLeftButtonUp += new MouseButtonEventHandler(ellipse_MouseLeftButtonUp); canvas1.MouseWheel += new MouseWheelEventHandler(canvas1_MouseWheel); canvas1.MouseLeftButtonDown += new MouseButtonEventHandler(canvas1_MouseLeftButtonDown); canvas1.MouseMove+=new MouseEventHandler(canvas1_MouseMove); canvas1.MouseLeftButtonUp+=new MouseButtonEventHandler(canvas1_MouseLeftButtonUp); bu_change = new button_change(canvas1); bu_change.button.Click += new RoutedEventHandler(changebutton_MouseLeftButtonDown); panel_info = new Panel_info(canvas1); moveanimation.create_a_thread(); biggersmalleranimation.create_a_thread(); moveanimation.listtargetcities = cities_EL; moveanimation.target_circle = time_circle; // moveanimation.lsp = lineway_support; tb_showway_oncanvas.Foreground = new SolidColorBrush(Colors.White); tb_showway_oncanvas.FontFamily = new System.Windows.Media.FontFamily("SimHei"); tb_showway_oncanvas.FontSize = 21; tb_showway_oncanvas.Text = "火车时间图"; canvas1.Children.Add(tb_showway_oncanvas); lineway_support = new LineWay_Support(); lineway_support.Create(maincity_e, canvas1); }
public void random_set_citytime_value(City_E acity) { // Random r = new Random(); acity.distance_road = r23.Next(30) + 2; acity.distance_railway = r23.Next(24) + 4; acity.distance_air = r23.Next(2) + 0.5; acity.update_chosendistance(); }
public void start_smaller_animation(City_E ce) { citye = ce; if (ischosenmethod == true && isrunning == false) { dispatchertimer.Tick += new EventHandler(dispatchertimer_Tick_Smaller); // target_time = time; running_time = 0; dispatchertimer.Start(); isrunning = true; } }
public void start_Bigger_animation(City_E ce) { if(biggerlock==0) citye = ce; if (ischosenmethod == true && isrunning == false&&biggerlock==0) { citye.ellipse.Width=citye.r; dispatchertimer.Tick += new EventHandler(dispatchertimer_Tick_Bigger); // target_time = time; running_time = 0; dispatchertimer.Start(); isrunning = true; biggerlock = 1; } }