public RoomManagementWindow(MainWindow parent, JsonBase json)
        {
            InitializeComponent();

            mParent = parent;
            this.json = json;

            tvRooms.ItemTemplateSelector = new A();
            tvRooms.ItemsSource = new List<JsonBase>() { json };
        }
예제 #2
0
        public RoomManagementWindow(MainWindow parent, JsonBase json)
        {
            InitializeComponent();

            mParent   = parent;
            this.json = json;

            tvRooms.ItemTemplateSelector = new A();
            tvRooms.ItemsSource          = new List <JsonBase>()
            {
                json
            };
        }
예제 #3
0
        private void BTNOpenJsonFromURL_Click(object sender, RoutedEventArgs e)
        {
            WindowWithStringResult w = new WindowWithStringResult(async(path) =>
            {
                var result = string.Empty;
                using (var webClient = new System.Net.WebClient())
                {
                    try
                    {
                        result = await webClient.DownloadStringTaskAsync(new Uri(path));
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Nepodarilo sa stiahnut json");
                        return;
                    }

                    if (!string.IsNullOrEmpty(result))
                    {
                        jsonBase = await Task.Factory.StartNew(() =>
                        {
                            JsonBase b;
                            try
                            {
                                b = JsonConvert.DeserializeObject <JsonBase>(result, settings);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Neplatny json");
                                return(null);
                            }
                            return(b);
                        });

                        TXTSkyboxpath.Text                  = jsonBase.SkyboxPath;
                        ButtonSaveFile.IsEnabled            = true;
                        ButtonManageDW.IsEnabled            = true;
                        ButtonAddInterior.IsEnabled         = true;
                        ButtonManageManufacturers.IsEnabled = true;
                        ButtonManageRooms.IsEnabled         = true;
                        BTNEditProducts.IsEnabled           = true;
                    }
                }
            });

            w.ShowDialog();
        }
예제 #4
0
        async void dialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            OpenFileDialog d = sender as OpenFileDialog;
            LabelOpenedFilName.Text = d.FileName;
            Stream stream = d.OpenFile();
            StreamReader sr = new StreamReader(stream);
            baseJson = await sr.ReadToEndAsync();

            sr.Close();

            jsonBase = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject<JsonBase>(baseJson, settings));

            TXTSkyboxpath.Text = jsonBase.SkyboxPath;
            ButtonSaveFile.IsEnabled = true;
            ButtonManageDW.IsEnabled = true;
            ButtonAddInterior.IsEnabled = true;
            ButtonManageManufacturers.IsEnabled = true;
            ButtonManageRooms.IsEnabled = true;
            BTNEditProducts.IsEnabled = true;
        }
예제 #5
0
        async void dialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            OpenFileDialog d = sender as OpenFileDialog;

            LabelOpenedFilName.Text = d.FileName;
            Stream       stream = d.OpenFile();
            StreamReader sr     = new StreamReader(stream);

            baseJson = await sr.ReadToEndAsync();

            sr.Close();

            jsonBase = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <JsonBase>(baseJson, settings));

            TXTSkyboxpath.Text                  = jsonBase.SkyboxPath;
            ButtonSaveFile.IsEnabled            = true;
            ButtonManageDW.IsEnabled            = true;
            ButtonAddInterior.IsEnabled         = true;
            ButtonManageManufacturers.IsEnabled = true;
            ButtonManageRooms.IsEnabled         = true;
            BTNEditProducts.IsEnabled           = true;
        }
예제 #6
0
        private bool IsValidJson(JsonBase json)
        {
            for (int i = json.elements.Count - 1; i >= 0; i--)
            {
                if (!IsValidRoom(json.elements[i]))
                {
                    MessageBoxResult mResult = MessageBox.Show(this, string.Format("Izba \"{0}\" nieje vytvorena spravne. Chcete tuto izbu vymazat ?", json.elements[i].uidisplayname), "Nespravna izba", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.Yes);
                    switch (mResult)
                    {
                    case MessageBoxResult.Yes:
                        json.elements.RemoveAt(i);
                        UpdateTree();
                        break;

                    case MessageBoxResult.No:
                        return(false);

                        break;
                    }
                }
            }
            return(true);
        }
 private bool IsValidJson(JsonBase json)
 {
     for (int i = json.elements.Count - 1; i >= 0; i-- )
     {
         if(!IsValidRoom(json.elements[i]))
         {
             MessageBoxResult mResult = MessageBox.Show(this, string.Format("Izba \"{0}\" nieje vytvorena spravne. Chcete tuto izbu vymazat ?", json.elements[i].uidisplayname), "Nespravna izba", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.Yes);
             switch(mResult)
             {
                 case MessageBoxResult.Yes:
                     json.elements.RemoveAt(i);
                     UpdateTree();
                     break;
                 case MessageBoxResult.No:
                     return false;
                     break;
             }
         }
     }
     return true;
 }
예제 #8
0
        private void BTNOpenJsonFromURL_Click(object sender, RoutedEventArgs e)
        {
            WindowWithStringResult w = new WindowWithStringResult(async (path) =>
            {
                var result = string.Empty;
                using (var webClient = new System.Net.WebClient())
                {
                    try
                    {
                        result = await webClient.DownloadStringTaskAsync(new Uri(path));
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Nepodarilo sa stiahnut json");
                        return;
                    }

                    if (!string.IsNullOrEmpty(result))
                    {
                        jsonBase = await Task.Factory.StartNew(() => 
                            {
                                JsonBase b;
                                try
                                {
                                    b = JsonConvert.DeserializeObject<JsonBase>(result, settings);
                                }
                                catch(Exception)
                                {
                                    MessageBox.Show("Neplatny json");
                                    return null;
                                }
                                return b;
                            });

                        TXTSkyboxpath.Text = jsonBase.SkyboxPath;
                        ButtonSaveFile.IsEnabled = true;
                        ButtonManageDW.IsEnabled = true;
                        ButtonAddInterior.IsEnabled = true;
                        ButtonManageManufacturers.IsEnabled = true;
                        ButtonManageRooms.IsEnabled = true;
                        BTNEditProducts.IsEnabled = true;
                    }
                }
            });
            w.ShowDialog();
        }