private void CoupledRelationsListChanged(ICustomControl checkedControl, ItemCheckEventArgs e) { if (checkedControl is CComboBox && validCoupleComboBox(checkedControl)) { currentVisibleList.Add(checkedControl); System.Diagnostics.Debug.WriteLine("+ [" + relationsComboBox.SelectedItem + "] Checked: " + checkedControl.cd.Name); } else if (checkedControl is CCheckBox) { currentVisibleList.Add(checkedControl); } else if (checkedControl is CComboBox && !validCoupleComboBox(checkedControl)) { //They can't be coupled! e.NewValue = CheckState.Unchecked; String caption = Model.GetTranslationFromID(37); String msg = checkedControl.cd.Name + Model.GetTranslationFromID(64) + control.cd.Name; MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!(checkedControl is CComboBox) && !(checkedControl is CCheckBox)) { e.NewValue = CheckState.Unchecked; String caption = Model.GetTranslationFromID(37); String msg = Model.GetTranslationFromID(65); MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MainBar_DockTabChange(object sender, DevComponents.DotNetBar.DockTabChangeEventArgs e) { TreeTSI.Nodes.Clear(); propertyGrid.SelectedObject = null; if (e.NewTab.GetType() == typeof(XmlDockContainer)) { XmlDockContainer SelectXmlDockContainer = (XmlDockContainer)e.NewTab; SelectXmlDockContainer.Reload(); treeTSIMenuStrip.Enabled = false; } else if (e.NewTab.GetType() == typeof(DDSDockContainer)) { DDSDockContainer SelectDDSDockContainer = (DDSDockContainer)e.NewTab; SelectDDSDockContainer.Reload(); treeTSIMenuStrip.Enabled = false; } else if (e.NewTab.GetType() == typeof(TSIDockContainer)) { TSIDockContainer SelectTSIDockContainer = (TSIDockContainer)e.NewTab; SelectTSIDockContainer.Reload(); tabControl.SelectedTab = tabPageTSI; treeTSIMenuStrip.Enabled = true; } else { treeTSIMenuStrip.Enabled = false; } if (e.OldTab.GetType() == typeof(ICustomControl)) //avoid error with "about tab" which isn't a ICustomControl { ICustomControl oldDock = (ICustomControl)e.OldTab; oldDock.Save(); } }
private static String ReReadXMLFile(ICustomControl r) { try { XmlDocument xdoc = new XmlDocument(); xdoc.Load(r.cd.MainDestination); String value = xdoc.SelectSingleNode(r.cd.SubDestination).InnerText; if (r.cd.SubDestination.Contains('*') || r.cd.SubDestination.Contains("node()")) { foreach (XmlNode n in xdoc.SelectNodes(r.cd.SubDestination)) { value += n.InnerText; } } return(value); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("*** ERROR *** Re-Reading XML file for: " + r.cd.Name); System.Diagnostics.Debug.WriteLine(e.ToString()); Model.getInstance().logCreator.Append("[ERROR] Re-Reading XML file for " + r.cd.Name); } return(""); }
public static string GetUnformattedValue(ICustomControl r) { string value = ""; if (!String.IsNullOrEmpty(r.cd.MainDestination)) { System.Diagnostics.Debug.WriteLine("<< Getting Unformatted value: " + r.cd.SubDestination); String fileType = r.cd.MainDestination.Substring(r.cd.MainDestination.Length - 4, 4); if (fileType == ".ini" && r.cd.DestinationType == ".INI") { value = ReReadINIFile(r); } else if (fileType == "conf" && r.cd.DestinationType == ".INI") { value = ReReadINIFile(r); } else if (fileType == ".xml" && r.cd.DestinationType == ".XML") { value = ReReadXMLFile(r); } else if (r.cd.DestinationType == "REG") { value = ReReadRegistry(r); } } return(value); }
// Control.Show() method overload public void Show(Control c) { this.control = (ICustomControl)c; if (this.control == null) { this.Close(); return; } this.parent = control.cd.Parent; this.type = c.GetType().Name; ShowMousePosition(); ShowHeadLine(); ShowDefaultSize(); DisableControls(type); if (this.control is CLabel) { SetOrientationComboBox(); } if (this.control is CComboBox) { textLabel.Text = ""; } SetRelationComboBox(); ReadFromControl(); SetLocation(); SetCheckBoxValuesOptions(); base.Show(); //SaveToControl(); }
public void CheckSnapOnDrop(Control control, Control parent) { ICustomControl c = control as ICustomControl; int margin = 10; int marginTop = 10; if (parent is TabPage) { margin = 4; } if (parent is CGroupBox) { marginTop = 20; } // Check Snaps to parent if (c.cd.Top < marginTop) { c.cd.Top = marginTop; } if (c.cd.Left < margin) { c.cd.Left = margin; } if (c.cd.Top + c.cd.Height > parent.Height - margin) { c.cd.Top = parent.Height - c.cd.Height - margin; } if (c.cd.Left + c.cd.Width > parent.Width - margin) { c.cd.Left = parent.Width - c.cd.Width - margin; } }
public void TextChanged(object sender, EventArgs e) { ICustomControl c = sender as ICustomControl; c.cd.Text = (sender as Control).Text; c.cd.RealText = (sender as Control).Text; }
public void ActivateDragDrop(ControlEditor editor) { this.Visible = true; this.Enabled = false; this.mouseOverForm = true; this.editor = editor; this.Activate(); dragControl = model.currentClickedControl as ICustomControl; if (dragControl != null) { oldLocation = model.currentClickedControl.Location; oldParent = model.currentClickedControl.Parent; model.currentClickedControl.BringToFront(); dragControl.cd.Parent.Controls.Remove(dragControl as Control); this.Controls.Add(dragControl as Control); this.Activate(); for (double i = .00; i < 0.30; i += 0.05) { this.Opacity = i; System.Threading.Thread.Sleep(10); } System.Diagnostics.Debug.WriteLine("Starting Drag&Drop with: " + dragControl.cd.Name); dragControl.cd.Enabled = false; this.DoDragDrop(dragControl, DragDropEffects.Move); } }
private void SetSelectedTab(ICustomControl c, XElement i) { if (c is CTabControl) { c.cd.SelectedTab = Convert.ToInt32(i.Element("Settings").Element("ActiveTab").Value); } }
private Boolean HasRelations(Control control, out String Message) { String msg = ""; //String question = "\nAre you sure you want to remove " + control.Name + "?"; String references = ""; String referencedBy = ""; ICustomControl c = control as ICustomControl; // Check if this control has anything else inside the related list if (ControlReferencesOthers(c, out references)) { msg += c.cd.Name + GetTranslationFromID(34) + "\n"; msg += references + "\n"; } // Check if this control is inside the related lists of other controls if (ControlIsReferenced(c, out referencedBy)) { msg += GetTranslationFromID(35) + " " + c.cd.Name + ":\n"; msg += referencedBy; } Message = msg; if (msg != "") { return(true); } else { return(false); } }
private bool ControlIsReferenced(ICustomControl c, out String referencedBy) { referencedBy = ""; foreach (ICustomControl co in model.allControls) { if (co.cd.RelatedRead.Contains(c)) { referencedBy += co.cd.Name + " "; } else if (co.cd.RelatedWrite.Contains(c)) { referencedBy += co.cd.Name + " "; } else if (co.cd.RelatedVisibility.Contains(c)) { referencedBy += co.cd.Name + " "; } else if (co.cd.CoupledControls.Contains(c)) { referencedBy += co.cd.Name + " "; } } if (referencedBy != "") { return(true); } return(false); }
public void ApplyRelations(ICustomControl c) { if (c.cd.CoupledControls.Count > 0 || c.cd.RelatedVisibility.Count > 0 || c.cd.RelatedRead.Count > 0) { if (c is CCheckBox) { CheckState state = (c as CheckBox).CheckState; if (state == CheckState.Checked) { (c as CheckBox).CheckState = CheckState.Unchecked; } else { (c as CheckBox).CheckState = CheckState.Checked; } (c as CheckBox).CheckState = state; } if (c is CComboBox) { int index = (c as ComboBox).SelectedIndex; (c as ComboBox).SelectedIndex = -1; (c as ComboBox).SelectedIndex = index; } } }
private static void SaveControlChanges(ICustomControl c) { //if (c.cd.Type == "CComboBox" || c.cd.Type == "CTextBox" || c.cd.Type == "CCheckBox") //{ String fileType = c.cd.MainDestination.Substring(c.cd.MainDestination.Length - 4, 4); String path = TokenTextTranslator.TranslateFromTextFile(c.cd.RealSubDestination); path = TokenControlTranslator.TranslateFromControl(path).TrimStart('\\'); String value = GetValueToSave(c); if (c.cd.DestinationType == ".INI") { SaveINIFile(c, path, value); } else if (fileType == ".xml" && c.cd.DestinationType == ".XML") { SaveXMLFile(c, path, value); } else if (c.cd.DestinationType == "REG") { SaveRegistryKey(c, path, value); } else { Model.getInstance().logCreator.Append("[ERROR] Destination file and type not matching for " + c.cd.Name); System.Diagnostics.Debug.WriteLine("!ERROR : Destination file and type not matching for " + c.cd.Name); } //} }
public void ShowControlInfoHint(object sender, EventArgs e) { if (model.progMode && sender != null) { Control s = (sender as Control); ICustomControl cc = (sender as ICustomControl); string text = " "; this.controlTip.ToolTipTitle = cc.cd.Name; this.controlTip.ToolTipTitle += " " + cc.cd.RealText; if (!String.IsNullOrEmpty(cc.cd.MainDestination)) { text += "\n" + this.mainDestination + ": " + cc.cd.MainDestination; } if (!String.IsNullOrEmpty(cc.cd.RealSubDestination)) { text += "\n" + this.subDestination + ": " + cc.cd.RealSubDestination; } //if(cc.cd.RelatedRead.Count > 0) // text += "\n" +this.relatedRead +": " + String.Join(", ", cc.cd.RelatedRead.ToArray()); //if(cc.cd.RelatedVisibility.Count > 0) // text += "\n" +this.relatedVisibility +": " +cc.cd.RelatedVisibility.ToString(); this.controlTip.SetToolTip(s, text); } }
private static void TranslateSubDestination(ICustomControl r) { String text = TokenControlTranslator.TranslateFromControl(r.cd.RealSubDestination); text = TokenTextTranslator.TranslateFromTextFile(text); r.cd.SubDestination = text; }
private static void ReReadControl(ICustomControl c) { foreach (ICustomControl r in c.cd.RelatedRead) { //ReadRelationManager rm = new ReadRelationManager(); ReadRelationManager.ReadConfiguration(r); } }
private static void TranslateText(ICustomControl r) { String text = TokenControlTranslator.TranslateFromControl(r.cd.RealText); text = TokenTextTranslator.TranslateFromTextFile(text); r.cd.Text = text; }
private void SetPaths(ICustomControl c, XElement i) { c.cd.DestinationType = i.Element("Paths").Element("DestinationType").Value; String p = i.Element("Paths").Element("DestinationFile").Value; c.cd.RealMainDestination = p; c.cd.RealSubDestination = i.Element("Paths").Element("SubDestination").Value; c.cd.SubDestination = i.Element("Paths").Element("SubDestination").Value; }
private void SetRealProperties(ICustomControl c, XElement i) { Font newFont; Color newColor; if (!(c is CTextBox)) { c.cd.RealText = i.Element("Text").Value; } String text = TokenTextTranslator.TranslateFromTextFile(c.cd.RealText); c.cd.Text = TokenControlTranslator.TranslateFromControl(text); c.cd.Hint = i.Element("Hint").Value; c.cd.Hint = c.cd.Hint.Replace(" ", "\r\n"); c.cd.ParentSection = Model.getInstance().sections.Find(se => se.Name == i.Element("Section").Value); c.cd.Top = Convert.ToInt32(i.Element("Settings").Element("Top").Value); c.cd.Left = Convert.ToInt32(i.Element("Settings").Element("Left").Value); c.cd.Width = Convert.ToInt32(i.Element("Settings").Element("Width").Value); c.cd.Height = Convert.ToInt32(i.Element("Settings").Element("Height").Value); newFont = (Font)fontConverter.ConvertFromString(i.Element("Settings").Element("Font").Value); c.cd.CurrentFont = newFont; colorConverter = TypeDescriptor.GetConverter(typeof(Color)); newColor = (Color)colorConverter.ConvertFromString(i.Element("Settings").Element("FontColor").Value); c.cd.ForeColor = newColor; String colorValue = i.Element("Settings").Element("BackColor").Value; if (colorValue != "") { c.cd.BackColor = (Color)colorConverter.ConvertFromString(colorValue); } else { c.cd.BackColor = System.Drawing.SystemColors.Control; } //newColor = (Color)colorConverter.ConvertFromString(i.Element("Settings").Element("BackColor").Value); //c.cd.BackColor = newColor; if (c is CLabel) { String align = (String)i.Element("Settings").Element("TextAlignment") ?? "TopLeft"; SetTextAlignment(c, align); } c.cd.Format = i.Element("Settings").Element("Format").Value; // Get Display and Modification rights c.cd.DisplayRight = i.Element("Settings").Element("DisplayRight").Value.Substring(2); c.cd.ModificationRight = i.Element("Settings").Element("ModificationRight").Value.Substring(2); }
private Control CopyControlProperties(ICustomControl dest, ICustomControl source) { dest.cd.Text = source.cd.Text; dest.cd.Changed = source.cd.Changed; dest.cd.RealText = source.cd.RealText; dest.cd.Type = source.cd.Type; dest.cd.Format = source.cd.Format; dest.cd.TextAlign = source.cd.TextAlign; dest.cd.Width = source.cd.Width; dest.cd.Height = source.cd.Height; dest.cd.CurrentFont = source.cd.CurrentFont; dest.cd.BackColor = source.cd.BackColor; dest.cd.ThisControl = dest as Control; dest.cd.DisplayRight = source.cd.DisplayRight; dest.cd.ModificationRight = source.cd.ModificationRight; //c.cd.operatorModification = source.cd.operatorModification; //c.cd.operatorVisibility = source.cd.operatorVisibility; dest.cd.checkBoxCheckedValue = source.cd.checkBoxCheckedValue; dest.cd.checkBoxUncheckedValue = source.cd.checkBoxUncheckedValue; dest.cd.DestinationType = source.cd.DestinationType; dest.cd.MainDestination = source.cd.MainDestination; dest.cd.RealMainDestination = source.cd.RealMainDestination; dest.cd.SubDestination = source.cd.SubDestination; dest.cd.RealSubDestination = source.cd.RealSubDestination; dest.cd.RealPath = source.cd.RealPath; dest.cd.Parameters = source.cd.Parameters; //dest.cd.RelatedRead.AddRange(source.cd.RelatedRead); //dest.cd.RelatedVisibility.AddRange(source.cd.RelatedVisibility); //dest.cd.CoupledControls.AddRange(source.cd.CoupledControls); dest.cd.ParentSection = model.currentSection; //dest.cd.Parent = model.CurrentClickedControl; dest.cd.Top = source.cd.Top; dest.cd.Left = source.cd.Left; if (source.cd.comboBoxItems != null && source.cd.comboBoxItems.Count > 0) { dest.cd.comboBoxItems.AddRange(source.cd.comboBoxItems); dest.cd.comboBoxRealItems.AddRange(source.cd.comboBoxRealItems); dest.cd.comboBoxConfigItems.AddRange(source.cd.comboBoxConfigItems); (dest as ComboBox).Items.AddRange(dest.cd.comboBoxItems.ToArray()); (dest as ComboBox).SelectedItem = dest.cd.comboBoxItems.First(); (dest as ComboBox).Update(); } dest.cd.Visible = source.cd.Visible; return(dest as Control); }
private void MapControl(ICustomControl customControlData, ICustomControl customControlControl) { customControlControl.ControlType = customControlData.ControlType; customControlControl.DefaultValue = customControlData.DefaultValue; customControlControl.Description = customControlData.Description; customControlControl.Effort = customControlData.Effort; customControlControl.Weight = customControlData.Weight; customControlControl.Category = customControlData.Category; }
private void ApplyRights(ICustomControl c) { if (!c.cd.inRelatedVisibility && !(c is CTabPage)) { (c as Control).Visible = c.cd.operatorVisibility; } (c as Control).Enabled = c.cd.operatorModification; }
private void RefreshEditorWindow(ICustomControl c) { foreach (ControlEditor ed in Application.OpenForms.OfType <ControlEditor>()) { if (ed.control == model.currentClickedControl) { ed.ReadFromControl(); } } }
private static void SetReadValue(ICustomControl r, String value) { if (r is CComboBox) { if (!String.IsNullOrEmpty(r.cd.Format)) { string formattedValue = StringFormatter.GetFormattedText(value, r.cd.Format); formattedValue = TokenControlTranslator.TranslateFromControl(formattedValue); formattedValue = TokenTextTranslator.TranslateFromTextFile(formattedValue); int index = r.cd.comboBoxConfigItems.IndexOf(formattedValue); if ((r as ComboBox).Items.Count >= index) { (r as ComboBox).SelectedIndex = index; } } else { int index = r.cd.comboBoxConfigItems.IndexOf(value); if (index == -1) { index = r.cd.comboBoxItems.IndexOf(value); } if ((r as ComboBox).Items.Count >= index) { (r as ComboBox).SelectedIndex = index; } } } else if (r is CCheckBox) { if (!String.IsNullOrEmpty(r.cd.Format)) { value = StringFormatter.GetFormattedText(value, r.cd.Format); } if (value.Equals(r.cd.checkBoxCheckedValue, StringComparison.OrdinalIgnoreCase)) { (r as CCheckBox).CheckState = CheckState.Checked; } else { (r as CCheckBox).CheckState = CheckState.Unchecked; } } else if (!String.IsNullOrEmpty(r.cd.Format)) { r.cd.Text = StringFormatter.GetFormattedText(value, r.cd.Format); } else { r.cd.Text = value; } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (this.MainBar.SelectedDockTab >= 0) { if (MainBar.Items[MainBar.SelectedDockTab].GetType() == typeof(ICustomControl)) //avoid error with "about tab" which isn't a ICustomControl { ICustomControl selectedDockContainer = (ICustomControl)MainBar.Items[MainBar.SelectedDockTab]; selectedDockContainer.Save(); } } }
private Boolean validCoupleComboBox(ICustomControl checkedControl) { if (checkedControl.cd.comboBoxRealItems.Count != control.cd.comboBoxRealItems.Count) { return(false); } else { return(true); } }
public static void ReadConfiguration(ICustomControl r) { if (!String.IsNullOrEmpty(r.cd.RealSubDestination)) { TranslateSubDestination(r); } // Updates the Text field or Items from the ComboBox if (r is CComboBox) { TranslateComboBoxItems(r); } else { TranslateText(r); } // Re-reads the value from the source file if (!String.IsNullOrEmpty(r.cd.MainDestination)) { String value = ""; System.Diagnostics.Debug.WriteLine("<< Reading key: " + r.cd.SubDestination); String fileType = r.cd.MainDestination.Substring(r.cd.MainDestination.Length - 4, 4); if (fileType == ".ini" && r.cd.DestinationType == ".INI") { value = ReReadINIFile(r); } else if (fileType == "conf" && r.cd.DestinationType == ".INI") { value = ReReadINIFile(r); } else if (fileType == ".xml" && r.cd.DestinationType == ".XML") { value = ReReadXMLFile(r); } else if (r.cd.DestinationType == "REG") { value = ReReadRegistry(r); } SetReadValue(r, value); //r.cd.Changed = false; } if (r is CBitmap) { r.cd.RealPath = r.cd.RealPath; } //r.cd.Changed = false; }
private void closeToolStripMenuItem_Click(object sender, EventArgs e) { if (this.MainBar.SelectedDockTab >= 0) { Type type = MainBar.Items[MainBar.SelectedDockTab].GetType(); if (MainBar.Items[MainBar.SelectedDockTab].GetType().Equals(typeof(ICustomControl))) //avoid error with "about tab" which isn't a ICustomControl { ICustomControl selectedDockContainer = (ICustomControl)MainBar.Items[MainBar.SelectedDockTab]; selectedDockContainer.Save(); this.MainBar.Items.RemoveAt(this.MainBar.SelectedDockTab); } } }
public String DeleteControlReferences(Control c) { ICustomControl d = c as ICustomControl; foreach (ICustomControl s in allControls) { s.cd.RelatedRead.Remove(d); s.cd.RelatedVisibility.Remove(d); s.cd.RelatedWrite.Remove(d); s.cd.CoupledControls.Remove(d); } return(""); }
// Handler that updates all the control fields that should be updated // for the read related controls. public static void ReadRelationUpdate(object sender, EventArgs e) { ICustomControl c = sender as ICustomControl; foreach (ICustomControl r in c.cd.RelatedRead) { ReadConfiguration(r); } foreach (ICustomControl r in c.cd.RelatedRead) { r.cd.Changed = false; } }