Example #1
0
 /// <summary>
 /// Create a FormsCardView to display the QslCard and position the view
 /// in the middle of the CardPanel
 /// </summary>
 /// <param name="card">CardWF object to create view of</param>
 public void AddCard(CardWF card)
 {
     QslCard = card;
     FormsCardView view = new FormsCardView(QslCard);
     view.Location = new Point(0, 0);
     view.Size = new Size(this.Width, this.Height);
     view.CardLocation = new Point((this.Width - QslCard.Width) / 2,
                               (this.Height - QslCard.Height) / 2);
     this.Controls.Add(view);
 }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="card">Card object to display on the CardTabItem</param>
 public CardTabItem(CardWF card)
 {
     InitializeComponent();
     cardPanel.AddCard(card);
     cardProperties.Visibility = Visibility.Visible;
     cardProperties.printPropsPanel.cardsLayoutGroupBox.Visibility =
         Visibility.Collapsed;
     cardProperties.QslCard = cardPanel.QslCard;
     cardPanel.QslCard.DispPropertyChanged += OnQslCardDispPropertyChanged;
     // load list of font names that are available to Windows Forms
     System.Drawing.Text.InstalledFontCollection fontCol =
         new System.Drawing.Text.InstalledFontCollection();
     foreach(System.Drawing.FontFamily family in fontCol.Families)
     {
         FontFaceComboBox.Items.Add(family.Name);
         QsosBoxFontFaceComboBox.Items.Add(family.Name);
     }
 }
Example #3
0
 /// <summary>
 /// Gets the text in this StaticText object.
 /// </summary>
 /// <returns>
 /// The text
 /// </returns>
 /// <param name="card">Qsl card that is being displayed/printed</param>
 /// <param name="qsos">Qsos to print on the card</param>
 /// <param name='screen'>
 /// not used
 /// </param>
 public override string GetText(CardWF card, List<DispQso> qsos, bool screen)
 {
     return Text;
 }
Example #4
0
 /// <summary>
 /// Make a copy of CardItem properties
 /// </summary>
 /// <param name="card">Card object this CardItem belongs to</param>
 /// <param name="cItem">CardItem whose properties are to be copied.</param>
 protected void CopyBaseProperties(CardWF card, CardItem cItem)
 {
     DisplayX = cItem.DisplayX;
     DisplayY = cItem.DisplayY;
     DisplayWidth = cItem.DisplayWidth;
     DisplayHeight = cItem.DisplayHeight;
     IsInDesignMode = cItem.IsInDesignMode;
     QslCard = card;
 }
Example #5
0
 /// <summary>
 /// Retrieve the text associated with this TextPart
 /// </summary>
 /// <param name="card">Qsl card that is being displayed/printed</param>
 /// <param name="qsos">Qsos to print on the card</param>
 /// <param name="screen">Indicates whether the text will be displayed on screen, or printed</param>
 /// <returns>the text</returns>
 public abstract string GetText(CardWF card, List<DispQso> qsos, bool screen);
Example #6
0
 /// <summary>
 /// Gets the text in this AdifExistsMacro object.
 /// </summary>
 /// <returns>
 /// The text
 /// </returns>
 /// <param name="card">Qsl card that is being displayed/printed</param>
 /// <param name="qsos">Qsos to print on the card</param>
 /// <param name='screen'>
 /// Indicates whether in design mode (true) or in print mode (false)
 /// </param>
 public override string GetText(CardWF card, List<DispQso> qsos, bool screen)
 {
     if(screen)
     {
         return DesignText.GetText(card, qsos, screen);
     }
     else if(qsos != null && qsos.Count != 0)
     {
         string val = qsos[0].Qso[AdifField.GetText(card, qsos, screen), null];
         if(val != null && val != string.Empty)
         {
             return ExistsText.GetText(card, qsos, screen);
         }
         else
         {
             return DoesntExistText.GetText(card, qsos, screen);
         }
     }
     else
     {
         return DoesntExistText.GetText(card, qsos, screen);
     }
 }
Example #7
0
 /// <summary>
 /// Convert XQSL card data to CardWF and CardWFItem data
 /// </summary>
 /// <param name="card">CardWF object to convert to</param>
 /// <param name="cardNode">XmlNode object that contains the card info</param>
 /// <param name="culture">CultureInfo that the card was saved with</param>
 private static void LoadXQSLCard(CardWF card, XmlNode cardNode, CultureInfo culture)
 {
     card.TextItems.Clear();
     card.QsosBox = null;
     XmlNode node = XmlProcs.GetFirstChildElement(cardNode);
     while(node != null)
     {
         switch(node.Name)
         {
             case "BackgroundImage":
                 CreateBackgroundImage(card, node, culture);
                 break;
             case "SecondaryImage":
                 SecondaryWFImage sImage = CreateSecondaryImage(card, node, culture);
                 if(sImage != null)
                 {
                     card.SecondaryImages.Add(sImage);
                 }
                 break;
             case "TextItem":
                 TextWFItem tItem = CreateTextItem(card, node, culture);
                 card.TextItems.Add(tItem);
                 break;
             case "QsosBox":
                 card.QsosBox = CreateQsosBox(card, node, culture);
                 break;
         }
         node = XmlProcs.GetNextSiblingElement(node);
     }
 }
Example #8
0
        /// <summary>
        /// Create a SecondaryWFImage object based on an XmlNode for it from
        /// an XQSL file
        /// </summary>
        /// <param name="card">The CardWF object that will contain the image</param>
        /// <param name="node">XmlNode containing the SecondaryImage data</param>
        /// <param name="culture">CultureInfo object that describes the culture
        /// that the XQSL file was saved with</param>
        /// <returns>The created SecondaryWFImage object or null if ImageFileName is empty string</returns>
        private static SecondaryWFImage CreateSecondaryImage(CardWF card, XmlNode node,
		                                                     CultureInfo culture)
        {
            SecondaryWFImage sImage = new SecondaryWFImage();
            sImage.QslCard = card;
            XmlNode siNode = XmlProcs.GetFirstChildElement(node);
            switch(siNode.Name)
            {
                case "CardImageBase":
                    CreateCardImageBase(sImage, siNode, culture);
                    break;
            }
            return sImage;
        }
Example #9
0
        /// <summary>
        /// Save BackgroundImage properties based on the XQSL file
        /// </summary>
        /// <param name="card">CardWF object that contains the BackgroundImage</param>
        /// <param name="node">XmlNode object that describes the BackgroundImage</param>
        /// <param name="culture">CultureInfo object that describes the culture
        /// that the XQSL file was saved with</param>
        private static void CreateBackgroundImage(CardWF card, XmlNode node,
		                                          CultureInfo culture)
        {
            XmlNode biNode = XmlProcs.GetFirstChildElement(node);
            switch(biNode.Name)
            {
                case "CardImageBase":
                    CreateCardImageBase(card.BackgroundImage, biNode, culture);
                    break;
            }
        }
Example #10
0
        /// <summary>
        /// Create a QsosWFBox 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 that contains the data for the text item</param>
        /// <param name="culture">CultureInfo object that describes the culture
        /// that the XQSL file was saved with</param>
        /// <returns></returns>
        private static QsosWFBox CreateQsosBox(CardWF card, XmlNode node,
		                                       CultureInfo culture)
        {
            QsosWFBox qBox = new QsosWFBox();
            qBox.QslCard = card;
            qBox.FontSize = 12.0F * FontScaleFactor;
            XmlNode qNode = XmlProcs.GetFirstChildElement(node);
            while(qNode != null)
            {
                XmlText text = XmlProcs.GetTextNode(qNode);
                switch(qNode.Name)
                {
                    case "QsoBoxBase":
                        qNode = XmlProcs.GetFirstChildElement(qNode);
                        break;
                    case "CardItem":
                        GetCardItemData(qBox, qNode, culture);
                        break;
                    case "ShowManager":
                        if(text != null)
                        {
                            qBox.ShowManager = text.Value=="true" ? true : false;
                        }
                        break;
                    case "ShowFrequency":
                        if(text != null)
                        {
                            qBox.ShowFrequency = text.Value=="true" ? true : false;
                        }
                        break;
                    case "ShowPseTnx":
                        if(text != null)
                        {
                            qBox.ShowPseTnx = text.Value=="true" ? true : false;
                        }
                        break;
                    case "MaximumQsos":
                        if(text != null)
                        {
                            qBox.MaximumQsos = Int32.Parse(text.Value, culture);
                        }
                        break;
                    case "DateFormat":
                        if(text != null)
                        {
                            qBox.DateFormat = text.Value;
                        }
                        break;
                    case "LineTextBrush":
                        qBox.LineTextColor = XmlProcs.ConvertXmlToColor(qNode, culture);
                        break;
                    case "CallsignBrush":
                        qBox.CallsignColor = XmlProcs.ConvertXmlToColor(qNode, culture);
                        break;
                    case "ManagerBrush":
                        qBox.ManagerColor = XmlProcs.ConvertXmlToColor(qNode, culture);
                        break;
                    case "FaceName":
                        if(text != null)
                        {
                            qBox.FontName = GetValidFont(text.Value);
                        }
                        break;
                    case "BackgroundBrush":
                        qBox.BackgroundColor = XmlProcs.ConvertXmlToColor(qNode, culture);
                        break;
                    case "BackgroundOpacity":
                        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 QsosBox property value in card file." +
                                        Environment.NewLine +
                                        "Did you modify the card file by hand?");
                                    ex.Data.Add("Property", "BackgroundOpacity");
                                    ex.Data.Add("Value", text.Value);
                                    App.Logger.Log(ex);
                                }
                            }
                            qBox.BackgroundOpacity = value;
                        }
                        break;
                    case "ConfirmingMultiText":
                        CountMacro cMacro = new CountMacro();
                        StaticText designText = new StaticText();
                        designText.Text = ((App)App.Current).UserPreferences.
                            ConfirmingText.GetText(card, null, true);
                        cMacro.DesignText.Clear();
                        cMacro.DesignText.Add(designText);
                        StaticText falseText = new StaticText();
                        string fText = text.Value;
                        if(!fText.EndsWith("  "))
                        {
                            fText += "  ";
                        }
                        falseText.Text = fText;
                        cMacro.FalseText.Clear();
                        cMacro.FalseText.Add(falseText);
                        qBox.ConfirmingText.Clear();
                        qBox.ConfirmingText.Add(cMacro);
                        break;
                    case "Confirming1Text":		// code assumes that Confirming1Text occurs
                                                // after ConfirmingMultiText in the
                                                // xqsl file. This matches the save order in
                                                // QslDesignAndPrint.
                        StaticText trueText = new StaticText();
                        string tText = text.Value;
                        if(!tText.EndsWith("  "))
                        {
                            tText += "  ";
                        }
                        trueText.Text = tText;
                        CountMacro countMacro = qBox.ConfirmingText[0] as CountMacro;
                        countMacro.TrueText.Clear();
                        countMacro.TrueText.Add(trueText);
                        break;
                    case "ViaText":
                        if(text != null)
                        {
                            qBox.ViaText = text.Value;
                        }
                        break;
                    case "YYYYMMDDText":
                        if(text != null)
                        {
                            qBox.YYYYMMDDText = text.Value;
                        }
                        break;
                    case "DDMMMYYText":
                        if(text != null)
                        {
                            qBox.DDMMMYYText = text.Value;
                        }
                        break;
                    case "DDMMYYText":
                        if(text != null)
                        {
                            qBox.DDMMYYText = text.Value;
                        }
                        break;
                    case "TimeText":
                        if(text != null)
                        {
                            qBox.TimeText = text.Value;
                        }
                        break;
                    case "ModeText":
                        if(text != null)
                        {
                            qBox.ModeText = text.Value;
                        }
                        break;
                    case "BandText":
                        if(text != null)
                        {
                            qBox.BandText = text.Value;
                        }
                        break;
                    case "FrequencyText":
                        if(text != null)
                        {
                            qBox.FreqText = text.Value;
                        }
                        break;
                    case "RSTText":
                        if(text != null)
                        {
                            qBox.RSTText = text.Value;
                        }
                        break;
                    case "QSLText":
                        if(text != null)
                        {
                            qBox.QSLText = text.Value;
                        }
                        break;
                    case "PseText":
                        if(text != null)
                        {
                            qBox.PseText = text.Value;
                        }
                        break;
                    case "TnxText":
                        if(text != null)
                        {
                            qBox.TnxText = text.Value;
                        }
                        break;
                }
                qNode = XmlProcs.GetNextSiblingElement(qNode);
            }
            return qBox;
        }
Example #11
0
        /// <summary>
        /// Create a CardWF object based on an XQSL file
        /// </summary>
        /// <param name="file">name of the XQSL file</param>
        /// <returns>CardWF object created</returns>
        private static CardWF ConvertFromXQSL(string file)
        {
            CardWF card = null;
            XmlDocument doc = new XmlDocument();
            try
            {
                Stream fStream = new FileStream(file, FileMode.Open);
                doc.Load(fStream);
                XmlNode node = doc.DocumentElement;
                switch(node.Name)
                {
                    case "LandscapeCard55x425":
                        card = new CardWF(550, 425, false);
                        break;
                    case "LandscapeCard6x4":	// note fallthrough
                    case "LandscapeCard15x10":
                        card = new CardWF(600, 400, false);
                        break;
                    case "LandscapeCard55x35":
                    case "LandscapeCard":
                        card = new CardWF(550, 350, false);
                        break;
                    default:
                        throw new XmlException("Invalid card file");
                }
                CultureInfo cardCulture = CultureInfo.InvariantCulture;
                XmlAttributeCollection attrCollection = node.Attributes;
                XmlAttribute culture = attrCollection["Culture"];
                if(culture != null)
                {
                    cardCulture = new CultureInfo(culture.Value, false);
                }
                XmlNode cNode = XmlProcs.GetFirstChildElement(node);
                if(cNode != null && cNode.Name.Equals("Card"))
                {
                    LoadXQSLCard(card, cNode, cardCulture);
                }
                else
                {
                    throw new XmlException("Invalid card file - Node is not a Card node");
                }
                fStream.Close();
                return card;
            }
            catch(IOException ioe)
            {
                Exception ex = new Exception("IO error occurred loading file: " + file, ioe);
                App.Logger.Log(ex, true, false);
                string err = string.Format("IO error encountered while trying to convert file {0}." +
                                           Environment.NewLine +
                                           "See the log file for more information.", file);

                MessageBox.Show(err, "IO Error During Conversion", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return null;
            }
            catch(XmlException xe)
            {
                Exception ex = new Exception("XML error occurred while reading file: " + file, xe);
                App.Logger.Log(ex, true, false);
                string err = string.Format("XML error encountered while trying to convert file {0}." +
                                           Environment.NewLine +
                                           "See the log file for more information.", file);

                MessageBox.Show(err, "XML Error During Conversion", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return null;
            }
        }
Example #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="card">QslCard to display</param>
 public FormsCardView(CardWF card)
 {
     this.DoubleBuffered = true;
     QslCard = card;
     QslCard.DispPropertyChanged += OnDispPropertyChanged;
     BuildContextMenu();
 }
Example #13
0
 /// <summary>
 /// Gets the text in this CountMacro object.
 /// </summary>
 /// <returns>
 /// The text
 /// </returns>
 /// <param name="card">Qsl card that is being displayed/printed</param>
 /// <param name="qsos">Qsos to print on the card</param>
 /// <param name='screen'>
 /// Indicates whether in design mode (true) or in print mode (false)
 /// </param>
 public override string GetText(CardWF card, List<DispQso> qsos, bool screen)
 {
     if(screen)
     {
         return DesignText.GetText(card, qsos, screen);
     }
     else if(card != null && card.QsosBox != null)
     {
         int qCount = card.QsosBox.MaximumQsos;
         if(qsos != null && qsos.Count != 0)
         {
             qCount = qsos.Count;
         }
         bool match = false;
         if(CountEquals)
         {
             if(qCount == Count)
             {
                 match = true;
             }
         }
         else if(CountLessThan)
         {
             if(qCount < Count)
             {
                 match = true;
             }
         }
         else if(CountGreaterThan)
         {
             if(qCount > Count)
             {
                 match = true;
             }
         }
         return match ? TrueText.GetText(card, qsos, screen) :
             FalseText.GetText(card, qsos, screen);
     }
     else
     {
         return string.Empty;
     }
 }
Example #14
0
        /// <summary>
        /// Create a new CardWF object that is a hardcopy of this card
        /// </summary>
        /// <returns>CardWF object that is a hardcopy of this CardWF object</returns>
        public CardWF Clone()
        {
            CardWF card = new CardWF();
            card.CopyBaseProperties(this);
            card.QslCard = card;
            card.BackgroundImage = BackgroundImage.Clone();
            card.backgroundImage.QslCard = card;
            foreach(SecondaryWFImage sImage in SecondaryImages)
            {
                SecondaryWFImage si = sImage.Clone();
                si.QslCard = card;
                card.SecondaryImages.Add(si);

            }
            foreach(TextWFItem tItem in TextItems)
            {
                TextWFItem ti = tItem.Clone();
                ti.QslCard = card;
                card.TextItems.Add(ti);
            }
            card.QsosBox = null;
            if(this.QsosBox != null)
            {
                QsosWFBox box = QsosBox.Clone();
                box.QslCard = card;
                card.QsosBox = box;
            }
            card.CardPrintProperties = new PrintProperties(this.CardPrintProperties);
            return card;
        }
Example #15
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 #16
0
 /// <summary>
 /// Gets the text in this ManagerMacro object.
 /// </summary>
 /// <returns>
 /// The text
 /// </returns>
 /// <param name="card">Qsl card that is being displayed/printed</param>
 /// <param name="qsos">Qsos to print on the card</param>
 /// <param name='screen'>
 /// Indicates whether in design mode (true) or in print mode (false)
 /// </param>
 public override string GetText(CardWF card, List<DispQso> qsos, bool screen)
 {
     if(screen)
     {
         return DesignText.GetText(card, qsos, screen);
     }
     else if(qsos != null && qsos.Count != 0)
     {
         string manager = qsos[0].Manager;
         if(Call.IsValid(manager))
         {
             return manager;
         }
         else
         {
             return NoManagerText.GetText(card, qsos, screen);
         }
     }
     else
     {
         return NoManagerText.GetText(card, qsos, screen);
     }
 }
Example #17
0
 /// <summary>
 /// Gets the text in this AdifMacro object.
 /// </summary>
 /// <returns>
 /// The text
 /// </returns>
 /// <param name="card">Qsl card that is being displayed/printed</param>
 /// <param name="qsos">Qsos to print on the card</param>
 /// <param name='screen'>
 /// Indicates whether in design mode (true) or in print mode (false)
 /// </param>
 public override string GetText(CardWF card, List<DispQso> qsos, bool screen)
 {
     if(screen)
     {
         // return design text
         return DesignText.GetText(card, qsos, screen);
     }
     else if(qsos != null && qsos.Count != 0)
     {
         // return retrieved ADIF field from first QSO
         // or noFieldText if ADIF field not present
         return qsos[0].Qso[AdifField.GetText(card, qsos, screen),
                            NoFieldText.GetText(card, qsos, screen)];
     }
     else
     {
         // no QSOs, so there can be no field
         return NoFieldText.GetText(card, qsos, screen);
     }
 }