/// <summary> /// Generate the code. /// </summary> /// <param name="data">The data collection.</param> /// <returns>The code unit.</returns> public CodeCompileUnit GenerateCode(DataObjectContainer data) { // If not null. if (data != null) { _dataBaseName = data.Database; _companyName = data.NamespaceCompanyName; _className = data.ClassName; _extendedName = data.NamespaceExtendedName; // Create the namespace. InitialiseNamespace(); } // If not null. if (data != null) { _data = data; // Add the classes. AddClasses(); } // Return the complie unit. _targetUnit.Namespaces.Add(samples); return(_targetUnit); }
private set; } /// <summary> /// init control /// </summary> public void init() { //DataBinder.OnBindException += HandleOnBindException; DataObjects = new DataObjectContainer(); BtnOpenFile.Clicked += HandleOpenFileClicked; BtnGenerate.Clicked += BtnGenerateClicked; BtnNew.Clicked += HandleBtnNewClicked; BtnAddFile.Clicked += HandleBtnAddClicked; BtnRemoveSelected.Clicked += HandleBtnRemoveClicked; BtnSaveAs.Clicked += HandleBtnSaveAsClicked; //the tree (not used as tree here) TsData = new TreeStore(dfFilename,dfGladefile); Treeview1.DataSource = TsData; Treeview1.Columns.Add ("Filename", dfFilename); Treeview1.Columns.Add ("GladeFile", dfGladefile); Treeview1.SelectionChanged += TreeViewSelectionChangend; Treeview1.ButtonPressed += HandleTreeViewButtonPressed; CurrentFile = String.Empty;
/// <summary> /// binds data from a gtk widget (e.g. entry) to a custom object property /// </summary> /// <param name='container'> /// a container with a "DataObjects" property that contains the target objects which receive data /// </param> /// <param name='dataholder'> /// a object (control) containing the source data /// </param> /// <param name='property'> /// propertyname wich recieves the date /// </param> public void BindData(object container, object dataholder, string property) { try { PropertyInfo pi = container.GetType().GetProperty("DataObjects"); if (pi == null) { throw new Exception("Container does not have a DataObjects property"); } DataObjectContainer dataobjects = (pi.GetValue(container, null) as DataObjectContainer); if (dataobjects == null) { throw new Exception("Could not get DataObjects Property, this must be a Dictionary<String,object> "); } object target = null; String key = getDataObjectKey(property); if (dataobjects.ContainsKey(key)) { target = dataobjects.Get(key); } if (target == null) { throw new Exception("Could not find target object: " + key); } if (target is Sharpend.Databinding.BindableData) { //check if we are binding in the other direction if ((target as Sharpend.Databinding.BindableData).IsBinding) { return; } } String tp = getTargetPropertyName(property); PropertyInfo pi2 = target.GetType().GetProperty(tp); if (pi2 == null) { throw new Exception("Container does not have a DataObjects property"); } object val = getValue(dataholder); pi2.SetValue(target, val, null); } catch (Exception ex) { if (OnBindException != null) { OnBindException(ex, new EventArgs()); } else { throw; } } }