private void Grid_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(string))) { String theItem = e.Data.GetData(typeof(string)).ToString(); try { if (e.OriginalSource.ToString() == "System.Windows.Shapes.Ellipse") { var rec = (Ellipse)e.OriginalSource; LiteBrite dataCt = rec.DataContext as LiteBrite; var xPosition = dataCt.xPos; var yPosition = dataCt.yPos; LiteBrite newEllipse = new LiteBrite(theItem, dataCt.xPos, dataCt.yPos); mvm.AddList(newEllipse); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void NewFile(object obj) { ColorList.Clear(); for (int i = 0; i < 50; i++) { for (int j = 0; j < 50; j++) { LiteBrite f = new LiteBrite("WHITE", i, j); ColorList.Add(f); } } }
public MainViewModel() { OpenCommand = new RelayCommand(OpenFile); SaveCommand = new RelayCommand(SaveFile); NewCommand = new RelayCommand(NewFile); RandomCommand = new RelayCommand(RandomFile); AboutCommand = new RelayCommand(AboutFile); ColorList = new ObservableCollection <LiteBrite>(); for (int i = 0; i < 50; i++) { for (int j = 0; j < 50; j++) { LiteBrite f = new LiteBrite("White", i, j); ColorList.Add(f); } } }
private void OpenFile(object obj) { OpenFileDialog openDialog = new OpenFileDialog(); string CombinedPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\"); openDialog.InitialDirectory = System.IO.Path.GetFullPath(CombinedPath); if (openDialog.ShowDialog() == true) { fileName = openDialog.FileName; } string excelFile = fileName; try { using (var reader = new StreamReader(excelFile)) { List <string> listA = new List <string>(); List <string> listB = new List <string>(); while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); LiteBrite lb = new LiteBrite(); lb.Lcolor = values[0]; lb.xPos = Convert.ToInt32(values[1]); lb.yPos = Convert.ToInt32(values[2]); ColorList.Add(lb); } } } catch (Exception ex) { MessageBox.Show("Error occured: " + ex.Message); } }
private void RandomFile(object obj) { ColorList.Clear(); List <string> ranColorList = new List <string> { "Azure", "Gold", "Magenta", "Tan", "Violet", "Plum", "Maroon", "Red", "Orange", "Pink", "Yellow", "Blue", "Purple", "Green", "Brown", "Black", "Navy", "SkyBlue" }; Random rnd = new Random(); for (int i = 0; i < 50; i++) { for (int j = 0; j < 50; j++) { int randIndex = rnd.Next(ranColorList.Count()); string s = ranColorList.ElementAt(randIndex).ToString(); LiteBrite f = new LiteBrite(s, j, i); ColorList.Add(f); } } }
public void AddList(LiteBrite lb) { ColorList.Add(lb); }