Esempio n. 1
0
        protected void onBnFace2Remove(object sender, EventArgs e)
        {
            TreeSelection selection = treeviewFace2.Selection;
            TreeModel     model;
            TreeIter      iter;

            if (selection.CountSelectedRows() == 1)
            {
                TreePath tp     = selection.GetSelectedRows()[0];
                int      iPlace = tp.Indices[0];

                if (selection.GetSelected(out model, out iter))
                {
                    // get the face1 list
                    //

                    Dictionary <String, String>         cardDefinition = CardGeneratorDB.Instance.getRowFromTable(CardGeneratorDB.TABLECardDefinitions, "FaceCardName", _SelectedCardTypeName);
                    List <CardDefinitions.CardDefClass> face1          = CardDefinitions.faceCardStructureFromJSONString(cardDefinition["Face2"]);
                    face1.RemoveAt(iPlace);
                    String face1JSONString = CardDefinitions.JSONStringFromfaceCardStructure(face1);

                    CardGeneratorDB.Instance.updateRowField(CardGeneratorDB.TABLECardDefinitions, CardGeneratorDB.COLUMNCardDefinitionID, cardDefinition[CardGeneratorDB.COLUMNCardDefinitionID], "Face2", face1JSONString);

                    SelectCardType(_SelectedCardTypeName);
                }
            }
        }
Esempio n. 2
0
        private void SelectCardType(String strID)
        {
            Gtk.ListStore lsf1 = (Gtk.ListStore)treeviewFace1.Model;
            Gtk.ListStore lsf2 = (Gtk.ListStore)treeviewFace2.Model;
            lsf1.Clear();
            lsf2.Clear();
            _SelectedCardTypeName = strID;

            if (strID != null)
            {
                Dictionary <String, String>         cardDefinition = CardGeneratorDB.Instance.getRowFromTable(CardGeneratorDB.TABLECardDefinitions, "FaceCardName", strID);
                List <CardDefinitions.CardDefClass> face1          = CardDefinitions.faceCardStructureFromJSONString(cardDefinition["Face1"]);
                List <CardDefinitions.CardDefClass> face2          = CardDefinitions.faceCardStructureFromJSONString(cardDefinition["Face2"]);

                PopulateFaceTable(treeviewFace1, face1);
                PopulateFaceTable(treeviewFace2, face2);
            }
        }
Esempio n. 3
0
        protected void onBnFace2Add(object sender, EventArgs e)
        {
            DialogAddFaceData dialog = new DialogAddFaceData();

            if (dialog.Run() == (int)ResponseType.Ok)
            {
                Dictionary <String, String>         cardDefinition = CardGeneratorDB.Instance.getRowFromTable(CardGeneratorDB.TABLECardDefinitions, "FaceCardName", _SelectedCardTypeName);
                List <CardDefinitions.CardDefClass> face           = CardDefinitions.faceCardStructureFromJSONString(cardDefinition["Face2"]);

                CardDefinitions.CardDefClass newFaceDef = new CardDefinitions.CardDefClass();
                newFaceDef.COLUMNSOURCE = dialog.Column;
                newFaceDef.LANGUAGECODE = dialog.LanguageCode;
                newFaceDef.TYPE         = dialog.Voice;

                face.Add(newFaceDef);
                String faceJSONString = CardDefinitions.JSONStringFromfaceCardStructure(face);
                CardGeneratorDB.Instance.updateRowField(CardGeneratorDB.TABLECardDefinitions, CardGeneratorDB.COLUMNCardDefinitionID, cardDefinition[CardGeneratorDB.COLUMNCardDefinitionID], "Face2", faceJSONString);
                SelectCardType(_SelectedCardTypeName);
            }
            dialog.Destroy();
        }
Esempio n. 4
0
        public static String textFromKLEIOOutput()
        {
            StringWriter fileout = new StringWriter();

            List <Dictionary <String, String> > outputTable = CardGeneratorDB.Instance.getDataFromTable(CardGeneratorDB.TABLECardOutput);

            foreach (Dictionary <String, String> outputEntry in outputTable)
            {
                String CardDataID       = outputEntry[CardGeneratorDB.COLUMNCardDataID];
                String CardDefinitionID = outputEntry[CardGeneratorDB.COLUMNCardDefinitionID];


                // ("+COLUMNCardOutputID+" INTEGER NOT NULL, "+COLUMNCardDefinitionID+" INTEGER, "+COLUMNCardDataID+" INTEGER)",
                Dictionary <String, String> cardDefinition = CardGeneratorDB.Instance.getRowFromTable(CardGeneratorDB.TABLECardDefinitions, CardGeneratorDB.COLUMNCardDefinitionID, CardDefinitionID);
                Dictionary <String, String> cardData       = CardGeneratorDB.Instance.getRowFromTable(CardGeneratorDB.TABLECardData, CardGeneratorDB.COLUMNCardDataID, CardDataID);

                StringWriter faceOutput    = new StringWriter();
                int          iFace         = 1;
                bool         bFirstFaceRun = true;
                bool         bContinue     = true;
                while (bContinue)
                {
                    String faceColumn = "Face" + (iFace++);
                    if (cardDefinition.ContainsKey(faceColumn))
                    {
                        if (!bFirstFaceRun)
                        {
                            faceOutput.Write(",");
                        }
                        else
                        {
                            bFirstFaceRun = false;
                        }

                        String faceDefinition = cardDefinition[faceColumn];
                        List <CardDefinitions.CardDefClass> faceLanguages = CardDefinitions.faceCardStructureFromJSONString(faceDefinition);
                        bool bFirstRun = true;                         // first entry in a face

                        foreach (CardDefinitions.CardDefClass item in faceLanguages)
                        {
                            if (item.TYPE == false)
                            {
                                if (!bFirstRun)
                                {
                                    faceOutput.Write(" - ");
                                }
                                else
                                {
                                    bFirstRun = false;
                                }

                                if (item.TYPE == false)
                                {
                                    faceOutput.Write(cardData[item.COLUMNSOURCE]);
                                }
                                else
                                {
                                    // a sound, get the sound instead
                                    //String filename = AudioFiles.generateFilename(item.LANGUAGECODE, cardData[item.COLUMNSOURCE]);
                                    //faceOutput.Write("[sound:" + filename + "]");
                                }
                            }
                        }
                    }
                    else
                    {
                        bContinue = false;
                    }
                }

                String outLn = faceOutput.ToString();
                fileout.WriteLine(outLn);

                // ok, now build the faces from each
                // get faces data

                // DE-JSON into class data

                // build string for each JSON context
            }
            fileout.Close();

            return(fileout.ToString());
        }