public Size GetWorkItemSize(WorkItemSize size)
        {
            EnsureCustomResourceDictionary();

            var templateWidthFullPropertyName  = GetFullPropertyName(TemplateWidth, size);
            var templateHeightFullPropertyName = GetFullPropertyName(TemplateHeight, size);
            // The template is not cached. retrieve it from the current dictionary
            var templateFile = WorkItemTemplatesFile;

            if (_localResources.ContainsKey(templateFile))
            {
                var templateWidth  = _localResources[templateFile][templateWidthFullPropertyName];
                var templateHeight = _localResources[templateFile][templateHeightFullPropertyName];
                if (templateWidth != null && templateHeight != null)
                {
                    return(new Size((double)templateWidth, (double)templateHeight));
                }
            }

            var width  = Application.Current.MainWindow.TryFindResource(templateWidthFullPropertyName);
            var height = Application.Current.MainWindow.TryFindResource(templateHeightFullPropertyName);

            if (width != null && height != null)
            {
                return(new Size((double)width, (double)height));
            }

            return(Size.Empty);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> OnPostSave(WorkItemSize record)
        {
            record.OrganizationId = Data.CurrentOrg.Id;
            await Data.TrySaveAsync(record);

            return(RedirectToPage("/Setup/Sizes"));
        }
 private string GetFullPropertyName(string basePropertyName, WorkItemSize size)
 {
     if (size != WorkItemSize.Medium)
     {
         basePropertyName = size.ToString() + basePropertyName;
     }
     return(basePropertyName);
 }
Exemplo n.º 4
0
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null || parameter == null)
            {
                return(null);
            }

            bool   useValue    = (bool)value;
            string targetValue = parameter.ToString();

            if (useValue)
            {
                return(WorkItemSize.Parse(targetType, targetValue));
            }

            return(null);
        }
        public bool IsSizeDefined(WorkItemSize workItemSize)
        {
            EnsureCustomResourceDictionary();

            // The template is not cached. retrieve it from the current dictionary
            if (_localResources.ContainsKey(WorkItemTemplatesFile))
            {
                var templateWidthFullPropertyName  = GetFullPropertyName(TemplateWidth, workItemSize);
                var templateHeightFullPropertyName = GetFullPropertyName(TemplateHeight, workItemSize);
                return(_localResources[WorkItemTemplatesFile].Contains(templateWidthFullPropertyName) && _localResources[WorkItemTemplatesFile].Contains(templateHeightFullPropertyName));
            }
            else
            {
                object width  = Application.Current.MainWindow.TryFindResource(GetFullPropertyName(TemplateWidth, workItemSize));
                object height = Application.Current.MainWindow.TryFindResource(GetFullPropertyName(TemplateHeight, workItemSize));
                return(width != null && height != null);
            }
        }
        public DataTemplate GetWorkItemTemplate(WorkItemType workItemType, WorkItemSize size)
        {
            // TODO: Query template cache first
            // TODO: Cache Dictionary
            // TODO: Cache found templates
            // TODO: Clean templates cache on dictionary change

            // Ensure that the resource dictionary is correctly set up.
            EnsureCustomResourceDictionary();

            // Determine the key of the data template to use for the work item
            var keyName = String.Format("{0}WorkItemTemplate", workItemType.Name).Replace(" ", "");

            DataTemplate template    = null;
            var          fullKeyName = GetFullPropertyName(keyName, size);

            template = FindDataTemplate(fullKeyName);
            if (template != null)
            {
                return(template);
            }
            return((DataTemplate)Application.Current.MainWindow.TryFindResource(fullKeyName));
        }
Exemplo n.º 7
0
 public ConfigurationV4()
     : base()
 {
     WorkItemSize = defaultWorkItemSize;
 }