public Formatter(byte digits, DisplayFormat format, sbyte fixedUnderflowExponentThreshold, bool hasExtraDigitBetween0And1, bool padMantissa, bool showPlusSignInExponent, bool stripZeros) { // Assign *before* calling Digits/Format below. this.fixedUnderflowExponentThreshold = fixedUnderflowExponentThreshold; this.hasExtraDigitBetween0And1 = hasExtraDigitBetween0And1; this.padMantissa = padMantissa; this.stripZeros = stripZeros; if (showPlusSignInExponent) { exponentTemplate = "+" + exponentMetaTemplate.Substring(1); } else { exponentTemplate = " " + exponentMetaTemplate.Substring(1); } formatted = 0.0M; Digits = digits; Format = format; }
protected void SetFunction(DisplayFormat fmt) { if (this.InvokeRequired) { this.BeginInvoke((Delegate) new BaseForm.SetFunctionDelegate(this.SetFunction), (object)fmt); } else { this.DisplayFormat = fmt; switch (fmt) { case DisplayFormat.LED: this.radioButtonLED.Checked = true; break; case DisplayFormat.Binary: this.radioButtonBinary.Checked = true; break; case DisplayFormat.Hex: this.radioButtonHex.Checked = true; break; case DisplayFormat.Integer: this.radioButtonInteger.Checked = true; break; } } }
/// <summary> /// Initializes a new instance of the <see cref="CalendarControl"/> class. /// </summary> public CalendarControl() { DisplayFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; if (!String.IsNullOrEmpty(DisplayFormat)) { char splitter = CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator[0]; string[] format = DisplayFormat.Split(new char[] { splitter }); StringBuilder sbFormat = new StringBuilder(); for (int i = 0; i < format.Length; i++) { sbFormat.Append("%"); sbFormat.Append(format[i][0]); if (i + 1 != format.Length) { sbFormat.Append(splitter); } } JavaScriptFormat = sbFormat.ToString().ToLower() + " %I:%M %p"; } else { DisplayFormat = DEFAULT_FORMAT; JavaScriptFormat = DEFAULT_JAVASCRIPT_FORMAT; } Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; }
internal static void ApplyColumnFormat(ReportColumn reportColumn, ReportColumnConditionalFormat format) { DisplayFormat columnDisplayFormat = reportColumn.ColumnDisplayFormat != null?reportColumn.ColumnDisplayFormat.AsWritable <DisplayFormat>() : new DisplayFormat(); if (format.Rules != null && format.Rules.Count > 0) { columnDisplayFormat.ColumnShowText = format.ShowValue; columnDisplayFormat.DisableDefaultFormat = format.DisableDefaultFormat; switch (format.Style) { case ConditionalFormatStyleEnum.ProgressBar: ApplyProgressFormat(reportColumn, format.Rules); break; case ConditionalFormatStyleEnum.Highlight: ApplyHighlightFormat(reportColumn, format.Rules); break; case ConditionalFormatStyleEnum.Icon: ApplyIconFormat(reportColumn, format.Rules); break; } columnDisplayFormat.Save(); reportColumn.ColumnDisplayFormat = columnDisplayFormat; } else { columnDisplayFormat.Delete(); reportColumn.ColumnDisplayFormat = null; } reportColumn.Save(); }
protected void SetFunction(DisplayFormat fmt) { if (InvokeRequired) { BeginInvoke(new SetFunctionDelegate(SetFunction), new object[] { fmt }); return; } DisplayFormat = fmt; switch (fmt) { case DisplayFormat.Integer: radioButtonInteger.Checked = true; break; case DisplayFormat.Binary: radioButtonBinary.Checked = true; break; case DisplayFormat.Hex: radioButtonHex.Checked = true; break; case DisplayFormat.LED: radioButtonLED.Checked = true; break; case DisplayFormat.FloatReverse: radioButtonReverseFloat.Checked = true; break; } }
/// <summary> A constructor used when creating a writable record /// /// </summary> /// <param name="fnt">the font /// </param> /// <param name="form">the format /// </param> public XFRecord(FontRecord fnt, DisplayFormat form) : base(NExcel.Biff.Type.XF) { initialized = false; locked = true; hidden = false; align = Alignment.GENERAL; valign = VerticalAlignment.BOTTOM; orientation = Orientation.HORIZONTAL; wrap = false; leftBorder = BorderLineStyle.NONE; rightBorder = BorderLineStyle.NONE; topBorder = BorderLineStyle.NONE; bottomBorder = BorderLineStyle.NONE; leftBorderColour = Colour.PALETTE_BLACK; rightBorderColour = Colour.PALETTE_BLACK; topBorderColour = Colour.PALETTE_BLACK; bottomBorderColour = Colour.PALETTE_BLACK; pattern = Pattern.NONE; backgroundColour = Colour.DEFAULT_BACKGROUND; shrinkToFit = false; // This will be set by the initialize method and the subclass respectively parentFormat = 0; xfFormatType = null; font = fnt; format = form; biffType = biff8; read = false; copied = false; formatInfoInitialized = true; Assert.verify(font != null); Assert.verify(format != null); }
/// <summary> Adds a cell format to the hash map, keyed on its index. If the format /// record is not initialized, then its index number is determined and its /// initialize method called. If the font is not a built in format, then it /// is added to the list of formats for writing out /// /// </summary> /// <param name="fr">the format record /// </param> public void addFormat(DisplayFormat fr) { if (!fr.isInitialized()) { fr.initialize(nextCustomIndexNumber); nextCustomIndexNumber++; } if (nextCustomIndexNumber > maxFormatRecordsIndex) { nextCustomIndexNumber = maxFormatRecordsIndex; throw new NumFormatRecordsException(); } if (fr.FormatIndex >= nextCustomIndexNumber) { nextCustomIndexNumber = fr.FormatIndex + 1; } if (!fr.isBuiltIn()) { formatsList.Add(fr); formats[fr.FormatIndex] = fr; } }
public void AssertPrintRegex(Thread thread, DisplayFormat format, string expression, string exp_re) { string text = null; try { ScriptingContext context = GetContext(thread); object obj = EvaluateExpression(context, expression); text = context.FormatObject(obj, format); } catch (AssertionException) { throw; } catch (Exception ex) { Assert.Fail("Failed to print expression `{0}': {1}", expression, ex); } Match match = Regex.Match(text, exp_re); if (!match.Success) { Assert.Fail("Expression `{0}' evaluated to `{1}', but expected `{2}'.", expression, text, exp_re); } }
public void Format_Positive(DisplayFormat format, string expected) { var coordinate = new Latitude(40, 26, 46); var formatter = new CoordinateTextFormatter(coordinate); string actual = formatter.Format(format); Assert.Equal(expected, actual); }
public void Format_Negative(DisplayFormat format, string expected) { var coordinate = new Longitude(-79, 58, 56); var formatter = new CoordinateTextFormatter(coordinate); string actual = formatter.Format(format); Assert.Equal(expected, actual); }
public override string FormatObject(Thread target, object obj, DisplayFormat format) { ObjectFormatter formatter = new ObjectFormatter(format); formatter.Format(target, obj); return(formatter.ToString()); }
public static IList <Column> SetFormat(this IList <Column> columns, DisplayFormat value, params int[] columnIndexes) { foreach (var i in columnIndexes) { columns[i].SetFormat(value); } return(columns); }
public void Add(HLinkBase argCard, DisplayFormat argDisplayFormat = DisplayFormat.Default) { Contract.Assert(argCard != null); argCard.CardType = argDisplayFormat; base.Add(argCard); }
public LogSettings() { this.TransmittedColor = Color.Blue; this.ReceivedColor = Color.Green; this.SystemColor = Color.Orange; this.TimeColor = Color.Silver; this.mFormat = DisplayFormat.Hex; }
private void SetFormat() { if (DisplayFormat.Equals(DisplayFormatList.ShortDatePattern)) { this.CustomFormat = UserData.GetUserData().DateTimeFormat.ShortDatePattern; } else if (DisplayFormat.Equals(DisplayFormatList.LongDatePattern)) { this.CustomFormat = UserData.GetUserData().DateTimeFormat.LongDatePattern; } }
public static void WriteToConsole(BitGrid grid, DisplayFormat format) { if ((format & DisplayFormat.ASCII) != 0) { WriteLine(Console.OpenStandardOutput(), Converter.ToASCII(grid)); } if ((format & DisplayFormat.Bits) != 0) { WriteLine(Console.OpenStandardOutput(), Converter.ToBits(grid)); } }
private void SetupVideo(DisplayFormat videoFormat, VideoCompressor compressor, int fps) { int colorDepth = Bitmap.GetPixelFormatSize(videoFormat.PixelFormat); int width = videoFormat.Width; int height = videoFormat.Height; // Calculate pitch int bytesPerPixel = colorDepth / 8; int pitch = width * bytesPerPixel; int pitch_factor = 4; if (pitch % pitch_factor != 0) { pitch = pitch + pitch_factor - pitch % pitch_factor; } // Create AVI Stream Avi32Interop.AVISTREAMINFO asf = new Avi32Interop.AVISTREAMINFO(); asf.dwRate = fps; asf.dwSuggestedBufferSize = pitch * height * bytesPerPixel; asf.dwScale = 1; asf.fccType = Avi32Interop.streamtypeVIDEO; asf.szName = null; asf.rcFrame = new Avi32Interop.RECT(0, 0, width, height); int hr = Avi32Interop.AVIFileCreateStream(this.pAviFile, out this.pVideoStream, ref asf); if (hr != 0) { throw new AviException("AVIFileCreateStream", hr); } // Set stream format Avi32Interop.BITMAPINFOHEADER bih = new Avi32Interop.BITMAPINFOHEADER(); bih.biBitCount = (ushort)colorDepth; bih.biCompression = 0; // BI_RGB bih.biHeight = videoFormat.Height; bih.biPlanes = 1; bih.biSize = (uint)Marshal.SizeOf(bih); bih.biSizeImage = (uint)(pitch * height * (colorDepth / 8)); bih.biWidth = videoFormat.Width; if (compressor != null && !compressor.Equals(VideoCompressor.None)) { // Setup compressor this.SetupVideoCompressor(compressor); hr = Avi32Interop.AVIStreamSetFormat(this.pAviCompressedStream, 0, ref bih, Marshal.SizeOf(bih)); } else { hr = Avi32Interop.AVIStreamSetFormat(this.pVideoStream, 0, ref bih, Marshal.SizeOf(bih)); } if (hr != 0) { throw new AviException("AVIStreamSetFormat", hr); } }
private void RadioButtonDisplayFormatCheckedChanged(object sender, EventArgs e) { if (sender is RadioButton) { var rb = (RadioButton)sender; if (rb.Checked) { DisplayFormat.TryParse(rb.Tag.ToString(), true, out _displayFormat); CurrentTab.DisplayFormat = DisplayFormat; RefreshData(); } } }
protected override void OnCursorPressed(Point cursorPosition) { CurrentIndex++; if (CurrentIndex >= Values.Length) { CurrentIndex = 0; } var value = Values[CurrentIndex]; Text = DisplayFormat.FormatValue(value) ?? string.Empty; ValueChanged?.Invoke(this, value); }
internal static void ApplyColumnFormat(ReportColumn reportColumn, ReportColumnValueFormat format) { DisplayFormat columnDisplayFormat = reportColumn.ColumnDisplayFormat != null?reportColumn.ColumnDisplayFormat.AsWritable <DisplayFormat>() : new DisplayFormat(); columnDisplayFormat.ColumnShowText = !format.HideDisplayValue; columnDisplayFormat.DisableDefaultFormat = format.DisableDefaultFormat; columnDisplayFormat.FormatPrefix = format.Prefix; columnDisplayFormat.FormatSuffix = format.Suffix; columnDisplayFormat.FormatDecimalPlaces = format.DecimalPlaces > 0 ? Convert.ToInt32(format.DecimalPlaces) : new int?(); if (reportColumn.ColumnExpression != null && reportColumn.ColumnExpression.ReportExpressionResultType != null) { if (reportColumn.ColumnExpression.ReportExpressionResultType.Is <DateArgument>()) { DateColFmtEnum dateColFmtEnum = Entity.Get <DateColFmtEnum>(new EntityRef(format.DateTimeFormat)); columnDisplayFormat.DateColumnFormat = dateColFmtEnum; } else if (reportColumn.ColumnExpression.ReportExpressionResultType.Is <TimeArgument>()) { TimeColFmtEnum timeColFmtEnum = Entity.Get <TimeColFmtEnum>(new EntityRef(format.DateTimeFormat)); columnDisplayFormat.TimeColumnFormat = timeColFmtEnum; } else if (reportColumn.ColumnExpression.ReportExpressionResultType.Is <DateTimeArgument>()) { DateTimeColFmtEnum dateTimeColFmtEnum = Entity.Get <DateTimeColFmtEnum>(new EntityRef(format.DateTimeFormat)); columnDisplayFormat.DateTimeColumnFormat = dateTimeColFmtEnum; } } columnDisplayFormat.MaxLineCount = format.NumberOfLines > 0 ? Convert.ToInt32(format.NumberOfLines) : new int?(); if (format.ImageScaleId != null) { columnDisplayFormat.FormatImageScale = Entity.Get <ImageScaleEnum>(format.ImageScaleId); } if (format.ImageSizeId != null) { columnDisplayFormat.FormatImageSize = Entity.Get <ThumbnailSizeEnum>(format.ImageSizeId); } if (format.Alignment != null) { columnDisplayFormat.FormatAlignment = Entity.Get <AlignEnum>(new EntityRef(format.Alignment)); } if (format.EntityListColumnFormat != null) { columnDisplayFormat.EntityListColumnFormat = Entity.Get <EntityListColFmtEnum>(new EntityRef(format.EntityListColumnFormat)); } columnDisplayFormat.Save(); reportColumn.ColumnDisplayFormat = columnDisplayFormat; }
public static string ToFormattedTitle(SongNames infos, DisplayFormat type) { switch (type) { case DisplayFormat.Title_Author_Product_Mapper: case DisplayFormat.Title_Product_Author_Mapper: case DisplayFormat.Title_Subtitle_Author_Mapper: case DisplayFormat.Title_Subtitle_Author_Product: case DisplayFormat.Title_Subtitle_Product_Mapper: default: return(infos.Title ?? ""); } ; }
public GuiEnumSwitchButton() { var values = Enum.GetValues(typeof(TEnum)); List <TEnum> v = new List <TEnum>(); foreach (var value in values) { v.Add((TEnum)value); } Values = v.ToArray(); Text = DisplayFormat?.FormatValue(Values[CurrentIndex]) ?? string.Empty; }
public static int ModifySongs(IEnumerable <CustomPreviewBeatmapLevel> previewBeatmapLevels, DisplayFormat type) { Logger.Debug("ModifySongs"); var counter = 0; try { var beatmapType = typeof(CustomPreviewBeatmapLevel); var _songName = beatmapType.GetField("_songName", BindingFlags.NonPublic | BindingFlags.Instance); var _songSubName = beatmapType.GetField("_songSubName", BindingFlags.NonPublic | BindingFlags.Instance); var _songAuthorName = beatmapType.GetField("_songAuthorName", BindingFlags.NonPublic | BindingFlags.Instance); var _levelAuthorName = beatmapType.GetField("_levelAuthorName", BindingFlags.NonPublic | BindingFlags.Instance); if (_songName == null || _songSubName == null || _songAuthorName == null || _levelAuthorName == null) { Logger.IPALogger.Critical("Failed to reflect fields"); return(counter); } foreach (var song in previewBeatmapLevels) { var hash = song.levelID.Split('_')[2].ToLower(); if (!SongsStore.Instance.Store.TryGetValue(hash, out var infos)) { continue; } ModifiyTitle(_songName, song, infos, type); ModifiySubtitle(_songSubName, song, infos, type); ModifiyAuthor(_songAuthorName, song, infos, type); ModifiyMapper(_levelAuthorName, song, infos, type); counter++; } } catch (Exception ex) { Logger.IPALogger.Error(ex); } finally { } return(counter); }
private void SaveUserData() { Properties.Settings.Default.CommunicationMode = CommunicationMode.ToString(); Properties.Settings.Default.IPAddress = IPAddress.ToString(); Properties.Settings.Default.DisplayFormat = DisplayFormat.ToString(); Properties.Settings.Default.TCPPort = TCPPort; Properties.Settings.Default.PortName = PortName; Properties.Settings.Default.Baud = Baud; Properties.Settings.Default.Parity = Parity; Properties.Settings.Default.StartAddress = StartAddress; Properties.Settings.Default.DataLength = DataLength; Properties.Settings.Default.SlaveId = SlaveId; Properties.Settings.Default.SlaveDelay = SlaveDelay; Properties.Settings.Default.DataBits = DataBits; Properties.Settings.Default.StopBits = StopBits; Properties.Settings.Default.Save(); }
public void Open(string fileName, DisplayFormat videoFormat, int fps, VideoCompressor compressor, SoundFormat audioFormat, AcmEncoder audioEncoder) { if (this.opened) { throw new InvalidOperationException(); } if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } this.video = videoFormat != null; this.audio = audioFormat != null; if (!this.audio && !this.video) { // There is nothing to do! throw new InvalidOperationException(); } // Open AVI File int hr = Avi32Interop.AVIFileOpen(out this.pAviFile, fileName, Avi32Interop.OF_CREATE, IntPtr.Zero); if (hr != 0) { throw new AviException("AVIFileOpen", hr); } try { if (this.video) { this.SetupVideo(videoFormat, compressor, fps); } if (this.audio) { this.SetupAudio(audioFormat, audioEncoder); } this.opened = true; } finally { if (!this.opened) { this.Close(); } } }
public static int ModifySongCoreStore(DisplayFormat type, bool isForce = false) { Logger.Debug("ModifySongCoreStore"); try { SongsStore.Instance.LoadPlaylist(isForce); } catch (Exception ex) { Logger.Debug(ex); } if (SongCore.Loader.AreSongsLoading) { return(0); } return(ModifySongs(SongCore.Loader.CustomLevels.Values, type)); }
protected override string Execute(ScriptingContext context, Expression expression, DisplayFormat format) { // try-catch block for whole method: if an exception occurs, we are able to // release the semaphore waiting for the command answer try { TargetType type = expression.EvaluateType(context); string fieldNames = ""; string fieldNamesStaticOnly = ""; if (type.Kind == TargetObjectKind.Class || type.Kind == TargetObjectKind.Struct) { TargetClassType stype = (TargetClassType)type; foreach (TargetFieldInfo field in stype.Fields) { fieldNames += field.Name; fieldNames += " "; if (field.IsStatic) { fieldNamesStaticOnly += field.Name; fieldNamesStaticOnly += " "; } } fieldNames = fieldNames.Trim(); fieldNamesStaticOnly = fieldNamesStaticOnly.Trim(); } string text = context.FormatType(type); context.Print(text); EmonicInterpreter.ptypeOutput = fieldNames; EmonicInterpreter.ptypeOutputStaticOnly = fieldNamesStaticOnly; EmonicInterpreter.ptypeSem.Release(); return(text); } catch { EmonicInterpreter.ptypeOutput = "--"; EmonicInterpreter.ptypeOutputStaticOnly = "--"; EmonicInterpreter.ptypeSem.Release(); throw; } }
public string FormatObject(object obj, DisplayFormat format) { string formatted; try { if (obj is TargetObject) { TargetObject tobj = (TargetObject)obj; formatted = String.Format("({0}) {1}", tobj.TypeName, DoFormatObject(tobj, format)); } else { formatted = interpreter.Style.FormatObject( CurrentThread, obj, format); } } catch { formatted = "<cannot display object>"; } return(formatted); }
string DoFormatObject(TargetObject obj, DisplayFormat format) { if (format == DisplayFormat.Object) { TargetClassObject cobj = obj as TargetClassObject; if (cobj != null) { string formatted = MonoObjectToString(cobj); if (formatted != null) { return(formatted); } TargetObject proxy = CheckTypeProxy(cobj); if (proxy != null) { obj = proxy; } } } return(CurrentThread.PrintObject(interpreter.Style, obj, format)); }
/// <summary> Copy constructor. Used for copying writable formats, typically /// when duplicating formats to handle merged cells /// /// </summary> /// <param name="fmt">XFRecord /// </param> protected internal XFRecord(XFRecord fmt) : base(NExcel.Biff.Type.XF) { initialized = false; locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; shrinkToFit = fmt.shrinkToFit; parentFormat = fmt.parentFormat; backgroundColour = fmt.backgroundColour; // Shallow copy is sufficient for these purposes font = fmt.font; format = fmt.format; fontIndex = fmt.fontIndex; formatIndex = fmt.formatIndex; formatInfoInitialized = fmt.formatInfoInitialized; biffType = biff8; read = false; copied = true; }
/** * Adds a cell format to the hash map, keyed on its index. If the format * record is not initialized, then its index number is determined and its * initialize method called. If the font is not a built in format, then it * is added to the list of formats for writing out * * @param fr the format record */ public void addFormat(DisplayFormat fr) { // Handle the case the where the index number in the read Excel // file exhibits some major weirdness if (fr.isInitialized() && fr.getFormatIndex() >= maxFormatRecordsIndex) { //logger.warn("Format index exceeds Excel maximum - assigning custom number"); fr.initialize(nextCustomIndexNumber); nextCustomIndexNumber++; } // Initialize the format record with a custom index number if (!fr.isInitialized()) { fr.initialize(nextCustomIndexNumber); nextCustomIndexNumber++; } if (nextCustomIndexNumber > maxFormatRecordsIndex) { nextCustomIndexNumber = maxFormatRecordsIndex; throw new NumFormatRecordsException(); } if (fr.getFormatIndex() >= nextCustomIndexNumber) { nextCustomIndexNumber = fr.getFormatIndex() + 1; } if (!fr.isBuiltIn()) { formatsList.Add(fr); formats.Add(fr.getFormatIndex(), fr); } }
public string EvaluateExpression(ScriptingContext context, string text, DisplayFormat format) { F.Expression expression = context.ParseExpression (text); try { expression = expression.Resolve (context); } catch (ScriptingException ex) { throw new ScriptingException ("Cannot resolve expression `{0}': {1}", text, ex.Message); } catch { throw new ScriptingException ("Cannot resolve expression `{0}'.", text); } try { object retval = expression.Evaluate (context); return context.FormatObject (retval, format); } catch (ScriptingException ex) { throw new ScriptingException ("Cannot evaluate expression `{0}': {1}", text, ex.Message); } catch { throw new ScriptingException ("Cannot evaluate expression `{0}'.", text); } }
protected override bool DoResolve(ScriptingContext context) { if (Argument.StartsWith ("/")) { int pos = Argument.IndexOfAny (new char[] { ' ', '\t' }); if (pos < 0) throw new ScriptingException ("Syntax error."); string fstring = Argument.Substring (1, pos-1); string arg = Argument.Substring (pos + 1); switch (fstring) { case "o": case "object": format = DisplayFormat.Object; break; case "a": case "address": format = DisplayFormat.Address; break; case "x": case "hex": format = DisplayFormat.HexaDecimal; break; case "default": format = DisplayFormat.Default; break; default: throw new ScriptingException ( "Unknown format: `{0}'", fstring); } expression = DoParseExpression (context, arg); } else expression = ParseExpression (context); if (expression == null) return false; if (this is PrintTypeCommand) { Expression resolved = expression.TryResolveType (context); if (resolved != null) { expression = resolved; return true; } } expression = expression.Resolve (context); return expression != null; }
protected override string Execute(ScriptingContext context, Expression expression, DisplayFormat format) { // try-catch block for whole method: if an exception occurs, we are able to // release the semaphore waiting for the command answer try { TargetType type = expression.EvaluateType (context); string fieldNames = ""; string fieldNamesStaticOnly = ""; if (type.Kind == TargetObjectKind.Class || type.Kind == TargetObjectKind.Struct) { TargetClassType stype = (TargetClassType) type; foreach (TargetFieldInfo field in stype.Fields) { fieldNames += field.Name; fieldNames += " "; if (field.IsStatic) { fieldNamesStaticOnly += field.Name; fieldNamesStaticOnly += " "; } } fieldNames = fieldNames.Trim(); fieldNamesStaticOnly = fieldNamesStaticOnly.Trim(); } string text = context.FormatType (type); context.Print (text); EmonicInterpreter.ptypeOutput = fieldNames; EmonicInterpreter.ptypeOutputStaticOnly = fieldNamesStaticOnly; EmonicInterpreter.ptypeSem.Release(); return text; } catch { EmonicInterpreter.ptypeOutput = "--"; EmonicInterpreter.ptypeOutputStaticOnly = "--"; EmonicInterpreter.ptypeSem.Release(); throw; } }
public string FormatObject(object obj, DisplayFormat format) { string formatted; try { if (obj is TargetObject) { TargetObject tobj = (TargetObject) obj; formatted = String.Format ("({0}) {1}", tobj.TypeName, DoFormatObject (tobj, format)); } else formatted = interpreter.Style.FormatObject ( CurrentThread, obj, format); } catch { formatted = "<cannot display object>"; } return formatted; }
public override string PrintObject(Style style, TargetObject obj, DisplayFormat format) { return (string) SendCommand (delegate { return style.FormatObject (thread, obj, format); }); }
protected ActionResult Display(string pageTitle, DisplayFormat format, SearchOrder order, bool votedOnly, int? page, string search) { int pageNumber = page.GetValueOrDefault(1); if (format == DisplayFormat.Rss) { pageNumber = 1; } IPagedList<TweetReport> tweets = TweetRepository.Search(App, pageNumber, 20, Tweeter, search, votedOnly, DefaultLanguage, order, null); TweetViewList tweetList = new TweetViewList(pageTitle, tweets.TotalItems, tweets.PageNumber, tweets.ItemsPerPage); tweetList.SearchTerm = String.IsNullOrWhiteSpace(search) ? null : search; foreach (TweetReport tweet in tweets) { TweetView tweetView = new TweetView() { Id = tweet.Id, TwitterId = tweet.TwitterId, Username = tweet.Username, ProfileImageUrl = tweet.ProfileImageUrl, Message = tweet.Message, DatePosted = tweet.DatePosted, DeviceName = tweet.DeviceName, DeviceUrl = tweet.DeviceUrl, TotalVotes = (int)tweet.TotalVotes, HasBeenVotedByUser = tweet.HasBeenVotedByUser }; tweetList.Tweets.Add(tweetView); } if (format == DisplayFormat.Html) { return View(tweetList); } else if (format == DisplayFormat.HtmlSnippet) { return PartialView("Tweet", tweetList); } else if (format == DisplayFormat.Json) { return Json(tweetList, JsonRequestBehavior.AllowGet); } else if (format == DisplayFormat.Rss) { string rssTitle = pageTitle; if (!String.IsNullOrWhiteSpace(search)) { rssTitle += " Containing \"" + search + "\""; } rssTitle += " - " + App.Title; RssResult<TweetView> rssResult = new RssResult<TweetView>(rssTitle, "http://" + App.Url, App.Blurb); rssResult.DataSource = tweetList.Tweets; Uri requestUrl = Request.Url; string baseUrl = "http://" + requestUrl.Host + (requestUrl.Port != 80 ? ":" + requestUrl.Port : ""); rssResult.SetDataSourceFields(t => t.Message, t => baseUrl + Url.Action("Status", new { twitterId = t.TwitterId, message = t.Message.ToFriendlyUrl() }), t => "@" + t.Username + " tweeted \"" + t.Message + "\"", t => "@" + t.Username, t => t.DatePosted); return rssResult; } else { throw new NotSupportedException(format + " is not supported"); } }
/** * A constructor which specifies the font and date/number format for cells * which wish to use this format * * @param font the font * @param format the date/number format */ public WritableCellFormat(WritableFont font, DisplayFormat format) : base(font, format) { }
protected override string Execute(ScriptingContext context, Expression expression, DisplayFormat format) { TargetType type = expression.EvaluateType (context); string text = context.FormatType (type); context.Print (text); return text; }
public string PrintObject(Style style, TargetObject obj, DisplayFormat format) { check_alive (); return servant.PrintObject (style, obj, format); }
public override string FormatObject(Thread target, object obj, DisplayFormat format) { ObjectFormatter formatter = new ObjectFormatter (format); formatter.Format (target, obj); return formatter.ToString (); }
string DoFormatObject(TargetObject obj, DisplayFormat format) { if (format == DisplayFormat.Object) { TargetClassObject cobj = obj as TargetClassObject; if (cobj != null) { string formatted = MonoObjectToString (cobj); if (formatted != null) return formatted; TargetObject proxy = CheckTypeProxy (cobj); if (proxy != null) obj = proxy; } } return CurrentThread.PrintObject (interpreter.Style, obj, format); }
/** * Constructor * * @param fnt the font * @param form the format */ public CellXFRecord(FontRecord fnt, DisplayFormat form) : base(fnt, form) { setXFDetails(XFRecord.cell, 0); }
public abstract string FormatObject(Thread target, object obj, DisplayFormat format);
protected abstract string Execute(ScriptingContext context, Expression expression, DisplayFormat format);
protected override string Execute(ScriptingContext context, Expression expression, DisplayFormat format) { try { if (expression is TypeExpression) throw new ScriptingException ( "`{0}' is a type, not a variable.", expression.Name); object retval = expression.Evaluate (context); EmonicInterpreter.printData output = new EmonicInterpreter.printData(); output.type = ""; output.varValue = ""; output.varNames = ""; if (retval != null) { output.type = ((TargetObject)retval).TypeName; if (output.type == null) output.type = ""; switch (((TargetObject)retval).Kind) { case TargetObjectKind.Fundamental: // we send the value of the fundamental type TargetFundamentalObject tfo = retval as TargetFundamentalObject; if (tfo == null) { // element is "null" output.varValue = "<null>"; break; } output.varValue = tfo.GetObject(context.CurrentThread).ToString(); if (output.varValue == null) output.varValue = ""; break; case TargetObjectKind.Array: // we send back the number of array elements TargetArrayObject tao = retval as TargetArrayObject; if (tao == null) { // element is "null" output.varValue = "<null>"; break; } int lower = tao.GetLowerBound (context.CurrentThread, 0); int upper = tao.GetUpperBound (context.CurrentThread, 0); output.varNames = (upper-lower).ToString(); break; // same for struct and class case TargetObjectKind.Struct: case TargetObjectKind.Class: // we send back the member's names // NOTE! we also show static and constant fields TargetObject obj = retval as TargetObject; if (obj.HasAddress && obj.GetAddress(context.CurrentThread).IsNull) { output.varValue = "<null>"; break; } Mono.Debugger.Thread thread = context.CurrentThread; TargetClass tc = ((TargetClassObject)retval).Type.GetClass(thread); if (tc == null) break; TargetFieldInfo[] tfi = tc.GetFields(thread); if (tfi == null) break; output.varNames = ""; for (int i=0; i<tfi.Length; i++) { if (tfi[i].IsStatic) // do not show static fields, they're not accessible via the instance! continue; output.varNames += tfi[i].Name; output.varNames += " "; } output.varNames = output.varNames.Trim(); break; case TargetObjectKind.Object: case TargetObjectKind.Pointer: case TargetObjectKind.Unknown: case TargetObjectKind.Function: case TargetObjectKind.Alias: case TargetObjectKind.Enum: context.Print("ERROR: Print Command will return no values because of an implementation error"); break; } } string text = context.FormatObject (retval, format); context.Print (text); EmonicInterpreter.printOutput = output; EmonicInterpreter.printSem.Release(); return text; } catch { EmonicInterpreter.printData output = new EmonicInterpreter.printData(); output.type = ""; output.varValue = ""; output.varNames = ""; EmonicInterpreter.printOutput = output; EmonicInterpreter.printSem.Release(); throw; } }
protected override string Execute(ScriptingContext context, Expression expression, DisplayFormat format) { if (NestedBreakStates) context.ScriptingFlags |= ScriptingFlags.NestedBreakStates; if (expression is TypeExpression) throw new ScriptingException ( "`{0}' is a type, not a variable.", expression.Name); object retval = expression.Evaluate (context); string text = context.FormatObject (retval, format); context.Print (text); return text; }
public ActionResult RecentlyVoted(DisplayFormat format, int? page, string search) { // TODO: Remove title string title = "Recently Voted for " + HttpUtility.HtmlEncode(App.Noun.Plural.CapitaliseFirstLetter()); return Display(title, format, SearchOrder.RecentlyVoted, true, page, search); }
/** * A public copy constructor which can be used for copy formats between * different sheets. Unlike the the other copy constructor, this * version does a deep copy * * @param cellFormat the format to copy */ protected XFRecord(CellFormat cellFormat) : base(Type.XF) { Assert.verify(cellFormat != null); Assert.verify(cellFormat is XFRecord); XFRecord fmt = (XFRecord)cellFormat; if (!fmt.formatInfoInitialized) { fmt.initializeFormatInformation(); } locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; parentFormat = fmt.parentFormat; indentation = fmt.indentation; shrinkToFit = fmt.shrinkToFit; backgroundColour = fmt.backgroundColour; // Deep copy of the font font = new FontRecord(fmt.getFont()); // Copy the format if (fmt.getFormat() == null) { // format is writable if (fmt.format.isBuiltIn()) { format = fmt.format; } else { // Format is not built in, so do a deep copy format = new FormatRecord((FormatRecord)fmt.format); } } else if (fmt.getFormat() is BuiltInFormat) { // read excel format is built in excelFormat = (BuiltInFormat)fmt.excelFormat; format = (BuiltInFormat)fmt.excelFormat; } else { // read excel format is user defined Assert.verify(fmt.formatInfoInitialized); // in this case FormattingRecords should initialize the excelFormat // field with an instance of FormatRecord Assert.verify(fmt.excelFormat is FormatRecord); // Format is not built in, so do a deep copy FormatRecord fr = new FormatRecord((FormatRecord)fmt.excelFormat); // Set both format fields to be the same object, since // FormatRecord implements all the necessary interfaces excelFormat = fr; format = fr; } biffType = biff8; // The format info should be all OK by virtue of the deep copy formatInfoInitialized = true; // This format was not read in read = false; // Treat this as a new cell record, so set the copied flag to false copied = false; // The font or format indexes need to be set, so set initialized to false initialized = false; }
/** * Constructor * * @param fnt the font for this style * @param form the format of this style */ public StyleXFRecord(FontRecord fnt, DisplayFormat form) : base(fnt, form) { setXFDetails(XFRecord.style, 0xfff0); }
/** * A constructor which specifies a date/number format for Cells which * use this format object * * @param format the format */ public WritableCellFormat(DisplayFormat format) : this(WritableWorkbook.ARIAL_10_PT, format) { }
/** * Copy constructor. Used for copying writable formats, typically * when duplicating formats to handle merged cells * * @param fmt XFRecord */ protected XFRecord(XFRecord fmt) : base(Type.XF) { initialized = false; locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; indentation = fmt.indentation; shrinkToFit = fmt.shrinkToFit; parentFormat = fmt.parentFormat; backgroundColour = fmt.backgroundColour; // Shallow copy is sufficient for these purposes font = fmt.font; format = fmt.format; fontIndex = fmt.fontIndex; formatIndex = fmt.formatIndex; formatInfoInitialized = fmt.formatInfoInitialized; biffType = biff8; read = false; copied = true; }
// copied from the PrintCommand class - we must be able to catch Exceptions here protected override bool DoResolve(ScriptingContext context) { // big try-catch block: we are able to react to Exceptions this way // and release the semaphore waiting for the command answer try { if (Argument.StartsWith ("/")) { int pos = Argument.IndexOfAny (new char[] { ' ', '\t' }); string fstring = Argument.Substring (1, pos-1); string arg = Argument.Substring (pos + 1); switch (fstring) { case "o": case "object": format = DisplayFormat.Object; break; case "a": case "address": format = DisplayFormat.Address; break; case "x": case "hex": format = DisplayFormat.HexaDecimal; break; case "default": format = DisplayFormat.Default; break; default: throw new ScriptingException ( "Unknown format: `{0}'", fstring); } expression = DoParseExpression (context, arg); } else expression = ParseExpression (context); if (expression == null) return false; if (this is PrintTypeCommand) { Expression resolved = expression.TryResolveType (context); if (resolved != null) { expression = resolved; return true; } } expression = expression.Resolve (context); return expression != null; } catch { EmonicInterpreter.ptypeOutput = "--"; EmonicInterpreter.ptypeOutputStaticOnly = "--"; EmonicInterpreter.ptypeSem.Release(); throw; } }
/** * A constructor used when creating a writable record * * @param fnt the font * @param form the format */ public XFRecord(FontRecord fnt,DisplayFormat form) : base(Type.XF) { initialized = false; locked = true; hidden = false; align = Alignment.GENERAL; valign = VerticalAlignment.BOTTOM; orientation = Orientation.HORIZONTAL; wrap = false; leftBorder = BorderLineStyle.NONE; rightBorder = BorderLineStyle.NONE; topBorder = BorderLineStyle.NONE; bottomBorder = BorderLineStyle.NONE; leftBorderColour = Colour.AUTOMATIC; rightBorderColour = Colour.AUTOMATIC; topBorderColour = Colour.AUTOMATIC; bottomBorderColour = Colour.AUTOMATIC; pattern = Pattern.NONE; backgroundColour = Colour.DEFAULT_BACKGROUND; indentation = 0; shrinkToFit = false; usedAttributes = (byte)(USE_FONT | USE_FORMAT | USE_BACKGROUND | USE_ALIGNMENT | USE_BORDER); // This will be set by the initialize method and the subclass respectively parentFormat = 0; xfFormatType = null; font = fnt; format = form; biffType = biff8; read = false; copied = false; formatInfoInitialized = true; Assert.verify(font != null); Assert.verify(format != null); }
// copied that from PrintCommand class - we need that here because we need // to know if any exceptions in this method are raised protected override bool DoResolve(ScriptingContext context) { // whole method in a try-catch block - if any exceptions occur, we are able to generate // an invalid web service response and release the semaphore try { if (Argument.StartsWith ("/")) { int pos = Argument.IndexOfAny (new char[] { ' ', '\t' }); string fstring = Argument.Substring (1, pos-1); string arg = Argument.Substring (pos + 1); switch (fstring) { case "o": case "object": format = DisplayFormat.Object; break; case "a": case "address": format = DisplayFormat.Address; break; case "x": case "hex": format = DisplayFormat.HexaDecimal; break; case "default": format = DisplayFormat.Default; break; default: throw new ScriptingException ( "Unknown format: `{0}'", fstring); } expression = DoParseExpression (context, arg); } else expression = ParseExpression (context); if (expression == null) return false; expression = expression.Resolve (context); return expression != null; } catch { EmonicInterpreter.printData output = new EmonicInterpreter.printData(); output.type = ""; output.varValue = ""; output.varNames = ""; EmonicInterpreter.printOutput = output; EmonicInterpreter.printSem.Release(); throw; } }
protected void SetFunction(DisplayFormat fmt) { if (InvokeRequired) { BeginInvoke(new SetFunctionDelegate(SetFunction), new object[] { fmt }); return; } DisplayFormat = fmt; switch (fmt) { case DisplayFormat.Integer: radioButtonInteger.Checked = true; break; case DisplayFormat.Binary: radioButtonBinary.Checked = true; break; case DisplayFormat.Hex: radioButtonHex.Checked = true; break; case DisplayFormat.LED: radioButtonLED.Checked = true; break; } }
public ActionResult Latest(DisplayFormat format, int? page, string search) { // TODO: Remove title string title = "Latest " + HttpUtility.HtmlEncode(App.Noun.Plural.CapitaliseFirstLetter()) + " from Twitter"; return Display(title, format, SearchOrder.Latest, false, page, search); }
public void AssertPrintRegex(Thread thread, DisplayFormat format, string expression, string exp_re) { string text = null; try { ScriptingContext context = GetContext (thread); object obj = EvaluateExpression (context, expression); text = context.FormatObject (obj, format); } catch (AssertionException) { throw; } catch (Exception ex) { Assert.Fail ("Failed to print expression `{0}': {1}", expression, ex); } Match match = Regex.Match (text, exp_re); if (!match.Success) Assert.Fail ("Expression `{0}' evaluated to `{1}', but expected `{2}'.", expression, text, exp_re); }
public override string PrintObject(Style style, TargetObject obj, DisplayFormat format) { return style.FormatObject (Thread, obj, format); }
public ObjectFormatter(DisplayFormat format) { this.DisplayFormat = format; }