public frmMain() { XMLSettings.WriteDefaultSettings(); XMLSettings.ListenPort = ushort.Parse(XMLSettings.ReadValue("ListenPort")); XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen")); XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup")); XMLSettings.Password = XMLSettings.ReadValue("Password"); if (bool.Parse(XMLSettings.ReadValue("ShowToU"))) { using (var frm = new frmTermsOfUse()) { frm.ShowDialog(); } Thread.Sleep(300); } InitializeComponent(); this.Menu = mainMenu; lvwColumnSorter = new ListViewColumnSorter(); lstClients.ListViewItemSorter = lvwColumnSorter; ListViewExtensions.removeDots(lstClients); ListViewExtensions.changeTheme(lstClients); }
private void UpWorkpiece() { Models.ProductionPlan production = this.gridView.GetRow(this.gridView.FocusedRowHandle) as Models.ProductionPlan; //productionPlans.Add(production); if (m_xmlSettings == null) { m_xmlSettings = new XMLSettings(); m_xmlSettings.ReadXMLSettings(); } int result = opcClient.ReadDataFromOpcServer(m_xmlSettings.Count); if (!_isStop && result > 0) { this.gridView.SetRowCellValue(m_focusedRowHandle, "TotalNum", result); } _isStop = true; m_focusedRowHandle = this.gridView.FocusedRowHandle; opcClient.WriteDataToOpcServer(m_xmlSettings.Count, (ushort)0); opcClient.WriteDataToOpcServer(production); RunAsync(() => { ReadAsync(production.WorkpieceType, production.TotalNum, 0); }); }
public OpcClient() { xmlSettings = new XMLSettings(); m_productionInfoDao = new ProductionInfoDao(); m_statusInfoDao = new StatusInfoDao(); m_uaClient = new UaClient(); db203Site_KeyValue = new Dictionary <string, string>(); xmlSettings.ReadXMLSettings(); db203Site_KeyValue.Add("Heartbeat", xmlSettings.Heartbeat); db203Site_KeyValue.Add("WorkpieceType", xmlSettings.WorkpieceType); db203Site_KeyValue.Add("PrimerColor", xmlSettings.PrimerColor); db203Site_KeyValue.Add("PrimerCraft", xmlSettings.PrimerCraft); db203Site_KeyValue.Add("PrimerFirm", xmlSettings.PrimerFirm); db203Site_KeyValue.Add("PigmentedCoatingColor", xmlSettings.PigmentedCoatingColor); db203Site_KeyValue.Add("PigmentedCoatingCraft", xmlSettings.PigmentedCoatingCraft); db203Site_KeyValue.Add("PigmentedCoatingFirm", xmlSettings.PigmentedCoatingFirm); db203Site_KeyValue.Add("VarnishColor", xmlSettings.VarnishColor); db203Site_KeyValue.Add("VarnishCraft", xmlSettings.VarnishCraft); db203Site_KeyValue.Add("VarnishFirm", xmlSettings.VarnishFirm); db203Site_KeyValue.Add("BatchNo", xmlSettings.BatchNo); db203Site_KeyValue.Add("Receive_1", xmlSettings.Receive_1); db203Site_KeyValue.Add("Receive_2", xmlSettings.Receive_2); db203Site_KeyValue.Add("Receive_3", xmlSettings.Receive_3); db203Site_KeyValue.Add("Receive_4", xmlSettings.Receive_4); db203Site_KeyValue.Add("Receive_5", xmlSettings.Receive_5); db203Site_KeyValue.Add("Receive_6", xmlSettings.Receive_6); db203Site_KeyValue.Add("Receive_7", xmlSettings.Receive_7); db203Site_KeyValue.Add("Receive_8", xmlSettings.Receive_8); db203Site_KeyValue.Add("Receive_9", xmlSettings.Receive_9); db203Site_KeyValue.Add("Receive_10", xmlSettings.Receive_10); db203Site_KeyValue.Add("TotalNum", xmlSettings.TotalNum); //m_uaClient = new OpcUaClient.UaClient(); }
private void btnSave_Click(object sender, EventArgs e) { XMLSettings.WriteValue("ListenPort", ncPort.Value.ToString(CultureInfo.InvariantCulture)); XMLSettings.ListenPort = ushort.Parse(ncPort.Value.ToString(CultureInfo.InvariantCulture)); XMLSettings.WriteValue("AutoListen", chkAutoListen.Checked.ToString()); XMLSettings.AutoListen = chkAutoListen.Checked; XMLSettings.WriteValue("ShowPopup", chkPopup.Checked.ToString()); XMLSettings.ShowPopup = chkPopup.Checked; XMLSettings.WriteValue("Password", txtPassword.Text); XMLSettings.Password = txtPassword.Text; XMLSettings.WriteValue("UseUPnP", chkUseUpnp.Checked.ToString()); XMLSettings.UseUPnP = chkUseUpnp.Checked; XMLSettings.WriteValue("ShowToolTip", chkShowTooltip.Checked.ToString()); XMLSettings.ShowToolTip = chkShowTooltip.Checked; XMLSettings.WriteValue("EnableNoIPUpdater", chkNoIPIntegration.Checked.ToString()); XMLSettings.IntegrateNoIP = chkNoIPIntegration.Checked; XMLSettings.WriteValue("NoIPHost", txtNoIPHost.Text); XMLSettings.NoIPHost = txtNoIPHost.Text; XMLSettings.WriteValue("NoIPUsername", txtNoIPUser.Text); XMLSettings.NoIPUsername = txtNoIPUser.Text; XMLSettings.WriteValue("NoIPPassword", txtNoIPPass.Text); XMLSettings.NoIPPassword = txtNoIPPass.Text; this.Close(); }
public StationInfoControl3() { InitializeComponent(); opcClient = new OpcClient(); m_xmlSettings = new XMLSettings(); m_xmlSettings.ReadXMLSettings(); GetDataValue(); }
public LabelProductionInfoControl() { InitializeComponent(); _productionInfoDao = new ProductionInfoDao(); m_xmlSettings = new XMLSettings(); m_xmlSettings.ReadXMLSettings(); m_uaClient = new OpcClient(); //gridControl.DataSource = _productionInfoDao.GetDataSource(); }
public XmlLibrary(XMLSettings config) { Report = new ReportWriter(); AlbumArtists = new List<XmlAlbumArtist>(); Albums = new List<XmlAlbum>(); Discs = new List<XmlDisc>(); Tracks = new List<XmlTrack>(); Config = config; Worker.DoWork += Worker_DoWork; }
private void main_Load(object sender, EventArgs e) { txt_Action.Text = Logging.LogMessage("OnLoad::Start"); string sUserProfileSetupPath = AppSettings.App_Path() + "CustomModuleUserProfileSetup.xml"; txt_Action.Text = Logging.LogMessage("OnLoad::UserProfilePath, " + sUserProfileSetupPath); XMLSettings.LoadUserSettings(sUserProfileSetupPath); txt_Action.Text = Logging.LogMessage("OnLoad::LoginToRuntime"); g_oBatman.LoginToRuntime(); txt_Action.Text = Logging.LogMessage("OnLoad::ProcessesingBatch"); }
private void ReadSettings(bool writeIfNotExist = true) { if (writeIfNotExist) { XMLSettings.WriteDefaultSettings(); } XMLSettings.ListenPort = ushort.Parse(XMLSettings.ReadValue("ListenPort")); XMLSettings.ShowToU = bool.Parse(XMLSettings.ReadValue("ShowToU")); XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen")); XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup")); XMLSettings.UseUPnP = bool.Parse(XMLSettings.ReadValue("UseUPnP")); XMLSettings.Password = XMLSettings.ReadValue("Password"); }
private void btnBrowseRootDir_Click(object sender, EventArgs e) { string oldRootDir = txtRootFolder.Text; string dirNew = Adapter.GetDirPathUsingFolderBrowser("Configure Root directory..."); if (!string.IsNullOrEmpty(dirNew)) { Engine.SetRootFolder(dirNew); txtRootFolder.Text = Engine.ConfigApp.RootDir; FileSystem.MoveDirectory(oldRootDir, txtRootFolder.Text); ConfigurePaths(); Engine.ConfigUI = XMLSettings.Read(); Loader.MainForm.ZScreen_ConfigGUI(); } }
private void AppSettingsImport() { OpenFileDialog dlg = new OpenFileDialog { Filter = FILTER_XML_FILES, InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) }; if (dlg.ShowDialog() == DialogResult.OK) { XMLSettings temp = XMLSettings.Read(dlg.FileName); temp.FirstRun = false; Engine.ConfigUI = temp; Loader.MainForm.ZScreen_ConfigGUI(); } }
private void btnSave_Click(object sender, EventArgs e) { XMLSettings.WriteValue("ListenPort", ncPort.Value.ToString()); XMLSettings.ListenPort = ushort.Parse(ncPort.Value.ToString()); XMLSettings.WriteValue("AutoListen", chkAutoListen.Checked.ToString()); XMLSettings.AutoListen = chkAutoListen.Checked; XMLSettings.WriteValue("ShowPopup", chkPopup.Checked.ToString()); XMLSettings.ShowPopup = chkPopup.Checked; XMLSettings.WriteValue("Password", txtPassword.Text); XMLSettings.Password = txtPassword.Text; this.Close(); }
protected override void OnStart(string[] args) { timer.Start(); Logging.LogMessage("OnStart::Start"); Logging.WriteToEventLog("OnStart::Start"); string sUserProfileSetupPath = AppSettings.App_Path() + "CustomModuleUserProfileSetup.xml"; Logging.LogMessage("OnStart::UserProfilePath, " + sUserProfileSetupPath); Logging.WriteToEventLog("OnStart::UserProfilePath, " + sUserProfileSetupPath); XMLSettings.LoadUserSettings(sUserProfileSetupPath); Logging.LogMessage("OnStart::LoginToRuntime"); Logging.WriteToEventLog("OnStart::LoginToRuntime"); g_oBatman.LoginToRuntime(); }
public XMLAdapter(XMLFileSettings xmlFileSettings = null, XMLSettings xmlSettings = null) { if (xmlFileSettings == null) { BH.Engine.Reflection.Compute.RecordError("Please set the File Settings correctly to enable the XML Adapter to work correctly"); return; } _fileSettings = xmlFileSettings; _xmlSettings = xmlSettings; AdapterId = "XML_Adapter"; Config.MergeWithComparer = false; //Set to true after comparers have been implemented Config.ProcessInMemory = false; Config.SeparateProperties = false; //Set to true after Dependency types have been implemented Config.UseAdapterId = false; //Set to true when NextId method and id tagging has been implemented }
public static void Main(string[] args) { IReadInputProvider readInputProvider = new ConsoleInput(); ISendOutputProvider sendOutputProvider = new ConsoleOutput(); ITextMessagesProvider textMessagesProvider = new XMLTextMessages("eng.xml"); ISettingsProvider settingsProvider = new XMLSettings("settings.xml"); ICommands commands = new Commands(); ConsoleDrawing consoleDrawing = new ConsoleDrawing( readInputProvider: readInputProvider, sendOutputProvider: sendOutputProvider, textMessagesProvider: textMessagesProvider, settingsProvider: settingsProvider, commands: commands); consoleDrawing.Run(); }
private void ReadSettings(bool writeIfNotExist = true) { if (writeIfNotExist) { XMLSettings.WriteDefaultSettings(); } XMLSettings.ListenPort = ushort.Parse(XMLSettings.ReadValue("ListenPort")); XMLSettings.ShowToU = bool.Parse(XMLSettings.ReadValue("ShowToU")); XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen")); XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup")); XMLSettings.UseUPnP = bool.Parse(XMLSettings.ReadValue("UseUPnP")); XMLSettings.ShowToolTip = bool.Parse(!string.IsNullOrEmpty(XMLSettings.ReadValue("ShowToolTip")) ? XMLSettings.ReadValue("ShowToolTip") : "False"); //fallback XMLSettings.Password = XMLSettings.ReadValue("Password"); }
public Main() { g_oBatman = new BatchManager(); try { string sSetupXMLPath = AppSettings.App_Path() + AppSettings.App_Name() + "Setup.xml"; Logging.LogMessage("Constructor::SetupXMLPath, " + sSetupXMLPath); XMLSettings.LoadBaseSettings(sSetupXMLPath); XMLSettings.LoadDefaults(sSetupXMLPath); g_oBatman.NewBatchProcess += G_oBatman_NewBatchProcess; } catch (Exception ex) { // Unable to write to log when the error can not find the workingPath Logging.LogMessage(String.Format("Exception: {0}, occured in {1}: {2}", ex.InnerException, ex.TargetSite, ex.Message)); } InitializeComponent(); }
/// <summary> /// Updates the database XML /// </summary> /// <returns>Connection string</returns> public static void UpdateSettingsXML(XMLSettings defaultSetting) { string xmlFilePath = SettingsXMLFilePath(true); string settingsRootName = "Settings"; XDocument doc; if (File.Exists(xmlFilePath)) { try { doc = XDocument.Load(xmlFilePath); } catch //if xml file fails to load recreate it { File.Delete(xmlFilePath); doc = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement("Settings") ); } } else { doc = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement("Settings") ); } if (!doc.Root.Descendants().Any(obj => obj.Name == settingsRootName)) { doc.Root.Add(new XElement(settingsRootName, new XAttribute("Username", defaultSetting.Username) )); } else { XElement findDatabase = doc.Root.Descendants().FirstOrDefault(obj => obj.Name == settingsRootName); //dont need to check for null because we've already checked for any findDatabase.Attribute("Username").Value = defaultSetting.Username; } doc.Save(xmlFilePath); }
private void btnSave_Click(object sender, EventArgs e) { ushort port = GetPortSafe(); if (port == 0) { MessageBox.Show("Please enter a valid port > 0.", "Please enter a valid port", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } XMLSettings.WriteValue("ListenPort", port.ToString()); XMLSettings.ListenPort = port; XMLSettings.WriteValue("AutoListen", chkAutoListen.Checked.ToString()); XMLSettings.AutoListen = chkAutoListen.Checked; XMLSettings.WriteValue("ShowPopup", chkPopup.Checked.ToString()); XMLSettings.ShowPopup = chkPopup.Checked; XMLSettings.WriteValue("Password", txtPassword.Text); XMLSettings.Password = txtPassword.Text; XMLSettings.WriteValue("UseUPnP", chkUseUpnp.Checked.ToString()); XMLSettings.UseUPnP = chkUseUpnp.Checked; XMLSettings.WriteValue("ShowToolTip", chkShowTooltip.Checked.ToString()); XMLSettings.ShowToolTip = chkShowTooltip.Checked; XMLSettings.WriteValue("EnableNoIPUpdater", chkNoIPIntegration.Checked.ToString()); XMLSettings.IntegrateNoIP = chkNoIPIntegration.Checked; XMLSettings.WriteValue("NoIPHost", txtNoIPHost.Text); XMLSettings.NoIPHost = txtNoIPHost.Text; XMLSettings.WriteValue("NoIPUsername", txtNoIPUser.Text); XMLSettings.NoIPUsername = txtNoIPUser.Text; XMLSettings.WriteValue("NoIPPassword", txtNoIPPass.Text); XMLSettings.NoIPPassword = txtNoIPPass.Text; this.Close(); }
/// <summary> /// Runs every time a batch is processed, this is entry level of batch processesing /// </summary> /// <returns>true if successful</returns> private bool ProcessNewBatch() { g_oBatch = null; string sSetupXMLPath = AppSettings.App_Path() + AppSettings.App_Name() + "Setup.xml"; try { g_oActiveBatch = (Batch)g_oRuntimeSession.NextBatchGet(g_oLogin.ProcessID, Kofax.Capture.SDK.CustomModule.KfxDbFilter.KfxDbFilterOnProcess | Kofax.Capture.SDK.CustomModule.KfxDbFilter.KfxDbFilterOnStates, Kofax.Capture.SDK.CustomModule.KfxDbState.KfxDbBatchReady | Kofax.Capture.SDK.CustomModule.KfxDbState.KfxDbBatchSuspended); if (g_oActiveBatch != null) { g_oBatch = g_oActiveBatch; XMLSettings.LoadXMLSettings(sSetupXMLPath, g_oBatch.BatchClassName.Replace(" ", "")); NewBatchProcess?.Invoke(this, g_oBatch); if (AppSettings.IsService()) { Logging.WriteToEventLog("ActiveBatch::XMLExport, " + XMLSettings.g_sWorkingPath + "ActiveBatch.xml"); } Logging.LogMessage("ActiveBatch::XMLExport, " + XMLSettings.g_sWorkingPath + "ActiveBatch.xml"); g_oBatch.XMLExport(XMLSettings.g_sWorkingPath + "ActiveBatch.xml"); ProcessXMLBatchField(XMLSettings.g_sWorkingPath + "ActiveBatch.xml"); g_oBatch.XMLImport(XMLSettings.g_sWorkingPath + "ActiveBatch.xml"); File.Delete(XMLSettings.g_sWorkingPath + "ActiveBatch.xml"); if (AppSettings.IsService()) { Logging.WriteToEventLog("ProcessNewBatch::BatchClose"); } Logging.LogMessage("ProcessNewBatch::BatchClose"); CloseBatch(); return(true); } else { return(false); } } catch (Exception ex) { Logging.LogMessage("ProcessNewBatch::ERROR, an error occured: " + ex.Message); CloseBatchWithError(); return(false); } }
private void btn_apply_Click(object sender, EventArgs e) { string message = ""; bool validated = ValidateFields(out message); if (message != "" && validated == false) { MessageBox.Show(message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (message != "" && validated == true) { MessageBox.Show(message, "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!XMLSettings.XMLBatchClassElementExists(XMLPath, BatchClass.Name.Replace(" ", ""))) { XMLSettings.CreateNewBatchClassNodes(XMLPath, BatchClass.Name.Replace(" ", "")); } XMLSettings.SaveXMLSettings(XMLPath, BatchClass.Name.Replace(" ", ""), g_aNewMethodOrder, txt_shortdateformat.Text, txt_longdateformat.Text, txt_shorttimeformat.Text, txt_longtimeformat.Text, txt_localizationvalue.Text, txt_stringtoformat.Text, txt_formatteddate.Text, txt_formattedtime.Text, txt_targetdateformat.Text, txt_targettimeformat.Text, txt_usewaterfallformatter.Text, txt_usedistancerule.Text, txt_ruledays.Text, txt_distancerulefuture.Text); ApplyState(false); } else { if (!XMLSettings.XMLBatchClassElementExists(XMLPath, BatchClass.Name.Replace(" ", ""))) { XMLSettings.CreateNewBatchClassNodes(XMLPath, BatchClass.Name.Replace(" ", "")); } XMLSettings.SaveXMLSettings(XMLPath, BatchClass.Name.Replace(" ", ""), g_aNewMethodOrder, txt_shortdateformat.Text, txt_longdateformat.Text, txt_shorttimeformat.Text, txt_longtimeformat.Text, txt_localizationvalue.Text, txt_stringtoformat.Text, txt_formatteddate.Text, txt_formattedtime.Text, txt_targetdateformat.Text, txt_targettimeformat.Text, txt_usewaterfallformatter.Text, txt_usedistancerule.Text, txt_ruledays.Text, txt_distancerulefuture.Text); ApplyState(false); } }
private void ReadSettings(bool writeIfNotExist = true) { if (writeIfNotExist) { XMLSettings.WriteDefaultSettings(); } XMLSettings.ListenPort = ushort.Parse(XMLSettings.ReadValue("ListenPort")); XMLSettings.ShowToU = bool.Parse(XMLSettings.ReadValue("ShowToU")); XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen")); XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup")); XMLSettings.UseUPnP = bool.Parse(XMLSettings.ReadValue("UseUPnP")); XMLSettings.ShowToolTip = bool.Parse(XMLSettings.ReadValueSafe("ShowToolTip", "False")); XMLSettings.IntegrateNoIP = bool.Parse(XMLSettings.ReadValueSafe("EnableNoIPUpdater", "False")); XMLSettings.NoIPHost = XMLSettings.ReadValueSafe("NoIPHost"); XMLSettings.NoIPUsername = XMLSettings.ReadValueSafe("NoIPUsername"); XMLSettings.NoIPPassword = XMLSettings.ReadValueSafe("NoIPPassword"); XMLSettings.Password = XMLSettings.ReadValue("Password"); }
private void btnSave_Click(object sender, EventArgs e) { XMLSettings.WriteValue("ListenPort", ncPort.Value.ToString(CultureInfo.InvariantCulture)); XMLSettings.ListenPort = ushort.Parse(ncPort.Value.ToString(CultureInfo.InvariantCulture)); XMLSettings.WriteValue("AutoListen", chkAutoListen.Checked.ToString()); XMLSettings.AutoListen = chkAutoListen.Checked; XMLSettings.WriteValue("ShowPopup", chkPopup.Checked.ToString()); XMLSettings.ShowPopup = chkPopup.Checked; XMLSettings.WriteValue("Password", txtPassword.Text); XMLSettings.Password = txtPassword.Text; XMLSettings.WriteValue("UseUPnP", chkUseUpnp.Checked.ToString()); XMLSettings.UseUPnP = chkUseUpnp.Checked; XMLSettings.WriteValue("ShowToolTip", chkShowTooltip.Checked.ToString()); XMLSettings.ShowToolTip = chkShowTooltip.Checked; this.Close(); }
private void btn_verify_Click(object sender, EventArgs e) { if (XMLSettings.VerifyXMLStructure(XMLPath, BatchClass.Name.Replace(" ", ""), out string message)) { MessageBox.Show(message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DialogResult result = MessageBox.Show(message + "\n\nDo you want to reset all values to default?", "ERROR", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { result = MessageBox.Show("Are you sure you want to reset everything back to default?\n\nAll data will be wiped!", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { XMLSettings.ResetBatchClassValuesToDefault(XMLPath, BatchClass.Name.Replace(" ", "")); UpdateUI(); ApplyState(false); } } } }
public batchService() { g_oBatman = new BatchManager(); timer.Interval = 60000; timer.Elapsed += Timer_Elapsed;; timer.Enabled = true; try { string sSetupXMLPath = AppSettings.App_Path() + AppSettings.App_Name() + "Setup.xml"; Logging.LogMessage("Constructor::SetupXMLPath, " + sSetupXMLPath); Logging.WriteToEventLog("Constructor::SetupXMLPath, " + sSetupXMLPath); XMLSettings.LoadBaseSettings(sSetupXMLPath); XMLSettings.LoadDefaults(sSetupXMLPath); } catch (Exception ex) { Logging.WriteToEventLog(String.Format("Exception: {0}, occured in {1}: {2}", ex.InnerException, ex.TargetSite, ex.Message), "batchService", EventLogEntryType.Error); // Unable to write to log when the error can not find the workingPath //LogMessage(String.Format("Exception: {0}, occured in {1}: {2}", ex.InnerException, ex.TargetSite, ex.Message)); } InitializeComponent(); }
static void SettingsReader_DoWork(object sender, DoWorkEventArgs e) { Program.Config = XMLSettings.Read(ConfigCoreFilePath); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static void SerializeCollection(IEnumerable <IEnumerable <Panel> > inputElements, List <Level> levels, List <Panel> openings, BH.oM.XML.GBXML gbx, XMLSettings settings) { List <List <Panel> > elementsAsSpaces = new List <List <Panel> >(); foreach (IEnumerable <Panel> input in inputElements) { elementsAsSpaces.Add(input.ToList()); } List <Panel> uniqueBuildingElements = elementsAsSpaces.UniquePanels(); List <Panel> allElements = new List <Panel>(uniqueBuildingElements); allElements.AddRange(openings); //List<BH.oM.Environment.Elements.Space> spaces = elementsAsSpaces.Spaces(); List <Panel> usedBEs = new List <Panel>(); List <BH.oM.XML.Construction> usedConstructions = new List <BH.oM.XML.Construction>(); List <BH.oM.XML.Material> usedMaterials = new List <Material>(); List <BH.oM.XML.Layer> usedLayers = new List <Layer>(); List <string> usedSpaceNames = new List <string>(); List <BH.oM.XML.WindowType> usedWindows = new List <WindowType>(); foreach (List <Panel> space in elementsAsSpaces) { //For each collection of BuildingElements that define a space, convert the panels to XML surfaces and add to the GBXML List <Surface> spaceSurfaces = new List <Surface>(); for (int x = 0; x < space.Count; x++) { if (usedBEs.Where(i => i.BHoM_Guid == space[x].BHoM_Guid).FirstOrDefault() != null) { continue; } //Fix panel type //if(space[x].Type == PanelType.WallExternal && space[x].ConnectedSpaces.Count == 2) //space[x].Type = PanelType.WallInternal; BHP.OriginContextFragment envContextProperties = space[x].FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); List <List <Panel> > adjacentSpaces = BH.Engine.Environment.Query.AdjacentSpaces(space[x], elementsAsSpaces); Surface srf = space[x].ToGBXML(adjacentSpaces, space); srf.ID = "Panel-" + gbx.Campus.Surface.Count.ToString().Replace(" ", "").Replace("-", ""); srf.Name = "Panel" + gbx.Campus.Surface.Count.ToString().Replace(" ", "").Replace("-", ""); if (space[x] != null) { srf.CADObjectID = BH.Engine.XML.Query.CADObjectID(space[x], settings.ReplaceCurtainWalls); } if (settings.IncludeConstructions) { srf.ConstructionIDRef = (envContextProperties != null ? envContextProperties.TypeName.CleanName() : space[x].ConstructionID()); } else { srf.ConstructionIDRef = null; } if (settings.ReplaceCurtainWalls) { //If the surface is a basic Wall: SIM_EXT_GLZ so Curtain Wall after CADObjectID translation add the wall as an opening if (srf.CADObjectID.Contains("Curtain") && srf.CADObjectID.Contains("GLZ")) { List <BHG.Polyline> newOpeningBounds = new List <oM.Geometry.Polyline>(); if (space[x].Openings.Count > 0) { //This surface already has openings - cut them out of the new opening List <BHG.Polyline> refRegion = space[x].Openings.Where(y => y.Polyline() != null).ToList().Select(z => z.Polyline()).ToList(); newOpeningBounds.AddRange((new List <BHG.Polyline> { space[x].Polyline() }).BooleanDifference(refRegion, 0.01)); } else { newOpeningBounds.Add(space[x].Polyline()); } BH.oM.Environment.Elements.Opening curtainWallOpening = BH.Engine.Environment.Create.Opening(externalEdges: newOpeningBounds.ToEdges()); curtainWallOpening.Name = space[x].Name; BHP.OriginContextFragment curtainWallProperties = new BHP.OriginContextFragment(); if (envContextProperties != null) { curtainWallProperties.ElementID = envContextProperties.ElementID; curtainWallProperties.TypeName = envContextProperties.TypeName; } curtainWallOpening.Type = OpeningType.CurtainWall; curtainWallOpening.OpeningConstruction = space[x].Construction; curtainWallOpening.Fragments.Add(curtainWallProperties); space[x].Openings.Add(curtainWallOpening); //Update the host elements element type srf.SurfaceType = (adjacentSpaces.Count == 1 ? PanelType.WallExternal : PanelType.WallInternal).ToGBXML(); srf.ExposedToSun = BH.Engine.XML.Query.ExposedToSun(srf.SurfaceType).ToString().ToLower(); } } else { //Fix surface type for curtain walls if (space[x].Type == PanelType.CurtainWall) { srf.SurfaceType = (adjacentSpaces.Count == 1 ? PanelType.WallExternal : PanelType.WallInternal).ToGBXML(); srf.ExposedToSun = BH.Engine.XML.Query.ExposedToSun(srf.SurfaceType).ToString().ToLower(); } } if (settings.FixIncorrectAirTypes && space[x].Type == PanelType.Undefined && space[x].ConnectedSpaces.Count == 1) { //Fix external air types if (space[x].Tilt() == 0) { srf.SurfaceType = PanelType.Roof.ToGBXML(); } else if (space[x].Tilt() == 90) { srf.SurfaceType = PanelType.WallExternal.ToGBXML(); } else if (space[x].Tilt() == 180) { srf.SurfaceType = PanelType.SlabOnGrade.ToGBXML(); } } //Openings if (space[x].Openings.Count > 0) { srf.Opening = SerializeOpenings(space[x].Openings, space, allElements, elementsAsSpaces, gbx, settings).ToArray(); foreach (BH.oM.Environment.Elements.Opening o in space[x].Openings) { string nameCheck = ""; BHP.OriginContextFragment openingEnvContextProperties = o.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); if (openingEnvContextProperties != null) { nameCheck = openingEnvContextProperties.TypeName; } else if (o.OpeningConstruction != null) { nameCheck = o.OpeningConstruction.Name; } var t = usedWindows.Where(a => a.Name == nameCheck).FirstOrDefault(); if (t == null && o.OpeningConstruction != null) { usedWindows.Add(o.OpeningConstruction.ToGBXMLWindow(o)); } } } gbx.Campus.Surface.Add(srf); usedBEs.Add(space[x]); if (settings.IncludeConstructions && space[x].Construction != null) { BH.oM.XML.Construction conc = space[x].ToGBXMLConstruction(); BH.oM.XML.Construction test = usedConstructions.Where(y => y.ID == conc.ID).FirstOrDefault(); if (test == null) { List <BH.oM.XML.Material> materials = new List <Material>(); BHC.Construction construction = space[x].Construction as BHC.Construction; foreach (BHC.Layer l in construction.Layers) { materials.Add(l.ToGBXML()); } BH.oM.XML.Layer layer = materials.ToGBXML(); conc.LayerID.LayerIDRef = layer.ID; usedConstructions.Add(conc); if (usedLayers.Where(y => y.ID == layer.ID).FirstOrDefault() == null) { usedLayers.Add(layer); } foreach (BH.oM.XML.Material mat in materials) { if (usedMaterials.Where(y => y.ID == mat.ID).FirstOrDefault() == null) { usedMaterials.Add(mat); } } } } } BH.oM.XML.Space xmlSpace = new oM.XML.Space(); xmlSpace.Name = space.ConnectedSpaceName(); xmlSpace.ID = "Space" + xmlSpace.Name.Replace(" ", "").Replace("-", ""); xmlSpace.CADObjectID = BH.Engine.XML.Query.CADObjectID(space); xmlSpace.ShellGeometry.ClosedShell.PolyLoop = BH.Engine.XML.Query.ClosedShellGeometry(space).ToArray(); xmlSpace.ShellGeometry.ID = "SpaceShellGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10); xmlSpace.SpaceBoundary = BH.Engine.XML.Query.SpaceBoundaries(space, uniqueBuildingElements); xmlSpace.PlanarGeoemtry.ID = "SpacePlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10); if (BH.Engine.Environment.Query.FloorGeometry(space) != null) { xmlSpace.PlanarGeoemtry.PolyLoop = BH.Engine.XML.Convert.ToGBXML(BH.Engine.Environment.Query.FloorGeometry(space)); xmlSpace.Area = BH.Engine.Environment.Query.FloorGeometry(space).Area(); xmlSpace.Volume = space.Volume(); } Level spaceLevel = space.Level(levels); if (spaceLevel != null) { string levelName = ""; if (spaceLevel.Name == "") { levelName = spaceLevel.Elevation.ToString(); } else { levelName = spaceLevel.Name; } xmlSpace.BuildingStoreyIDRef = "Level-" + levelName.Replace(" ", "").ToLower(); } gbx.Campus.Building[0].Space.Add(xmlSpace); usedSpaceNames.Add(xmlSpace.Name); } //Reorder the spaces gbx.Campus.Building[0].Space = gbx.Campus.Building[0].Space.OrderBy(x => x.Name).ToList(); gbx.Construction = usedConstructions.ToArray(); gbx.Layer = usedLayers.ToArray(); gbx.Material = usedMaterials.ToArray(); if (settings.IncludeConstructions) { gbx.WindowType = usedWindows.ToArray(); } else //We have to force null otherwise WindowType will be created { gbx.WindowType = null; } //Set the building area List <Panel> floorElements = allElements.Where(x => x.Type == PanelType.Floor || x.Type == PanelType.FloorExposed || x.Type == PanelType.FloorInternal || x.Type == PanelType.FloorRaised || x.Type == PanelType.SlabOnGrade || x.Type == PanelType.UndergroundSlab).ToList(); double buildingFloorArea = 0; foreach (Panel be in floorElements) { buildingFloorArea += be.Area(); } gbx.Campus.Building[0].Area = buildingFloorArea; }
public static void SerializeCollection(IEnumerable <Panel> inputElements, List <Level> levels, List <Panel> openings, BH.oM.XML.GBXML gbx, XMLSettings settings) { List <List <Panel> > elementsAsSpaces = new List <List <Panel> >(); elementsAsSpaces.Add(inputElements.ToList()); SerializeCollection(elementsAsSpaces, levels, openings, gbx, settings); }
public static void SerializeCollection(IEnumerable <Panel> inputElements, BH.oM.XML.GBXML gbx, XMLSettings settings) { //For serializing shade elements List <Panel> buildingElements = inputElements.ToList(); List <BH.oM.XML.Construction> usedConstructions = new List <oM.XML.Construction>(gbx.Construction); List <BH.oM.XML.Material> usedMaterials = new List <Material>(gbx.Material); List <BH.oM.XML.Layer> usedLayers = new List <Layer>(gbx.Layer); foreach (Panel be in buildingElements) { Surface gbSrf = be.ToGBXML(); gbSrf.ID = "Panel-" + gbx.Campus.Surface.Count.ToString().Replace(" ", "").Replace("-", ""); gbSrf.Name = "Panel" + gbx.Campus.Surface.Count.ToString().Replace(" ", "").Replace("-", ""); gbSrf.SurfaceType = "Shade"; gbSrf.ExposedToSun = BH.Engine.XML.Query.ExposedToSun(gbSrf.SurfaceType).ToString().ToLower(); gbSrf.CADObjectID = be.CADObjectID(); if (settings.IncludeConstructions) { BHP.OriginContextFragment envContextProperties = be.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); gbSrf.ConstructionIDRef = (envContextProperties != null ? envContextProperties.TypeName.CleanName() : be.ConstructionID()); BH.oM.XML.Construction conc = be.ToGBXMLConstruction(); BH.oM.XML.Construction test = usedConstructions.Where(y => y.ID == conc.ID).FirstOrDefault(); if (test == null) { List <BH.oM.XML.Material> materials = new List <Material>(); BHC.Construction construction = be.Construction as BHC.Construction; foreach (BHC.Layer l in construction.Layers) { materials.Add(l.ToGBXML()); } BH.oM.XML.Layer layer = materials.ToGBXML(); conc.LayerID.LayerIDRef = layer.ID; usedConstructions.Add(conc); if (usedLayers.Where(y => y.ID == layer.ID).FirstOrDefault() == null) { usedLayers.Add(layer); } foreach (BH.oM.XML.Material mat in materials) { if (usedMaterials.Where(y => y.ID == mat.ID).FirstOrDefault() == null) { usedMaterials.Add(mat); } } } } else //We have to force null otherwise Construction will be created { gbSrf.ConstructionIDRef = null; } gbx.Campus.Surface.Add(gbSrf); } gbx.Construction = usedConstructions.ToArray(); gbx.Layer = usedLayers.ToArray(); gbx.Material = usedMaterials.ToArray(); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static List <BH.oM.XML.Opening> SerializeOpenings(IEnumerable <BH.oM.Environment.Elements.Opening> openings, List <Panel> space, List <Panel> allElements, List <List <Panel> > spaces, BH.oM.XML.GBXML gbx, XMLSettings settings) { List <BH.oM.XML.Opening> gbOpenings = new List <oM.XML.Opening>(); foreach (BH.oM.Environment.Elements.Opening opening in openings) { Polyline openingPoly = opening.Polyline(); if (openingPoly == null || openingPoly.CleanPolyline(distanceTolerance: settings.DistanceTolerance) == null) { continue; } openingPoly = openingPoly.CleanPolyline(distanceTolerance: settings.DistanceTolerance); BH.oM.XML.Opening gbOpening = BH.Engine.XML.Convert.ToGBXML(opening); //Normals away from space if (!BH.Engine.Environment.Query.NormalAwayFromSpace(openingPoly, space)) { gbOpening.PlanarGeometry.PolyLoop = BH.Engine.XML.Convert.ToGBXML(openingPoly.Flip()); } Panel buildingElement = new Panel(); ; BHP.OriginContextFragment contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); string elementID = ""; string familyName = ""; if (contextProperties != null) { elementID = contextProperties.ElementID; familyName = contextProperties.TypeName; } gbOpening.CADObjectID = opening.CADObjectID(); gbOpening.OpeningType = opening.Type.ToGBXML(); if (gbOpening.OpeningType.ToLower() == "fixedwindow" && contextProperties != null && contextProperties.TypeName.ToLower().Contains("skylight")) { gbOpening.OpeningType = "FixedSkylight"; } if (familyName == "System Panel") //No SAM_BuildingElementType for this one atm { gbOpening.OpeningType = "FixedWindow"; } if (settings.ReplaceSolidOpeningsIntoDoors && gbOpening.OpeningType.Contains("Window") && (opening.OpeningConstruction != null && opening.OpeningConstruction.Name.Contains("SLD"))) //Change windows with SLD construction into doors for IES { gbOpening.OpeningType = "NonSlidingDoor"; } if (settings.IncludeConstructions) { gbOpening.WindowTypeIDRef = "window-" + (contextProperties != null? contextProperties.TypeName.CleanName() : (opening.OpeningConstruction != null ? opening.OpeningConstruction.Name.CleanName() : "")); } else { gbOpening.WindowTypeIDRef = null; } gbOpening.ConstructionIDRef = null; //ToDo review having this property on an opening? gbOpenings.Add(gbOpening); } return(gbOpenings); }
private void UpdateUI() { txt_batchclass.Text = BatchClass.Name; XMLPath = AppSettings.App_Path() + AppSettings.App_Name() + "Setup.xml"; XMLSettings.LoadBaseSettings(XMLPath); XMLSettings.LoadDefaults(XMLPath); XMLSettings.LoadXMLSettings(XMLPath, BatchClass.Name.Replace(" ", "")); Logging.LogMessage("UpdateUI::DoneLoadingXMLSettings"); // Defaults cb_shortdateformat.Items.AddRange(XMLSettings.g_aShortDateFormat_DEF); cb_longdateformat.Items.AddRange(XMLSettings.g_aLongDateFormat_DEF); cb_shorttimeformat.Items.AddRange(XMLSettings.g_aShortTimeFormat_DEF); cb_longtimeformat.Items.AddRange(XMLSettings.g_aLongTimeFormat_DEF); cb_localizationvalue.Items.AddRange(XMLSettings.g_aLocalizationValue_DEF); cb_timestringtoformat.Items.AddRange(XMLSettings.g_aTimeStringToFormat_DEF); cb_formatteddate.Items.AddRange(XMLSettings.g_aFormattedDate_DEF); cb_formattedtime.Items.AddRange(XMLSettings.g_aFormattedTime_DEF); cb_targetdateformat.Items.AddRange(XMLSettings.g_aTargetDateFormat_DEF); cb_targettimeformat.Items.AddRange(XMLSettings.g_aTargetTimeFormat_DEF); cb_usewaterfallformatter.Items.AddRange(XMLSettings.g_aUseWaterfallFormater_DEF); cb_usedistancerule.Items.AddRange(XMLSettings.g_aUseDistanceRule_DEF); cb_distanceruledays.Items.AddRange(XMLSettings.g_aDistanceRuleDays_DEF); cb_distancerulefuture.Items.AddRange(XMLSettings.g_aDistanceRuleFuture_DEF); // Reset combobox selected index cb_shortdateformat.SelectedIndex = 0; cb_longdateformat.SelectedIndex = 0; cb_shorttimeformat.SelectedIndex = 0; cb_longtimeformat.SelectedIndex = 0; cb_localizationvalue.SelectedIndex = 0; cb_timestringtoformat.SelectedIndex = 0; cb_timestringtoformat.Items.Add("Browse ..."); cb_formatteddate.SelectedIndex = 0; cb_formattedtime.SelectedIndex = 0; cb_targetdateformat.SelectedIndex = 0; cb_targettimeformat.SelectedIndex = 0; cb_usewaterfallformatter.SelectedIndex = 0; cb_usedistancerule.SelectedIndex = 0; cb_distanceruledays.SelectedIndex = 0; cb_distancerulefuture.SelectedIndex = 0; // Value Assignments txt_shortdateformat.Text = XMLSettings.g_sShortDateFormat; txt_longdateformat.Text = XMLSettings.g_sLongDateFormat; txt_shorttimeformat.Text = XMLSettings.g_sShortTimeFormat; txt_longtimeformat.Text = XMLSettings.g_sLongTimeFormat; txt_localizationvalue.Text = XMLSettings.g_sLocalizationValue; txt_stringtoformat.Text = XMLSettings.g_sTimeStringToFormat; txt_formatteddate.Text = XMLSettings.g_sFormattedDate; txt_formattedtime.Text = XMLSettings.g_sFormattedTime; // Settings txt_targetdateformat.Text = XMLSettings.g_sTargetDateFormat; txt_targettimeformat.Text = XMLSettings.g_sTargetTimeFormat; txt_usewaterfallformatter.Text = XMLSettings.g_bUseWaterfallFormatter.ToString(); txt_usedistancerule.Text = XMLSettings.g_bUseDistanceRule.ToString(); txt_ruledays.Text = XMLSettings.g_iDistanceRuleDays.ToString(); txt_distancerulefuture.Text = XMLSettings.g_bDistanceRuleFuture.ToString(); //Waterfall Check Priority txt_format1.Text = XMLSettings.g_aMethodOrder[0]; if (XMLSettings.g_aMethodOrder.Count > 1) { txt_format2.Text = XMLSettings.g_aMethodOrder[1]; } if (XMLSettings.g_aMethodOrder.Count > 2) { txt_format3.Text = XMLSettings.g_aMethodOrder[2]; } if (XMLSettings.g_aMethodOrder.Count > 3) { txt_format4.Text = XMLSettings.g_aMethodOrder[3]; } // Internal variable setup g_aNewMethodOrder = XMLSettings.g_aMethodOrder; g_aTxtMethodOrder = new List <TextBox>(); g_aTxtMethodOrder.Add(txt_format1); g_aTxtMethodOrder.Add(txt_format2); g_aTxtMethodOrder.Add(txt_format3); g_aTxtMethodOrder.Add(txt_format4); Logging.LogMessage("UpdateUI::FinishedUpdating"); }
internal void CheckLowResArtwork(XMLSettings xMLSettings, ReportWriter reportWriter) { List<string> artwork_low = new List<string>(); if (this.Artwork.Width > 0 && this.Artwork.Width < xMLSettings.LowResArtworkSize) { artwork_low.Add(this.Artwork.Width.ToString()); } if (this.Artwork.Height > 0 && this.Artwork.Height < xMLSettings.LowResArtworkSize) { artwork_low.Add(this.Artwork.Height.ToString()); } if (artwork_low.Count > 0) reportWriter.AddTrackLowResArtwork(this, artwork_low); }
internal void EmbedArtwork(XMLSettings xMLSettings, ReportWriter reportWriter) { if (this.Tags.Pictures.Length == 0) { foreach (string fileName in xMLSettings.ArtworkLookupFileNames) { string fp = Path.Combine(Path.GetDirectoryName(this.Location), fileName); if (AddArtwork(fp)) break; } } }
internal bool ExportArtwork(XMLSettings config) { if (this.Tags.Pictures.Length > 0) { try { string ext = "jpg"; string[] mime = this.Tags.Pictures[0].MimeType.ToString().Trim().Split('/'); if (mime.Length > 1) ext = mime[1].Replace("jpeg", "jpg"); string fp = Path.Combine(Path.GetDirectoryName(this.Location), config.ArtworkFileNameWithoutExtension + "." + ext); if (!System.IO.File.Exists(fp)) { using (FileStream fs = new FileStream(fp, FileMode.Create)) { fs.Write(this.Tags.Pictures[0].Data.Data, 0, this.Tags.Pictures[0].Data.Data.Length); DebugHelper.WriteLine(this.FileName + " --> exported artwork"); } } return true; } catch (Exception ex) { DebugHelper.WriteException(ex, "while exporting artwork"); } } return false; }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static void SerializeLevels(List <BH.oM.Architecture.Elements.Level> levels, List <List <Panel> > spaces, BH.oM.XML.GBXML gbx, XMLSettings settings) { List <BH.oM.XML.BuildingStorey> xmlLevels = new List <BuildingStorey>(); foreach (BH.oM.Architecture.Elements.Level level in levels) { string levelName = ""; if (level.Name == "") { levelName = level.Elevation.ToString(); } else { levelName = level.Name; } BuildingStorey storey = BH.Engine.XML.Convert.ToGBXML(level); Polyline storeyGeometry = BH.Engine.Environment.Query.StoreyGeometry(level, spaces); if (storeyGeometry == null) { continue; } storey.PlanarGeometry.PolyLoop = BH.Engine.XML.Convert.ToGBXML(storeyGeometry); storey.PlanarGeometry.ID = "LevelPlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10); storey.Name = levelName; storey.Level = (float)level.Elevation; storey.ID = "Level-" + levelName.Replace(" ", "").ToLower(); xmlLevels.Add(storey); } gbx.Campus.Building[0].BuildingStorey = xmlLevels.ToArray(); }