Пример #1
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            if (tableDialogs.SelectedItems == null || tableDialogs.SelectedItems.Length == 0)
            {
                return;
            }

            CategoryDataSet.CategoryRow row = ((CategoryDataSet.CategoryRow)tableDialogs.SelectedItems[0].Tag);

            DialogDataSet.DialogRow dialogRow;
            if (row == null)
            {
                dialogRow = GetDialogRowFromCategory(0);
            }
            else
            {
                dialogRow = GetDialogRowFromCategory(row.CategoryID);
            }

            OpenFileDialog fileDlg = new OpenFileDialog();

            fileDlg.Filter = StringTable.XmlFileDialogFilter;

            if (fileDlg.ShowDialog(this) == DialogResult.OK)
            {
                // Prüfen, ob es sich um einen Dialog handelt
                string xmlDialog    = File.ReadAllText(fileDlg.FileName);
                string errorMessage = "";

                if (!MainCDUserControl.IsHitbaseDialog(xmlDialog, ref errorMessage))
                {
                    MessageBox.Show(StringTable.NoHitbaseDialog, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                DialogTableAdapter ta = new DialogTableAdapter(dataBase);

                if (dialogRow == null)      // Neu
                {
                    DialogDataSet ds = new DialogDataSet();
                    dialogRow = ds.Dialog.AddDialogRow(row.CategoryID, xmlDialog);
                }
                else
                {
                    dialogRow.DialogXML = xmlDialog;
                }

                ta.Update(dialogRow);

                LoadDialogs();
                FillList();
            }
        }
        /// <summary>
        /// Speichert das Dialogdesign für die angegebene Kategorie.
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public bool SaveDialogDesign(int categoryId)
        {
            string dialog = GetXMLStringFromDialog();

            DialogDataSet      ds = new DialogDataSet();
            DialogTableAdapter dialogTableAdapter = new DialogTableAdapter(DataBase);

            dialogTableAdapter.FillByCategoryID(ds.Dialog, categoryId);

            if (ds.Dialog.Rows.Count == 0)      // Noch nicht vorhanden, also anlegen
            {
                ds.Dialog.AddDialogRow(categoryId, dialog);
            }
            else
            {
                ds.Dialog[0].DialogXML = dialog;
            }

            dialogTableAdapter.Update(ds.Dialog);
            return(true);
        }
        public bool OpenDialogDesign(int categoryId)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            Debug.WriteLine("1.: " + sw.ElapsedMilliseconds.ToString());
            DialogDataSet      ds = new DialogDataSet();
            DialogTableAdapter dialogTableAdapter = new DialogTableAdapter(DataBase);

            Debug.WriteLine("2.: " + sw.ElapsedMilliseconds.ToString());
            dialogTableAdapter.FillByCategoryID(ds.Dialog, categoryId);

            Debug.WriteLine("3.: " + sw.ElapsedMilliseconds.ToString());
            if (ds.Dialog.Rows.Count < 1)         // nichts gefunden
            {
                return(false);
            }

            Type[] extraTypes = new Type[] { typeof(Field) };
            //TODO_WPF!!!!!!!!!!!!!!!extraTypes[0] = typeof(TrackListColumn);
            XmlSerializer     bf                = new XmlSerializer(typeof(HitbaseDialogData), extraTypes);
            StringReader      xmlString         = new StringReader(ds.Dialog[0].DialogXML);
            HitbaseDialogData hitbaseDialogData = (HitbaseDialogData)bf.Deserialize(xmlString);

            xmlString.Close();

            Debug.WriteLine("4.: " + sw.ElapsedMilliseconds.ToString());
            ReadDialogFromDialogData(null, hitbaseDialogData);
            Debug.WriteLine("5.: " + sw.ElapsedMilliseconds.ToString());

            UpdateAllControls();
            Debug.WriteLine("6.: " + sw.ElapsedMilliseconds.ToString());

//TODO_WPF!!!!!!!!!!!!!            undoEngine.Initialize();

            return(true);
        }
Пример #4
0
        private void LoadDialogs()
        {
            dialogsDataset = new DialogDataSet();

            dialogTableAdapter.Fill(dialogsDataset.Dialog);
        }