179 lines
6.4 KiB
C#
179 lines
6.4 KiB
C#
using Plane.FormationCreator.Formation;
|
|
using Plane.FormationCreator.ViewModels;
|
|
using Microsoft.Practices.ServiceLocation;
|
|
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.Navigation;
|
|
using System.Windows.Shapes;
|
|
using Plane.Geography;
|
|
using Plane.FormationCreator.Util;
|
|
using System.Drawing;
|
|
|
|
namespace Plane.FormationCreator.Views
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ModifyTaskView.xaml
|
|
/// </summary>
|
|
|
|
public partial class ModifyTaskView : UserControl
|
|
{
|
|
private int[] defcolor= { 255, 65280, 16711680, 65535 , 16711935, 16776960,0 };
|
|
ModifyTaskViewModel _modifyTaskViewModel = ServiceLocator.Current.GetInstance<ModifyTaskViewModel>();
|
|
CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
|
|
|
private childItem FindVisualChild<childItem>(DependencyObject obj)
|
|
where childItem : DependencyObject
|
|
{
|
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
|
|
{
|
|
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
|
|
if (child != null && child is childItem)
|
|
{
|
|
return (childItem)child;
|
|
}
|
|
else
|
|
{
|
|
childItem childOfChild = FindVisualChild<childItem>(child);
|
|
if (childOfChild != null)
|
|
return childOfChild;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
public ModifyTaskView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.DataContext = _modifyTaskViewModel;
|
|
|
|
|
|
|
|
|
|
if (!VersionControl.IsFullVersion)
|
|
{
|
|
//lightDesign.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
/*
|
|
DependencyObject myListItem = LEDItems.ItemContainerGenerator.ContainerFromItem(LEDItems.Items.CurrentItem);
|
|
ContentPresenter myContentPresenter = FindVisualChild<ContentPresenter>(myListItem);
|
|
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
|
|
ComboBox ledcomb = (ComboBox)myDataTemplate.FindName("cmbTemplateLEDMode", myContentPresenter);
|
|
// ledcomb.SelectedIndex = 2;
|
|
*/
|
|
|
|
|
|
// distanceCopters.Text;
|
|
/*
|
|
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
|
|
|
int firstIndex = int.Parse( firstCopter.Text );
|
|
int secondIndex = int.Parse( secondCopter.Text );
|
|
|
|
if (_flightTaskManager.SelectedTask != null)
|
|
{
|
|
var firstCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos[firstIndex-1];
|
|
var secondCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos[secondIndex-1];
|
|
double distance = GeographyUtils.CalcDistance(firstCopterInfo.TargetLat, firstCopterInfo.TargetLng, firstCopterInfo.TargetAlt,
|
|
secondCopterInfo.TargetLat, secondCopterInfo.TargetLng, secondCopterInfo.TargetAlt);
|
|
|
|
distanceCopters.Text = ((double)Math.Round(distance*100)/100).ToString();
|
|
|
|
}
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnCBLoaded(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();
|
|
colorDialog.CustomColors = defcolor;
|
|
try
|
|
{
|
|
colorDialog.Color = ColorTranslator.FromHtml("#" + (sender as TextBox).Text);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
colorDialog.Color = System.Drawing.Color.White;
|
|
}
|
|
|
|
|
|
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
defcolor = colorDialog.CustomColors;
|
|
(sender as TextBox).Text = String.Format("{0:X2}", colorDialog.Color.R) +
|
|
String.Format("{0:X2}", colorDialog.Color.G) +
|
|
String.Format("{0:X2}", colorDialog.Color.B);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void cmbTemplateLEDMode_Initialized(object sender, EventArgs e)
|
|
{
|
|
int selind = 0;
|
|
ComboBox cb = (ComboBox)sender;
|
|
selind = cb.SelectedIndex;
|
|
cb.Items.Clear();
|
|
if (_copterManager.FC_VER_NO == 1)
|
|
{
|
|
cb.Items.Add("常亮"); //0
|
|
cb.Items.Add("同步闪烁(单色)"); //1
|
|
cb.Items.Add("异步闪烁(随机)"); //2
|
|
cb.Items.Add("渐亮"); //3
|
|
cb.Items.Add("渐暗"); //4
|
|
cb.Items.Add("呼吸灯(单色)"); //5
|
|
cb.Items.Add("同步闪烁(随机)"); //6
|
|
cb.Items.Add("异步闪烁(单色)"); //7
|
|
cb.Items.Add("拉烟"); //8
|
|
}
|
|
else
|
|
{
|
|
cb.Items.Add("常亮"); //0
|
|
cb.Items.Add("同步闪烁(单色)"); //1
|
|
cb.Items.Add("异步闪烁(随机)"); //2
|
|
cb.Items.Add("同步闪烁(随机)"); //3
|
|
cb.Items.Add("异步闪烁(单色)"); //4
|
|
cb.Items.Add("渐亮"); //5
|
|
cb.Items.Add("渐暗"); //6
|
|
cb.Items.Add("同步呼吸灯(单色)"); //7
|
|
cb.Items.Add("同步呼吸灯(随机色)"); //8
|
|
cb.Items.Add("异步呼吸(单色)"); //9
|
|
cb.Items.Add("异步呼吸(随机色)"); //10
|
|
cb.Items.Add("变色(单色)"); //11
|
|
cb.Items.Add("变色(随机)"); //12
|
|
cb.Items.Add("异步变色(单色)"); //13
|
|
cb.Items.Add("异步变色(随机)"); //14
|
|
cb.Items.Add("拉烟"); //15
|
|
}
|
|
cb.SelectedIndex = selind;
|
|
|
|
}
|
|
}
|
|
}
|