﻿/*
        Copyright 2015 Verloka Vadim, http://ogy.pp.ua

        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
 */
using System;
using System.Windows.Controls;
using JPDeploy.assets.core;
using System.IO;

namespace JPDeploy.assets.pages.install
{
    public partial class installSelectFolder : Page
    {
        AppInstall App;
        public installSelectFolder(AppInstall App)
        {
            InitializeComponent();
            this.App = App;

            string path;
            if (String.IsNullOrWhiteSpace(this.App.Path))
            {
                path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                this.App.Path = path + "\\Ogy Code";
            }
            tbPath.Text = this.App.Path;
        }

        private void tbPathTextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (File.Exists(tbPath.Text))
                    App.Path = tbPath.Text;
            }
            catch { }
        }
    }
}
