private TemplateProperty CreateXMLStructure() { TemplateProperty template = new TemplateProperty() { SimModelClass = "SimTemplateOccupancyDriven", Type = "Default", SubType = "Default" }; TemplateProperty zoneLoadsProp = new TemplateProperty() { PropertyName = "Loads", Category = "Loads", SimModelClass = "SimInternalLoad", Type = "Any", SubType = "Any", InstanceSpeciferPropName = "Loads", Properties = new List <ComponentProperty>() { new TemplateProperty() { } } }; return(template); }
TemplatePropertyList ConstructNamedProperties(MessageTemplate template, object[] messageTemplateParameters) { var namedProperties = template.NamedProperties; if (namedProperties == null) { return(NoProperties); } var matchedRun = namedProperties.Length; if (namedProperties.Length != messageTemplateParameters.Length) { matchedRun = Math.Min(namedProperties.Length, messageTemplateParameters.Length); SelfLog.WriteLine("Named property count does not match parameter count: {0}", template); } var result = new TemplateProperty[matchedRun]; for (var i = 0; i < matchedRun; ++i) { var property = template.NamedProperties[i]; var value = messageTemplateParameters[i]; result[i] = ConstructProperty(property, value); } return(new TemplatePropertyList(result)); }
static KeyboardShortcutBox() { var res = new ResourceDictionary() { Source = new Uri("pack://application:,,,/VolumeSwitch;component/View/Theme/KeyboardShortcutBoxTemplate.xaml", UriKind.Absolute) }; TemplateProperty.OverrideMetadata(typeof(KeyboardShortcutBox), new FrameworkPropertyMetadata(res[typeof(KeyboardShortcutBox)])); }
/// <summary> /// Loads templates from the template folder. /// </summary> /// <param name="templateFolderPath">Folder containing all templates.</param> /// <returns>List of templates.</returns> public static List <Template> LoadTemplates(string templateFolderPath) { List <Template> templates = new List <Template>(); DirectoryInfo templateDirectory = new DirectoryInfo(templateFolderPath); foreach (FileInfo fileInfo in templateDirectory.GetFiles()) { string fileName = fileInfo.FullName; if (fileName.Length < 5) { continue; } if (fileName.Substring(fileName.Length - 5) == ".html") { string templateContent = Utils.GetFullFileConent(fileName); bool acceptsContent = templateContent.Contains("@ChildContent;"); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(templateContent); doc.RemoveComments(); string templateFileNameWithoutExtension = fileInfo.Name.Substring(0, fileInfo.Name.Length - Path.GetExtension(fileInfo.Name).Length); string templateTagName = HttpUtility.UrlEncode(templateFileNameWithoutExtension); List <TemplateProperty> properties = new List <TemplateProperty>(); HtmlNode[] nameNodes = doc.DocumentNode.Descendants("TName").ToArray(); if (nameNodes.Length > 0) { templateTagName = HttpUtility.UrlEncode(nameNodes[0].GetAttributeValue("name", templateTagName)); } foreach (HtmlNode node in nameNodes) { node.Remove(); } HtmlNode[] propertyNodes = doc.DocumentNode.Descendants("TProperty").ToArray(); foreach (HtmlNode node in propertyNodes) { string propertyName = HttpUtility.UrlEncode(node.GetAttributeValue("name", string.Empty)); string propertyDefault = HttpUtility.UrlEncode(node.GetAttributeValue("default", null)); if (!string.IsNullOrEmpty(propertyName)) { TemplateProperty property = new TemplateProperty(propertyName, propertyDefault); properties.Add(property); } node.Remove(); } Template template = new Template(templateTagName, fileName, doc.DocumentNode.OuterHtml, acceptsContent); template.Properties = properties; templates.Add(template); } } return(templates); }
static MeterControl() { ResourceDictionary dictionary = new ResourceDictionary { Source = new Uri("pack://application:,,,/Synth.WPF;component/Controls/ControlResources.xaml") }; ControlTemplate defaultTemplate = (ControlTemplate)dictionary["MeterControlDefaultTemplate"]; TemplateProperty.OverrideMetadata(typeof(MeterControl), new FrameworkPropertyMetadata(defaultTemplate)); }
protected static void InitializeClassMetadata <T>(ControlTemplate template) where T : Module { DefaultStyleKeyProperty.OverrideMetadata(typeof(T), new FrameworkPropertyMetadata(typeof(T))); TemplateProperty.SetDefaultValue <T>(template); DescriptionProperty.SetDefaultValue <T>(typeof(T).Name); }
static LabelControl() { //DefaultStyleKeyProperty.OverrideMetadata(typeof(LabelControl), new FrameworkPropertyMetadata(typeof(LabelControl))); ResDict = new ResourceDictionary { Source = new Uri("WPFControlExt;component/LabelControl.res.xaml", UriKind.RelativeOrAbsolute) }; LabelControlTemplate = (ControlTemplate)ResDict["LabelControlTemplate"]; TemplateProperty.OverrideMetadata(typeof(LabelControl), new FrameworkPropertyMetadata(LabelControlTemplate)); }
public ServiceResponse <TemplatePropertyDto> GetTemplateProperty(long id) { var Rm = new RepositoryManager(ServiceContext); TemplateProperty entity = Rm.TemplatePropertyRepository.Get(id); if (entity == null) { throw new ServiceException(ExceptionType.Warning, Translate(MessagesConstants.WRN_RECORD_NOT_FOUND)); } return(new ServiceResponse <TemplatePropertyDto>(entity.CopyTo(new TemplatePropertyDto()))); }
private void Detach() { MaximumFrequencyProperty.Detach(OnRequireUpdateLayout); MinimumFrequencyProperty.Detach(OnRequireUpdateLayout); BarCountProperty.Detach(OnRequireUpdateLayout); BarSpacingProperty.Detach(OnRequireUpdateLayout); IsFrequencyScaleLinearProperty.Detach(OnRequireUpdateLayout); BarStyleProperty.Detach(OnRequireUpdateLayout); PeakStyleProperty.Detach(OnRequireUpdateLayout); RefreshIntervalProperty.Detach(OnRefreshIntervalChanged); TemplateProperty.Detach(OnSpectrumTemplateChanged); }
//COMMENT 26.03.2020: // ERROR DESCRIPTION: // see Ticket #1711, problem about icons not appearing: // In the project that was sent to us on the 26th of March 2020: // BasePage.xaml -> ItemsControl named "icSubNavigation" -> ItemTemplate Property -> DataTemplate with the key: dtSubNavigationIcon: // Properly generated in C# but when translated into js, the first letter of the methods that are called is lowercased. // I could not find the conditions nor the reasons for such a case to appear so I settled with the following workaround: // WORKAROUND: // Create an additional private method with the same signature except with the first character of its name lowercased, that calls the original one. // NOTE: // This workaround was used only for the methods that were in that specific case, so we might need to use it for other methods if other cases appear. // Workaround currently used on: // - INTERNAL_GetVisualStateGroups // - RegisterName //END OF COMMENT // Note: this should be protected and the Control class should be abstract. /// <summary> /// Represents the base class for UI elements that use a <see cref="ControlTemplate"/> /// to define their appearance. /// </summary> public Control() { // Initialize the _templateCache to the default value for TemplateProperty. // If the default value is non-null then wire it to the current instance. PropertyMetadata metadata = TemplateProperty.GetMetadata(this.GetType()); ControlTemplate defaultValue = (ControlTemplate)metadata.DefaultValue; if (defaultValue != null) { OnTemplateChanged(this, new DependencyPropertyChangedEventArgs(null, defaultValue, TemplateProperty)); } }
void Initialize() { // Initialize the _templateCache to the default value for TemplateProperty. // If the default value is non-null then wire it to the current instance. PropertyMetadata metadata = TemplateProperty.GetMetadata(DependencyObjectType); DataTemplate defaultValue = (DataTemplate)metadata.DefaultValue; if (defaultValue != null) { OnTemplateChanged(this, new DependencyPropertyChangedEventArgs(TemplateProperty, metadata, null, defaultValue)); } DataContext = null; // this presents a uniform view: CP always has local DC }
public bool CreateTemplateProperty(TemplatePropCreate model) { var entity = new TemplateProperty() { TemplateId = model.TemplateId, PropertyName = model.PropertyName, PropertyType = model.PropertyType, }; using (var ctx = new ApplicationDbContext()) { ctx.TemplateProperties.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateCardProperty(CardPropCreate model) { using (var ctx = new ApplicationDbContext()) { TemplateProperty tempProp = ctx.TemplateProperties.Find(model.TemplatePropId); var entity = new CardProperty(tempProp) { CardId = model.CardId, Value = model.Value }; ctx.CardProperties.Add(entity); return(ctx.SaveChanges() == 1); } }
static ViewElement() { var self = typeof(ViewElement); var template = new ControlTemplate(self); var contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter)); contentPresenter.SetValue(ContentPresenter.ContentSourceProperty, "View"); template.VisualTree = contentPresenter; template.Seal(); TemplateProperty.OverrideMetadata(self, new FrameworkPropertyMetadata(template)); }
private bool TrySetProperty(string propertyName, object value) { if (value is TemplateProperty) { _Properties[propertyName] = value as TemplateProperty; return(true); } else if (value is string) { _Properties[propertyName] = new TemplateProperty(value as string, null); return(true); } else { return(false); } }
static void Init() { templateFolders = TemplateLoader.GetTemplateFolders(); templateOptions = TemplateLoader.GetTemplateNames(templateFolders); popupIndex = 0; licenceScroll = new Vector2(); messages = new List <Message>(); if (templateFolders.Length > 0) { templateProperty = TemplateLoader.GetTemplateProperty(templateFolders[popupIndex]); replaceStringList = CreateReplaceStringList(templateProperty.replaceList); } else { messages.Add(new Message(LocalizedMessage.Get("TemplateLoaderWindow.TemplatesAreNotExists"), MessageType.Warning)); } }
public ServiceResponse <int> UpdateTemplateProperty(TemplatePropertyDto templatePropertyDto) { if (templatePropertyDto == null) { throw new ServiceException(Translate(MessagesConstants.ERR_DATA_NOT_FOUND_TO_SAVE)); } TemplateProperty entity = new TemplateProperty(); var Rm = new RepositoryManager(ServiceContext); int rowsAffected = Rm.TemplatePropertyRepository.Update(entity.CopyFrom(templatePropertyDto)); if (rowsAffected > 0) { return(new ServiceResponse <int>(rowsAffected, Translate(MessagesConstants.SCC_DATA_UPDATED))); } throw new ServiceException(Translate(MessagesConstants.ERR_UPDATE)); }
public ServiceResponse <long> InsertTemplateProperty(TemplatePropertyDto templatePropertyDto) { if (templatePropertyDto == null) { throw new ServiceException(Translate(MessagesConstants.ERR_DATA_NOT_FOUND_TO_SAVE)); } TemplateProperty entity = new TemplateProperty(); var Rm = new RepositoryManager(ServiceContext); long id = Rm.TemplatePropertyRepository.Insert(entity.CopyFrom(templatePropertyDto)); if (id > 0) { return(new ServiceResponse <long>(id, Translate(MessagesConstants.SCC_DATA_INSERTED))); } throw new ServiceException(Translate(MessagesConstants.ERR_INSERT)); }
static void Init() { templateFolders = TemplateLoader.GetTemplateFolders(); templateOptions = TemplateLoader.GetTemplateNames(templateFolders); popupIndex = 0; licenceScroll = new Vector2(); messages = new List <Message>(); if (templateFolders.Length > 0) { templateProperty = TemplateLoader.GetTemplateProperty(templateFolders[popupIndex]); replaceStringList = CreateReplaceStringList(templateProperty.replaceList); } else { messages.Add(new Message("テンプレートがありません。", MessageType.Warning)); } }
TemplatePropertyList ConstructPositionalProperties(MessageTemplate template, object[] messageTemplateParameters) { var positionalProperties = template.PositionalProperties; if (positionalProperties.Length != messageTemplateParameters.Length) { SelfLog.WriteLine("Positional property count does not match parameter count: {0}", template); } var result = new TemplateProperty[messageTemplateParameters.Length]; foreach (var property in positionalProperties) { int position; if (property.TryGetPositionalValue(out position)) { if (position < 0 || position >= messageTemplateParameters.Length) { SelfLog.WriteLine("Unassigned positional value {0} in: {1}", position, template); } else { result[position] = ConstructProperty(property, messageTemplateParameters[position]); } } } var next = 0; for (var i = 0; i < result.Length; ++i) { if (result[i] != null) { result[next] = result[i]; ++next; } } if (next != result.Length) { Array.Resize(ref result, next); } return(new TemplatePropertyList(result)); }
/// <summary> /// Static constructor /// </summary> static RibbonWindow() { StyleProperty.OverrideMetadata(typeof(RibbonWindow), new FrameworkPropertyMetadata(null, OnCoerceStyle)); DefaultStyleKeyProperty.OverrideMetadata(typeof(RibbonWindow), new FrameworkPropertyMetadata(typeof(RibbonWindow))); if (FrameworkHelper.PresentationFrameworkVersion < new Version("4.0")) { // On older versions of the framework the client size of the window is incorrectly calculated. TemplateProperty.AddOwner(typeof(RibbonWindow), new FrameworkPropertyMetadata(OnWindowPropertyChangedThatRequiresTemplateFixup)); FlowDirectionProperty.AddOwner(typeof(RibbonWindow), new FrameworkPropertyMetadata(OnWindowPropertyChangedThatRequiresTemplateFixup)); } // Register commands CommandManager.RegisterClassCommandBinding(typeof(RibbonWindow), new CommandBinding(CloseCommand, OnCloseCommandExecuted)); CommandManager.RegisterClassCommandBinding(typeof(RibbonWindow), new CommandBinding(MinimizeCommand, OnMinimizeCommandExecuted)); CommandManager.RegisterClassCommandBinding(typeof(RibbonWindow), new CommandBinding(MaximizeCommand, OnMaximizeCommandExecuted)); CommandManager.RegisterClassCommandBinding(typeof(RibbonWindow), new CommandBinding(NormalizeCommand, OnNormalizeCommandExecuted)); }
protected override EmailMessage MapTo(ResetPasswordMessage obj) { TemplateProperty templateProperty = new TemplateProperty() { ClientId = obj.ClientId, Language = obj.Language, Year = DateTime.Today.Year, BizGroup = "DAF.SSO", TemplateName = "ResetPassword.cshtml" }; var result = engine.LoadTemplate(obj, templateProperty); EmailMessage mail = new EmailMessage() { To = new string[] { obj.Email }, Subject = Resources.Locale(o => o.ResetPasswordTitle), Body = result.Body }; return(mail); }
set => SetValue(TemplateProperty, value);
static BendModPanel() { ControlTemplate defaultTemplate = GetResource <ControlTemplate>("BendModDefaultTemplate"); TemplateProperty.OverrideMetadata(typeof(BendModPanel), new FrameworkPropertyMetadata(defaultTemplate)); }
IEnumerable<TemplateProperty> ConstructNamedProperties(MessageTemplate template, object[] messageTemplateParameters) { var namedProperties = template.NamedProperties; if (namedProperties == null) return Enumerable.Empty<TemplateProperty>(); var matchedRun = namedProperties.Length; if (namedProperties.Length != messageTemplateParameters.Length) { matchedRun = Math.Min(namedProperties.Length, messageTemplateParameters.Length); SelfLog.WriteLine("Named property count does not match parameter count: {0}", template); } var result = new TemplateProperty[matchedRun]; for (var i = 0; i < matchedRun; ++i) { var property = template.NamedProperties[i]; var value = messageTemplateParameters[i]; result[i] = ConstructProperty(property, value); } return result; }
IEnumerable<TemplateProperty> ConstructPositionalProperties(MessageTemplate template, object[] messageTemplateParameters) { var positionalProperties = template.PositionalProperties; if (positionalProperties.Length != messageTemplateParameters.Length) SelfLog.WriteLine("Positional property count does not match parameter count: {0}", template); var result = new TemplateProperty[messageTemplateParameters.Length]; foreach (var property in positionalProperties) { int position; if (property.TryGetPositionalValue(out position)) { if (position < 0 || position >= messageTemplateParameters.Length) SelfLog.WriteLine("Unassigned positional value {0} in: {1}", position, template); else result[position] = ConstructProperty(property, messageTemplateParameters[position]); } } var next = 0; for (var i = 0; i < result.Length; ++i) { if (result[i] != null) { result[next] = result[i]; ++next; } } if (next != result.Length) Array.Resize(ref result, next); return result; }
static void Render(TextWriter output, TemplateProperty property, IFormatProvider formatProvider = null) { output.Write(property.Name); output.Write(": "); property.Value.Render(output, null, formatProvider); }
private void OnGUI() { EditorGUIUtility.labelWidth = 80; EditorGUILayout.LabelField("Template Loader"); popupIndex = EditorGUILayout.Popup("Template:", popupIndex, templateOptions); if (UnityEngine.GUI.changed) { templateProperty = TemplateLoader.GetTemplateProperty(templateFolders[popupIndex]); replaceStringList = CreateReplaceStringList(templateProperty.replaceList); licenceScroll = new Vector2(); messages = new List <Message>(); } if (templateProperty != null) { //Template Property EditorGUILayout.LabelField("", UnityEngine.GUI.skin.horizontalSlider); EditorGUILayout.LabelField("Description:", templateProperty.description); EditorGUILayout.LabelField("Developer:", templateProperty.developer); if (!string.IsNullOrEmpty(templateProperty.developerUrl)) { CustomGUILayout.URLButton("Open developer website", templateProperty.developerUrl); } if (templateProperty.lisenseFile) { licenceScroll = EditorGUILayout.BeginScrollView(licenceScroll); GUILayout.TextArea(templateProperty.lisenseFile.text); EditorGUILayout.EndScrollView(); } //Replace List EditorGUILayout.LabelField("", UnityEngine.GUI.skin.horizontalSlider); EditorGUI.BeginDisabledGroup(ProductSettings.HideMenuItem); { if (templateProperty.replaceList != null) { foreach (var replace in templateProperty.replaceList) { replaceStringList[replace.ID] = EditorGUILayout.TextField(replace.label, replaceStringList[replace.ID]); } } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!CheckAllReplaceFieldFilled(replaceStringList)); if (GUILayout.Button("Load")) { if (UnityEditor.EditorSettings.serializationMode == SerializationMode.ForceBinary && !EditorUtility.DisplayDialog("Template Loader", LocalizedMessage.Get("TemplateLoaderWindow.ForceBinaryDetected"), LocalizedMessage.Get("TemplateLoaderWindow.ForceBinaryDetected.Continue"), LocalizedMessage.Get("TemplateLoaderWindow.ForceBinaryDetected.Cancel"))) { return; } messages = new List <Message>(); var folderName = templateFolders[popupIndex]; var templateName = templateOptions[popupIndex]; if (TemplateLoader.Load(folderName, replaceStringList)) { messages.Add(new Message(LocalizedMessage.Get("TemplateLoaderWindow.Succeeded", templateName), MessageType.Info)); } else { messages.Add(new Message(LocalizedMessage.Get("TemplateLoaderWindow.Failed", templateName), MessageType.Error)); } } EditorGUI.EndDisabledGroup(); } foreach (var msg in messages) { EditorGUILayout.HelpBox(msg.message, msg.type, true); } }
static MeteredSlider() { ControlTemplate defaultTemplate = GetResource <ControlTemplate>("MeteredSliderDefaultTemplate"); TemplateProperty.OverrideMetadata(typeof(MeteredSlider), new FrameworkPropertyMetadata(defaultTemplate)); }
static CustomersTreeFilterView() { ControlTemplate defaultTemplate = new CustomersTreeFilterViewTemplate(); TemplateProperty.OverrideMetadata(typeof(CustomersTreeFilterView), new System.Windows.FrameworkPropertyMetadata(defaultTemplate)); }
get => (Pen)GetValue(TemplateProperty); set => SetValue(TemplateProperty, value);