private void MnuAppSaveNew_Click()
        {
            Microsoft.Win32.SaveFileDialog sXml = new Microsoft.Win32.SaveFileDialog();
            string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

            sXml.InitialDirectory = dir;
            sXml.Title            = "Select a folder for creating a new projectfile!";
            sXml.Filter           = "XML (*.xml)|*.xml";

            // pressed OK:
            if (sXml.ShowDialog() == true)
            {
                this._pfadKonfigurationsdatei = sXml.FileName.ToString();
            }

            //if (File.Exists(this.txtKonfigurationsdatei.Text))
            if (this._pfadKonfigurationsdatei != String.Empty)
            {
                // Create customer object based on Form values.
                FormularData formdata = this.FormData;//this.CreateFormularData();

                //Save form object to XML file using our ObjectXMLSerializer class...
                try
                {
                    ObjectXmlSerializer <FormularData> .Save(formdata, this._pfadKonfigurationsdatei);

                    this.Title = "Legend Generator 5.0 für ArcMap 10.0 - " + this._pfadKonfigurationsdatei;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to save formular data object!" + Environment.NewLine + Environment.NewLine + ex.Message,
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        //konstruktor:
        public SymbolDialog(FormularData formData)
        {
            this._isInitializing = true;

            this._formData = formData;
            InitializeComponent();
            this._isInitializing = false;
        }
    public static Dictionary <string, string> ConvertToDictionary(this FormularData formularData)
    {
        var dictionary = new Dictionary <string, string>();

        if (!string.IsNullOrEmpty(formularData.Item1))
        {
            dictionary.Add(nameof(formularData.Item1), formularData.Item1);
        }
        if (!string.IsNullOrEmpty(formularData.Item2))
        {
            dictionary.Add(nameof(formularData.Item2), formularData.Item2);
        }
        return(dictionary);
    }
Beispiel #4
0
        public static void FillFormToDataCollection()
        {
            try
            {
                // initialize metadata of DataGrid
                int iFormNr = 0;
                int iKey    = 0;

                // loop over the HTML form element to extract the input fields
                foreach (HtmlAgilityPack.HtmlNode HtmlFormNode in HtmlDocData.HtmlFormCollection)
                {
                    ++iFormNr;
                    ++iKey;
                    view.URLFormSubmitter.ChoosenForm.Items.Add(iFormNr);

                    string       sFormAction        = HtmlFormNode.Attributes["action"].Value;
                    FormularData actualFormularData = new FormularData(iFormNr, sFormAction, "", "", "");
                    HtmlDocData.FormExtractedData.Add(iKey, actualFormularData);

                    // extract data from the input tag
                    foreach (HtmlAgilityPack.HtmlNode InputNode in HtmlFormNode.SelectNodes(".//input"))
                    {
                        ++iKey;
                        string sInputType = "", sInputName = "", sInputValue = "";
                        if (InputNode.Attributes["type"] != null)
                        {
                            sInputType = InputNode.Attributes["type"].Value;
                        }
                        if (InputNode.Attributes["name"] != null)
                        {
                            sInputName = InputNode.Attributes["name"].Value;
                        }
                        if (InputNode.Attributes["value"] != null)
                        {
                            sInputValue = InputNode.Attributes["value"].Value;
                        }
                        //for each row create a new element to contain input node's values
                        FormularData actualFormularElements = new FormularData(iFormNr, "", sInputType, sInputName, sInputValue);
                        // add pair key - input values
                        HtmlDocData.FormExtractedData.Add(iKey, actualFormularElements);
                    }
                }
            }
            catch (Exception ex)
            {
                view.URLFormSubmitter.XMLFormularText.Text = ex.ToString();
            }
        }
        private void MnuAppLoad_Click()
        {
            Microsoft.Win32.OpenFileDialog oXml = new OpenFileDialog
            {
                Title  = "Select XML-ConfigFile",
                Filter = "XML (*.xml)|*.xml"
            };
            //oDlg.RestoreDirectory = true;
            string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

            oXml.InitialDirectory = dir;

            // Show open file dialog box
            Nullable <bool> result = oXml.ShowDialog();

            if (result == true)
            {
                this._pfadKonfigurationsdatei = oXml.FileName.ToString();
            }
            // Load the form object from the existing XML file (if any)...
            if (File.Exists(this._pfadKonfigurationsdatei) == true)
            {
                // Load the form object from the XML file using our custom class...
                FormularData formdata = ObjectXmlSerializer <FormularData> .Load(this._pfadKonfigurationsdatei);

                if (formdata == null)
                {
                    MessageBox.Show("Unable to load a formular data object from file '" + this._pfadKonfigurationsdatei + "'!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else  // Load form properties into form data...
                {
                    //this.LoadCustomerIntoForm(formdata);
                    this.FormData.DeepCopy(formdata);
                    //this.FormData = formdata;
                    this.Title = this._pfadKonfigurationsdatei;
                }
            }
            else
            {
                MessageBox.Show(this.CreateFileDoesNotExistMsg(), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void MnuAppSave_Click()
        {
            if (File.Exists(this._pfadKonfigurationsdatei) == true)
            {
                // Create form object based on Form values.
                FormularData formdata = this.FormData;// this.CreateFormularData();

                //Save form object to XML file using our ObjectXMLSerializer class...
                try
                {
                    ObjectXmlSerializer <FormularData> .Save(formdata, this._pfadKonfigurationsdatei);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to save formular data object!" + Environment.NewLine + Environment.NewLine + ex.Message,
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                this.MnuAppSaveNew_Click();
            }
        }