コード例 #1
0
 /// <summary>
 /// make Text column
 /// </summary>
 /// <param name="wid"></param>
 /// <param name="colName"></param>
 /// <param name="Text"></param>
 /// <param name="editable"></param>
 /// <param name="alignMode"></param>
 public EasyGridColumnInfo(int wid, String colName, String Text, bool editable, TextAlignModes alignMode = TextAlignModes.None)
 {
     ColumnName         = colName;
     Width              = wid;
     this.ItemType      = ItemTypes.TextBox;
     IsEditable         = editable;
     this.TitleText     = Text;
     this.TextAlignMode = alignMode;
 }
コード例 #2
0
        void MakeAColumn(int wid, ItemTypes itemType, String name, XmlNode prop, Actions ac1, Actions ac2, Actions ac3)
        {
            _columnTypes.Add(itemType);

            switch (itemType)
            {
            case ItemTypes.Button:
            {
                String headerText = "";
                headerText = XmlGetter.Attribute(prop, "HeaderText");
                String baseText = XmlGetter.Attribute(prop, "BaseText");
                AddTitleButtonColumn(wid, name, headerText, baseText, ac1, ac2, ac3);
                break;
            }

            case ItemTypes.CheckBox:
            {
                bool isTriState = ValueParser.IsTrue(XmlGetter.Attribute(prop, "TriState"));
                //string initVal = XmlGetter.Attribute(prop, "InitValue");
                //int initValue = (initVal.Length > 0) ? int.Parse(initVal) : 0;
                AddTitleCheckBoxColumn(wid, name, isTriState, ac1, ac2, ac3);
                break;
            }

            case ItemTypes.CheckBoxGroup:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                if (prop.HasChildNodes)
                {
                    List <String> items    = new List <String>();
                    XmlNodeList   xItems   = prop.ChildNodes[0].ChildNodes;    //ComboBoxProperties/SingleSelItems/SingleSelItem
                    List <int>    selected = new List <int>();
                    for (int i = 0; i < xItems.Count; i++)
                    {
                        if (xItems[i].NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }

                        if (ValueParser.IsTrue(XmlGetter.Attribute(xItems[i], "Checked")))
                        {
                            selected.Add(i);
                        }
                        items.Add(xItems[i].InnerText);
                    }
                    if (selected.Count == 0)
                    {
                        selected = null;
                    }
                    AddTitleCheckBoxGroupColumn(wid, name, headerText, items.ToArray(), selected.ToArray(), ac1, ac2, ac3);
                }
                else
                {
                    AddTitleCheckBoxGroupColumn(wid, name, headerText, null, null, ac1, ac2, ac3);
                }
            }
            break;

            case ItemTypes.CloseButton:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                String baseText   = XmlGetter.Attribute(prop, "BaseText");
                AddTitleCloseButtonColumn(wid, name, headerText, baseText, ac1, ac2, ac3);
                break;
            }

            case ItemTypes.ComboBox:
            {
                String headerText   = XmlGetter.Attribute(prop, "HeaderText");
                String selIndexText = XmlGetter.Attribute(prop, "SelectedIndex");
                int    selIndex     = (selIndexText.Length > 0) ? int.Parse(selIndexText) : -1;
                if (prop.HasChildNodes)
                {
                    List <String> items  = new List <String>();
                    XmlNodeList   xItems = prop.ChildNodes[0].ChildNodes;      //ComboBoxProperties/SingleSelItems/SingleSelItem
                    for (int i = 0; i < xItems.Count; i++)
                    {
                        if (xItems[i].NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }

                        items.Add(xItems[i].InnerText);
                    }
                    AddTitleComboBoxColumn(wid, name, headerText, items.ToArray(), selIndex, ac1, ac2, ac3);
                }
                else
                {
                    AddTitleComboBoxColumn(wid, name, headerText, null, -1, ac1, ac2, ac3);
                }
            }
            break;

            case ItemTypes.FileOpenBox:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                bool   editable   = XmlGetter.Attribute(prop, "Editable").Equals("true");
                // bool autoSort = XmlGetter.Attribute("IsAutoSort").Equals("true");

                TextAlignModes mode = (TextAlignModes)(TextAlignModesText.ToList().IndexOf(XmlGetter.Attribute(prop, "TextAlignMode")));

                AddTitleFileOpenBoxColumn(wid, name, headerText, editable, mode, ac1, ac2, ac3);
                break;
            }

            case ItemTypes.Image:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                //int initValue = int.Parse(XmlGetter.Attribute(prop,"InitValue"));
                int titleShowImage = int.Parse(XmlGetter.Attribute(prop, "TitleShowImage"));

                if (prop.HasChildNodes)
                {
                    try
                    {
                        XmlNode xImgs = XmlGetter.Child(prop, "ImageList");
                        if (xImgs != null && xImgs.ChildNodes.Count > 0)
                        {
                            XmlImageList imgs = new XmlImageList("ImageList");
                            imgs.LoadXml(_xDoc, xImgs);
                            AddTitleImageColumn(wid, name, headerText, imgs, titleShowImage, ac1, ac2, ac3);
                        }
                        else
                        {
                            AddTitleImageColumn(wid, name, headerText, (Image[])null, -1, ac1, ac2, ac3);
                        }

                        /*
                         * // List<Image> imgs = new List<Image>();
                         * //XmlNodeList xImgs = prop.ChildNodes[0].ChildNodes;//ImageCheckBoxProperties/CheckImageList/
                         * for (int i = 0; i < xImgs.Count; i++)
                         * {
                         *  if (xImgs[i].NodeType == XmlNodeType.Comment) continue;
                         *
                         *  imgs.Add(Image.FromFile(xImgs[i], "URL")));
                         * }
                         * AddTitleImageColumn(wid, name, headerText, imgs.ToArray(), titleShowImage, ac1, ac2, ac3);
                         */
                    }
                    catch
                    {
                        AddTitleImageColumn(wid, name, headerText, (Image[])null, -1, ac1, ac2, ac3);
                    }
                }
                else
                {
                    AddTitleImageColumn(wid, name, headerText, (Image[])null, -1, ac1, ac2, ac3);
                }
                break;
            }

            case ItemTypes.ImageButton:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                //int initValue = int.Parse(XmlGetter.Attribute("InitValue"));
                int  titleShowImage = int.Parse(XmlGetter.Attribute(prop, "TitleShowImage"));
                bool showTitleText  = (XmlGetter.Attribute(prop, "ShowTitleText").Equals("true"));
                bool useColumnTextForButtonValue = (XmlGetter.Attribute(prop, "UseColumnTextForButtonValue").Equals("true"));
                if (prop.HasChildNodes)
                {
                    XmlNode xImgs = XmlGetter.Child(prop, "ImageList");        //( prop.SelectNodes("ImageList");
                    if (xImgs.ChildNodes.Count > 0)
                    {
                        XmlImageList imgs = new XmlImageList("ImageList");
                        try
                        {
                            imgs.LoadXml(_xDoc, xImgs);
                            AddTitleImageButtonColumn(wid, name, headerText, imgs, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                            AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3);
                        }
                    }
                    else
                    {
                        AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3);
                    }

                    /*
                     * try
                     * {
                     *  List<Image> imgs = new List<Image>();
                     *  XmlNodeList xImgs = prop.ChildNodes[0].ChildNodes;//ImageCheckBoxProperties/CheckImageList/
                     *  for (int i = 0; i < xImgs.Count; i++)
                     *  {
                     *      if (xImgs[i].NodeType == XmlNodeType.Comment) continue;
                     *
                     *      imgs.Add(Image.FromFile(xImgs[i], "URL")));
                     *  }
                     *  AddTitleImageButtonColumn(wid, name, headerText, imgs.ToArray(), titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3);
                     * }
                     * catch
                     * {
                     *  AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3);
                     * }
                     */
                }
                else
                {
                    AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3);
                }
                break;
            }

            case ItemTypes.ImageCheckBox:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                //bool isTriState = XmlGetter.Attribute("TriState").Equals("true");
                //int initValue = int.Parse(XmlGetter.Attribute(prop,"InitValue"));

                if (prop.HasChildNodes)
                {
                    XmlNode xImgs = XmlGetter.Child(prop, "CheckImageList");        // prop.SelectNodes("CheckImageList");
                    if (xImgs.ChildNodes.Count > 0)
                    {
                        XmlCheckImageList imgs = new XmlCheckImageList("CheckImageList");
                        try
                        {
                            imgs.LoadXml(_xDoc, xImgs);
                            AddTitleImageCheckColumn(wid, name, headerText, imgs, ac1, ac2, ac3);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("XmlScenarioTable.MakeColumn:" + e.Message);
                            AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3);
                        }
                    }
                    else
                    {
                        AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3);
                    }

                    /*
                     * List<Image> imgs = new List<Image>();
                     * XmlNodeList xImgs = prop.ChildNodes[0].ChildNodes;//ImageCheckBoxProperties/CheckImageList/
                     * try
                     * {
                     *  for (int i = 0; i < xImgs.Count; i++)
                     *  {
                     *      if (xImgs[i].NodeType == XmlNodeType.Comment) continue;
                     *
                     *      imgs.Add(Image.FromFile(xImgs[i], "URL")));
                     *  }
                     *  AddTitleImageCheckColumn(wid, name, headerText, imgs, ac1, ac2, ac3);
                     * }
                     * catch (Exception e)
                     * {
                     *  AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3);
                     * }
                     */
                }
                else
                {
                    XmlAttribute attr = prop.Attributes["CheckColor"];
                    if (attr == null)
                    {
                        AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3);
                    }
                    else if (attr.Value.Equals("Blue"))
                    {
                        AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Blue, ac1, ac2, ac3);
                    }
                    else
                    {
                        AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3);
                    }
                }

                break;
            }

            case ItemTypes.KeyValue:
            {
                String         headerText = XmlGetter.Attribute(prop, "HeaderText");
                TextAlignModes mode       = (TextAlignModes)(TextAlignModesText.ToList().IndexOf(XmlGetter.Attribute(prop, "TextAlignMode")));
                AddTitleKeyValueColumn(wid, name, headerText, mode, ac1, ac2, ac3);
                break;
            }

            case ItemTypes.RadioButton:
            {
                String headerText   = XmlGetter.Attribute(prop, "HeaderText");
                String selIndexText = XmlGetter.Attribute(prop, "SelectedIndex");
                int    selIndex     = (selIndexText.Length > 0)? int.Parse(selIndexText) : -1;
                if (prop.HasChildNodes)
                {
                    List <String> items  = new List <String>();
                    XmlNodeList   xItems = prop.ChildNodes[0].ChildNodes;      //ComboBoxProperties/SingleSelItems/SingleSelItem
                    for (int i = 0; i < xItems.Count; i++)
                    {
                        if (xItems[i].NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }

                        items.Add(xItems[i].InnerText);
                    }
                    AddTitleRadioButtonColumn(wid, name, headerText, items.ToArray(), selIndex, ac1, ac2, ac3);
                }
                else
                {
                    AddTitleRadioButtonColumn(wid, name, headerText, null, -1, ac1, ac2, ac3);
                }
            }
            break;

            case ItemTypes.TextBox:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");
                bool   editable   = XmlGetter.Attribute(prop, "Editable").Equals("true");
                bool   autoSort   = XmlGetter.Attribute(prop, "IsAutoSort").Equals("true");

                //String initValue = XmlGetter.Attribute(prop, "InitValue");
                TextAlignModes        mode = (TextAlignModes)(TextAlignModesText.ToList().IndexOf(XmlGetter.Attribute(prop, "TextAlignMode")));
                EasyGridTextBoxColumn col  = AddTitleTextBoxColumn(wid, name, headerText, editable, autoSort, mode, ac1, ac2, ac3);

                break;
            }

            case ItemTypes.Various:
            {
                String headerText = XmlGetter.Attribute(prop, "HeaderText");

                AddTitleVariousColumn(wid, name, headerText, ac1, ac2, ac3);
                break;
            }
            }
        }
コード例 #3
0
ファイル: Gdi32PI.cs プロジェクト: rajeshwarn/MochaNote
 public static extern int SetTextAlign(IntPtr hdc, TextAlignModes fMode);
コード例 #4
0
 // ========================================
 // constructor
 // ========================================
 public Gdi32TextRenderer(Graphics g)
 {
     _graphics     = g;
     _hdc          = _graphics.GetHdc();
     _oldAlignMode = Gdi32PI.GetTextAlign(_hdc);
 }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="scale"></param>
        /// <param name="color"></param>
        /// <param name="lineSpacing"></param>
        public void DrawText(SpriteBatch spriteBatch, int x, int y, string text, float scale, Color color, int lineSpacing, TextAlignModes alignMode)
        {
            string[] lines = text.Split(new string[] { @"\n" }, StringSplitOptions.RemoveEmptyEntries);
            Vector2  size  = MeasureString(lines, scale, lineSpacing);

            int dx = x;
            int dy = y;

            foreach (string line in lines)
            {
                float maxHeight = 0;

                if (alignMode == TextAlignModes.Center)
                {
                    Vector2 lineSize = MeasureString(line, scale);
                    dx = (int)(dx + (size.X / 2 - lineSize.X / 2));
                }

                foreach (char c in line)
                {
                    FontChar fc;

                    if (_characterMap.TryGetValue(c, out fc))
                    {
                        var sourceRectangle = new Rectangle(fc.X, fc.Y, fc.Width, fc.Height);
                        var destination     = new Rectangle(dx + fc.XOffset, dy + fc.YOffset, (int)(fc.Width * scale), (int)(fc.Height * scale));

                        spriteBatch.Draw(_texture, destination, sourceRectangle, color);
                        dx += (int)(fc.XAdvance * scale);

                        if (fc.Height * scale > maxHeight)
                        {
                            maxHeight = fc.Height * scale;
                        }
                    }
                }

                dx  = x;
                dy += (int)maxHeight + lineSpacing;
            }
        }
コード例 #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="scale"></param>
        /// <param name="color"></param>
        /// <param name="lineSpacing"></param>
        public void DrawText(SpriteBatch spriteBatch, int x, int y, string text, float scale, Color color, int lineSpacing, TextAlignModes alignMode)
        {
            string[] lines = text.Split(new string[] { @"\n" }, StringSplitOptions.RemoveEmptyEntries);
            Vector2 size = MeasureString(lines, scale, lineSpacing);

            int dx = x;
            int dy = y;

            foreach (string line in lines)
            {
                float maxHeight = 0;

                if (alignMode == TextAlignModes.Center)
                {
                    Vector2 lineSize = MeasureString(line, scale);
                    dx = (int)(dx + (size.X / 2 - lineSize.X / 2));
                }

                foreach (char c in line)
                {
                    FontChar fc;

                    if (_characterMap.TryGetValue(c, out fc))
                    {
                        var sourceRectangle = new Rectangle(fc.X, fc.Y, fc.Width, fc.Height);
                        var destination = new Rectangle(dx + fc.XOffset, dy + fc.YOffset, (int)(fc.Width * scale), (int)(fc.Height * scale));

                        spriteBatch.Draw(_texture, destination, sourceRectangle, color);
                        dx += (int)(fc.XAdvance * scale);

                        if (fc.Height * scale > maxHeight)
                        {
                            maxHeight = fc.Height * scale;
                        }
                    }
                }

                dx = x;
                dy += (int)maxHeight + lineSpacing;
            }
        }