using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.Security.Principal;
using System.Xml;
using Stentofon.AlphaCom.AlphaNet.Client;
using Stentofon.AlphaCom.Data.State;
namespace AV4._1_ClientTool.Dialogs1.Configurations
{
/*
* The IP Address and Port # are needed when creating an AlphaNetClient object. This AlphaNetClient
* construct takes the IP Address and Port# and after assigning them to global variables, those
* variables are used when performing a TCP Client Connect() call. It is at this point the connection
* is made between the API and the exchange.
*/
public partial class ServerConfigurations : Form
{
//private AlphaComState _stateStorage;
//private AlphaNetClient _alphaNetClient;
public ServerConfigurations()
{
InitializeComponent();
}
#region Text Field Display
// I am assuming this is the form load event
public void PopulateServerForm(object sender, EventArgs e)
{
// XElement.Load("File name with path") loads the XML file into myDoc
// File name without path, file gets place where the exe file is
// located, should be bin/debug in the project folder
XElement myDoc = XElement.Load("Config.xml");
// Fill the text boxes with the values from the XML file
IPaddressBox.Text = myDoc.Descendants("IPAddress").FirstOrDefault().Value;
IPportBox.Text = myDoc.Descendants("IPPort").FirstOrDefault().Value;
ConfigPathBox.Text = myDoc.Descendants("ConfigurationPath").FirstOrDefault().Value;
}
#endregion Text Field Display
#region Buttons
private void evOKPS1_Click(object sender, EventArgs e)
{//upon Ok button pressed stores IP Address and IP Port then closes window
string XmlFile = "Config.xml";
XElement myDoc = XElement.Load(XmlFile);
// Save the values to the XML file from the text boxes
myDoc.Descendants("IPAddress").FirstOrDefault().Value = IPaddressBox.Text;
myDoc.Descendants("IPPort").FirstOrDefault().Value = IPportBox.Text;
myDoc.Descendants("ConfigurationPath").FirstOrDefault().Value = ConfigPathBox.Text;
myDoc.Save(XmlFile);
this.Hide();
}
private void evApplyPS1_Click(object sender, EventArgs e)
{//instantly stores IP Address and IP Port but does not close window
//Store & Apply IPaddressBox, IPportBox, ConfigPathBox
string XmlFile = "Config.xml";
XElement myDoc = XElement.Load(XmlFile);
// Save the values to the XML file from the text boxes
myDoc.Descendants("IPAddress").FirstOrDefault().Value = IPaddressBox.Text;
myDoc.Descendants("IPPort").FirstOrDefault().Value = IPportBox.Text;
myDoc.Descendants("ConfigurationPath").FirstOrDefault().Value = ConfigPathBox.Text;
myDoc.Save(XmlFile);
}
private void evCancelPS1_Click(object sender, EventArgs e)
{//Closes the window without saving or editing information
this.Close();
}
#endregion Buttons
}
}
|