예제 #1
0
        /// <summary>
        /// Formats the BibtexEntry as a styled string containing the styled information.
        /// </summary>
        /// <param name="style">Style to apply.</param>
        /// <returns>A string LaTeX formatted string with styling.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public string ApplyStyle(EntryStyle style)
        {
            if (style is null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            var builder = new StringBuilder();

            var isFirst = true;

            foreach (var field in style.Fields)
            {
                string text = null;

                switch (field.Type)
                {
                case FieldType.Constant:
                    text = (field as ConstantField).Value;
                    break;

                case FieldType.Field:
                    _propertyGetters.TryGetValue((field as EntryField).Value, out var propertyGetter);
                    text = propertyGetter(this);
                    break;

                case FieldType.AuthorField:
                    text = (field as EntryAuthorField).Format.FormatAuthorField(Author);
                    break;
                }

                if (text != null)
                {
                    if (field.Prefix != null)
                    {
                        builder.Append(field.Prefix);
                    }
                    else
                    {
                        if (!isFirst)
                        {
                            builder.Append(" ");
                        }
                        else
                        {
                            isFirst = false;
                        }
                    }
                    builder.Append(new LatexString(text)
                    {
                        Bold = field.Bold, Italic = field.Italic
                    });
                    builder.Append(field.Suffix);
                }
            }

            return(builder.ToString());
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] EntryStyle entryStyle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(entryStyle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Edit), new { id = entryStyle.Id }));
            }
            return(View(entryStyle));
        }
예제 #3
0
        internal RecorderEvent(QFSignal signal, string name, string location, string entryFormat, EntryStyle style, IEnumerable <XElement> values, IEnumerable <string> commandFilter, IEnumerable <string> responseFilter)
            : this(signal)
        {
            if ((string.IsNullOrEmpty(name)))
            {
                throw new ArgumentNullException("name", "A valid Recorder name must be provided.");
            }

            Name           = name;
            Location       = location;
            EntryFormat    = entryFormat;
            EntryStyle     = style;
            Values         = values;
            CommandFilter  = commandFilter;
            ResponseFilter = responseFilter;
        }
예제 #4
0
        /// <summary>
        /// Styles the BibtexEntry's label according to the provided style.
        /// </summary>
        /// <param name="style">Style to apply.</param>
        /// <returns>A string LaTeX formatted string with styling.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public string GetStyledLabel(EntryStyle style, int index)
        {
            if (style is null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            if (style.Label != null)
            {
                style.Label = style.Label.Replace("{Index}", index.ToString(), SC.OrdinalIgnoreCase).Replace($"{{{CITATION_KEY}}}", CitationKey, SC.OrdinalIgnoreCase).Replace($"{{{ENTRY_TYPE}}}", EntryType.ToString(), SC.OrdinalIgnoreCase);

                foreach (var property in _keyValuePairs)
                {
                    style.Label = style.Label.Replace($"{{{property.Key}}}", property.Value, SC.OrdinalIgnoreCase);
                }

                return(style.Label);
            }

            return(index.ToString());
        }
        public async Task <IActionResult> Edit(int id, string entryStyleString)
        {
            EntryStyle entryStyle = null;

            try
            {
                entryStyle    = JsonConvert.DeserializeObject <EntryStyle>(entryStyleString);
                entryStyle.Id = id;
            }
            catch (Exception ex)
            {
                entryStyle = await _context.EntryStyles.FindAsync(id);

                ModelState.AddModelError("", ex.Message);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(entryStyle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EntryStyleExists(entryStyle.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(entryStyle));
        }
예제 #6
0
        public static async void GetData(String uri, EntryType type, EntryStyle style)
        {
            HttpClient client = new HttpClient();

            Uri request = new Uri(uri);

            HttpResponseMessage response = new HttpResponseMessage();
            string responseString        = "";

            try
            {
                response = await client.GetAsync(request);

                response.EnsureSuccessStatusCode();
                string json = await response.Content.ReadAsStringAsync();

                Debug.WriteLine(json);
                json.Replace("\\", "");
                EntryManager.UpdateData(style, type, json);
            } catch (Exception ex)
            {
                responseString = "Error: " + ex.HResult.ToString("X") + " Message: " + ex.Message;
            }
        }
예제 #7
0
        public static void UpdateData(EntryStyle style, EntryType type, string json)
        {
            switch (type)
            {
            case EntryType.CURRENT:
                if (style == EntryStyle.TEMPERATURE)
                {
                    currentT = JsonConvert.DeserializeObject <Entry>(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.PRESSURE)
                {
                    currentP = JsonConvert.DeserializeObject <Entry>(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                break;

            case EntryType.TODAY:
                if (style == EntryStyle.TEMPERATURE)
                {
                    todayT = JsonConvert.DeserializeObject <List <Entry> >(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.PRESSURE)
                {
                    todayP = JsonConvert.DeserializeObject <List <Entry> >(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                break;

            case EntryType.YESTERDAY:
                if (style == EntryStyle.TEMPERATURE)
                {
                    yesterdayT = JsonConvert.DeserializeObject <List <Entry> >(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.PRESSURE)
                {
                    yesterdayP = JsonConvert.DeserializeObject <List <Entry> >(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.TEMPERATUREMID)
                {
                    yesterdayMidT = JsonConvert.DeserializeObject <Entry>(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.PRESSUREMID)
                {
                    yesterdayMidP = JsonConvert.DeserializeObject <Entry>(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                break;

            case EntryType.LASTWEEK:
                if (style == EntryStyle.TEMPERATURE)
                {
                    lastweekT = JsonConvert.DeserializeObject <List <Entry> >(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.PRESSURE)
                {
                    lastweekP = JsonConvert.DeserializeObject <List <Entry> >(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.TEMPERATUREMID)
                {
                    lastweekMidT = JsonConvert.DeserializeObject <Entry>(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                else if (style == EntryStyle.PRESSUREMID)
                {
                    lastweekMidP = JsonConvert.DeserializeObject <Entry>(json, new IsoDateTimeConverter {
                        DateTimeFormat = "dd.MM.yyyy HH:mm"
                    });
                }
                break;

            default:
                return;
            }
        }