private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs e) { if (e.LoadedAssembly.GetCustomAttributes <AssemblyMetadataAttribute>().Any(m => m.Key == "gui"))// || m.Key == "module" { var types = (Type[])null; try { types = e.LoadedAssembly?.GetExportedTypes(); } catch (Exception ex) { Helper.OnException(ex); return; } foreach (var item in types) { if (TypeHelper.IsInterface(item, typeof(IModuleInitialize))) { try { var imodule = (IModuleInitialize)EmitInvoker.CreateObject(item); imodule.Initialize(); } catch (Exception ex) { Helper.OnException(ex); } } } } }
public List <DockPage> GetPages(Type documentType) { var documentWidgets = new List <DockPage>(); foreach (var type in GetTypes(documentType)) { var name = type.Name; var page = dock.GetPage(name); if (page == null) { if (!TypeBinding.TryGetValue(type, out var widgetType)) { widgetType = typeof(DocumentDetailView <>); } if (widgetType.IsGenericType) { widgetType = widgetType.MakeGenericType(type, type); } var widget = (Widget)EmitInvoker.CreateObject(widgetType); widget.Name = name; page = dock.Put(widget, TypeHelper.IsBaseType(type, typeof(DocumentData)) ? DockType.LeftBottom : DockType.Content); } documentWidgets.Add(page); } return(documentWidgets); }
public T GetCached <T>(string name) { if (!Cache.TryGetValue(name, out object o)) { Cache[name] = o = EmitInvoker.CreateObject(typeof(T), true); } return((T)o); }
public T GetGlobalCached <T>() { var name = typeof(T).Name; if (!GlobalCache.TryGetValue(name, out object o)) { GlobalCache[name] = o = EmitInvoker.CreateObject(typeof(T), true); } return((T)o); }
public void InitProcedure(DBItem owner, StageProcedure param) { if (!(param.Procedure is DBProcedure proc) || param.ProcedureType != StageParamProcudureType.Manual) { return; } string name = "procedure" + proc.Name; if (proc.ProcedureType == ProcedureTypes.Query) { DockPage page = dock.GetPage(name); if (page == null) { page = dock.Put(new PQueryView { Name = name, Text = param.Name == null || param.Name.Length == 0 ? proc.ToString() : param.Name, Document = document, Procedure = proc }, DockType.Content); } page.Tag = owner; } Type t = proc.ProcedureType == ProcedureTypes.Assembly || proc.ProcedureType == ProcedureTypes.Source ? proc.GetObjectType() : null; if (t != null && !TypeHelper.IsBaseType(t, typeof(Window)) && TypeHelper.IsBaseType(t, typeof(Widget))) { DockPage page = dock.GetPage(name); if (page == null) { var control = (Widget)EmitInvoker.CreateObject(t, true); control.Name = name; if (control is IText) { ((IText)control).Text = param.Name == null || param.Name.Length == 0 ? proc.ToString() : param.Name; } page = dock.Put(control, DockType.Content); } page.Tag = owner; } else { if (!(toolProcedures.DropDown?.Items[name] is MenuItemProcedure item)) { item = new MenuItemProcedure(proc) { Name = name }; item.Click += ProcedureItemClick; toolProcedures.DropDown.Items.Add(item); } item.Tag = owner; } }
public virtual DBTable CreateTable() { Debug.WriteLine($"Generate {Attribute.TableName} - {this.ItemType.Name}"); var type = typeof(DBTable <>).MakeGenericType(ItemType); // var logicType = ItemType.Assembly.ExportedTypes.FirstOrDefault(p => p.BaseType == type); var table = (DBTable)EmitInvoker.CreateObject(type); table.Name = Attribute.TableName; table.Schema = Schema; return(table); }
public virtual DBTable CreateTable() { if (TableAttribute == null) { throw new InvalidOperationException("Table attribute not initializes!"); } Debug.WriteLine($"Generate {TableAttribute.Attribute.TableName} - {Type.Name}"); var table = (DBTable)EmitInvoker.CreateObject(typeof(DBVirtualTable <>).MakeGenericType(Type)); table.Name = Type.Name; table.Schema = Schema; ((IDBVirtualTable)table).BaseTable = TableAttribute.Table; table.DisplayName = Type.Name; return(table); }
protected void MenuViewItemClick(object sender, EventArgs e) { var item = (ToolWidgetHandler)sender; if (item.Widget == null) { item.Widget = dock.Find(item.Name); if (item.Widget == null) { item.Widget = (Widget)EmitInvoker.CreateObject(item.WidgetType); item.Widget.Name = item.Name; if (item.Widget is ILocalizable) { ((ILocalizable)item.Widget).Localize(); } } } ShowControl(item.Widget); }
public static void Start(string[] args, ToolkitType type, Type splashType, Type mainType) { Application.Initialize(type); GuiService.UIThread = Thread.CurrentThread; //exceptions Application.UnhandledException += (sender, e) => { Helper.OnException(e.ErrorException); }; //Load Configuration for (int i = 0; i < args.Length; i++) { string s = args[i]; if (s.Equals("-config")) { var obj = Serialization.Deserialize(args[++i]); using (var op = new ListExplorer()) { op.DataSource = obj; op.ShowWindow((WindowFrame)null); } Application.Run(); Serialization.Serialize(obj, args[i]); return; } } using (var splash = (Splash)EmitInvoker.CreateObject(splashType)) { splash.Run(); } using (var main = (MainWindow)EmitInvoker.CreateObject(mainType)) { main.LoadConfiguration(); main.Show(); Application.Run(); } Application.Dispose(); }
public static PullIndex Create(Pull pull, Type type, Type keyType, IComparer valueComparer) { object nullKey = ListIndexFabric.GetNullKey(keyType); object keyComparer = null; if (keyType == typeof(string)) { keyComparer = StringComparer.OrdinalIgnoreCase; } if (keyType.IsValueType || keyType.IsEnum) { var gtype = typeof(NullablePullIndex <,>).MakeGenericType(type, keyType); return((PullIndex)EmitInvoker.CreateObject(gtype, ctorTypes, new object[] { pull, nullKey, valueComparer, keyComparer }, true)); } else { var gtype = typeof(PullIndex <,>).MakeGenericType(type, keyType); return((PullIndex)EmitInvoker.CreateObject(gtype, ctorTypes, new object[] { pull, nullKey, valueComparer, keyComparer }, true)); } }
public object CreateObject(ExecuteArgs arg = null) { object temp = null; if (ProcedureType == ProcedureTypes.Assembly || ProcedureType == ProcedureTypes.Source) { temp = EmitInvoker.CreateObject(GetObjectType(), true); } else if (ProcedureType == ProcedureTypes.Table) { temp = DBService.Schems.ParseTable(Source); } else if (ProcedureType == ProcedureTypes.Constant) { temp = Source; } else { temp = BuildCommand(arg.Parameters); } return(temp); }
public ListEditor(LayoutList list) : base() { handleGetEditor = ListOnGetCellEditor; toolStatusArchive = new ToolMenuItem() { Name = "Archive", Tag = DBStatus.Archive, Glyph = GlyphType.FlagCheckered }; toolStatusEdit = new ToolMenuItem() { Name = "Edit", Tag = DBStatus.Edit, GlyphColor = Colors.DarkOrange, Glyph = GlyphType.Flag }; toolStatusError = new ToolMenuItem() { Name = "Error", Tag = DBStatus.Error, GlyphColor = Colors.DarkRed, Glyph = GlyphType.Flag }; toolStatusDelete = new ToolMenuItem() { Name = "Delete", Tag = DBStatus.Delete, GlyphColor = Colors.Purple, Sensitive = false, Glyph = GlyphType.Flag }; toolStatusActual = new ToolMenuItem() { Name = "Actual", Tag = DBStatus.Actual, GlyphColor = Colors.DarkGreen, Sensitive = false, Glyph = GlyphType.Flag }; toolStatusNew = new ToolMenuItem() { Name = "New", Tag = DBStatus.New, GlyphColor = Colors.DarkBlue, Sensitive = false, Glyph = GlyphType.Flag }; toolStatus = new ToolSplit() { Name = "Status", Glyph = GlyphType.Flag, DropDown = new Menubar { Name = "Status" } }; toolStatus.DropDownItems.AddRange(new[] { toolStatusNew, toolStatusActual, toolStatusEdit, toolStatusArchive, toolStatusError, toolStatusDelete }); toolStatus.ButtonClick += OnToolStatusClick; toolStatus.ItemClick += ToolStatusItemClicked; toolPosition = new ToolLabel { Name = "Position", Text = "_ / _" }; toolCopy = new ToolMenuItem(OnToolCopyClick) { Name = "Copy", Glyph = GlyphType.CopyAlias }; toolInsert = new ToolMenuItem(OnToolInsertClick) { Name = "Insert", Glyph = GlyphType.Plus }; toolCut = new ToolItem(OnToolCutClick) { Name = "Cut", DisplayStyle = ToolItemDisplayStyle.Text, Visible = false, Glyph = GlyphType.CutAlias }; toolLog = new ToolItem(OnToolLogClick) { Name = "Logs", DisplayStyle = ToolItemDisplayStyle.Text, Glyph = GlyphType.History }; toolAccess = new ToolItem(ToolAccessClick) { Name = "Access", DisplayStyle = ToolItemDisplayStyle.Text, CheckOnClick = true, Glyph = Glyph = GlyphType.Key }; toolRefresh = new ToolItem(OnToolRefreshClick) { Name = "Refresh", DisplayStyle = ToolItemDisplayStyle.Text, Glyph = GlyphType.Refresh }; toolSave = new ToolItem(OnToolSaveClick) { Name = "Save", DisplayStyle = ToolItemDisplayStyle.Text, GlyphColor = Colors.Blue, Glyph = GlyphType.SaveAlias }; toolLoad = new ToolItem(OnToolLoadClick) { Name = "Load", DisplayStyle = ToolItemDisplayStyle.Text, Glyph = GlyphType.FolderOpen }; toolAdd = new ToolDropDown(toolInsert, toolCopy) { Name = "Add", DisplayStyle = ToolItemDisplayStyle.Text, GlyphColor = Colors.Green, Glyph = GlyphType.PlusCircle }; toolRemove = new ToolItem(OnToolRemoveClick) { Name = "Remove", DisplayStyle = ToolItemDisplayStyle.Text, GlyphColor = Colors.Red, Glyph = GlyphType.MinusCircle }; toolEdit = new ToolItem(OnToolEditClick) { Name = "Edit", DisplayStyle = ToolItemDisplayStyle.Text, Visible = false, GlyphColor = Colors.SandyBrown, Glyph = GlyphType.Pencil }; bar = new Toolsbar( toolRefresh, toolLoad, toolSave, new ToolSeparator(), toolAccess, toolAdd, toolRemove, //toolEdit, toolCut, toolLog, toolStatus, new ToolSeparator() { FillWidth = true }, toolPosition) { Name = "ListEditor" }; box = new VBox() { Spacing = 1 }; box.PackStart(bar, false, false); container = new VPaned() { Name = "container" }; container.Panel1.Content = box; PackStart(container, true, true); List = list; fields = (LayoutList)EmitInvoker.CreateObject(list.GetType()); fields.EditMode = EditModes.ByClick; fields.RetriveCellEditor += handleGetEditor; toolWindow = new ToolWindow() { Target = fields, Mode = ToolShowMode.Dialog }; toolWindow.ButtonAcceptClick += OnToolWindowAcceptClick; toolWindow.ButtonCloseClick += OnToolWindowCancelClick; Localize(); }