Пример #1
0
 internal static CMapToUnicode GetToUnicodeFromUniMap(String uniMap)
 {
     if (uniMap == null)
     {
         return(null);
     }
     lock (uniMaps) {
         if (uniMaps.Contains(uniMap))
         {
             return(uniMaps.Get(uniMap));
         }
         CMapToUnicode toUnicode;
         if (PdfEncodings.IDENTITY_H.Equals(uniMap))
         {
             toUnicode = CMapToUnicode.GetIdentity();
         }
         else
         {
             CMapUniCid uni = FontCache.GetUni2CidCmap(uniMap);
             if (uni == null)
             {
                 return(null);
             }
             toUnicode = uni.ExportToUnicode();
         }
         uniMaps[uniMap] = toUnicode;
         return(toUnicode);
     }
 }
        /// <summary>
        /// Increases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further increasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomIn()
        {
            if (tblLogMessage.Font.Size < MAX_ZOOM_LEVEL)
            {
                try
                {
                    this.SuspendDrawing();

                    tblLogMessage.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tblLogMessage.Font.Size + 1
                        , FontStyle.Regular);

                    mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , mBoldCaptionFont.Size + 1
                        , FontStyle.Bold);

                    lblCaptionLogger.Font   = mBoldCaptionFont;
                    lblCaptionLevel.Font    = mBoldCaptionFont;
                    lblCaptionThread.Font   = mBoldCaptionFont;
                    lblCaptionDateTime.Font = mBoldCaptionFont;
                    lblCaptionMessage.Font  = mBoldCaptionFont;

                    return(tblLogMessage.Font.Size < MAX_ZOOM_LEVEL);
                }
                finally
                {
                    this.ResumeDrawing();
                }
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Decreases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomOut()
        {
            if (tblLogMessage.Font.Size > MIN_ZOOM_LEVEL)
            {
                try
                {
                    this.SuspendDrawing();

                    tblLogMessage.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tblLogMessage.Font.Size - 1
                        , FontStyle.Regular);

                    mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , mBoldCaptionFont.Size - 1
                        , FontStyle.Bold);

                    lblCaptionNumber.Font    = mBoldCaptionFont;
                    lblCaptionLevel.Font     = mBoldCaptionFont;
                    lblCaptionTime.Font      = mBoldCaptionFont;
                    lblCaptionProcessId.Font = mBoldCaptionFont;
                    lblCaptionMessage.Font   = mBoldCaptionFont;

                    return(tblLogMessage.Font.Size > MIN_ZOOM_LEVEL);
                }
                finally
                {
                    this.ResumeDrawing();
                }
            }

            return(false);
        }
Пример #4
0
        private void initImages()
        {
            _imgBB = new GraphicsImage(dlg_BB, true);
            _imgLB = new GraphicsImage(dlg_LB, false);
            _imgLL = new GraphicsImage(dlg_LL, true);
            _imgLT = new GraphicsImage(dlg_LT, false);
            _imgRB = new GraphicsImage(dlg_RB, false);
            _imgRR = new GraphicsImage(dlg_RR, true);
            _imgRT = new GraphicsImage(dlg_RT, false);
            _imgTT = new GraphicsImage(dlg_TT, true);

            button1.TransparentButton        = dlg_button;
            button1.TransparentButtonPressed = dlg_buttonPressed;
            button1.FontColor        = Color.FromArgb(145, 145, 145);
            button1.PressedFontColor = Color.FromArgb(255, 255, 255);
            button1.Font             = FontCache.CreateFont("Tahoma", 12, FontStyle.Regular, true);

            progressBar.EmptyImage = dlg_progressEmpty;
            progressBar.FullImage  = dlg_progressFull;
            //button1.Size = new Size(UISettings.CalcPix(button1.Width), UISettings.CalcPix(button1.Height));

            Canvas.Children.Add(_imgLT);
            Canvas.Children.Add(_imgTT);
            Canvas.Children.Add(_imgRT);
            Canvas.Children.Add(_imgLL);
            Canvas.Children.Add(_imgRR);
            Canvas.Children.Add(_imgLB);
            Canvas.Children.Add(_imgBB);
            Canvas.Children.Add(_imgRB);
        }
Пример #5
0
 private void Dispose(bool disposing)
 {
     if (!disposing)
     {
         return;
     }
     if (m_fontCache != null)
     {
         m_fontCache.Dispose();
         m_fontCache = null;
     }
     if (m_gdiWriter != null)
     {
         m_gdiWriter.Dispose();
         m_gdiWriter = null;
     }
     if (SharedImages == null)
     {
         return;
     }
     foreach (Image value in SharedImages.Values)
     {
         value.Dispose();
     }
     SharedImages = null;
 }
Пример #6
0
        public void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, bool bForPreview)
        {
            //_isStructureInSync = false;
            _isMeasureInSync = false; // Change: interpret text every time in order to update plot items and \ID

            if (!_isStructureInSync)
            {
                // this.Interpret(g);
                InterpretText();

                _isStructureInSync = true;
                _isMeasureInSync   = false;
            }

            using (var fontCache = new FontCache())
            {
                if (!_isMeasureInSync)
                {
                    // this.MeasureStructure(g, obj);
                    MeasureGlyphs(g, fontCache, paintContext);

                    MeasureBackground(g, _rootNode.SizeX, _rootNode.SizeY, _rootNode.SizeZ);

                    _isMeasureInSync = true;
                }

                _cachedSymbolPositions.Clear();

                var gs = g.SaveGraphicsState();

                var bounds = Bounds;

                var transformmatrix = Matrix4x3.NewScalingShearingRotationDegreesTranslation(
                    ScaleX, ScaleY, ScaleZ,
                    ShearX, ShearY, ShearZ,
                    RotationX, RotationY, RotationZ,
                    _location.AbsolutePivotPositionX, _location.AbsolutePivotPositionY, _location.AbsolutePivotPositionZ);
                transformmatrix.TranslatePrepend(bounds.X, bounds.Y, bounds.Z);

                if (!bForPreview)
                {
                    TransformGraphics(g);
                    g.TranslateTransform(bounds.X, bounds.Y, bounds.Z);
                }

                // first of all paint the background
                PaintBackground(g);

                var dc = new DrawContext
                {
                    FontCache              = fontCache,
                    bForPreview            = bForPreview,
                    LinkedObject           = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <HostLayer>(this),
                    transformMatrix        = transformmatrix,
                    _cachedSymbolPositions = _cachedSymbolPositions
                };
                DrawGlyphs(g, dc, _cachedTextOffset.X, _cachedTextOffset.Y, _cachedTextOffset.Z);
                g.RestoreGraphicsState(gs);
            }
        }
 void SetTypeface(MvvmAspire.Controls.Editor element)
 {
     if (!string.IsNullOrEmpty(element.FontFamily))
     {
         Control.Typeface = FontCache.GetTypeFace(element.FontFamily);
     }
 }
Пример #8
0
        }                                                     //TODO: can this be internal?


        /// <summary>
        /// A generator is only good for a single use. If you want to create many
        /// reports then you must create a new generator for each one.
        /// </summary>
        public Generator(
            User user, Client client,
            string documentId, int documentVersion, DateTimeOffset timestamp,
            string fontDirectory,
            IPhotoService photoService, IResourceService pictureService,
            IUnitOfWork unitOfWork, ILog logger,
            bool traceLayout, bool traceText, bool tracePath, bool traceOutline)
        {
            _user   = user;
            _client = client;

            _documentId      = documentId;
            _documentVersion = documentVersion;
            _timestamp       = timestamp;

            _unitOfWork      = unitOfWork;
            _logger          = logger;
            _fonts           = new FontCache(fontDirectory);
            _photoService    = photoService;
            _resourceService = pictureService;

            //	Layout tracing is done directly by calling Trace, but path tracing
            //	requires a delegate that can be sent to the path library
            _traceContext      = new TraceContextStack(0, traceLayout, traceText, tracePath, traceOutline);
            _tracePathDelegate = new Demon.Path.TracePathDelegate(TracePathResolution);
        }
Пример #9
0
    private static TextCharDef ChangeDefOnDemand(TextCharDef def, XmlAttributeCollection attributes)
    {
        if (attributes [FONT_ATTRIBUTE] != null)
        {
            def.font = FontCache.GetFont(attributes [FONT_ATTRIBUTE].InnerText);
        }

        if (attributes [SIZE_ATTRIBUTE] != null)
        {
            def.size = float.Parse(attributes [SIZE_ATTRIBUTE].InnerText);
        }

        if (attributes [FONTSIZE_ATTRIBUTE] != null)
        {
            def.fontSize = int.Parse(attributes [FONTSIZE_ATTRIBUTE].InnerText);
        }

        if (attributes [SPACING_ATTRIBUTE] != null)
        {
            def.spacing = float.Parse(attributes [SPACING_ATTRIBUTE].InnerText);
        }

        if (attributes [COLOR_ATTRIBUTE] != null)
        {
            def.color = ColorExtension.ParseColor(attributes [COLOR_ATTRIBUTE].InnerText);
        }

        return(def);
    }
Пример #10
0
 void SetTextFont()
 {
     if (label != null && !string.IsNullOrEmpty(Base.TextFontFamily))
     {
         label.Typeface = FontCache.GetTypeFace(Base.TextFontFamily);
     }
 }
Пример #11
0
        private void DrawNodeText(DrawTreeNodeEventArgs e)
        {
            if (e.Node.Bounds.IsEmpty)
            {
                return;
            }

            Rectangle bounds = e.Node.Bounds;

            Font font = FontCache.GetFontFromIdentifier(
                tvLoggerTree.Font.Name
                , tvLoggerTree.Font.Size
                , tvLoggerTree.Font.Style);

            bounds.Width = TextRenderer.MeasureText(e.Node.Text, font).Width;
            bounds.Y    -= 1;
            bounds.X    += 1;

            if (e.Node.Level == 0 && e.Node.PrevNode == null)
            {
                bounds = new Rectangle(
                    tvLoggerTree.Margin.Size.Width + ThemeManager.CurrentApplicationTheme.Resources.Images["FrmLogTreeNodeExpanded"].Width + 9
                    , 0
                    , bounds.Width
                    , bounds.Height);
            }

            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, bounds, e.Node.ForeColor);
        }
Пример #12
0
        public void CreateGDIFont(string family, ReportSize size, FontStyles style, FontWeights weight, TextDecorations decoration)
        {
            double num   = 12.0;
            bool   flag  = this.IsBold(weight);
            bool   flag2 = style == FontStyles.Italic;

            if (size != null)
            {
                num = size.ToPoints();
            }
            string fontFamilyName = "Arial";

            if (family != null)
            {
                fontFamilyName = family;
            }
            bool lineThrough = false;
            bool underLine   = false;

            switch (decoration)
            {
            case TextDecorations.Underline:
                underLine = true;
                break;

            case TextDecorations.LineThrough:
                lineThrough = true;
                break;
            }
            this.m_gdiFont = FontCache.CreateGdiPlusFont(fontFamilyName, (float)num, ref flag, ref flag2, lineThrough, underLine);
        }
Пример #13
0
 void SetDetailFont()
 {
     if (detailLabel != null && !string.IsNullOrEmpty(Base.DetailFontFamily))
     {
         detailLabel.Typeface = FontCache.GetTypeFace(Base.DetailFontFamily);
     }
 }
 private static void AddCharSet(string fontName)
 {
     if (fontName == null)
     {
         return;
     }
     lock (m_charSetLookupLock)
     {
         if (m_charSetLookup.ContainsKey(fontName))
         {
             return;
         }
         Font font = null;
         try
         {
             bool bold   = false;
             bool italic = false;
             font = FontCache.CreateGdiPlusFont(fontName, 400f, ref bold, ref italic, lineThrough: false, underLine: false);
             LOGFONT lOGFONT = new LOGFONT();
             font.ToLogFont(lOGFONT);
             m_charSetLookup.Add(fontName, (CharSet)lOGFONT.lfCharSet);
         }
         finally
         {
             if (font != null)
             {
                 font.Dispose();
                 font = null;
             }
         }
     }
 }
 private static void AddCharSet(string fontName)
 {
     if (fontName != null)
     {
         lock (StyleProperties.m_charSetLookupLock)
         {
             if (!StyleProperties.m_charSetLookup.ContainsKey(fontName))
             {
                 Font font = null;
                 try
                 {
                     bool flag  = false;
                     bool flag2 = false;
                     font = FontCache.CreateGdiPlusFont(fontName, 400f, ref flag, ref flag2, false, false);
                     LOGFONT lOGFONT = new LOGFONT();
                     font.ToLogFont(lOGFONT);
                     StyleProperties.m_charSetLookup.Add(fontName, (CharSet)lOGFONT.lfCharSet);
                 }
                 finally
                 {
                     if (font != null)
                     {
                         font.Dispose();
                         font = null;
                     }
                 }
             }
         }
     }
 }
Пример #16
0
 void SetTypeface(string fontName)
 {
     if (!string.IsNullOrEmpty(fontName))
     {
         Control.Typeface = FontCache.GetTypeFace(fontName);
     }
 }
 public virtual void Test()
 {
     FontCache.ClearSavedFonts();
     FontProgramFactory.ClearRegisteredFonts();
     LicenseKey.LoadLicenseFile(Environment.GetEnvironmentVariable("ITEXT7_LICENSEKEY") + "/all-products.xml");
     RunSamples();
     ResetLicense();
 }
 void SetTypeface(MvvmAspire.Controls.FormattedLabelChild element)
 {
     if (!string.IsNullOrEmpty(element.FontFamily))
     {
         var label = (TextView)Control;
         label.Typeface = FontCache.GetTypeFace(element.FontFamily);
     }
 }
Пример #19
0
        public static SpriteFont GetFont(string path)
        {
            path = NormalizePath(path);
            SpriteFont font = null;

            FontCache.TryGetValue(path, out font);
            return(font);
        }
Пример #20
0
        /// <summary>
        /// Creates a new instance of the <see cref="FrmLogWindow"/> window.
        /// </summary>
        /// <param name="logProvider">The <see cref="ILogProvider"/> that sends messages to this window.</param>
        /// <param name="logContainer">The <see cref="ILogContainer"/> that contains the source for <see cref="LogMessage"/>s.</param>
        public FrmLogWindow(ILogProvider logProvider, ILogContainer logContainer)
        {
            InitializeComponent();

            mLogcontainer = logContainer;
            mBookmarks    = new List <LogMessage>();
            InitializeColumns(logProvider);

            if (!logProvider.HasLoggerTree)
            {
                // Remove the synchronize tree menu item if no tree is available.
                cmLogMessage.Items.Remove(cmsSynchronizeTree);
                cmLogMessage.Items.Remove(cmsSeperator);
            }

            ThemeManager.ApplyTo(this);

            if (!string.IsNullOrEmpty(Settings.Default.LogMessagesFontName))
            {
                try
                {
                    dtgLogMessages.DefaultCellStyle.Font = FontCache.GetFontFromIdentifier(
                        Settings.Default.LogMessagesFontName
                        , Settings.Default.LogMessagesFontSize
                        , FontStyle.Regular);
                }
                catch
                {
                    // Reset the font on error.
                    dtgLogMessages.Font = FontCache.GetFontFromIdentifier(
                        DEFAULT_FONT_NAME
                        , DEFAULT_FONT_SIZE
                        , FontStyle.Regular);

                    mRowHeight = dtgLogMessages.RowTemplate.Height;

                    // Save the changed settings as new default.
                    Settings.Default.LogMessagesFontName = DEFAULT_FONT_NAME;
                    Settings.Default.LogMessagesFontSize = DEFAULT_FONT_SIZE;

                    Settings.Default.SaveSettings();
                }
            }

            if (Settings.Default.EnableColorMap)
            {
                tableLayoutPanel1.SetColumnSpan(dtgLogMessages, 1);
                colorMap1.Visible = true;
            }
            else
            {
                colorMap1.Visible = false;
                tableLayoutPanel1.SetColumnSpan(dtgLogMessages, 2);
            }

            // Listening for settings changes.
            Settings.Default.SettingChanging += DefaultSettingChanging;
        }
Пример #21
0
        void SetTypeface()
        {
            if (!string.IsNullOrEmpty(Element.FontFamily))
            {
                editText.Typeface = FontCache.GetTypeFace(Element.FontFamily);
            }

            editText.TextSize = (float)Element.FontSize;
        }
Пример #22
0
        public override void Dispose()
        {
            ProcessDelayedDeletes();

            // Dispose all cached fonts.
            FontCache.FreeCache();

            base.Dispose();
        }
Пример #23
0
        protected new Bitmap DrawPrivateFont_V(string drawstr, Color fontColor, Color edgeColor, bool bVertical)
        {
            #region [ 以前レンダリングしたことのある文字列/フォントか? (キャッシュにヒットするか?) ]
            int index = listFontCache.FindIndex(
                delegate(FontCache fontcache)
            {
                return(
                    drawstr == fontcache.drawstr &&
                    fontColor == fontcache.fontColor &&
                    edgeColor == fontcache.edgeColor &&
                    bVertical == true
                    // _font == fontcache.font
                    );
            }
                );
            #endregion
            if (index < 0)
            {
                // キャッシュにヒットせず。
                #region [ レンダリングして、キャッシュに登録 ]
                FontCache fc = new FontCache();
                fc.bmp         = base.DrawPrivateFont_V(drawstr, fontColor, edgeColor, true);
                fc.drawstr     = drawstr;
                fc.fontColor   = fontColor;
                fc.edgeColor   = edgeColor;
                fc.rectStrings = RectStrings;
                fc.ptOrigin    = PtOrigin;
                listFontCache.Add(fc);
                Debug.WriteLine(drawstr + ": Cacheにヒットせず。(cachesize=" + listFontCache.Count + ")");
                #endregion
                #region [ もしキャッシュがあふれたら、最も古いキャッシュを破棄する ]
                if (listFontCache.Count > MAXCACHESIZE)
                {
                    Debug.WriteLine("Cache溢れ。" + listFontCache[0].drawstr + " を解放します。");
                    if (listFontCache[0].bmp != null)
                    {
                        listFontCache[0].bmp.Dispose();
                    }
                    listFontCache.RemoveAt(0);
                }
                #endregion

                // 呼び出し元のDispose()でキャッシュもDispose()されないように、Clone()で返す。
                return((Bitmap)listFontCache[listFontCache.Count - 1].bmp.Clone());
            }
            else
            {
                Debug.WriteLine(drawstr + ": Cacheにヒット!! index=" + index);
                #region [ キャッシュにヒット。レンダリングは行わず、キャッシュ内のデータを返して終了。]
                RectStrings = listFontCache[index].rectStrings;
                PtOrigin    = listFontCache[index].ptOrigin;
                // 呼び出し元のDispose()でキャッシュもDispose()されないように、Clone()で返す。
                return((Bitmap)listFontCache[index].bmp.Clone());

                #endregion
            }
        }
Пример #24
0
        private void SetTypeface()
        {
            if (!string.IsNullOrEmpty(Element.FontFamily))
            {
                Control.Typeface = FontCache.GetTypeFace(Element.FontFamily);
            }

            Control.TextSize = (int)Math.Round(Element.FontSize);
        }
Пример #25
0
        private bool _showBlockBreak = false; /// transient

        // ========================================
        // constructor
        // ========================================
        public AbstractNode() : base()
        {
            _font                = SystemFontDescriptions.DefaultFont;
            _fontColor           = FigureConsts.WindowTextColor;
            _foreground          = FigureConsts.WindowTextColor;
            _background          = FigureConsts.WindowBrush;
            _isForegroundEnabled = true;
            _isBackgroundEnabled = true;
            _borderWidth         = 1;
            _borderDashStyle     = DashStyle.Solid;
            _minSize             = new Size(4, 4);
            _maxSize             = new Size(int.MaxValue, int.MaxValue);
            _autoSize            = AutoSizeKinds.None;

            _padding = new Insets(2);

            _text                    = string.Empty;
            _textSizeCache           = Size.Empty;
            _textHorizontalAlignment = DataType::HorizontalAlignment.Left;
            _textVerticalAlignment   = VerticalAlignment.Top;

            _styledText            = null;
            _selectionBorderColor  = FigureConsts.HighlightColor;
            _selectionBrush        = FigureConsts.HighlightBrush;
            _fontCache             = new FontCache();
            _updateStyledTextDepth = 0;

            _ResourceCache.RegisterResourceCreator(
                FontResourceKey,
                () => _font.CreateFont(),
                ResourceDisposingPolicy.Explicit
                );
            _ResourceCache.RegisterResourceCreator(
                PenResourceKey,
                () => {
                var ret       = new Pen(_foreground, _borderWidth);
                ret.DashStyle = _borderDashStyle;
                return(ret);
            },
                ResourceDisposingPolicy.Immediate
                );
            _ResourceCache.RegisterResourceCreator(
                BrushResourceKey,
                () => _background == null? null: _background.CreateBrush(Bounds),
                ResourceDisposingPolicy.Immediate
                );
            _ResourceCache.RegisterResourceCreator(
                SelectionPenResourceKey,
                () => new Pen(_selectionBorderColor),
                ResourceDisposingPolicy.Immediate
                );
            _ResourceCache.RegisterResourceCreator(
                SelectionBrushResourceKey,
                () => _selectionBrush.CreateBrush(Bounds),
                ResourceDisposingPolicy.Immediate
                );
        }
Пример #26
0
        void SetTypeface()
        {
            if (!string.IsNullOrEmpty(Element.FontFamily))
            {
                textView.Typeface = FontCache.GetTypeFace(Element.FontFamily);
            }

            textView.TextSize = (int)Math.Round(Element.FontSize);
        }
Пример #27
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.buttonOk      = new UIButton(ButtonStyle.AlphaChannel);
            this.buttonReset   = new UIButton(ButtonStyle.AlphaChannel);
            this.buttonCancel  = new UIButton(ButtonStyle.AlphaChannel);
            this.textBoxStatus = new UITextControl();

            this.SuspendLayout();
            //
            // textBoxStatus
            //
            this.textBoxStatus.Location  = new Point(8, 0);
            this.textBoxStatus.Size      = new Size(100, 25);
            this.textBoxStatus.Name      = "textBoxStatus";
            this.textBoxStatus.BackColor = Color.White;
            this.textBoxStatus.Font      = FontCache.CreateFont("Calibri", 18, FontStyle.Regular, true);//12
            //TODO через Init
            this.textBoxStatus.SetImages(MasterForm.SkinManager.GetImage("UITextBoxLeftBorder"), MasterForm.SkinManager.GetImage("UITextBoxRightBorder"),
                                         MasterForm.SkinManager.GetImage("UITextBoxTopBorder"), MasterForm.SkinManager.GetImage("UITextBoxBottomBorder"));
            this.textBoxStatus.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            //
            // buttonOk
            //
            buttonOk.Location = new Point(8, 20);
            buttonOk.Size     = new Size(100, 25);
            buttonOk.Text     = "ОК";
            buttonOk.Click   += new EventHandler(buttonOk_Click);
            //
            // buttonReset
            //
            buttonReset.Location = new Point(8, 40);
            buttonReset.Size     = new Size(100, 25);
            buttonReset.Text     = "Сбросить";
            buttonReset.Click   += new EventHandler(buttonReset_Click);
            //
            // buttonCancel
            //
            buttonCancel.Location = new Point(8, 60);
            buttonCancel.Size     = new Size(150, 25);
            buttonCancel.Text     = "Отмена";
            buttonCancel.Click   += new EventHandler(buttonCancel_Click);
            //
            // StatusDialogControl
            //
            this.Size = new Size(240, 268);
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Dpi;
            this.Canvas.Children.Add(this.buttonOk);
            this.Canvas.Children.Add(this.buttonReset);
            this.Canvas.Children.Add(this.buttonCancel);
            this.Canvas.Children.Add(textBoxStatus);
            this.Name = "StatusDialogControl";
            this.Canvas.RecalcDPIScaling();
            this.ResumeLayout(false);
        }
Пример #28
0
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        private void InitializeComponent()
        {
            this.buttonUpdate = new UIButton(ButtonStyle.AlphaChannel);
            this.buttonSkip   = new UIButton(ButtonStyle.AlphaChannel);
            this.buttonCancel = new UIButton(ButtonStyle.AlphaChannel);

            //
            // buttonUpdate
            //
            buttonUpdate.Location         = new Point(8, 20);
            buttonUpdate.Size             = new Size(100, 25);
            buttonUpdate.Text             = Resources.UpdateInfoDialogControl_Buttons_Update;
            buttonUpdate.Click           += new EventHandler(buttonUpdate_Click);
            buttonUpdate.Font             = FontCache.CreateFont("Tahoma", 11, FontStyle.Bold);
            buttonUpdate.FontColor        = Color.Black;
            buttonUpdate.PressedFontColor = Color.White;

            //
            // buttonSkip
            //
            buttonSkip.Location         = new Point(8, 40);
            buttonSkip.Size             = new Size(100, 25);
            buttonSkip.Text             = Resources.UpdateInfoDialogControl_Buttons_Skip;
            buttonSkip.Click           += new EventHandler(buttonSkip_Click);
            buttonSkip.Font             = FontCache.CreateFont("Tahoma", 11, FontStyle.Bold);
            buttonSkip.FontColor        = Color.Black;
            buttonSkip.PressedFontColor = Color.White;

            //
            // buttonCancel
            //
            buttonCancel.Location         = new Point(8, 60);
            buttonCancel.Size             = new Size(100, 25);
            buttonCancel.Text             = string.Empty;
            buttonCancel.Click           += new EventHandler(buttonCancel_Click);
            buttonCancel.Font             = FontCache.CreateFont("Tahoma", 11, FontStyle.Bold);
            buttonCancel.FontColor        = Color.Black;
            buttonCancel.PressedFontColor = Color.White;

            //
            // PasswordRestoreDialogControl
            //
            this.Size = new Size(240, 268);
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Dpi;
            this.Name = "UpdateInfoDialogControl";

            this.Canvas.Children.Add(this.buttonUpdate);
            this.Canvas.Children.Add(this.buttonSkip);
            this.Canvas.Children.Add(this.buttonCancel);

            this.Canvas.RecalcDPIScaling();

            this.ResumeLayout(false);
        }
Пример #29
0
 public D3D9Renderer(ID3D9Context context, FontCache fontCache, D3D9TextureManager9 textureManager)
 {
     this.context        = context;
     this.fontCache      = fontCache;
     this.textureManager = textureManager;
     this.line           = new Line(this.context.Device);
     this.sprite         = new Sprite(this.context.Device);
     context.PreReset   += this.OnPreReset;
     context.PostReset  += this.OnPostReset;
     context.Draw       += this.OnDraw;
 }
Пример #30
0
        private RectangleF[] MeasureStringParts(CharacterRange[] range, Graphics g, string str, Style style)
        {
            UpdateTabStop(str, style);

            stringFormat.SetMeasurableCharacterRanges(range);

            Region[] regn = g.MeasureCharacterRanges(str, FontCache.get(style),
                                                     RectangleF.Empty, stringFormat);

            return(Array.ConvertAll(regn, rgn => rgn.GetBounds(g)));
        }
Пример #31
0
        public Theme(string themeName)
        {
            path = "themes\\" + themeName;
           

            // if theme not found pick the first theme on theme dir
            if (!File.Exists(Directory.GetCurrentDirectory() + "\\" + path + "\\settings.ini"))
            {
                System.Windows.MessageBox.Show("Could not find theme named '" + themeName + "' from '" + Directory.GetCurrentDirectory() + "\\" + path + "\\'");

                DirectoryInfo d = new DirectoryInfo(Directory.GetCurrentDirectory() + "\\themes\\");
                DirectoryInfo[] dis = d.GetDirectories();
                foreach (DirectoryInfo di in dis)
                {
                    if (File.Exists(Directory.GetCurrentDirectory() + "\\themes\\" + di.Name + "\\settings.ini"))
                    {
                        themeName = di.Name;
                        break;
                    }
                }
            }

            path = "themes\\" + themeName;
            name = themeName;
            fontCache = new FontCache();
            fontCache.SetPath(Path.Combine(Directory.GetCurrentDirectory(), "themes\\" + themeName));

            settings = new CfgFile(path + "\\settings.ini");

            if (getIniValueBool("General", "dynamic"))
            {
                logger.Info("Dynamic Theme configuration activated");
                List<string> secs = settings.getAllSections();
                Dictionary<string, List<string>> secStuff = new Dictionary<string, List<string>>();
                
                foreach (string s in secs)
                {
                    string[] parts = s.Split('-');
                    if (parts.Length != 2)
                        continue;
                    if ( !secStuff.ContainsKey( parts[0].ToLowerInvariant() ) )
                        secStuff[parts[0].ToLowerInvariant()] = new List<string>();
                    secStuff[parts[0].ToLowerInvariant()].Add(parts[1]);
                }
                foreach( string k in secStuff.Keys )
                {
                    logger.Info("Setting {0}s = {1}",k,String.Join(",", secStuff[k]));
                    settings.setValue("General", k+"s", String.Join(",", secStuff[k]), false);
                }
            }
            string filename = Directory.GetCurrentDirectory() + "\\themes\\" + name + "\\tracks.ini";
            if (!File.Exists(filename))
                filename = Directory.GetCurrentDirectory() + "\\tracks.ini";

            if (File.Exists(filename))
            {
                TrackNames = new CfgFile(filename);                
            }


            
            width = Int32.Parse(getIniValue("General", "width"));
            height = Int32.Parse(getIniValue("General", "height"));

            defaultFont = settings.getValue("General", "font", false, "Arial", false);

            // point schema
            pointscol = Int32.Parse(getIniValue("General", "pointscol"));
            minscoringdistance = Single.Parse(getIniValue("General", "minscoringdistance"))/100;
            if (minscoringdistance == 0.0f)
                minscoringdistance = 1.0f;
            string[] pointschemastr = getIniValue("General", "pointschema").Split(',');
            pointschema = new Int32[pointschemastr.Length];
            for (int i = 0; i < pointschemastr.Length; i++)
                pointschema[i] = Int32.Parse(pointschemastr[i]);

            // load objects
            string tmp = getIniValue("General", "overlays");
            string[] overlays;
            if (tmp != "0")
            {
                overlays = tmp.Split(',');
                objects = new ObjectProperties[overlays.Length];
            }
            else
            {
                objects = new ObjectProperties[0];
                overlays = new string[0];
            }

            for(int i = 0; i < overlays.Length; i++) {

                objects[i].name = overlays[i];
                objects[i].width = Int32.Parse(getIniValue("Overlay-" + overlays[i], "width"));
                objects[i].height = Int32.Parse(getIniValue("Overlay-" + overlays[i], "height"));
                objects[i].left = Int32.Parse(getIniValue("Overlay-" + overlays[i], "left"));
                objects[i].top = Int32.Parse(getIniValue("Overlay-" + overlays[i], "top"));
                objects[i].zIndex = Int32.Parse(getIniValue("Overlay-" + overlays[i], "zIndex"));
                objects[i].offset = Int32.Parse(getIniValue("Overlay-" + overlays[i], "offset"));
                objects[i].dataset = (DataSets)Enum.Parse(typeof(DataSets), getIniValue("Overlay-" + overlays[i], "dataset"));

                if (getIniValue("Overlay-" + overlays[i], "class") != "0")
                    objects[i].carclass = getIniValue("Overlay-" + overlays[i], "class");
                else
                    objects[i].carclass = null;

                if (getIniValue("Overlay-" + overlays[i], "fixed") == "true")
                    objects[i].presistent = true;
                else
                    objects[i].presistent = false;

                if (getIniValue("Overlay-" + overlays[i], "leader") != "0")
                    objects[i].leadervalue = getIniValue("Overlay-" + overlays[i], "leader");
                else
                    objects[i].leadervalue = null;
                objects[i].session = (SessionTypes)Enum.Parse(typeof(SessionTypes), getIniValue("Overlay-" + overlays[i], "session"));
                int extraHeight = 0;

                // load labels
                tmp = getIniValue("Overlay-" + overlays[i], "labels");
                string[] labels = tmp.Split(',');
                objects[i].labels = new LabelProperties[labels.Length];
                for (int j = 0; j < labels.Length; j++)
                {
                    objects[i].labels[j] = loadLabelProperties("Overlay-" + overlays[i], labels[j]);
                    if (objects[i].labels[j].height > extraHeight)
                        extraHeight = objects[i].labels[j].height;
                    if (objects[i].labels[j].session == SessionTypes.none)
                        objects[i].labels[j].session = objects[i].session;
                }

                if (objects[i].dataset == DataSets.standing || objects[i].dataset == DataSets.points || objects[i].dataset == DataSets.pit)
                {
                    objects[i].itemCount = Int32.Parse(getIniValue("Overlay-" + overlays[i], "number"));
                    objects[i].itemSize = Int32.Parse(getIniValue("Overlay-" + overlays[i], "itemHeight"));
                    objects[i].itemSize += Int32.Parse(getIniValue("Overlay-" + overlays[i], "itemsize"));
                    objects[i].height = Math.Max(objects[i].height, (objects[i].itemCount * objects[i].itemSize) + extraHeight);
                    objects[i].page = -1;
                    objects[i].direction = (direction)Enum.Parse(typeof(direction), getIniValue("Overlay-" + overlays[i], "direction"));
                    objects[i].offset = Int32.Parse(getIniValue("Overlay-" + overlays[i], "offset"));
                    objects[i].maxpages = Int32.Parse(getIniValue("Overlay-" + overlays[i], "maxpages"));
                    objects[i].skip = Int32.Parse(getIniValue("Overlay-" + overlays[i], "skip"));
                }

                switch (getIniValue("Overlay-" + overlays[i], "dataorder"))
                {
                    case "fastestlap":
                        objects[i].dataorder = DataOrders.fastestlap;
                        break;
                    case "previouslap":
                        objects[i].dataorder = DataOrders.previouslap;
                        break;
                    case "class":
                        objects[i].dataorder = DataOrders.previouslap;
                        break;
                    case "points":
                        objects[i].dataorder = DataOrders.points;
                        break;
                    case "liveposition":
                        objects[i].dataorder = DataOrders.liveposition;
                        break;
                    case "trackposition":
                        objects[i].dataorder = DataOrders.trackposition;
                        break;
                    default:
                        objects[i].dataorder = DataOrders.position;
                        break;
                }
                objects[i].visible = false;
            }

            // load images
            tmp = getIniValue("General", "images");
            string[] files;
            if (tmp != "0")
            {
                files = tmp.Split(',');
                images = new ImageProperties[files.Length];
            }
            else
            {
                images = new ImageProperties[0];
                files = new string[0];
            }
            
            for (int i = 0; i < files.Length; i++)
            {
                images[i].filename = getIniValue("Image-" + files[i], "filename");
                images[i].zIndex = Int32.Parse(getIniValue("Image-" + files[i], "zIndex"));
                images[i].visible = false;
                images[i].name = files[i];

                images[i].width = Int32.Parse(getIniValue("Image-" + files[i], "width"));
                images[i].height = Int32.Parse(getIniValue("Image-" + files[i], "height"));
                images[i].left = Int32.Parse(getIniValue("Image-" + files[i], "left"));
                images[i].top = Int32.Parse(getIniValue("Image-" + files[i], "top"));

                if (getIniValue("Image-" + files[i], "dynamic") == "true")
                {
                    images[i].dynamic = true;
                    images[i].defaultFile = getIniValue("Image-" + files[i], "default");
                }
                else
                    images[i].dynamic = false;

                if (getIniValue("Image-" + files[i], "fixed") == "true")
                    images[i].presistent = true;
                else
                    images[i].presistent = false;

                 if (getIniValue("Image-" + files[i], "animate") == "true")
                     images[i].doAnimate = true;
                 else
                     images[i].doAnimate = false;

            }

            // load videos
            tmp = getIniValue("General", "videos");
            if (tmp != "0")
            {
                files = tmp.Split(',');
                videos = new VideoProperties[files.Length];
            }
            else
            {
                videos = new VideoProperties[0];
                files = new string[0];
            }

            for (int i = 0; i < files.Length; i++)
            {
                videos[i].filename = getIniValue("Video-" + files[i], "filename");
                videos[i].zIndex = Int32.Parse(getIniValue("Video-" + files[i], "zIndex"));
                videos[i].width = Int32.Parse(getIniValue("Video-" + files[i], "width"));
                videos[i].height = Int32.Parse(getIniValue("Video-" + files[i], "height"));
                videos[i].left = Int32.Parse(getIniValue("Video-" + files[i], "left"));
                videos[i].top = Int32.Parse(getIniValue("Video-" + files[i], "top"));
                videos[i].visible = false;
                videos[i].playing = false;
                videos[i].name = files[i];
                videos[i].muteSimulator = getIniValueBool("Video-" + files[i], "mute");

                Double volume = 100.0;
                bool result = Double.TryParse(getIniValueWithDefault("Video-" + files[i], "volume", "100.0"), NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-US"), out volume);
                if (!result)
                    volume = 100.0;
                
                videos[i].volume = Math.Min(volume / 100.0, 100.0);
                if (videos[i].volume <= 0)
                    videos[i].volume = 1.0;

                if (getIniValue("Video-" + files[i], "fixed") == "true")
                    videos[i].presistent = true;
                else
                    videos[i].presistent = false;

                if (getIniValue("Video-" + files[i], "loop") == "true")
                    videos[i].loop = true;
                else
                    videos[i].loop = false;
            }


            // load sounds
            tmp = getIniValue("General", "sounds");

            if (tmp != "0")
            {
                files = tmp.Split(',');
                sounds = new SoundProperties[files.Length];
            }
            else
            {
                sounds = new SoundProperties[0];
                files = new string[0];
            }

            for (int i = 0; i < files.Length; i++)
            {
                sounds[i].filename = getIniValue("Sound-" + files[i], "filename");
                sounds[i].playing = false;
                sounds[i].name = files[i];

                Double volume = 100.0;
                bool result = Double.TryParse(getIniValueWithDefault("Sound-" + files[i], "volume", "100.0"), NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-US"), out volume);
                if (!result)
                    volume = 100.0;

                sounds[i].volume = Math.Min(volume / 100.0, 100.0);
                if (sounds[i].volume <= 0)
                    sounds[i].volume = 1.0;

                if (getIniValue("Sound-" + files[i], "loop") == "true")
                    sounds[i].loop = true;
                else
                    sounds[i].loop = false;
            }

            // load tickers
            tmp = getIniValue("General", "tickers");
            string[] tickersnames;
            if (tmp != "0")
            {
                tickersnames = tmp.Split(',');
                tickers = new TickerProperties[tickersnames.Length];
            }
            else
            {
                tickers = new TickerProperties[0];
                tickersnames = new string[0];
            }

            for (int i = 0; i < tickersnames.Length; i++)
            {
                tickers[i].name = tickersnames[i];
                tickers[i].width = Int32.Parse(getIniValue("Ticker-" + tickersnames[i], "width"));
                tickers[i].height = Int32.Parse(getIniValue("Ticker-" + tickersnames[i], "height"));
                tickers[i].left = Int32.Parse(getIniValue("Ticker-" + tickersnames[i], "left"));
                tickers[i].top = Int32.Parse(getIniValue("Ticker-" + tickersnames[i], "top"));
                tickers[i].zIndex = Int32.Parse(getIniValue("Ticker-" + tickersnames[i], "zIndex"));
                tickers[i].dataset = (DataSets)Enum.Parse(typeof(DataSets), getIniValue("Ticker-" + tickersnames[i], "dataset"));

                if (getIniValue("Ticker-" + tickersnames[i], "class") != "0")
                    tickers[i].carclass = getIniValue("Ticker-" + tickersnames[i], "class");
                else
                    tickers[i].carclass = null;

                switch (getIniValue("Ticker-" + tickersnames[i], "dataorder"))
                {
                    case "fastestlap":
                        tickers[i].dataorder = DataOrders.fastestlap;
                        break;
                    case "previouslap":
                        tickers[i].dataorder = DataOrders.previouslap;
                        break;
                    case "class":
                        tickers[i].dataorder = DataOrders.classposition;
                        break;
                    case "classposition":
                        tickers[i].dataorder = DataOrders.classposition;
                        break;
                    default:
                        tickers[i].dataorder = DataOrders.position;
                        break;
                }

                if (getIniValue("Ticker-" + tickersnames[i], "speed") != "0")
                    tickers[i].speed = Double.Parse(getIniValue("Ticker-" + tickersnames[i], "speed"));
                else
                    tickers[i].speed = 1.0;

                if (getIniValue("Ticker-" + tickersnames[i], "header") != "0")
                    tickers[i].header = loadLabelProperties("Ticker-" + tickersnames[i], getIniValue("Ticker-" + tickersnames[i], "header"));

                if (getIniValue("Ticker-" + tickersnames[i], "footer") != "0")
                    tickers[i].footer = loadLabelProperties("Ticker-" + tickersnames[i], getIniValue("Ticker-" + tickersnames[i], "footer"));

                if (getIniValue("Ticker-" + tickersnames[i], "fillvertical") == "true")
                    tickers[i].fillVertical = true;
                else
                    tickers[i].fillVertical = false;

                if (getIniValue("Ticker-" + tickersnames[i], "fixed") == "true")
                    tickers[i].presistent = true;
                else
                    tickers[i].presistent = false;

                if (getIniValue("Ticker-" + tickersnames[i], "leader") != "0")
                    tickers[i].leadervalue = getIniValue("Ticker-" + overlays[i], "leader");
                else
                    tickers[i].leadervalue = null;

                // load labels
                tmp = getIniValue("Ticker-" + tickersnames[i], "labels");
                string[] labels = tmp.Split(',');
                tickers[i].labels = new LabelProperties[labels.Length];
                for (int j = 0; j < labels.Length; j++)
                    tickers[i].labels[j] = loadLabelProperties("Ticker-" + tickersnames[i], labels[j]);

                tickers[i].visible = false;
            }


            // load buttons
            tmp = getIniValue("General", "buttons");
            string[] btns = tmp.Split(',');
           
            ButtonProperties[] tmpButtons = new ButtonProperties[btns.Length];
            for (int i = 0; i < btns.Length; i++)
            {
                tmpButtons[i].name = btns[i];
                tmpButtons[i].text = getIniValue("Button-" + btns[i], "text");
                tmpButtons[i].row = Int32.Parse(getIniValue("Button-" + btns[i], "row"));
                tmpButtons[i].delay = Int32.Parse(getIniValue("Button-" + btns[i], "delay"));
                tmpButtons[i].order = Int32.Parse(getIniValue("Button-" + btns[i], "order"));
                tmpButtons[i].active = false;
                tmpButtons[i].pressed = DateTime.Now;

                if (getIniValue("Button-" + btns[i], "loop") == "true")
                    tmpButtons[i].delayLoop = true;
                else
                    tmpButtons[i].delayLoop = false;

                if (getIniValue("Button-" + btns[i], "hidden") == "true")
                    tmpButtons[i].hidden = true;
                else
                    tmpButtons[i].hidden = false;

                // hotkey
                string hotkey = settings.getValue("Button-" + btns[i], "hotkey", false, String.Empty, false);
                if (hotkey.Length > 0)
                {
                    tmpButtons[i].hotkey = new HotKeyProperties();
                    tmpButtons[i].hotkey.key = new Key();
                    tmpButtons[i].hotkey.modifier = new KeyModifier();

                    string[] hotkeys = hotkey.Split('-');
                    tmpButtons[i].hotkey.key = (Key)Enum.Parse(typeof(Key), hotkeys[hotkeys.Length - 1]);
                    tmpButtons[i].hotkey.modifier = KeyModifier.None;

                    if (hotkeys.Length > 1)
                    {
                        for (int j = 0; j < hotkeys.Length - 1; j++)
                        {
                            tmpButtons[i].hotkey.modifier |= (KeyModifier)Enum.Parse(typeof(KeyModifier), hotkeys[j]);
                        }
                    }
                }

                // actions
                tmpButtons[i].actions = new string[Enum.GetValues(typeof(ButtonActions)).Length][];
                foreach (ButtonActions action in Enum.GetValues(typeof(ButtonActions)))
                {
                    tmp = getIniValue("Button-" + btns[i], action.ToString());
                    if (tmp != "0")
                    {
                        string[] objs = tmp.Split(',');

                        tmpButtons[i].actions[(int)action] = new string[objs.Length];
                        for (int j = 0; j < objs.Length; j++)
                        {
                            tmpButtons[i].actions[(int)action][j] = objs[j];
                        }
                    }
                    else if (action == ButtonActions.replay)
                    {
                        string value = settings.getValue("Button-" + btns[i], "replay", false, String.Empty, false);
                        if (value.Length > 0)
                        {
                            tmpButtons[i].actions[(int)action] = new string[1];
                            tmpButtons[i].actions[(int)action][0] = value;
                        }
                    }
                    else
                    {
                        tmpButtons[i].actions[(int)action] = null;
                    }
                }
            }

            // Sort and order buttons for display nicely
            buttons = new ButtonProperties[btns.Length];
            int btnPos = 0;
            foreach (var currentButton in tmpButtons.OrderBy(b => b.row).ThenBy(b => b.order))
            {
#if DEBUG
                logger.Debug("{0},{1} {2}", currentButton.row, currentButton.order, currentButton.text);
#endif
                buttons[btnPos] = currentButton;
                btnPos++;
            }
            
            // load triggers
            triggers = new TriggerProperties[Enum.GetValues(typeof(TriggerTypes)).Length];
            int trigidx = 0;
            foreach (TriggerTypes trigger in Enum.GetValues(typeof(TriggerTypes)))
            {

                foreach (ThemeTypes type in Enum.GetValues(typeof(ThemeTypes)))
                {
                    triggers[trigidx].name = trigger.ToString();
                    triggers[trigidx].actions = new string[Enum.GetValues(typeof(ButtonActions)).Length][];

                    foreach (ButtonActions action in Enum.GetValues(typeof(ButtonActions)))
                    {
                        tmp = getIniValue("Trigger-" + trigger.ToString(), action.ToString());
                        if (tmp != "0")
                        {
                            string[] objs = tmp.Split(',');

                            triggers[trigidx].actions[(int)action] = new string[objs.Length];
                            for (int j = 0; j < objs.Length; j++)
                            {
                                triggers[trigidx].actions[(int)action][j] = objs[j];
                            }
                        }
                        else if (action == ButtonActions.replay)
                        {
                            string value = settings.getValue("Button-" + trigger.ToString(), "replay",false,String.Empty,false);
                            if (value.Length > 0)
                            {
                                triggers[trigidx].actions[(int)action] = new string[1];
                                triggers[trigidx].actions[(int)action][0] = value;
                            }
                        }
                        else
                        {
                            triggers[trigidx].actions[(int)action] = null;
                        }
                    }
                }
                trigidx++;
            }

            SharedData.refreshButtons = true;

            string[] translations = new string[20] { // default translations
                    "lap",
                    "laps",
                    "minutes",
                    "of",
                    "race",
                    "qualify",
                    "practice",
                    "out",
                    "remaining",
                    "gridding",
                    "pacelap",
                    "finallap",
                    "finishing",
                    "leader",
                    "invalid",
                    "replay",
                    "Clear",
                    "Partly Cloudy",
                    "Mostly Cloudy",
                    "Overcast"
            };

            foreach (string word in translations)
            {
                string translatedword = getIniValue("Translation", word);
                if(translatedword == "0") // default is the name of the property
                    translation.Add(word, word);
                else
                    translation.Add(word, translatedword);
            }

            // signs
            if (getIniValue("General", "switchsign") == "true")
            {
                translation.Add("ahead", "+");
                translation.Add("behind", "-");
            }
            else
            {
                translation.Add("ahead", "-");
                translation.Add("behind", "+");
            }

            // load scripts
            SharedData.scripting = new Scripting();
            tmp = getIniValue("General", "scripts");
            string[] scripts = tmp.Split(',');
            for (int i = 0; i < scripts.Length; i++)
            {
                if (File.Exists(Directory.GetCurrentDirectory() + "\\" + path + "\\scripts\\" + scripts[i] + ".cs"))
                    SharedData.scripting.loadScript(Directory.GetCurrentDirectory() + "\\" + path + "\\scripts\\" + scripts[i] + ".cs");
                else if (File.Exists(Directory.GetCurrentDirectory() + "\\scripts\\" + scripts[i] + ".cs"))
                    SharedData.scripting.loadScript(Directory.GetCurrentDirectory() + "\\scripts\\" + scripts[i] + ".cs");
                else
                {
                    IScript myScript = System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(scripts[i]) as IScript;
                    if (myScript != null)
                        SharedData.scripting.addScript(myScript);
                    else
                        Console.WriteLine("Script " + scripts[i] + ".cs not found!");
                }
            }
        }
Пример #32
0
        // parent - main containing window that this source window lives inside of.
        // function - function for which we're building virtual source around.
        // Get the IL from the given frame.
        // Called on UI thread.
        internal VirtualSourceViewerForm(MainForm parent, MDbgFunction function)
        {
            m_function = function;
            Debug.Assert(function != null);

            // Now actually right in text. do this first so that we can get the current font.
            BeginInit(parent);

            // Get fonts
            FontCache cache;
            {
                Font fontCurrent = this.richText.Font;
                Font emphasis = new Font(
                                   fontCurrent.FontFamily,
                                   fontCurrent.Size,
                                   FontStyle.Bold
                                );

                cache = new FontCache(emphasis);
            }

            // Underlying writer to the window.
            RawWriter rawWriter = new RawWriter(cache);

            // Il2Native mapping can be used to find out what IL offsets we can actually stop on.
            Il2NativeIterator il2nativeIterator = null;

            // Actual IL disassembly in string form.
            ILDasmIterator ilDasm = null;

            // Iterator through sequence points and source files.
            SequencePointIterator seqIterator = null;

            string fullName = "?";
            int token = 0;

            ulong nativeStartAddress = 0;
            CorDebugJITCompilerFlags codeFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DEFAULT;

            // Make cross-thread call to worker thread to collect raw information.
            // This needs to access MDbg and so can't be done on our UI thread.
            parent.ExecuteOnWorkerThreadIfStoppedAndBlock(delegate(MDbgProcess proc)
            {
                Debug.Assert(proc != null);
                Debug.Assert(!proc.IsRunning);
                Debug.Assert(function.Module.Process == proc);

                // Get some properties about this function to display.
                token = function.CorFunction.Token;
                nativeStartAddress = function.CorFunction.NativeCode.Address;
                codeFlags = function.CorFunction.NativeCode.CompilerFlags;

                CorCode ilCode = function.CorFunction.ILCode;
                Debug.Assert(true == ilCode.IsIL);
                byte[] code = ilCode.GetCode();
                fullName = function.FullName;

                // This does the real disassembly work.
                string[] lines = null; // strings of IL.
                ILDisassembler.Disassemble(code, function.Module.Importer, out lines, out m_il2RowMapping);

                ilDasm = new ILDasmIterator(rawWriter, m_il2RowMapping, lines);

                IL2NativeMap[] il2nativeMapping = function.CorFunction.NativeCode.GetILToNativeMapping();
                il2nativeIterator = new Il2NativeIterator(rawWriter, il2nativeMapping, code);

                // Get sequence points
                ISymbolMethod symMethod = function.SymMethod;

                // Sequence point information
                int[] seqIlOffsets = null;
                string[] seqPaths = null;
                int[] seqStartLines = null, seqEndLines = null, seqStartColumns = null, seqEndColumns = null;
                int seqCount = 0;

                if (symMethod != null)
                {
                    seqCount = symMethod.SequencePointCount;
                    seqIlOffsets = new int[seqCount];
                    ISymbolDocument[] seqDocuments = new ISymbolDocument[seqCount];
                    seqPaths = new string[seqCount];
                    seqStartLines = new int[seqCount];
                    seqEndLines = new int[seqCount];
                    seqStartColumns = new int[seqCount];
                    seqEndColumns = new int[seqCount];

                    symMethod.GetSequencePoints(seqIlOffsets, seqDocuments, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns);

                    for (int i = 0; i < seqCount; i++)
                    {
                        seqPaths[i] = seqDocuments[i].URL;
                    }
                }
                seqIterator = new SequencePointIterator(rawWriter, parent, seqIlOffsets, seqPaths, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns);
            }
            ); // end worker call

            // We assume sequence points are sorted by IL offset. We assert that in the iterators below.
            // Now we need to go through and stitch the IL + Source together.
            // This also works even if we have no source (since that's just the degenerate case of 0 sequence points)

            // Print out header information
            Debug.Assert(token != 0);
            rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture,
                "> Function name:{0} (token={1:x})", fullName, token));
            rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture,
                "> Native Code Address =0x{0:x}, flags={1}", nativeStartAddress, codeFlags));

            // Walk through the IL in order and write out interleaved IL and Sequence Points.
            while (!seqIterator.IsDone)
            {
                // Add IL snippets that occur before this sequence point.
                WriteIlAndNative(ilDasm, il2nativeIterator, seqIterator.IlOffset);

                seqIterator.WriteSource();
                seqIterator.Next();
            }
            // Write the IL that's after the last sequence point
            WriteIlAndNative(ilDasm, il2nativeIterator, ilDasm.IlLength);

            // Set the text.
            InitLines(null, rawWriter.Lines, rawWriter.FormatList);

            EndInit(fullName);
        }
Пример #33
0
 public RawWriter(FontCache cache)
 {
     m_cache = cache;
 }
Пример #34
0
		public void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, bool bForPreview)
		{
			//_isStructureInSync = false;
			_isMeasureInSync = false;  // Change: interpret text every time in order to update plot items and \ID

			if (!this._isStructureInSync)
			{
				// this.Interpret(g);
				this.InterpretText();

				_isStructureInSync = true;
				_isMeasureInSync = false;
			}

			using (FontCache fontCache = new FontCache())
			{
				if (!this._isMeasureInSync)
				{
					// this.MeasureStructure(g, obj);
					this.MeasureGlyphs(g, fontCache, paintContext);

					MeasureBackground(g, _rootNode.SizeX, _rootNode.SizeY, _rootNode.SizeZ);

					_isMeasureInSync = true;
				}

				_cachedSymbolPositions.Clear();

				var gs = g.SaveGraphicsState();

				var bounds = Bounds;

				var transformmatrix = Matrix4x3.NewScalingShearingRotationDegreesTranslation(
				ScaleX, ScaleY, ScaleZ,
					ShearX, ShearY, ShearZ,
					RotationX, RotationY, RotationZ,
					_location.AbsolutePivotPositionX, _location.AbsolutePivotPositionY, _location.AbsolutePivotPositionZ);
				transformmatrix.TranslatePrepend(bounds.X, bounds.Y, bounds.Z);

				if (!bForPreview)
				{
					TransformGraphics(g);
					g.TranslateTransform(bounds.X, bounds.Y, bounds.Z);
				}

				// first of all paint the background
				PaintBackground(g);

				DrawContext dc = new DrawContext();
				dc.FontCache = fontCache;
				dc.bForPreview = bForPreview;
				dc.LinkedObject = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<HostLayer>(this);
				dc.transformMatrix = transformmatrix;
				dc._cachedSymbolPositions = _cachedSymbolPositions;
				DrawGlyphs(g, dc, _cachedTextOffset.X, _cachedTextOffset.Y, _cachedTextOffset.Z);
				g.RestoreGraphicsState(gs);
			}
		}
Пример #35
0
		public void Paint(Graphics g, IPaintContext paintContext, bool bForPreview)
		{
			//_isStructureInSync = false;
			_isMeasureInSync = false;  // Change: interpret text every time in order to update plot items and \ID

			if (!this._isStructureInSync)
			{
				// this.Interpret(g);
				this.InterpretText();

				_isStructureInSync = true;
				_isMeasureInSync = false;
			}

			using (FontCache fontCache = new FontCache())
			{
				if (!this._isMeasureInSync)
				{
					// this.MeasureStructure(g, obj);
					this.MeasureGlyphs(g, fontCache, paintContext);

					MeasureBackground(g, _rootNode.Width, _rootNode.Height);

					_isMeasureInSync = true;
				}

				_cachedSymbolPositions.Clear();

				System.Drawing.Drawing2D.GraphicsState gs = g.Save();
				g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

				var bounds = Bounds;

				Matrix transformmatrix = new Matrix();
				transformmatrix.Translate((float)_location.AbsolutePivotPositionX, (float)_location.AbsolutePivotPositionY);
				transformmatrix.Rotate((float)(-Rotation));
				transformmatrix.Shear((float)Shear, 0);
				transformmatrix.Scale((float)ScaleX, (float)ScaleY);
				transformmatrix.Translate((float)bounds.X, (float)bounds.Y);

				if (!bForPreview)
				{
					TransformGraphics(g);
					g.TranslateTransform((float)bounds.X, (float)bounds.Y);
				}

				// first of all paint the background
				PaintBackground(g);

				DrawContext dc = new DrawContext();
				dc.FontCache = fontCache;
				dc.bForPreview = bForPreview;
				dc.LinkedObject = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<HostLayer>(this);
				dc.transformMatrix = transformmatrix;
				dc._cachedSymbolPositions = _cachedSymbolPositions;
				DrawGlyphs(g, dc, _cachedTextOffset.X, _cachedTextOffset.Y);
				g.Restore(gs);
			}
		}
Пример #36
0
		private void MeasureGlyphs(Graphics g, FontCache cache, IPaintContext paintContext)
		{
			MeasureContext mc = new MeasureContext();
			mc.FontCache = cache;
			mc.LinkedObject = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<HostLayer>(this);
			mc.TabStop = Glyph.MeasureString(g, "MMMM", _font).X;

			if (null != _rootNode)
				_rootNode.Measure(g, mc, 0);
		}