private static void ReReadControl(ICustomControl c) { foreach (ICustomControl r in c.cd.RelatedRead) { //ReadRelationManager rm = new ReadRelationManager(); ReadRelationManager.ReadConfiguration(r); } }
private void SaveToControl() { String text = TokenTextTranslator.TranslateFromTextFile(this.textTextBox.Text); control.cd.Text = TokenControlTranslator.TranslateFromControl(text); control.cd.RealText = this.textTextBox.Text; control.cd.Type = this.type; control.cd.Hint = this.hintTextBox.Text; control.cd.CurrentFont = this.controlFont; control.cd.BackColor = this.backColor; control.cd.ForeColor = this.fontColor; control.cd.Width = this.width; control.cd.Height = this.height; control.cd.Top = this.top; control.cd.Left = this.left; control.cd.DestinationType = this.destinationTypeComboBox.Text; control.cd.RealMainDestination = this.fileDestinationTextBox.Text; control.cd.RealSubDestination = this.subDestinatonTextBox.Text; control.cd.Format = this.formattingTextBox.Text; control.cd.ModificationRight = this.modificationRightTextBox.Text.Substring(2); control.cd.DisplayRight = this.displayRightTextBox.Text.Substring(2); if (control is CCheckBox) { control.cd.checkBoxCheckedValue = this.checkedTextBox.Text; control.cd.checkBoxUncheckedValue = this.uncheckedTextBox.Text; } if (control is CLabel) { SetOrientationToLabel(); } if (control is CButton) { control.cd.RealPath = exePathTextBox.Text; control.cd.Parameters = exeArgumentsTextBox.Text; } if (control is CBitmap) { control.cd.RealPath = exePathTextBox.Text; } model.ApplyRelations(control); ReadRelationManager.ReadConfiguration(control as ICustomControl); if (control.cd.Format != null && control.cd.Format != "") { FormatValue(control); } model.uiChanged = true; }
private void updateButton_Click(object sender, EventArgs e) { CheckCommonAttributes(); if (ErrorMsg != "" && !(control is CTabPage)) { String caption = Model.GetTranslationFromID(37); ErrorMsg = Model.GetTranslationFromID(57) + ErrorMsg; MessageBox.Show(ErrorMsg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ValidMainDestination()) { SaveToControl(); ReadRelationManager.ReadConfiguration(control as ICustomControl); } ErrorMsg = ""; }
private void CreateDefinedControls(XDocument xdoc) { List <XContainer> CTabs = new List <XContainer>(); List <XContainer> CTabControls = new List <XContainer>(); this.xdoc = xdoc; var items = from item in this.xdoc.Descendants("Controls") .Descendants("Control") select item; // Create a "preview" of the controls. // Everyone is assigned a section as its parent. foreach (var i in items) { if (i.Attribute("type").Value == "CTabPage") { CTabs.Add(i); } else { Section s = model.sections.Find(se => se.Name == i.Element("Section").Value); CreatePreviewControls(s, i); } } // CTabControls are created and in place. // Now it's time to set the Custom Tabs. if (CTabs.Count > 0) { foreach (XElement e in CTabs) { CTabControl parentControl = model.allControls.Find(p => p.cd.Name == e.Element("Parent").Value) as CTabControl; CTabPage ctp = ControlFactory.BuildCTabPage(parentControl); ctp.cd.Name = e.Element("Name").Value; ctp.cd.RealText = e.Element("Text").Value; } } int incPerItem = 90 / items.Count(); progress = 10; //Fill out the controls with the info from ObjectDefinition.xml foreach (var i in items) { foreach (ICustomControl c in model.allControls) { if (c.cd.Name == i.Element("Name").Value) { try { SetRealParent(c, i as XContainer); SetRealProperties(c, i); SetPaths(c, i); SetControlSpecificProperties(c, i); SetRelatedReadList(c, i); SetRelatedVisibility(c, i); SetCoupledControls(c, i); } catch (Exception e) { String caption = Model.GetTranslationFromID(37); String msg = Model.GetTranslationFromID(47) + " " + Model.GetTranslationFromID(52); MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); model.logCreator.Append("Creating: " + c.cd.Name); model.logCreator.Append(msg); model.logCreator.Append(e.ToString()); System.Environment.Exit(1); } ReadRelationManager.ReadConfiguration(c); ApplyRights(c); model.ApplyRelations(c); if (c.cd.Format != "") { ApplyFormats(c); } if (c is CTabControl) { try { SetSelectedTab(c, i); } catch (Exception e) { String caption = Model.GetTranslationFromID(37); String msg = Model.GetTranslationFromID(47) + " " + Model.GetTranslationFromID(52); MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); model.logCreator.Append("Setting tab: " + c.cd.Name); model.logCreator.Append(msg); model.logCreator.Append(e.ToString()); System.Environment.Exit(1); } } c.cd.Changed = false; System.Diagnostics.Debug.WriteLine("+ Added : " + c.cd.Name + " with parent: " + c.cd.Parent.Name + " in Section: " + c.cd.ParentSection.Name); } // Update the Splash Screen progress += incPerItem; } } model.ApplyRightsToControls(); model.ApplyRightsToSections(); }
private static string GetValueToSave(ICustomControl c) { String value = ""; try { if (c is CComboBox) { if (!String.IsNullOrEmpty(c.cd.Format)) { String unformatted = ReadRelationManager.GetUnformattedValue(c); String currentValue = c.cd.comboBoxConfigItems[(c as CComboBox).SelectedIndex]; value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format); value = TokenControlTranslator.TranslateFromControl(value); value = TokenTextTranslator.TranslateFromTextFile(value); } else { if (c.cd.comboBoxConfigItems.Count > 0 && (c as CComboBox).SelectedIndex != -1) { value = c.cd.comboBoxConfigItems[(c as CComboBox).SelectedIndex]; if (String.IsNullOrEmpty(value)) { value = c.cd.comboBoxItems[(c as CComboBox).SelectedIndex]; } } } } else if (c is CTextBox) { if (!String.IsNullOrEmpty(c.cd.Format)) { String unformatted = ReadRelationManager.GetUnformattedValue(c); String currentValue = c.cd.Text; value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format); value = TokenControlTranslator.TranslateFromControl(value); value = TokenTextTranslator.TranslateFromTextFile(value); } else { value = c.cd.Text; } } else if (c is CCheckBox) { if (!String.IsNullOrEmpty(c.cd.Format)) { String unformatted = ReadRelationManager.GetUnformattedValue(c); String currentValue = c.cd.checkBoxUncheckedValue; if ((c as CCheckBox).CheckState == System.Windows.Forms.CheckState.Checked) { currentValue = c.cd.checkBoxCheckedValue; } else { currentValue = c.cd.checkBoxUncheckedValue; } value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format); } else { value = c.cd.checkBoxUncheckedValue; if ((c as CCheckBox).CheckState == System.Windows.Forms.CheckState.Checked) { value = c.cd.checkBoxCheckedValue; } else { value = c.cd.checkBoxUncheckedValue; } } } else { if (!String.IsNullOrEmpty(c.cd.Format)) { String unformatted = ReadRelationManager.GetUnformattedValue(c); String currentValue = c.cd.Text; value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format); value = TokenControlTranslator.TranslateFromControl(value); value = TokenTextTranslator.TranslateFromTextFile(value); } else { String t = TokenControlTranslator.TranslateFromControl(c.cd.RealText); t = TokenTextTranslator.TranslateFromTextFile(t); value = t; } } } catch (Exception) { System.Diagnostics.Debug.WriteLine("*** ERROR *** There was an exception while getting value to save for: " + c.cd.Name); } return(value); }