public void  createCSVFromRows(DataGrid dt)
        {
            var items = dt.SelectedItems;

            csvBasketList.Clear();
            if (items != null)
            {
                foreach (var item in items)
                {
                    csvBasketList.Add((ArticleModel)item);
                }

                if (csvBasketList.Count > 0)
                {
                    SaveFileDialog svd = new SaveFileDialog();
                    svd.Filter = "CSV File|*.csv";
                    svd.Title  = "Save CSV File";
                    svd.ShowDialog();

                    List <ArticleModel> myCsvBasket = new List <ArticleModel>(csvBasketList);
                    CSVEditor.createCSVFromInventarList(myCsvBasket, svd.FileName, checkBoxes);
                    openGeneratedFile(svd.FileName);
                }
                else
                {
                    MessageBox.Show("CSV Basket is Empty");
                }
            }
        }
示例#2
0
 private static void Init()
 {
     if (!_instance)
     {
         _instance         = GetWindow <CSVEditor>();
         _instance.minSize = new Vector2(800, 600);
     }
 }
示例#3
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.LogError("Two same wondows : CSVEditor");
     }
 }
示例#4
0
        public void BaseCSVReadTest()
        {
            string filename = "./Resources/FL_insurance_sample.csv";

            CSVEditor CSVEdit = new CSVEditor();

            CSVEdit.ReadFile(filename);

            Assert.Equal(18, CSVEdit.CSVDT.Columns.Count);
            Assert.Equal(36635, CSVEdit.CSVDT.Rows.Count);
        }
示例#5
0
        public void JaggedCSVWriteTest()
        {
            string filename = "./Resources/JaggedCSV.csv";

            CSVEditor CSVEdit = new CSVEditor();

            CSVEdit.ReadFile(filename);

            Assert.Equal(4, CSVEdit.CSVDT.Columns.Count);
            Assert.Equal(3, CSVEdit.CSVDT.Rows.Count);
        }
示例#6
0
        private void cmdEditMachineNames_Click(object sender, EventArgs e)
        {
            CSVEditor csvEditor = new CSVEditor();

            csvEditor.Text            = "Machine names";
            csvEditor.ItemDescription = "Machine";
            csvEditor.CSVData         = txtMachines.Text;
            if (csvEditor.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txtMachines.Text = csvEditor.CSVData;
            }
        }
示例#7
0
        private void cmdEditColumnNames_Click(object sender, EventArgs e)
        {
            CSVEditor csvEditor = new CSVEditor();

            csvEditor.Text            = "Column names";
            csvEditor.ItemDescription = "Column";
            csvEditor.Sorted          = false;
            csvEditor.CSVData         = txtColumnNames.Text;
            if (csvEditor.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txtColumnNames.Text = csvEditor.CSVData;
            }
        }
示例#8
0
        private void cmdEditEventIds_Click(object sender, EventArgs e)
        {
            CSVEditor csvEditor = new CSVEditor();

            csvEditor.Sorted            = false;
            csvEditor.ClearTextOnUpdate = true;
            csvEditor.ValuesAreIntegers = true;
            csvEditor.CSVData           = txtEventIds.Text;

            if (csvEditor.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txtEventIds.Text = csvEditor.CSVData;
            }
        }
示例#9
0
        static void Main(string[] args)
        {
            string source = @"C:\Users\Nobel360\Desktop\leftovers.csv";

            //string source2 = @"C:\Users\Nobel360\Desktop\outgoing_btn.csv";
            //string dest = @"C:\Users\Nobel360\Desktop\leftovers.csv";
            //string dest2 = @"C:\Users\Nobel360\Desktop\outgoing_GBP.csv";
            //string dest = @"C:\Users\Nobel360\Desktop\bitcoin_in.csv";

            string dest  = @"C:\Users\Nobel360\Desktop\outgoing_leftovers_btn.csv";
            string dest2 = @"C:\Users\Nobel360\Desktop\outgoing_leftovers_gbp.csv";

            List <List <string> > outgoing_complete = CSVEditor.Read(source);

            CSVEditor.Write(dest, outgoing_complete.ToBTNList());
            CSVEditor.Write(dest2, outgoing_complete.ToGBPList());
        }
示例#10
0
        public void BaseCSVWriteTestWithQuotationMarks()
        {
            string    filename     = "./Resources/FL_insurance_sample.csv";
            string    destfilename = "./Resources/FL_insurance_sample3.csv";
            CSVEditor CSVEdit      = new CSVEditor();

            CSVEdit.ReadFile(filename);

            CSVEdit.WriteFile(destfilename, true);

            CSVEdit.ReadFile(destfilename);

            File.Delete(destfilename);

            Assert.Equal(18, CSVEdit.CSVDT.Columns.Count);
            Assert.Equal(36636, CSVEdit.CSVDT.Rows.Count);
        }
示例#11
0
    void OnGUI()
    {
        ///// Just in case
        if (instance == null)
        {
            Debug.Log("Was not initiate ");
            instance = this;
            if (aH == null && gM == null)
            {
                InitAllListString();
            }
        }
        /////
        if (GUILayout.Button("Load CSV from selected gameObject", GUILayout.Width(300)))
        {
            UpdateCSVInSelectedGameObject();
        }

        //add a browser button (or even a 3 sliders of : room -> objet -> interaction)
        if (GUILayout.Button("Browse/Create a CSV", GUILayout.Width(300)))
        {
            string[] filters     = { "Text", "txt" };
            string   pathRecover = EditorUtility.OpenFilePanelWithFilters("Choose a CSV file", BASIC_PATH, filters);
            if (pathRecover.EndsWith(".txt"))
            {
                //load all Room name, Zone name and Interaction name.
                InitAllListString();

                //Get the correct path name, from Path folder and without the ending (.txt here)
                int index = pathRecover.IndexOf(BASIC_PATH);
                pathToTreat = pathRecover.Remove(0, index + BASIC_PATH.Length);
                pathToTreat = pathToTreat.Remove(pathToTreat.Length - 4);
                //Finish the path to treat.
                //Now, we split it in three and test each one to see if they are correct name for the popup menu : Room/Zone/Interaction
                string[] folder = pathToTreat.Split('/');
                if (folder.Length == 3)
                {
                    CSVindexRoom = roomsName.IndexOf(folder[0]);
                    if (CSVindexRoom != -1)
                    {
                        CSVindexZone = zoneName[CSVindexRoom].IndexOf(folder[1]);
                        if (CSVindexZone != -1)
                        {
                            CSVindexInter = interName[CSVindexRoom][CSVindexZone].IndexOf(folder[2]);
                            if (CSVindexInter != -1)
                            {
                                //Technically, they already set correctly all value
                            }
                            else
                            {
                                Debug.Log("No interaction with this name");
                                CSVindexInter = -1;
                            }
                        }
                        else
                        {
                            Debug.Log("No zone with this name");
                            CSVindexZone  = -1;
                            CSVindexInter = -1;
                        }
                    }
                    else
                    {
                        Debug.Log("No room with this name");
                        CSVindexRoom  = -1;
                        CSVindexZone  = -1;
                        CSVindexInter = -1;
                    }
                }
                else
                {
                    Debug.Log("It's : " + folder.Length + " long.");
                    CSVindexRoom  = -1;
                    CSVindexZone  = -1;
                    CSVindexInter = -1;
                }
                //Now that we have the correct path, we load the CSV
                LoadCSV();
            }
            else
            {
                Debug.Log("Not with .txt at the end");
            }
        }

        if (pathToTreat == "")
        {
        }
        else
        {
            if (CSVindexRoom != -1 && CSVindexZone != -1 && CSVindexInter != -1)//index -1 mean that's a custom CSV // need to test the three separatly
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Path of current CSV : ");
                CSVindexRoom = EditorGUILayout.Popup(Mathf.Min(CSVindexRoom, roomsName.Count - 1),
                                                     roomsName.ToArray());
                CSVindexZone = EditorGUILayout.Popup(Mathf.Min(CSVindexZone, zoneName[CSVindexRoom].Count - 1),
                                                     zoneName[CSVindexRoom].ToArray());
                CSVindexInter = EditorGUILayout.Popup(Mathf.Min(CSVindexInter, interName[CSVindexRoom][CSVindexZone].Count - 1),
                                                      interName[CSVindexRoom][CSVindexZone].ToArray());
                if (GUILayout.Button("Change for this CSV"))
                {
                    //update the path
                    pathToTreat = roomsName[CSVindexRoom] + "/" + zoneName[CSVindexRoom][CSVindexZone] + "/" + interName[CSVindexRoom][CSVindexZone][CSVindexInter];
                    //load that path
                    LoadCSV();//create it if it don't existe now ? no weird...
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.LabelField(" ");
            }
            else
            {
                //If room//inter
                EditorGUILayout.LabelField("Path of current CSV : " + pathToTreat);
            }

            EditorGUILayout.LabelField("Step list : ");

            stepIndex      = 0;
            listeOfCondYes = new List <int>();
            listeOfCondNo  = new List <int>();
            foreach (Step s in stepList)
            {
                LayoutForType(s);
            }
            if (stepToRemove != null)
            {
                stepList.Remove(stepToRemove);
            }

            EditorGUILayout.LabelField(" ");
            EditorGUILayout.LabelField("Edit list : ", GUILayout.Width(300));

            if (GUILayout.Button("Add", GUILayout.Width(300)))
            {
                Step newStep = new Step();
                stepList.Add(newStep);
            }
            //button : add a step, remove a step, reorder a step
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Swap"))
            {
                Step toSwap = stepList[swapIndex];
                stepList.RemoveAt(swapIndex);
                stepList.Insert(switchIndex, toSwap);
            }
            swapIndex   = EditorGUILayout.IntField(swapIndex);
            switchIndex = EditorGUILayout.IntField(switchIndex);
            EditorGUILayout.EndHorizontal();


            //save the CSV
            if (GUILayout.Button("Save/Update the CSV file", GUILayout.Width(300)))
            {
                UpdateCSV();
            }

            if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKey(KeyCode.S))
            {
                UpdateCSV();
            }
            if (displayFrame != 0)
            {
                EditorGUILayout.LabelField("Saved this CSV");
                displayFrame--;
            }
        }
        //end of "if path is empty"
    }