Exemple #1
0
 public void TestGetFont()
 {
     System.Drawing.Font f = graphics.Font;
     if (f.ToString().IndexOf("dialog") == -1 && f.ToString().IndexOf("Dialog") == -1)
     {
         //Assert.AreEqual("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.ToString());
         Assert.AreEqual("[Font: Name=Arial, Size=10, Units=3, GdiCharSet=1, GdiVerticalFont=False]", f.ToString());
     }
 }
Exemple #2
0
        public MainForm()
        {
            InitializeComponent();
            wordOutlines = new List<WordOutlineDrawing>();

            Font font = new Font(new FontFamily("����"), 100f);
            tbFont.Text = font.ToString();
            tbFont.Tag = font;
        }
Exemple #3
0
 private void m_btObjTexto_Click(object sender, System.EventArgs e)
 {
     CreateDataBase();
     System.Drawing.Font fntFonte = new System.Drawing.Font("Arial", 8);
     mdlRelatoriosJanelas.frmFRelatoriosPropriedadesObjetoTexto formFObj = new mdlRelatoriosJanelas.frmFRelatoriosPropriedadesObjetoTexto(ref m_cls_tre_tratadorErro, m_txtPath.Text, "Texto", System.Drawing.Color.Black.ToArgb(), fntFonte, true);
     formFObj.ShowDialog();
     if (formFObj.m_bModificado)
     {
         string strTexto;
         System.Drawing.Color clrCor;
         bool bVisivelImpressao;
         formFObj.RetornaValores(out strTexto, out clrCor, out fntFonte, out bVisivelImpressao);
         m_txtRetorno.Text = strTexto + " # " + clrCor.ToString() + " # " + fntFonte.ToString() + " # " + bVisivelImpressao;
     }
 }
Exemple #4
0
        /// <summary>
        /// Uses the fontDialog to allow the user to specify a font
        /// for the report body.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        private void SelectBodyFont_Click(object sender, System.EventArgs e)
        {
            // Set the initial selection to the currently selected body font.
            // Since this one dialog is used for selection of both the header
            // and body fonts, this needs to be set each time.
            fontDialog1.Font = bodyFont;

            // Show the font selection dialog.
            if (fontDialog1.ShowDialog() == DialogResult.OK)
            {
                // Update the selected font and the form controls
                // only if the user pressed OK.
                bodyFont = fontDialog1.Font;
                bodyFontDefinition.Text = bodyFont.ToString();
            }
        }
        /// <summary>
        /// This method is called after the engine has initalised the component
        /// </summary>
        protected override void OnTaskClerkInit()
        {
            base.OnTaskClerkInit();

            Font font = new Font("Arial", 9);
            font = (Font) Engine.SettingsProvider.Get("GeneralFont", font);
            textBox1.Text = font.ToString();

            for (int i = 0; i < checkedListBox.Items.Count; i++)
            {
                bool set = (bool) Engine.SettingsProvider.Get(checkedListBox.Items[i], true);
                checkedListBox.SetItemChecked(i, set);
            }

            checkedListBox.ItemCheck +=
                new ItemCheckEventHandler(checkedListBox_ItemCheck);
        }
Exemple #6
0
        /// <summary>
        /// Occurs before a form is displayed for the first time.
        /// Contains code to update read an XML file and update
        /// the text of some form controls.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // Set the default fonts for the header and text.
            headerFont = new Font("Arial", 14);
            bodyFont   = new Font("Arial", 10);

            // Update the form controls to display the default font settings.
            headerFontDefinition.Text = headerFont.ToString();
            bodyFontDefinition.Text   = bodyFont.ToString();


            // Perform the reading of the data file within a try block in case
            // the data file doesn't exist or an error is encountered reading the file.
            try
            {
                // The XmlTextReader reads the specified XML file and provides a way to
                // scroll through the data elements.
                xmlReader = new System.Xml.XmlTextReader("..\\..\\..\\Misc\\ReportData.xml");

                // Call the Read method in order to position the reader at the
                // first element.
                xmlReader.Read();

                // Show the entire contents of the data file in
                // a textbox for comparison to the printed report.
                reportData.Text = xmlReader.ReadOuterXml();

                // Closes the XmlReader.
                xmlReader.Close();
            }
            catch (Exception ex)
            {
                // An error was encountered opening or reading the data file.
                // Display an appropriate message to the user.
                MessageBox.Show("Error opening file: \r\n" + ex.Message);

                // Close the form since a report can't be printed without access
                // to the data file.
                this.Close();
            }
        }
Exemple #7
0
        public frmQuery(WorkDB aDB, CommandAS.QueryLib.ucTreeQuery aTVQuery)
        {
            _task = new Task(aDB);
              //aDB.pQP = _task;

              _lockModified = false;
              _sesFont = new Font(this.Font.FontFamily.Name, this.Font.Size);
              _currProc = null;
              _ofArr = new ArrayList(16);
              pLoadDefaultSession = string.Empty;

              //
              // Required for Windows Form Designer support
              //
              InitializeComponent();

              _tc.TabPages.Remove(_tcpParam);
              _tc.TabPages.Remove(_tcpXSLTInc);

              _txtConnection.AcceptsReturn = true;

              #region MANUAL DESIGN
              this._param = new ucParameters();
              this._splitQ = new System.Windows.Forms.Splitter();
              if (aTVQuery == null)
            this._tvQueries = new CommandAS.QueryLib.ucTreeQuery();
              else
            this._tvQueries = aTVQuery;
              //
              // _param
              //
              this._param.Dock = System.Windows.Forms.DockStyle.Fill;
              this._param.Location = new System.Drawing.Point(0, 144);
              this._param.Name = "_param";
              this._param.Size = new System.Drawing.Size(768, 156);
              this._param.TabIndex = 4;
              //
              // _splitQ
              //
              this._splitQ.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
              this._splitQ.Dock = System.Windows.Forms.DockStyle.Top;
              this._splitQ.Location = new System.Drawing.Point(0, 136);
              this._splitQ.Name = "_splitQ";
              this._splitQ.Size = new System.Drawing.Size(768, 8);
              this._splitQ.TabIndex = 3;
              this._splitQ.TabStop = false;
              //
              // _tvQueries
              //
              this._tvQueries.Dock = System.Windows.Forms.DockStyle.Top;
              this._tvQueries.ImageIndex = -1;
              this._tvQueries.Location = new System.Drawing.Point(0, 0);
              this._tvQueries.Name = "_tvQueries";
              this._tvQueries.SelectedImageIndex = -1;
              this._tvQueries.Size = new System.Drawing.Size(768, 136);
              this._tvQueries.TabIndex = 0;

              this._tcpQuery.Controls.Add(this._param);
              this._tcpQuery.Controls.Add(this._splitQ);
              this._tcpQuery.Controls.Add(this._tvQueries);
              #endregion

              _commParamDef = new ucParamDef(false);
              _commParamDef.Location = new Point(5, 5);
              _commParamDef.Size = new Size(_tcpXSLTInc.Width - 10, _tcpXSLTInc.Height - 10);
              _commParamDef.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
              _tcpXSLTInc.Controls.Add(_commParamDef);

              NewSession();
              _param.pPerf = _task;
              _commParamDef.SetData(_task.pCommonParamCollection);

              int iconSize = 0;
              try
              {
            iconSize = Convert.ToInt32(Registry.CurrentUser.OpenSubKey(AppConst.REG_APP_PATH).GetValue("IconSize"));
              }
              catch { }
              if (iconSize < 16)
            iconSize = 32;
              _iconColl = new QueryIconCollection(iconSize);

              _tb.ImageList = _iconColl.pImageList;
              _tbbExecRTab.ImageIndex = _iconColl.Index(QueryIconCollection.ExecRTab);
              _tbbExecRExcel.ImageIndex = _iconColl.Index(QueryIconCollection.ExecRExcel);
              _tbbExecRHTML.ImageIndex = _iconColl.Index(QueryIconCollection.ExecRHTML);
              _tbbNewQuery.ImageIndex = _iconColl.Index(QueryIconCollection.New);
              _tbbDelQuery.ImageIndex = _iconColl.Index(QueryIconCollection.Delete);
              _tbbSaveSession.ImageIndex = _iconColl.Index(QueryIconCollection.Save);
              _tbbLoadSession.ImageIndex = _iconColl.Index(QueryIconCollection.DocOpen);
              _tbbEditSQL.ImageIndex = _iconColl.Index(QueryIconCollection.TextSQL);
              _tbbEditParam.ImageIndex = _iconColl.Index(QueryIconCollection.TextParam);
              _tbbEditXSLT.ImageIndex = _iconColl.Index(QueryIconCollection.TextXSLT);
              _tbbAbout.ImageIndex = _iconColl.Index(QueryIconCollection.About);

              _tbbExecRTab.Tag = _mnuExecRTab;
              _tbbExecRExcel.Tag = _mnuExecRExcel;
              _tbbExecRHTML.Tag = _mnuExecRHTML;
              _tbbEditSQL.Tag = _mnuEditSQL;
              _tbbEditParam.Tag = _mnuEditParam;
              _tbbEditXSLT.Tag = _mnuEditXSLT;

              _tvQueries.HideSelection = false;
              _lcmTV = new ContextMenu();
              _miExecute = new MenuItem("Выполнить", new EventHandler(_mnuExecRTab_Click), Shortcut.F5);
              _lcmTV.MenuItems.Add(_miExecute);
              _lcmTV.MenuItems.Add(new MenuItem("-"));
              _lcmTV.MenuItems.Add(new MenuItem("Новый", new EventHandler(DoCommandNewQuery)));
              _miDeleteQuery = new MenuItem("Удалить", new EventHandler(DoCommandDeleteQuery));
              _lcmTV.MenuItems.Add(_miDeleteQuery);
              _miEditQuery = new MenuItem(this._mnuEdit.Text);
              MenuItem miEditSQL = new MenuItem(this._mnuEditSQL.Text, new EventHandler(DoCommandEditQuery));
              MenuItem miEditParam = new MenuItem(this._mnuEditParam.Text, new EventHandler(DoCommandEditQueryParam));
              MenuItem miEditXSLT = new MenuItem(this._mnuEditXSLT.Text, new EventHandler(DoCommandEditQuery));
              _miEditQuery.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { miEditSQL, miEditParam, miEditXSLT });
              _lcmTV.MenuItems.Add(_miEditQuery);
              _lcmTV.MenuItems.Add(new MenuItem("-"));
              _miPropertyQuery = new MenuItem("Свойства", new EventHandler(DoCommandPropertyQuery), Shortcut.F2);
              _lcmTV.MenuItems.Add(_miPropertyQuery);
              _lcmTV.Popup += new EventHandler(DoCommandTVQContextMenuPopup);

              _tvQueries.AfterSelect += new TreeViewEventHandler(DoCommandTVQAfterSelect);
              _tvQueries.DoubleClick += new EventHandler(DoCommandTVQDoubleClick);

              _cmdPassword.Click += new EventHandler(_cmdPassword_Click);

              _tc.SelectedIndexChanged += new EventHandler(_tc_SelectedIndexChanged);

              Load += new EventHandler(DoLoad);
              Closing += new CancelEventHandler(DoClosing);
              Activated += new EventHandler(DoActivated);

              TitleText();
              _txtFont.Text = _sesFont.ToString();
              _modified = false;
              _mnuExec.Enabled = false;
              _tbbExecRTab.Enabled = false;
              _tbbExecRExcel.Enabled = false;
              _tbbExecRHTML.Enabled = false;
              _mnuDeleteQuery.Enabled = false;
              _tbbDelQuery.Enabled = false;

              Icon = new Icon(GetType(), "Images.Icons.Query.ico");

              _img = null;
              _pnlImg.Paint += new PaintEventHandler(_pnlImg_Paint);
        }
 /// <summary>
 /// Set default values to the canvas fields
 /// </summary>
 private void SetDefaultValues()
 {
     //When the context is created, the font of the context must be set to 10px sans-serif.
     _family = new FontFamily(GenericFontFamilies.Serif);
     _parsedFont = new Font(_family, 10, FontStyle.Regular, GraphicsUnit.Pixel);
     _font = _parsedFont.ToString();
     path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     stack = new Stack<CanvasState> {};
     //_fillStyle = "rgba(0,0,0,0)";
     _transformation = new Matrix();
     _globalAlpha = 1.0;
     _globalCompositeOperation = "source-over";
     _textAlign = "start";
     _textBaseLine = "alphabetic";
     lineWidth = 1.0;
     lineCap = "butt";
     lineJoin = "miter";
     miterLimit = 10.0;
     _shadowColor = "rgba(0,0,0,0)";
     _shadowOffsetX = 0;
     _shadowOffsetY = 0;
     _shadowBlur = 0;
     surface.SmoothingMode = SmoothingMode.HighQuality;
     surface.InterpolationMode = InterpolationMode.HighQualityBicubic;
     surface.PixelOffsetMode = PixelOffsetMode.HighQuality;
     surface.PageUnit = GraphicsUnit.Pixel;
     //scale(surface.DpiX/96, surface.DpiY/96);
     //surface.PageScale = surface.DpiX * 2/96;
     _compositier = new Compositer();
 }
        private static TextServiceDirectWriteInterop EnsureInterop(Font font)
        {
            if (interops == null)
            {
                interops = new List<KeyValuePair<Font, TextServiceDirectWriteInterop>>(MaxCachedInterops);
            }

            if (lastWidth != Screen.PrimaryScreen.Bounds.Width)
            {
                ClearCache();
            }
            lastWidth = Screen.PrimaryScreen.Bounds.Width;

            int index = -1;
            for (int i = 0; i < interops.Count; i++)
            {
                if (font.Equals(interops[i].Key))
                {
                    index = i;
                }
            }
            if (index < 0)
            {
                if (interops.Count >= MaxCachedInterops)
                {
                    ClearCache();
                }
                index = interops.Count;
                TextServiceDirectWriteInterop interop = new TextServiceDirectWriteInterop();
                interop.Reset(TextServiceDirectWrite.InteropGlobals, font, lastWidth);
                interops.Add(new KeyValuePair<Font, TextServiceDirectWriteInterop>(font, interop));
            #if DEBUG
                Debugger.Log(
                    1,
                    "TextServiceDirectWrite",
                    String.Concat(
                        DateTime.Now.ToString(),
                        ": Added DirectWrite interop for ",
                        font.ToString(),
                        " ",
                        font.Style.ToString(),
                        Environment.NewLine));
            #endif
            }
            return interops[index].Value;
        }
Exemple #10
0
        protected static object GetIFontFromFont(Font font) {
            if (font == null) return null;

            if (font.Unit != GraphicsUnit.Point)
                throw new ArgumentException(SR.GetString(SR.AXFontUnitNotPoint), "font");

            try {
                return (UnsafeNativeMethods.IFont)UnsafeNativeMethods.OleCreateIFontIndirect(GetFONTDESCFromFont(font), ref ifont_Guid);
            }
            catch {
                Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "Failed to create IFrom from font: " + font.ToString());
                return null;
            }
        }
Exemple #11
0
        /// <summary>
        /// Caclulate the baseline from a font and a TextRenderingHint
        /// </summary>
        /// <param name="font">the font</param>
        /// <param name="hint">the used TextRenderingHint</param>
        /// <returns></returns>
        private static int getBaseline(Font font, TextRenderingHint hint)
        {
            lock (baselines)
            {
                String key = font.ToString() + hint.ToString();
                int baseline;
                if (!baselines.TryGetValue(key, out baseline))
                {
                    FontFamily family = font.FontFamily;
                    FontStyle style = font.Style;
                    float ascent = family.GetCellAscent(style);
                    float lineSpace = family.GetLineSpacing(style);

                    baseline = (int)Math.Round(font.GetHeight() * ascent / lineSpace);

                    // Until this point the calulation use only the Font. But with different TextRenderingHint there are smal differences.
                    // There is no API that calulate the offset from TextRenderingHint that we messure it.
                    const int w = 3;
                    const int h = 3;

                    Bitmap bitmap = new Bitmap(w, h);
                    Graphics g = Graphics.FromImage(bitmap);
                    g.TextRenderingHint = hint;
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);
                    g.DrawString("A", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT);
                    g.DrawString("X", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT);
                    g.Dispose();

                    int y = 0;
                LINE:
                    while (y < h)
                    {
                        for (int x = 0; x < w; x++)
                        {
                            Color color = bitmap.GetPixel(x, y);
                            if (color.GetBrightness() < 0.5)
                            {
                                //there is a black pixel, we continue in the next line.
                                baseline++;
                                y++;
                                goto LINE;
                            }
                        }
                        break; // there was a line without black pixel
                    }


                    baselines[key] = baseline;
                }
                return baseline;
            }
        }