private Stream GetExternalImageStream(object value) { string name = value as string; if (string.IsNullOrEmpty(name)) { return(null); } try { if (_resourceLocator != null) { Resource imageResource = _resourceLocator.GetResource(new ResourceInfo(name)); if (imageResource.Value != null) { return(imageResource.Value); } } if (File.Exists(name)) { return(File.OpenRead(name)); } return(null); } catch (Exception) { // catch everything -- there could be out of memory, file not found else??? Trace.TraceError("Failed to load image from '{0}'.", value); return(null); } }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // FileStatsView var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(FileStatsViewModel)).GetName().Name, "DataTemplates/FileStatsViewDataTemplate.xaml", "FileStatsViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(FileStatsViewModel), template); // RecentFiles template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(RecentFilesTWViewModel)).GetName().Name, "DataTemplates/RecentFilesViewDataTemplate.xaml", "RecentFilesViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(RecentFilesTWViewModel), template); // FileExplorer template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(FileExplorerViewModel)).GetName().Name, "DataTemplates/FileExplorerViewDataTemplate.xaml", "FileExplorerViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(FileExplorerViewModel), template); return(paneSel); }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // StartPageView var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(StartPageViewModel)).GetName().Name, "DataTemplates/StartPageViewDataTemplate.xaml", "StartPageViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(StartPageViewModel), template); //EdiView template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(EdiViewModel)).GetName().Name, "DataTemplates/EdiViewDataTemplate.xaml", "EdiViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(EdiViewModel), template); // MiniUml template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(MiniUmlViewModel)).GetName().Name, "DataTemplates/MiniUMLViewDataTemplate.xaml", "MiniUMLViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(MiniUmlViewModel), template); return(paneSel); }
/// <summary> /// Finds the editor template. /// </summary> /// <returns>DataTemplate the Editor should be applied.</returns> protected virtual DataTemplate FindEditorTemplate() { if (Entry == null) { return(null); } var editor = Entry.Editor; if (editor == null) { return(null); } var template = editor.InlineTemplate as DataTemplate; if (template != null) { return(template); } if (editor.InlineTemplate == null) { Console.Out.WriteLine($"Can't find template for {Entry.Name}"); return(null); } return(ResourceLocator.GetResource(editor.InlineTemplate) as DataTemplate); }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // Register Log4Net DataTemplates var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(Log4NetViewModel)).GetName().Name, "DataTemplates/Log4NetViewDataTemplate.xaml", "Log4NetDocViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(Log4NetViewModel), template); template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(Log4NetMessageToolViewModel)).GetName().Name, "DataTemplates/Log4NetViewDataTemplate.xaml", "Log4NetMessageViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(Log4NetMessageToolViewModel), template); template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(Log4NetToolViewModel)).GetName().Name, "DataTemplates/Log4NetViewDataTemplate.xaml", "Log4NetToolViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(Log4NetToolViewModel), template); return(paneSel); }
public override void Execute() { Guard.ArgumentValue(Command == null && string.IsNullOrEmpty(CommandName), "Command", COMMANDORNAME_MUSTBE_SPECIFIED); if (!this.IsEnabled) { return; } var _command = Command ?? ResourceLocator.GetResource <ICommand>(CommandName); Guard.ArgumentNotNull(_command, "Command", COMMAND_NOT_RESOLVED, CommandName); if (!string.IsNullOrEmpty(SiteArea)) { SiteMapService.InitializeSiteArea(SiteArea, (b) => { if (!b) { throw new SiteMapException(string.Format(AREA_COULDNOT_INITIALIZE, SiteArea, CommandName), SiteArea); } if (_command.CanExecute(CommandParameter)) { _command.Execute(CommandParameter); } }); } else { if (_command.CanExecute(CommandParameter)) { _command.Execute(CommandParameter); } } }
/// <summary> /// returns a controlltemplate or null /// </summary> /// <param name="template"></param> /// <returns></returns> private ControlTemplate GetControlTemplate(object template) { if (template == null) { return(null); } var controlTemplate = template as ControlTemplate; if (controlTemplate != null) { return(controlTemplate); } //return null; var resourceKey = template as string; if (resourceKey == null) { return(null); } //try find the resources from the application return(_resourceLocator.GetResource(resourceKey) as ControlTemplate); }
public static Object GetViewModel(Type viewType) { Guard.ArgumentNotNull(viewType, "viewType"); var _viewModelProvider = ResourceLocator.GetResource <IViewModelProvider>(viewType.FullName); return(_viewModelProvider.CreateViewModelInstance()); }
/// <summary> /// Load an AvalonDock DocumentHeaderTemplate from resources. /// </summary> /// <returns></returns> private DataTemplate LoadDocumentHeaderTemplate() { return (ResourceLocator.GetResource <DataTemplate>( "Edi.Apps", "Resources/DocumentHeaderDataTemplate.xaml", "AvalonDock_DocumentHeader") as DataTemplate); }
private PanesStyleSelector RegisterStyles(PanesStyleSelector selectPanesStyle) { var newStyle = ResourceLocator.GetResource <Style>( "Log4NetTools", "Styles/AvalonDockStyles.xaml", "Log4NetStyle") as Style; selectPanesStyle.RegisterStyle(typeof(Log4NetViewModel), newStyle); return(selectPanesStyle); }
private void RegisterStyles(PanesStyleSelector selectPanesStyle) { var newStyle = ResourceLocator.GetResource <Style>( "Edi.Apps", "Resources/Styles/AvalonDockStyles.xaml", "StartPageStyle"); selectPanesStyle.RegisterStyle(typeof(StartPageViewModel), newStyle); }
public void RegisterDataTemplates(PanesTemplateSelectorDynamic paneSel) { var template2 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(LoginViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "LoginViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(LoginViewModel), template2); }
public void RegisterDataTemplates(PanesTemplateSelectorDynamic paneSel) { var template2 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(SimpleExaminationViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "TecheartSlnPlugClassroomSimpleExaminationViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(SimpleExaminationViewModel), template2); }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // Register Log4Net DataTemplates var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(OutputTWViewModel)).GetName().Name, "DataTemplates/OutputViewDataTemplate.xaml", "OutputViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(OutputTWViewModel), template); return(paneSel); }
public void RegisterDataTemplates(PanesTemplateSelectorDynamic paneSel) { var template2 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(RelationListViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "RelationListViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(RelationListViewModel), template2); var template3 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(ProducerMonitorViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "ProducerMonitorViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(ProducerMonitorViewModel), template3); //var template4 = ResourceLocator.GetResource<DataTemplate>( // Assembly.GetAssembly(typeof(TecheartHostViewModel)).GetName().Name, // "FoundationDataTemplate.xaml", // "TecheartHostViewTemplate") as DataTemplate; //paneSel.RegisterDataTemplate(typeof(TecheartHostViewModel), template4); var template5 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(LoginViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "LoginViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(LoginViewModel), template5); var template6 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(SearchViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "TecheartSlnPlugSearchViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(SearchViewModel), template6); var template7 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(AddUserViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "TecheartSlnPlugAddUserViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(AddUserViewModel), template7); var template8 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(SearchUserViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "TecheartSlnPlugSearchUserViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(SearchUserViewModel), template8); }
public void UpdateGraphics() { if (data == null) { return; } nameText.text = data.Name; for (int i = levelPanel.childCount - 1; i >= 0; --i) { Destroy(levelPanel.GetChild(i).gameObject); } for (int i = costsPanel.childCount - 1; i >= 0; --i) { Destroy(costsPanel.GetChild(i).gameObject); } for (int i = effectsPanel.childCount - 1; i >= 0; --i) { Destroy(effectsPanel.GetChild(i).gameObject); } for (int i = 0; i < data.Level; ++i) { Instantiate(levelIconPrefab, levelPanel); } foreach (CardData.Cost cost in data.Costs) { Transform costTransform = Instantiate(costUIPrefab, costsPanel); costTransform.GetChild(0).GetComponent <TextMeshProUGUI>().text = cost.Amount.ToString(); costTransform.GetChild(1).GetComponent <Image>().sprite = ResourceLocator.GetResource(cost.ResourceType).Icon; } foreach (CardData.Effect effect in data.Effects) { Transform effectTransform = Instantiate(effectUIPrefab, effectsPanel); Transform onlyTextPanel = effectTransform.GetChild(0); Transform resourceEffectPanel = effectTransform.GetChild(1); switch (effect.EffectType) { case CardData.Effect.Type.AddResources: resourceEffectPanel.GetChild(0).GetComponent <TextMeshProUGUI>().text = effect.ResourceAmount.ToString(); resourceEffectPanel.GetChild(1).GetComponent <Image>().sprite = ResourceLocator.GetResource(effect.ResourceType).Icon; break; } } }
public void RedisterStyles(PanesStyleSelectorDynamic selectPanesStyle) { var newStyle = ResourceLocator.GetResource <Style>( "TecheartSln.Core", "FoundationStyle.xaml", "ToolStyle"); var fileStyle = ResourceLocator.GetResource <Style>( "TecheartSln.Core", "FoundationStyle.xaml", "FileStyle"); selectPanesStyle.RegisterStyle(typeof(ToolViewModel), newStyle); selectPanesStyle.RegisterStyle(typeof(TemplateBaseViewModel), fileStyle); }
/// <summary> /// Load an PanestayleSelector with initial styles from resources. /// </summary> /// <returns></returns> private void LoadPanesStyleSelector(PanesStyleSelector panesStyleSelector) { var newStyle = ResourceLocator.GetResource <Style>( "Edi.Apps", "Resources/Styles/AvalonDockStyles.xaml", "FileStyle"); panesStyleSelector.RegisterStyle(typeof(FileBaseViewModel), newStyle); newStyle = ResourceLocator.GetResource <Style>( "Edi.Apps", "Resources/Styles/AvalonDockStyles.xaml", "ToolStyle"); panesStyleSelector.RegisterStyle(typeof(ToolViewModel), newStyle); }
public void RegisterDataTemplates(PanesTemplateSelectorDynamic paneSel) { var template2 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(QuestionEditorViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "TecheartSlnPlugEditorQuestionEditorViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(QuestionEditorViewModel), template2); var template3 = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(StudentInfoEditorViewModel)).GetName().Name, "FoundationDataTemplate.xaml", "TecheartSlnPlugEditorStudentInfoEditorViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(StudentInfoEditorViewModel), template3); }
public object Convert(object value, Type targetType, object parameter, string language) { string encodedGlyph = value.ToString(); string glyph = GlyphEncoder.DecodeGlyph(encodedGlyph, out GlyphFamily family); FontIcon icon = new FontIcon { Glyph = glyph, }; string resourceName = GetFontIconStyleResourceName(family); if (!string.IsNullOrWhiteSpace(resourceName) && ResourceLocator.GetResource(resourceName, out Style fontStyle)) { icon.Style = fontStyle; } if (parameter != null && double.TryParse(parameter.ToString(), out double fontSize)) { icon.FontSize = fontSize; } return(icon); }
public override Resource GetResource(ResourceInfo resourceInfo) { Resource resource = _parentResourceLocator.GetResource(resourceInfo); // the rdl resource if (resource.Value != null && !string.IsNullOrEmpty(resourceInfo.Name) && resourceInfo.Name.ToLower().EndsWith(".rdlx")) { ReportDefinition rdl = new ReportDefinition(); rdl.Load(new StreamReader(resource.Value)); //need to centralize all DataSource in one Report source,so report source dynamically change report datasource on the fly for (int i = 0; i < rdl.Report.DataSources.Count; i++) { if (_dataSourceType == EmReportDataSourceType.DWDatabase.ToString()) { rdl.Report.DataSources[i].DataSourceReference = null; rdl.Report.DataSources[i].ConnectionProperties.ConnectString = DDSetup.DWDataSourceConnectionString; rdl.Report.DataSources[i].ConnectionProperties.DataProvider = "SQL"; } else { rdl.Report.DataSources[i].DataSourceReference = null; rdl.Report.DataSources[i].ConnectionProperties.ConnectString = DDSetup.PLMConnectionString; rdl.Report.DataSources[i].ConnectionProperties.DataProvider = "SQL"; } } // return the modified resource MemoryStream rdlStream = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(rdlStream, Encoding.UTF8); rdl.Save(writer); writer.Flush(); rdlStream.Seek(0, SeekOrigin.Begin); return(new Resource(rdlStream, resource.ParentUri)); } // for all other resources, just return them using the default resource locator return(resource); }
private DataTemplate GetDataTemplate(object template) { if (template == null) { return(null); } var dataTemplate = template as DataTemplate; if (dataTemplate != null) { return(dataTemplate); } var resourceKey = template as ComponentResourceKey; if (resourceKey == null) { return(null); } return(_resourceLocator.GetResource(resourceKey) as DataTemplate); }
protected virtual DataTemplate FindEditorTemplate(CategoryItem category) { if (category == null) { return(null); } var editor = category.Editor; if (editor == null) { return(null); } var template = editor.InlineTemplate as DataTemplate; if (template != null) { return(template); } return(_resourceLocator.GetResource(editor.InlineTemplate) as DataTemplate); }
/// <summary> /// Finds the editor template. /// </summary> /// <returns>DataTemplate the Editor should be applied.</returns> protected virtual DataTemplate FindEditorTemplate() { if (Entry == null) { return(null); } var editor = Entry.Editor; if (editor == null) { return(null); } var template = editor.InlineTemplate as DataTemplate; if (template != null) { return(template); } return(ResourceLocator.GetResource(editor.InlineTemplate) as DataTemplate); }
public void Testing() { ResourceLocator.GetResource("file1.txt"); }
public static object GetViewService(Type viewServiceType, string name) { return(ResourceLocator.GetResource(viewServiceType, name)); }
public static T GetViewService <T>(string name) where T : class { return(ResourceLocator.GetResource <T>(name)); }
// Get ViewService Related public static T GetViewService <T>() where T : class { return(ResourceLocator.GetResource <T>()); }
public static object GetChannelObserver(Type channelType, string name) { return(ResourceLocator.GetResource(GetObserverTypeForChannel(channelType), name)); }
public static IObserver <T> GetChannelObserver <T>(string name) { return(ResourceLocator.GetResource <IObserver <T> >(name)); }