Example #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="width">Width of the card (100 units/inch)</param>
 /// <param name="height">Height of the card (100 units/inch)</param>
 /// <param name="isInDesignMode">design mode indicator:
 /// true if in design mode, false otherwise</param>
 public CardWF(int width, int height, bool isInDesignMode)
     : base(width, height)
 {
     UserPreferences prefs = ((App)App.Current).UserPreferences;
     QslCard = this;
     App.Logger.Log("In CardWF constructor:" + Environment.NewLine,
                    App.Logger.DebugPrinting);
     CardPrintProperties = new PrintProperties();
     IsInDesignMode = isInDesignMode;
     ItemSize = new System.Drawing.Size(width, height);
     // background image
     BackgroundImage.QslCard = this;
     // call text item
     TextWFItem call = new TextWFItem();
     call.QslCard = this;
     foreach(TextPart part in prefs.Callsign)
     {
         call.Text.Add(part);
     }
     call.TextFontFace = prefs.DefaultTextItemsFontFace;
     call.IsBold = true;
     call.FontSize = 48.0F;
     call.X = -70;
     call.Y = 0;
     TextItems.Add(call);
     // name and Qth text item
     TextWFItem nameQth = new TextWFItem();
     nameQth.QslCard = this;
     foreach(TextPart part in prefs.NameQth)
     {
         nameQth.Text.Add(part);
     }
     nameQth.TextFontFace = prefs.DefaultTextItemsFontFace;
     nameQth.IsBold = false;
     nameQth.FontSize = 10.0F;
     nameQth.X = this.Width / 2;
     nameQth.Y = this.Height / 20;
     TextItems.Add(nameQth);
     // salutation text item
     TextWFItem salutation = new TextWFItem();
     salutation.QslCard = this;
     foreach(TextPart part in prefs.Salutation)
     {
         salutation.Text.Add(part);
     }
     salutation.TextFontFace = prefs.DefaultTextItemsFontFace;
     salutation.FontSize = 10.0F;
     salutation.X = this.Width / 75;
     salutation.Y = (int)((float)this.Height * 9F / 10F);
     TextItems.Add(salutation);
     // QsosBox
     QsosBox.QslCard = this;
 }
Example #2
0
        /// <summary>
        /// Create a TextWFItem object based on an XmlNode for it from an
        /// XQSL file
        /// </summary>
        /// <param name="card">The CardWF object that will contain the text item</param>
        /// <param name="node">XmlNode object containing the text item data</param>
        /// <param name="culture">CultureInfo object that describes the culture
        /// that the XQSL file was saved with</param>
        /// <returns></returns>
        private static TextWFItem CreateTextItem(CardWF card, XmlNode node,
		                                         CultureInfo culture)
        {
            TextWFItem tItem = new TextWFItem();
            tItem.QslCard = card;
            XmlNode tiNode = XmlProcs.GetFirstChildElement(node);
            while(tiNode != null)
            {
                XmlText text = XmlProcs.GetTextNode(tiNode);
                switch(tiNode.Name)
                {
                    case "CardItem":
                        GetCardItemData(tItem, tiNode, culture);
                        break;
                    case "FaceName":

                        tItem.TextFontFace = GetValidFont(text.Value);
                        break;
                    case "TextFontWeight":
                        tItem.IsBold = false;
                        switch(text.Value)
                        {
                            case "Normal":
                                break;
                            case "Bold":	// note fall through
                            case "Black":
                                tItem.IsBold = true;
                                break;
                        }
                        break;
                    case "IsItalic":
                        tItem.IsItalic = text.Value=="true" ? true : false;
                        break;
                    case "FontSize":
                        if(text != null)
                        {
                            float value = 0F;
                            if(!float.TryParse(text.Value, NumberStyles.Float,
                                               culture, out value))
                            {
                                if(!float.TryParse(text.Value, NumberStyles.Float,
                                                   CultureInfo.InvariantCulture,
                                                   out value))
                                {
                                    XmlException ex = new XmlException(
                                        "Bad TextItem property value in Card File" +
                                        Environment.NewLine +
                                        "Did you modify the card file by hand?");
                                    ex.Data.Add("Property", "FontSize");
                                    ex.Data.Add("Value", text.Value);
                                    App.Logger.Log(ex);
                                }
                            }
                            tItem.FontSize = value * FontScaleFactor;
                        }
                        break;
                    case "TextBrush":
                        tItem.TextColor = XmlProcs.ConvertXmlToColor(tiNode, culture);
                        break;
                    case "Text":
                        StaticText sText = new StaticText();
                        if(text.Value != null)
                        {
                            sText.Text = text.Value;
                            tItem.Text.Clear();
                            tItem.Text.Add(sText);
                        }
                        break;
                    case "CheckboxBefore":
                        if(text != null)
                        {
                            tItem.CheckboxBefore = text.Value == "true" ? true : false;
                        }
                        break;
                    case "CheckboxAfter":
                        if(text != null)
                        {
                            tItem.CheckboxAfter = text.Value == "true" ? true : false;
                        }
                        break;
                }
                tiNode = XmlProcs.GetNextSiblingElement(tiNode);
            }
            return tItem;
        }
Example #3
0
 /// <summary>
 /// Add a TextWFItem to the card
 /// </summary>
 /// <returns>TextWFItem that was added</returns>
 public TextWFItem AddTextItem()
 {
     TextWFItem tItem = new TextWFItem();
     tItem.QslCard = QslCard;
     tItem.IsSelected = true;
     StaticText sText = new StaticText();
     sText.Text = "Text Item";
     tItem.Text.Add(sText);
     tItem.X = (QslCard.Width - tItem.Width) / 2;
     tItem.Y = (QslCard.Height - tItem.Height) / 2;
     QslCard.TextItems.Add(tItem);
     return tItem;
 }
Example #4
0
        /// <summary>
        /// Paint the text item on the card.
        /// </summary>
        /// <param name="g">Graphics object on which to do the drawing</param>
        /// <param name="qsos">List of QSOs that will be printed in the QSOsBox</param>
        /// <param name="tItem">TextWFItem object to draw</param>
        /// <param name="fontAdjustmentFactor">amount to adjust font sizes by. This should be
        /// 1 except for images where it should be 96F/resolution</param>
        private void PaintTextItem(Graphics g, List<DispQso> qsos, TextWFItem tItem,
		                          float fontAdjustmentFactor)
        {
            FontStyle style = FontStyle.Regular;
            if(tItem.IsBold)
            {
                style = FontStyle.Bold;
            }
            if(tItem.IsItalic)
            {
                style |= FontStyle.Italic;
            }
            Font font = new Font(new FontFamily(tItem.TextFontFace),
                                 tItem.FontSize * fontAdjustmentFactor,
                         		 style, GraphicsUnit.Point);
            int startTextX = CardLocation.X + tItem.X + tItem.Height + 4;
            g.DrawString(tItem.Text.GetText(QslCard, qsos, QslCard.IsInDesignMode),
                         font, tItem.TextBrush, startTextX, CardLocation.Y + tItem.Y);
            float checkBoxSize = (float)tItem.Height * tItem.CheckBoxRelativeSize;
            float margin = (tItem.Height - checkBoxSize) / 2 + 2;
            if(tItem.CheckboxBefore)
            {
                Pen pen = new Pen(tItem.TextBrush, tItem.CheckboxLineThickness);
                g.DrawRectangle(pen, CardLocation.X + tItem.X + margin,
                                CardLocation.Y +tItem.Y + (tItem.Height - checkBoxSize) / 2,
                                checkBoxSize, checkBoxSize);
                pen.Dispose();
            }
            if(tItem.CheckboxAfter)
            {
                Pen pen = new Pen(tItem.TextBrush, tItem.CheckboxLineThickness);
                g.DrawRectangle(pen, CardLocation.X + tItem.X + tItem.Width -
                                tItem.Height + margin - 2,
                                 CardLocation.Y + tItem.Y + (tItem.Height - checkBoxSize) / 2,
                                checkBoxSize, checkBoxSize);
                pen.Dispose();
            }
            if(QslCard.IsInDesignMode)
            {
                if(tItem.IsHighlighted)
                {
                    g.DrawRectangle(highlighedPen, new Rectangle(
                        CardLocation.X + tItem.X, CardLocation.Y + tItem.Y,
                        tItem.Width, tItem.Height));
                }
                else if(tItem.IsSelected)
                {
                    g.DrawRectangle(selectedPen, new Rectangle(
                        CardLocation.X + tItem.X, CardLocation.Y + tItem.Y,
                        tItem.Width, tItem.Height));
                }
            }
        }
Example #5
0
 /// <summary>
 /// Create a TextWFItem object that is a deep copy of this one
 /// </summary>
 /// <returns>TextWFItem object that is a deep copy of this one</returns>
 public TextWFItem Clone()
 {
     TextWFItem tItem = new TextWFItem();
     tItem.CopyBaseProperties(this);
     tItem.TextFontFace = this.TextFontFace;
     tItem.IsBold = this.IsBold;
     tItem.IsItalic = this.IsItalic;
     tItem.FontSize = this.FontSize;
     tItem.TextColor = this.TextColor;
     tItem.Text.Clear();
     foreach(TextPart part in this.Text)
     {
         tItem.Text.Add(part.Clone());
     }
     tItem.CheckboxBefore = this.CheckboxBefore;
     tItem.CheckboxAfter = this.CheckboxAfter;
     tItem.CheckboxLineThickness = this.CheckboxLineThickness;
     tItem.CheckBoxRelativeSize = this.CheckBoxRelativeSize;
     return tItem;
 }