private void nextBtn_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(aircraftConfigCodeTextBox.Text))
     {
         MessageBox.Show(Messages.WARNING_ENTER_AIRCRAFT_CONFIG_CODE, Captions.WARNING);
         return;
     }
     if (string.IsNullOrEmpty(aircraftConfigNameTextBox.Text))
     {
         MessageBox.Show(Messages.WARNING_ENTER_AIRCRAFT_CONFIG_NAME, Captions.WARNING);
         return;
     }
     if (Status == STATUS.NEW)
     {
         AircraftConfiguration = new AircraftConfiguration();
     }
     AircraftConfiguration.AircraftConfigurationCode = aircraftConfigCodeTextBox.Text;
     AircraftConfiguration.AircraftConfigurationName = aircraftConfigNameTextBox.Text;
     AircraftConfiguration.AirlineCode  = Application.Current.Resources["AirlineCode"].ToString();
     AircraftConfiguration.AircraftType = new AircraftType
     {
         AircraftTypeCode = aircraftTypeComboBox.SelectedValue.ToString()
     };
     AircraftConfiguration.StatusCode = statusComboBox.SelectedValue.ToString();
     (window as NewEditAircraftConfigurationWindow).mainFrame.Navigate(
         new NewEditAircraftConfigurationPage2(AircraftConfiguration, Status));
 }
        public void OnAircraftConfigurationInfoReceived(object sender, NetworkDataReceivedEventArgs e)
        {
            AircraftConfigurationInfo info;

            try
            {
                info = AircraftConfigurationInfo.FromJson(e.Data);
            }
            catch
            {
                return;
            }
            if (info.Request.HasValue)
            {
                switch (info.Request.Value)
                {
                case AircraftConfigurationInfo.RequestType.Full:
                {
                    AircraftConfiguration cfg = AircraftConfiguration.FromUserAircraftData(UserAircraftData);
                    cfg.IsFullData = true;
                    mFsdManager.SendAircraftConfiguration(e.From, cfg);
                    break;
                }
                }
            }
        }
Exemple #3
0
 public void SetConfiguration(AircraftConfiguration aircraftConfig)
 {
     if (GetComponentInChildren <AircraftManager>())
     {
         GetComponentInChildren <AircraftManager>().SetWeapons(aircraftConfig.weapons);
     }
     this.aircraftConfig = aircraftConfig;
 }
Exemple #4
0
 public NewEditAircraftConfigurationPage2(AircraftConfiguration aircraftConfiguration, STATUS Status)
 {
     InitializeComponent();
     this.Status = Status;
     if (aircraftConfiguration != null)
     {
         AircraftConfiguration = aircraftConfiguration;
     }
 }
    public AircraftConfiguration getConfig()
    {
        var config = new AircraftConfiguration();

        config.weapons    = new string[2];
        config.weapons[0] = weapon1.WeaponSelected();
        config.weapons[1] = weapon2.WeaponSelected();
        return(config);
    }
        private async void DoSearch()
        {
            string aircraftConfigCode = aircraftConfigCodeTextBox.Text;
            string aircraftConfigName = aircraftConfigNameTextBox.Text;
            string status             = statusComboBox.SelectedValue.ToString();
            string aircraftTypeCode   = aircraftTypeComboBox.SelectedValue.ToString();

            DataList list = await dbCon.GetDataList("AircraftConfiguration", null,
                                                    string.Format("WHERE AircraftConfigurationCode LIKE '%{0}%' AND AircraftConfigurationName LIKE '%{1}%' AND StatusCode LIKE '%{2}%' AND AircraftTypeCode LIKE '%{3}%' COLLATE SQL_Latin1_General_CP1_CI_AS ORDER BY AircraftTypeCode",
                                                                  aircraftConfigCode, aircraftConfigName, status, aircraftTypeCode));

            if (list.HasData && list.Error == ERROR.NoError)
            {
                List <AircraftConfiguration> _itemSource = new List <AircraftConfiguration>();
                foreach (DataRow row in list)
                {
                    AircraftConfiguration aircraftConfiguration = new AircraftConfiguration
                    {
                        AircraftConfigurationId   = (Guid)row.Get("AircraftConfigurationId"),
                        AirlineCode               = row.Get("AirlineCode").ToString(),
                        AircraftConfigurationCode = row.Get("AircraftConfigurationCode").ToString(),
                        AircraftConfigurationName = row.Get("AircraftConfigurationName").ToString(),
                        AisleX                = (double)row.Get("AisleX"),
                        FrontDoorX            = (double)row.Get("FrontDoorX"),
                        FrontDoorY            = (double)row.Get("FrontDoorY"),
                        RearDoorX             = (double)row.Get("RearDoorX"),
                        RearDoorY             = (double)row.Get("RearDoorY"),
                        FrontDoorBoardingFlag = (bool)row.Get("FrontDoorBoardingFlag"),
                        RearDoorBoardingFlag  = (bool)row.Get("RearDoorBoardingFlag"),
                        StatusCode            = row.Get("StatusCode").ToString()
                    };
                    DataRow aircraftTypeData = await dbCon.GetDataRow("AircraftTypeReference", new DataRow("AircraftTypeCode", row.Get("AircraftTypeCode")));

                    if (aircraftTypeData.HasData && aircraftTypeData.Error == ERROR.NoError)
                    {
                        AircraftType aircraftType = new AircraftType
                        {
                            AircraftTypeCode = aircraftTypeData.Get("AircraftTypeCode").ToString(),
                            AircraftTypeName = aircraftTypeData.Get("AircraftTypeName").ToString(),
                            StatusCode       = aircraftTypeData.Get("StatusCode").ToString()
                        };
                        aircraftConfiguration.AircraftType = aircraftType;
                    }
                    _itemSource.Add(aircraftConfiguration);
                }
                aircraftConfigDataGrid.ItemsSource = _itemSource;
            }
            else
            {
                aircraftConfigDataGrid.ItemsSource   = null;
                aircraftConfigDataGrid.SelectedIndex = -1;
            }
        }
 public void SendIncrementalAircraftConfigurationUpdate(AircraftConfiguration config)
 {
     if (FSD.Connected)
     {
         AircraftConfigurationInfo aircraftConfigurationInfo = new AircraftConfigurationInfo
         {
             Config = config
         };
         FSD.SendPDU(new PDUClientQuery(OurCallsign, "@94836", ClientQueryType.AircraftConfiguration, new List <string>
         {
             aircraftConfigurationInfo.ToJson()
         }));
     }
 }
 public void SendAircraftConfiguration(string to, AircraftConfiguration config)
 {
     if (FSD.Connected)
     {
         AircraftConfigurationInfo aircraftConfigurationInfo = new AircraftConfigurationInfo
         {
             Config = config
         };
         FSD.SendPDU(new PDUClientQuery(OurCallsign, to, ClientQueryType.AircraftConfiguration, new List <string>
         {
             aircraftConfigurationInfo.ToJson()
         }));
     }
 }
        private void aircraftConfigDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGrid acDataGrid = sender as DataGrid;

            if (acDataGrid.SelectedIndex > -1)
            {
                AircraftConfiguration selectedItem = acDataGrid.SelectedItem as AircraftConfiguration;
                NewEditAircraftConfigurationWindow editACWindow = new NewEditAircraftConfigurationWindow(selectedItem.AircraftConfigurationId);
                editACWindow.ShowDialog();
                if (editACWindow.DialogResult.HasValue && editACWindow.DialogResult.Value)
                {
                    DoSearch();
                }
            }
        }
        public void OnUserAircraftDataUpdated(object sender, UserAircraftDataUpdatedEventArgs e)
        {
            if (UserAircraftData == null || !UserAircraftData.Equals(e.UserAircraftData))
            {
                UserAircraftData = e.UserAircraftData;
            }

            if ((mLastBroadcastConfig == null) || !mFsdManager.IsConnected)
            {
                mLastBroadcastConfig = AircraftConfiguration.FromUserAircraftData(UserAircraftData);
            }
            else if (mAcconfigAvailableTokens > 0)
            {
                AircraftConfiguration newCfg = AircraftConfiguration.FromUserAircraftData(UserAircraftData);
                if (!newCfg.Equals(mLastBroadcastConfig))
                {
                    AircraftConfiguration incremental = mLastBroadcastConfig.CreateIncremental(newCfg);
                    mFsdManager.SendIncrementalAircraftConfigurationUpdate(incremental);
                    mLastBroadcastConfig = newCfg;
                    mAcconfigAvailableTokens--;
                }
            }
            bool wasAirborne = mAirborne;

            mAirborne = !UserAircraftData.OnGround;
            if (mInitialAircraftDataReceived && !wasAirborne && mAirborne && !mConfig.SquawkingModeC && mConfig.AutoSquawkModeC)
            {
                var laminarB738 = new XPlaneConnector.DataRefElement
                {
                    DataRef = "laminar/B738/knob/transpoder_pos"
                };

                var laminarB738_Dn_Cmd = new XPlaneConnector.XPlaneCommand("laminar/B738/knob/transponder_mode_up", "");
                var laminarB738_Up_Cmd = new XPlaneConnector.XPlaneCommand("laminar/B738/knob/transponder_mode_up", "");

                SendXplaneCommand?.Invoke(this, new ClientEventArgs <XPlaneConnector.XPlaneCommand>(laminarB738_Up_Cmd));
                SetXplaneDataRefValue?.Invoke(this, new DataRefEventArgs(laminarB738, 3));
                SendXplaneCommand?.Invoke(this, new ClientEventArgs <XPlaneConnector.XPlaneCommand>(XPlaneConnector.Commands.TransponderTransponderAlt));
            }
            mInitialAircraftDataReceived = true;
        }
Exemple #11
0
    void SpawnAircraft(AircraftConfiguration config)
    {
        Time.timeScale = 1f;
        var aircraft = Instantiate(aircraftPrefab, transform.position, transform.rotation, transform);

        SetConfiguration(config);
        if (aircraftConfig.weapons != null)
        {
            aircraft.GetComponent <AircraftManager>().SetWeapons(aircraftConfig.weapons);
        }
        if (GetComponentInChildren <FollowCam>())
        {
            GetComponentInChildren <FollowCam>().target = aircraft.transform;
        }
        if (TerrainManager.singleton)
        {
            TerrainManager.singleton.playModeTransformToFollow = aircraft.transform;
        }
        Scores.UploadStart(Scores.username, UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
        SpawnGameUI();
    }
Exemple #12
0
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     AircraftConfiguration.Configuration(modelBuilder);
     AirportConfiguration.Configuration(modelBuilder);
     FlightConfiguration.Configuration(modelBuilder);
 }
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var window = this.window as NewEditAircraftConfigurationWindow;

            window.Top = SystemParameters.PrimaryScreenHeight / 2 - window.ActualHeight / 2;
            var aircraftTypeDataList = await dbCon.GetDataList("AircraftTypeReference", null,
                                                               "WHERE StatusCode = 'A' ORDER BY AircraftTypeCode");

            if (aircraftTypeDataList.HasData && aircraftTypeDataList.Error == ERROR.NoError)
            {
                foreach (DataRow row in aircraftTypeDataList)
                {
                    aircraftTypeComboBox.Items.Add(new CustomComboBoxItem
                    {
                        Text = string.Format("{0} - {1}", row.Get("AircraftTypeCode"),
                                             row.Get("AircraftTypeName")),
                        Value = row.Get("AircraftTypeCode").ToString()
                    });
                }
            }
            else
            {
                var result = MessageBox.Show(Messages.ERROR_AIRCRAFT_TYPE_NOTFOUND,
                                             Captions.NO_AIRCRAFT_TYPE_FOUND, MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    this.window.Hide();
                    var aircraftTypeWindow = new AircraftTypeWindow();
                    aircraftTypeWindow.ShowDialog();
                    this.window.Close();
                }
                else
                {
                    this.window.Close();
                }
            }

            statusComboBox.Items.Add(new CustomComboBoxItem {
                Text = "Active", Value = "A"
            });
            statusComboBox.Items.Add(new CustomComboBoxItem {
                Text = "Inactive", Value = "I"
            });

            if (Status == STATUS.NEW)
            {
                commitByStackPanel.Visibility   = Visibility.Collapsed;
                commitTimeStackPanel.Visibility = Visibility.Collapsed;
            }
            else
            {
                try
                {
                    var acData = await dbCon.GetDataRow("AircraftConfiguration",
                                                        new DataRow("AircraftConfigurationId", AircraftConfigId));

                    if (acData.HasData && acData.Error == ERROR.NoError)
                    {
                        AircraftConfiguration = new AircraftConfiguration();
                        var properties = AircraftConfiguration.GetType().GetProperties();
                        foreach (var property in properties)
                        {
                            if (acData.ContainKey(property.Name))
                            {
                                if (property.CanWrite)
                                {
                                    property.SetValue(AircraftConfiguration, acData.Get(property.Name), null);
                                }
                            }
                        }
                        var aircraftTypeData = await dbCon.GetDataRow("AircraftTypeReference",
                                                                      new DataRow("AircraftTypeCode", acData.Get("AircraftTypeCode")));

                        if (aircraftTypeData.HasData && aircraftTypeData.Error == ERROR.NoError)
                        {
                            var aircraftType = new AircraftType();
                            var atProps      = aircraftType.GetType().GetProperties();
                            foreach (var atProp in atProps)
                            {
                                if (atProp.CanWrite)
                                {
                                    atProp.SetValue(aircraftType, aircraftTypeData.Get(atProp.Name), null);
                                }
                            }
                            AircraftConfiguration.AircraftType = aircraftType;

                            aircraftConfigCodeTextBox.Text     = AircraftConfiguration.AircraftConfigurationCode;
                            aircraftConfigNameTextBox.Text     = AircraftConfiguration.AircraftConfigurationName;
                            aircraftTypeComboBox.SelectedValue = AircraftConfiguration.AircraftType.AircraftTypeCode;
                            statusComboBox.SelectedValue       = AircraftConfiguration.StatusCode;
                            commitByTextBlockValue.Text        =
                                await dbCon.GetFullNameFromUid(acData.Get("CommitBy").ToString());

                            commitTimeTextBlockValue.Text = acData.Get("CommitDateTime").ToString();
                        }
                        else
                        {
                            MessageBox.Show(Messages.ERROR_GET_AIRCRAFT_CONFIG, Captions.ERROR);
                            window.DialogResult = false;
                            window.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show(Messages.ERROR_GET_AIRCRAFT_CONFIG, Captions.ERROR);
                        window.DialogResult = false;
                        window.Close();
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    MessageBox.Show(Messages.ERROR_GET_AIRCRAFT_CONFIG, Captions.ERROR);
                    window.DialogResult = false;
                    window.Close();
                }
            }
            aircraftConfigCodeTextBox.Focus();
        }
        private void ProcessAircraftConfig(NetworkAircraft aircraft, AircraftConfiguration config)
        {
            NetworkAircraftConfig cfgInterop = new NetworkAircraftConfig
            {
                Callsign  = aircraft.Callsign,
                Timestamp = DateTime.Now
            };

            if (config.IsFullData.HasValue && config.IsFullData.Value)
            {
                config.EnsurePopulated();
                aircraft.SupportsConfigurationProtocol = true;
                aircraft.Configuration = config;
            }
            else
            {
                if (!aircraft.SupportsConfigurationProtocol || aircraft.Configuration == null)
                {
                    return;
                }
                aircraft.Configuration.ApplyIncremental(config);
            }

            if (!aircraft.InitialConfigurationSet)
            {
                if (aircraft.Configuration.Lights.StrobesOn.HasValue)
                {
                    cfgInterop.Lights.StrobesOn = aircraft.Configuration.Lights.StrobesOn.Value;
                }
                if (aircraft.Configuration.Lights.LandingOn.HasValue)
                {
                    cfgInterop.Lights.LandingOn = aircraft.Configuration.Lights.LandingOn.Value;
                }
                if (aircraft.Configuration.Lights.TaxiOn.HasValue)
                {
                    cfgInterop.Lights.TaxiOn = aircraft.Configuration.Lights.TaxiOn.Value;
                }
                if (aircraft.Configuration.Lights.BeaconOn.HasValue)
                {
                    cfgInterop.Lights.BeaconOn = aircraft.Configuration.Lights.BeaconOn.Value;
                }
                if (aircraft.Configuration.Lights.NavOn.HasValue)
                {
                    cfgInterop.Lights.NavOn = aircraft.Configuration.Lights.NavOn.Value;
                }
                if (aircraft.Configuration.OnGround.HasValue)
                {
                    cfgInterop.OnGround = aircraft.Configuration.OnGround.Value;
                }
                if (aircraft.Configuration.FlapsPercent.HasValue)
                {
                    cfgInterop.Flaps = aircraft.Configuration.FlapsPercent.Value / 100.0f;
                }
                if (aircraft.Configuration.GearDown.HasValue)
                {
                    cfgInterop.GearDown = aircraft.Configuration.GearDown.Value;
                }
                if (aircraft.Configuration.Engines.IsAnyEngineRunning)
                {
                    cfgInterop.EnginesOn = aircraft.Configuration.Engines.IsAnyEngineRunning;
                }
                if (aircraft.Configuration.SpoilersDeployed.HasValue)
                {
                    cfgInterop.SpoilersDeployed = aircraft.Configuration.SpoilersDeployed.Value;
                }
                aircraft.InitialConfigurationSet = true;
            }
            else
            {
                if (aircraft.LastAppliedConfiguration == null)
                {
                    aircraft.InitialConfigurationSet = false;
                    Console.WriteLine($"LastAppliedConfiguration null; Requesting full ACCONFIG for: {aircraft.Callsign}");
                    mFsdManager.RequestFullAircraftConfiguration(aircraft.Callsign);
                    return;
                }

                if (aircraft.Configuration.Lights.StrobesOn.HasValue && aircraft.Configuration.Lights.StrobesOn.Value != aircraft.LastAppliedConfiguration.Lights.StrobesOn.Value)
                {
                    cfgInterop.Lights.StrobesOn = aircraft.Configuration.Lights.StrobesOn.Value;
                }
                if (aircraft.Configuration.Lights.NavOn.HasValue && aircraft.Configuration.Lights.NavOn.Value != aircraft.LastAppliedConfiguration.Lights.NavOn.Value)
                {
                    cfgInterop.Lights.NavOn = aircraft.Configuration.Lights.NavOn.Value;
                }
                if (aircraft.Configuration.Lights.BeaconOn.HasValue && aircraft.Configuration.Lights.BeaconOn.Value != aircraft.LastAppliedConfiguration.Lights.BeaconOn.Value)
                {
                    cfgInterop.Lights.BeaconOn = aircraft.Configuration.Lights.BeaconOn.Value;
                }
                if (aircraft.Configuration.Lights.LandingOn.HasValue && aircraft.Configuration.Lights.LandingOn.Value != aircraft.LastAppliedConfiguration.Lights.LandingOn.Value)
                {
                    cfgInterop.Lights.LandingOn = aircraft.Configuration.Lights.LandingOn.Value;
                }
                if (aircraft.Configuration.Lights.TaxiOn.HasValue && aircraft.Configuration.Lights.TaxiOn.Value != aircraft.LastAppliedConfiguration.Lights.TaxiOn.Value)
                {
                    cfgInterop.Lights.TaxiOn = aircraft.Configuration.Lights.TaxiOn.Value;
                }
                if (aircraft.Configuration.GearDown.HasValue && aircraft.Configuration.GearDown.Value != aircraft.LastAppliedConfiguration.GearDown.Value)
                {
                    cfgInterop.GearDown = aircraft.Configuration.GearDown.Value;
                }
                if (aircraft.Configuration.OnGround.HasValue && aircraft.Configuration.OnGround.Value != aircraft.LastAppliedConfiguration.OnGround.Value)
                {
                    cfgInterop.OnGround = aircraft.Configuration.OnGround.Value;
                }
                if (aircraft.Configuration.FlapsPercent.HasValue && aircraft.Configuration.FlapsPercent.Value != aircraft.LastAppliedConfiguration.FlapsPercent.Value)
                {
                    cfgInterop.Flaps = aircraft.Configuration.FlapsPercent.Value / 100.0f;
                }
                if (aircraft.Configuration.SpoilersDeployed.HasValue && aircraft.Configuration.SpoilersDeployed.Value != aircraft.LastAppliedConfiguration.SpoilersDeployed.Value)
                {
                    cfgInterop.SpoilersDeployed = aircraft.Configuration.SpoilersDeployed.Value;
                }
                if (aircraft.Configuration.Engines.IsAnyEngineRunning != aircraft.LastAppliedConfiguration.Engines.IsAnyEngineRunning)
                {
                    cfgInterop.EnginesOn = aircraft.Configuration.Engines.IsAnyEngineRunning;
                }
            }
            aircraft.LastAppliedConfiguration = aircraft.Configuration.Clone();

            if (cfgInterop.HasConfig)
            {
                XplaneConnect xp = new XplaneConnect
                {
                    Type      = XplaneConnect.MessageType.SurfaceUpdate,
                    Timestamp = DateTime.Now,
                    Data      = cfgInterop
                };
                XPlaneEventPosted?.Invoke(this, new ClientEventArgs <string>(xp.ToJSON()));
                Console.WriteLine($"Sending ACCONFIG to the sim for: {aircraft.Callsign} - {xp.ToJSON()}");
            }
        }
Exemple #15
0
        private async Task LoadSeatMapImage()
        {
            DataRow aircraftConfigData = await dbCon.GetDataRow("AircraftConfiguration", new DataRow("AircraftConfigurationId", AircraftConfigurationId));

            if (aircraftConfigData.HasData && aircraftConfigData.Error == ERROR.NoError)
            {
                AircraftConfiguration = new AircraftConfiguration();
                PropertyInfo[] properties = typeof(AircraftConfiguration).GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    if (aircraftConfigData.ContainKey(property.Name))
                    {
                        property.SetValue(AircraftConfiguration, aircraftConfigData.Get(property.Name));
                    }
                }

                DataRow aircraftTypeData = await dbCon.GetDataRow("AircraftTypeReference", new DataRow("AircraftTypeCode", aircraftConfigData.Get("AircraftTypeCode")));

                if (aircraftTypeData.HasData && aircraftTypeData.Error == ERROR.NoError)
                {
                    AircraftType aircraftType = new AircraftType();
                    properties = typeof(AircraftType).GetProperties();
                    foreach (PropertyInfo property in properties)
                    {
                        if (aircraftTypeData.ContainKey(property.Name))
                        {
                            property.SetValue(aircraftType, aircraftTypeData.Get(property.Name));
                        }
                    }
                    AircraftConfiguration.AircraftType = aircraftType;
                }

                double AisleX         = AdjustRatio(AircraftConfiguration.AisleX);
                double FrontDoorX     = AdjustRatio(AircraftConfiguration.FrontDoorX);
                double FrontDoorY     = AdjustRatio(AircraftConfiguration.FrontDoorY, false);
                double FrontDoorWidth = AdjustRatio(AircraftConfiguration.FrontDoorWidth, false);

                double RearDoorX     = AdjustRatio(AircraftConfiguration.RearDoorX);
                double RearDoorY     = AdjustRatio(AircraftConfiguration.RearDoorY, false);
                double RearDoorWidth = AdjustRatio(AircraftConfiguration.RearDoorWidth, false);

                AircraftConfiguration.AisleX         = AisleX;
                AircraftConfiguration.FrontDoorX     = FrontDoorX;
                AircraftConfiguration.FrontDoorY     = FrontDoorY;
                AircraftConfiguration.FrontDoorWidth = FrontDoorWidth;

                AircraftConfiguration.RearDoorX     = RearDoorX;
                AircraftConfiguration.RearDoorY     = RearDoorY;
                AircraftConfiguration.RearDoorWidth = RearDoorWidth;

                seatMapImg.Source = aircraftConfigData.Get("SeatMapImage").BlobToSource();
                if (selectedSeat != null && FrontDoorUsingFlag && RearDoorUsingFlag)
                {
                    int selectedRow = int.Parse(selectedSeat.Split('_')[1]);
                    if (selectedRow < AircraftConfiguration.MiddleRow)
                    {
                        imageCanvas.LayoutTransform = new RotateTransform(180);
                    }
                }
                else if (FrontDoorUsingFlag)
                {
                    imageCanvas.LayoutTransform = new RotateTransform(180);
                }
            }
        }