Пример #1
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     foreach (Panorama pano in Panoramas)
     {
         System.Drawing.Image img = System.Drawing.Image.FromFile(CurrentFolder + @"\" + pano.Name + ".jpg");
         pano.Height = img.Height;
         pano.Width  = img.Width;
         img.Dispose();
     }
     ConfigWriter.ConfigWrite(Panoramas);
 }
Пример #2
0
        public void button1_Click(object
                                  sender, EventArgs e) //OpenFolder
        {
            using (FolderBrowserDialog fbd = new FolderBrowserDialog())
            {
                fbd.SelectedPath = CurrentFolder;
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    Panoramas = new List <Panorama>();
                    Panoramas.Clear();
                    CurrentFolder = fbd.SelectedPath;
                    comboBox1.Items.Clear();
                    ConfigPath = System.IO.Path.Combine(CurrentFolder, "pano.cfg");
                    string ExistingConfig;
                    ExistingConfig = File.Exists(ConfigPath) ? File.ReadAllText(ConfigPath) : ""; //Read config file if Exists
                    if (ExistingConfig != "")
                    {
                        Panoramas = JsonMapper.ToObject <List <Panorama> >(ExistingConfig);
                    }                                  //Config Data to Object List if not empty
                    bool isNotEmpty = Panoramas.Any(); //is Panorama list not empty?

                    //MessageBox.Show(ConfigData[3].Name.ToString());
                    //MessageBox.Show(ConfigData.Exists(x => x.Name == "1.1").ToString());

                    //-----Fill The Objetc List-------->>>>>>>>>>>>>>>
                    foreach (string fileName in Directory.GetFiles(CurrentFolder, "*.jpg"))
                    {
                        if (isNotEmpty)
                        {
                            if (!Panoramas.Exists(x => x.Name == Path.GetFileNameWithoutExtension(fileName)))
                            {
                                Panoramas.Add(new Panorama
                                {
                                    Name    = Path.GetFileNameWithoutExtension(fileName),
                                    Buttons = new List <Buttons> {
                                    }
                                });
                            }
                        }
                        else
                        {
                            Panoramas.Add(new Panorama
                            {
                                Name    = Path.GetFileNameWithoutExtension(fileName),
                                Buttons = new List <Buttons> {
                                }
                            });
                        }
                    }

                    for (int i = 0; i < Panoramas.Count; i++)
                    {
                        if (!Array.Exists(Directory.GetFiles(CurrentFolder, "*.jpg"), element => element.Contains(Panoramas[i].Name)))
                        {
                            Panoramas.RemoveAll(x => x.Name == Panoramas[i].Name);
                            i = i - 1;
                        }
                    }
                    //-----Fill The Objetc List--------<<<<<<<<<<<<<<<

                    //-----Fill The Combobox and Listbox-------->>>>>>>>>>>>>>>
                    foreach (Panorama pano in Panoramas)
                    {
                        UpdateComboBox(pano.Name);
                    }
                    //-----Fill The Combobox and Listbox--------<<<<<<<<<<<<<<<
                    ConfigWriter.ConfigWrite(Panoramas);
                }
            }
        }