123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using SAGA.GplotDrawData;
- using SAGA.Models;
- namespace DrawData {
- /// <summary>
- /// WinDrawPipePoint.xaml 的交互逻辑
- /// </summary>
- public partial class WinDrawPipePoint : Window {
- public WinDrawPipePoint() {
- InitializeComponent();
- }
- public WinDrawPipePoint(List<Point> endPoints, List<List<Point>> endLineList) : this() {
- var minPoint = GetMinPoint(endPoints, endLineList);
- endPoints.ForEach(t=>
- this.panel.Children.Add(new Vertex(t.Mult(minPoint))));
- endLineList.ForEach(t=>
- {
- this.panel.Children.Add(
- new SgLine(t[0].Mult(minPoint), t[1].Mult(minPoint)));
- });
- //画点
- //画线
- }
- private Point GetMinPoint(List<Point> endPoints, List<List<Point>> endLineList) {
- //找出最下的X,Y,使之在最下点
- var minX1 = endPoints.Min(t => t.X);
- var minY1 = endPoints.Min(t => t.Y);
- var minX2 = endLineList.Min(t => t.Min(t1 => t1.X));
- var minY2 = endLineList.Min(t => t.Min(t1 => t1.Y));
- var minX = Math.Min(0, Math.Min(minX1, minX2));
- var minY = Math.Min(0, Math.Min(minY1, minY2));
- return new Point(minX-100, minY-100);
- }
- private void Canvas_OnMouseWheel(object sender, MouseWheelEventArgs e) {
- int delta = e.Delta;
- double sliderValue = this.slider.Value;
- double seed = this.slider.LargeChange;
- if (delta > 0) {
- //下滚
- sliderValue -= seed;
- }
- else {
- //上滚
- sliderValue += seed;
- }
- this.slider.Value = sliderValue;
- }
- private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
- scalTrans.ScaleX = this.slider.Value;
- scalTrans.ScaleY = this.slider.Value;
- }
- private void ButtonBase_OnClick(object sender, RoutedEventArgs e) {
- }
- private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) {
- }
- }
- }
|