void INameCreationService.ValidateName(string name) { if (name == null || name.Length == 0) { throw new Exception("The name cannot be empty"); } if (VobUtil.RootComponentSelected && VobUtil.CurrentComponent != null) { InterfaceVOB vob = VobUtil.VobService; if (vob != null) { if (name != VobUtil.CurrentComponentName) { EventArgNameChange en = new EventArgNameChange(name, VobUtil.CurrentComponentName); en.Attributes = VobUtil.CurrentProjectName; en.Owner = VobUtil.CurrentComponent; en.ComponentType = _componentType; vob.SendNotice(enumVobNotice.BeforeRootComponentNameChange, en); if (en.Cancel) { if (string.IsNullOrEmpty(en.Message)) { throw new Exception("Invalid name: " + name); } else { throw new Exception(en.Message); } } } } } // First character must be a letter if (!Char.IsLetter(name, 0)) { throw new Exception("The first character of the name must be a letter"); } for (int i = 0; i < name.Length; i++) { char ch = name[i]; if (ch != '_') { UnicodeCategory uc = Char.GetUnicodeCategory(ch); switch (uc) { case UnicodeCategory.UppercaseLetter: case UnicodeCategory.LowercaseLetter: case UnicodeCategory.TitlecaseLetter: case UnicodeCategory.DecimalDigitNumber: break; default: throw new Exception("The name '" + name + "' is not a valid identifier."); } } } }
private void sendVOBnotice(enumVobNotice notice, object data) { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host != null) { InterfaceVOB vob = (InterfaceVOB)host.GetService(typeof(InterfaceVOB)); if (vob != null) { vob.SendNotice(notice, data); } } }
void itemList_MouseMove(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left || itemList.SelectedIndex <= 0 || itemList.SelectedIndex != nSelectedIndex) { bPrepareDrag = false; } if (bPrepareDrag) { if (Math.Abs(e.X - x0) > 3 || Math.Abs(e.Y - y0) > 3) { ToolboxItem tbi = itemList.Items[itemList.SelectedIndex] as ToolboxItem; xToolboxItem xt = tbi as xToolboxItem; InterfaceVOB vob = ((IServiceContainer)toolbox.Host).GetService(typeof(InterfaceVOB)) as InterfaceVOB; IToolboxService tbs = ((IServiceContainer)toolbox.Host).GetService(typeof(IToolboxService)) as IToolboxService; if (tbs == null) { if (vob == null) { bool b = true; TraceLogClass log = new TraceLogClass(); log.Log("service InterfaceVOB not available", ref b); } else { PassData data = new PassData(); vob.SendNotice(enumVobNotice.GetToolbox, data); tbs = data.Data as IToolboxService; } } if (tbs != null) { bool bCanDrop = true; if (vob != null) { if (xt != null) { if (xt.Properties != null && xt.Properties.Contains("ClassId")) { ToolboxItemXType.SelectedToolboxClassId = (UInt32)(xt.Properties["ClassId"]); ToolboxItemXType.SelectedToolboxType = null; ToolboxItemXType.SelectedToolboxTypeKey = null; ToolboxItemXType.SelectedToolboxClassName = (string)(xt.Properties["DisplayName"]); } else { PassData pd = new PassData(); pd.Key = xt.Type; pd.Data = true; pd.Attributes = xt.Properties; vob.SendNotice(enumVobNotice.ObjectCanCreate, pd); bCanDrop = (bool)pd.Data; if (bCanDrop && pd.Attributes != null) { ToolboxItem tx0 = pd.Attributes as ToolboxItem; if (tx0 != null) { tbi = tx0; } } } } } if (bCanDrop) { try { DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; toolbox.HideToolBox(this, null); itemList.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { bool b = true; TraceLogClass log = new TraceLogClass(); log.Log(this.FindForm(), ex, ref b); } } } } } }