public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (service != null) { IWithProject mc = context.Instance as IWithProject; if (mc == null) { MathNode.Log(new DesignerException("{0} does not implement IWithProject", context.Instance.GetType())); } else { if (mc.Project == null) { MathNode.Log(new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { Rectangle rc = new Rectangle(System.Windows.Forms.Cursor.Position, new Size(20, 60)); IMathExpression im = value as IMathExpression; if (im == null) { im = new MathNodeRoot(); } } } } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (service != null) { ILimnorProject p = null; IProjectAccessor pa = context.Instance as IProjectAccessor; if (pa != null) { p = pa.Project; } else { IWithProject wp = context.Instance as IWithProject; if (wp != null) { p = wp.Project; } } if (p != null) { LanguageList ctl = new LanguageList(service, p); service.DropDownControl(ctl); if (ctl.SelectedLanguage != null) { value = ctl.SelectedLanguage; } } } } return(value); }
protected override object OnEditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, System.Windows.Forms.Design.IWindowsFormsEditorService service, object value) { IWithProject mc = context.Instance as IWithProject; if (mc != null) { if (mc.Project == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { GetterClass val = value as GetterClass; System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position; rc.X = curPoint.X; rc.Y = curPoint.Y; DlgMethod dlg = val.CreateMethodEditor(rc); try { dlg.SetNameReadOnly(); dlg.LoadMethod(val, EnumParameterEditType.ReadOnly); dlg.Text = val.ToString(); if (service.ShowDialog(dlg) == DialogResult.OK) { value = val; ILimnorDesignerLoader l = LimnorProject.ActiveDesignerLoader as ILimnorDesignerLoader; if (l != null) { //save the property and hence save the getter DesignUtil.SaveCustomProperty(LimnorProject.ActiveDesignerLoader.Node, l.Writer, val.Property); //save actions List <IAction> actions = val.GetActions(); if (actions != null) { foreach (IAction a in actions) { l.GetRootId().SaveAction(a, l.Writer); } } LimnorProject.ActiveDesignerLoader.NotifyChanges(); } } } catch (Exception err) { MathNode.Log(TraceLogClass.GetForm(provider), err); } finally { val.ExitEditor(); } } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { IWithProject ip = context.Instance as IWithProject; if (ip != null) { LimnorProject prj = ip.Project; if (prj != null) { IList <ComponentID> lst = prj.GetAllComponents(); UInt32 id = 0; bool isString = false; if (context.PropertyDescriptor != null) { isString = (typeof(string).Equals(context.PropertyDescriptor.PropertyType)); } ComponentID cid = value as ComponentID; if (cid != null) { id = cid.ComponentId; } string pageAddr = null; if (isString) { pageAddr = value as string; } ComponentListControl list = new ComponentListControl(edSvc, lst, id, prj, isString, pageAddr); edSvc.DropDownControl(list); if (isString) { if (list.SelectedPageAddress != null) { value = list.SelectedPageAddress; } } else { if (list.SelectedObj != null) { value = list.SelectedObj; } } } } } } return(value); }
public static bool Validate(this IWithProject _, string directory) { var projectFiles = Directory.GetFiles(directory, "*.rune.json"); if (projectFiles.Length == 0) { Console.WriteLine($"{":fried_shrimp:".Emoji()} {"Couldn't".Nier().Color(Color.Red)} find a project to run. Ensure a project exists in {directory}."); return(false); } if (projectFiles.Length > 1) { Console.WriteLine($"{":fried_shrimp:".Emoji()} {"Specify".Nier().Color(Color.Red)} which project file to use because this folder contains more than one project file.."); return(false); } return(true); }
public static bool ValidateRuneSpec(this IWithProject _, string directory, out RuneSpec specFile, out string path) { var projectFiles = Directory.GetFiles(directory, "*.rspec.json"); specFile = default; path = string.Empty; if (projectFiles.Length == 0) { Console.WriteLine($"{":trident:".Emoji()} {"Couldn't".Nier().Color(Color.Red)} find a rune package spec. Ensure a project specification in {directory}."); return(false); } if (projectFiles.Length > 1) { Console.WriteLine($"{":trident:".Emoji()} {"Specify".Nier().Color(Color.Red)} which spec file to use because this folder contains more than one spec file.."); return(false); } path = projectFiles.Single(); try { specFile = JsonConvert.DeserializeObject <RuneSpec>(File.ReadAllText(path)); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine($"{":trident:".Emoji()} {"Fail".Nier(1).Color(Color.Red)} parse specification file..."); return(false); } // TODO regex rules if (string.IsNullOrEmpty(specFile.ID)) { Console.WriteLine($"{":trident:".Emoji()} [{"Validate".Nier(4).Color(Color.Red)}] ID can't empty."); return(false); } if (specFile.Version is null) { Console.WriteLine($"{":trident:".Emoji()} [{"Validate".Nier(4).Color(Color.Red)}] Version can't empty."); return(false); } return(true); }
public List <ParameterClass> GetParameters(IMethod method) { List <ParameterClass> pcList = new List <ParameterClass>(); ParameterInfo[] ps = Parameters; if (ps != null && ps.Length > 0) { IWithProject p = null; if (Owner != null) { p = Owner.RootPointer; } for (int i = 0; i < ps.Length; i++) { ParameterClass pc; pc = new ParameterClass(ps[i].ParameterType, ps[i].Name, p, method); pcList.Add(pc); } } return(pcList); }
public List <NamedDataType> GetEventParameters() { List <NamedDataType> pcList = new List <NamedDataType>(); ParameterInfo[] ps = Parameters; if (ps != null && ps.Length > 0) { IWithProject p = null; if (Owner != null) { p = Owner.RootPointer; } for (int i = 0; i < ps.Length; i++) { NamedDataType pc; pc = new NamedDataType(ps[i].ParameterType, ps[i].Name); pcList.Add(pc); } } return(pcList); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (service != null) { DataTypePointer typeScope = null; ITypeScopeHolder th = context.Instance as ITypeScopeHolder; if (th != null) { typeScope = th.GetTypeScope(context.PropertyDescriptor.Name); } if (typeScope == null) { foreach (Attribute a in context.PropertyDescriptor.Attributes) { TypeScopeAttribute ts = a as TypeScopeAttribute; if (ts != null && ts.Scope != null) { if (ts.Scope.IsGenericParameter) { Type[] ctps = ts.Scope.GetGenericParameterConstraints(); if (ctps != null && ctps.Length > 0) { typeScope = new DataTypePointer(new TypePointer(ctps[0])); break; } } else { typeScope = new DataTypePointer(new TypePointer(ts.Scope)); break; } } } } MethodClass scopeMethod = null; IScopeMethodHolder mh = context.Instance as IScopeMethodHolder; if (mh != null) { scopeMethod = mh.GetScopeMethod(); } IWithProject mc = context.Instance as IWithProject; if (mc == null) { ComponentInterfaceWrapper ciw = context.Instance as ComponentInterfaceWrapper; if (ciw != null) { mc = ciw.Value as IWithProject; } } if (mc == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("{0} does not implement IWithProject", context.Instance.GetType())); } else { if (mc.Project == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { MethodDiagramViewer mdv = mc as MethodDiagramViewer; if (mdv != null) { WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod; if (wcehm != null) { if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0) { return(value); } } } bool isMethodReturn = false; IObjectPointer op = value as IObjectPointer; DataTypePointer val = new DataTypePointer(); if (op != null) { val.SetDataType(op); } for (int i = 0; i < context.PropertyDescriptor.Attributes.Count; i++) { MethodReturnAttribute mra = context.PropertyDescriptor.Attributes[i] as MethodReturnAttribute; if (mra != null) { isMethodReturn = true; break; } } // bool bUseDropDown = false; EnumWebRunAt runAt = EnumWebRunAt.Inherit; PropertyClassWebClient pcwc = context.Instance as PropertyClassWebClient; if (pcwc != null) { bUseDropDown = true; runAt = EnumWebRunAt.Client; } else { PropertyClassWebServer pcws = context.Instance as PropertyClassWebServer; if (pcws != null) { bUseDropDown = true; runAt = EnumWebRunAt.Server; } } if (!bUseDropDown) { ParameterClass pc = context.Instance as ParameterClass; if (pc != null) { ConstructorClass cc = pc.Method as ConstructorClass; if (cc != null) { ClassPointer cp = cc.Owner as ClassPointer; if (cp != null) { if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType)) { //use drop down bUseDropDown = true; } } } } } // if (bUseDropDown) { TypeSelector drp = TypeSelector.GetAttributeParameterDialogue(service, runAt, val.BaseClassType); service.DropDownControl(drp); if (drp.SelectedType != null) { val.SetDataType(drp.SelectedType); bool bIsForLocalType = false; if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0) { PropertiesWrapper pw = context.Instance as PropertiesWrapper; if (pw != null) { AB_SingleAction sa = pw.Owner as AB_SingleAction; if (sa != null) { ActionAssignInstance aa = sa.ActionData as ActionAssignInstance; if (aa != null) { bIsForLocalType = true; aa.SetParameterValue(ConstObjectPointer.VALUE_Type, drp.SelectedType); } } } } if (bIsForLocalType) { } else { value = val; } } } else { Type typeAttr = null; MethodClass mc0 = scopeMethod; if (mc0 == null) { mc0 = mc as MethodClass; } if (mc0 == null) { MethodDiagramViewer mcv = mc as MethodDiagramViewer; if (mcv != null) { mc0 = mcv.Method; } } if (mc0 != null) { if (mc.Project.ProjectType == EnumProjectType.WebAppPhp) { if (mc0.WebUsage == EnumMethodWebUsage.Server) { typeAttr = typeof(PhpTypeAttribute); } else { typeAttr = typeof(JsTypeAttribute); } } else if (mc.Project.ProjectType == EnumProjectType.WebAppAspx) { if (mc0.WebUsage == EnumMethodWebUsage.Client) { typeAttr = typeof(JsTypeAttribute); } } } FrmObjectExplorer dlg = DesignUtil.GetDataTypeSelectionDialogue(mc.Project, scopeMethod, val, isMethodReturn, typeScope, typeAttr); if (service.ShowDialog(dlg) == DialogResult.OK) { val.SetDataType(dlg.SelectedDataType); bool bIsForLocalType = false; if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0) { PropertiesWrapper pw = context.Instance as PropertiesWrapper; if (pw != null) { AB_SingleAction sa = pw.Owner as AB_SingleAction; if (sa != null) { ActionAssignInstance aa = sa.ActionData as ActionAssignInstance; if (aa != null) { bIsForLocalType = true; aa.SetParameterValue(ActionAssignInstance.Instance_Type, dlg.SelectedDataType); } } } } else { ComponentIconLocal cil = context.Instance as ComponentIconLocal; bIsForLocalType = (cil != null); if (bIsForLocalType) { cil.LocalPointer.ClassType = dlg.SelectedDataType; } } if (bIsForLocalType) { } else { ExceptionHandlerList.PropertyDescriptorExceptionHandler pdeh = context.PropertyDescriptor as ExceptionHandlerList.PropertyDescriptorExceptionHandler; if (pdeh != null) { pdeh.Handler.ExceptionType = val; } else { value = val; } } } } } } } } return(value); }
public ParameterClass(Type type, string name, IWithProject prjHolder, IMethod method) : this(new TypePointer(type), name, method) { _prjItem = prjHolder; }