예제 #1
0
 /// <summary>
 /// Helper method that calls SetPropertiesVisibility in CardTabItem to set visibility
 /// of a properties panel based on selected carditem
 /// </summary>
 private void SetPropertiesPanelVisibility(CardWFItem ci)
 {
     GetCardTabItem().SetPropertiesVisibility(ci);
 }
예제 #2
0
 /// <summary>
 /// Retrieve CardItem data
 /// </summary>
 /// <param name="cItem">CardWFItem object that the data belongs to</param>
 /// <param name="ciNode">XmlNode object containing the CardItem data</param>
 /// <param name="culture">CultureInfo object that the XQSL file was stored with</param>
 private static void GetCardItemData(CardWFItem cItem, XmlNode ciNode, CultureInfo culture)
 {
     XmlNode node = XmlProcs.GetFirstChildElement(ciNode);
     if(node.Name != "DisplayRectangle")
     {
         throw new XmlException("CardItem first child not DisplayRectangle");
     }
     node = XmlProcs.GetFirstChildElement(node);
     while(node != null)
     {
         XmlText text = XmlProcs.GetTextNode(node);
         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))
                 {
                     throw new XmlException("Bad DisplayRectangle property value in card file");
                 }
             }
             value *= WPFToWFScale;
             switch(node.Name)
             {
                 case "X":
                     cItem.X = (int)value;
                     break;
                 case "Y":
                     cItem.Y = (int)value;
                     break;
                 case "Width":
                     cItem.Width = (int)value;
                     break;
                 case "Height":
                     cItem.Height = (int)value;
                     break;
             }
         }
         else
         {
             throw new XmlException("DisplayRectangle property does not have a value");
         }
         node = XmlProcs.GetNextSiblingElement(node);
     }
 }
예제 #3
0
 /// <summary>
 /// Set visibility of properties groupboxes based on the CardItem selected in the card
 /// </summary>
 /// <param name="card">Card that contains the CardItems</param>
 public void SetPropertiesVisibility(CardWFItem ci)
 {
     HideAllPropertiesPanels();
     if(ci != null)
     {
         if(ci.GetType() == typeof(BackgroundWFImage))
         {
             backgroundImageProperties.Visibility = Visibility.Visible;
             backgroundImageProperties.DataContext = ci;
         }
         else if(ci.GetType() == typeof(SecondaryWFImage))
         {
             secondaryImageProperties.Visibility = Visibility.Visible;
             secondaryImageProperties.DataContext = ci;
         }
         else if(ci.GetType() == typeof(TextWFItem))
         {
             TextWFItem ti = (TextWFItem)ci;
             textItemProperties.Visibility = Visibility.Visible;
             textItemProperties.DataContext = ti;
             if(ti.Text.Count == 1 && ti.Text[0].GetType() == typeof(StaticText))
             {
                 Text.Visibility = Visibility.Visible;
                 StaticText sText = (StaticText)ti.Text[0];
                 Text.Text = sText.Text;
             }
             else
             {
                 Text.Visibility = Visibility.Collapsed;
             }
         }
         else if(ci.GetType() == typeof(QsosWFBox))
         {
             qsosBoxProperties.Visibility = Visibility.Visible;
             qsosBoxProperties.DataContext = ci;
         }
     }
     else
     {
         cardProperties.Visibility = Visibility.Visible;
         cardProperties.DataContext = cardPanel.QslCard;
     }
 }
예제 #4
0
        /// <summary>
        /// Saves CardImageBase properties for a BackgroundImage or a SecondaryImage
        /// </summary>
        /// <param name="cItem">BackgroundImage or SecondaryImage that the CardImageBase
        /// corresponds to</param>
        /// <param name="node">XmlNode that describes the CardImageBase</param>
        /// <param name="culture">CultureInfo object that describes the culture
        /// that the XQSL file was saved with</param>
        private static void CreateCardImageBase(CardWFItem cItem, XmlNode node,
		                                        CultureInfo culture)
        {
            XmlNode cibNode = XmlProcs.GetFirstChildElement(node);
            while(cibNode != null)
            {
                switch(cibNode.Name)
                {
                    case "ImageFileName":
                        XmlText text = XmlProcs.GetTextNode(cibNode);
                        if(text != null)
                        {
                            string myDocs = Environment.GetFolderPath(
                                Environment.SpecialFolder.MyDocuments);
                            string qslDir = myDocs + "\\QslDnP";
                            string hamQSLerFolder = ((App)Application.Current).HamqslerFolder;
                            string fileName = text.Value;
                            if(fileName.StartsWith(myDocs))
                            {
                                fileName = "$MyDocs$" + fileName.Substring(myDocs.Length);
                            }
                            // if(fileName.StartsWith(qslDir))

                            if(fileName.StartsWith("$MyDocs$\\QslDnP"))
                            {
                                fileName = "$hamqslerFolder$" +
                                    fileName.Substring("$MyDocs$\\QslDnP".Length);
                            }
                            ((ImageWFBase)cItem).ImageFileName = fileName;
                        }
                        break;
                    case "CardItem":
                        GetCardItemData(cItem, cibNode, culture);
                        break;
                }
                cibNode = XmlProcs.GetNextSiblingElement(cibNode);
            }
        }
예제 #5
0
        /// <summary>
        /// Move or resize card items based on Relative location
        /// </summary>
        /// <param name="cardItem">card item to be moved or resized</param>
        /// <param name="x">Current card relative mouse cursor X coordinate</param>
        /// <param name="y">Current card relative mouse cursor Y coordinate</param>
        private void MoveOrResizeCardItem(CardWFItem cardItem, int x, int y)
        {
            double ratio = (double)originalItemRectangle.Width /
                (double)originalItemRectangle.Height;
            int minWidth = ratio > 1.0 ? (int)(CardWFItem.MinimumSize * ratio) :
                CardWFItem.MinimumSize;
            int width;
            switch(relativeLocation)
            {
                case CardWFItem.RelativeLocations.Inside:
                    cardItem.X = originalItemRectangle.X - cursorDownLocation.X + x;
                    cardItem.Y = originalItemRectangle.Y - cursorDownLocation.Y + y;
                    break;
                case CardWFItem.RelativeLocations.NW:
                    width = originalItemRectangle.Width + cursorDownLocation.X - x;
                    cardItem.Width = (width > minWidth) ? width : minWidth;
                    cardItem.Height = (int)(cardItem.Width / ratio);
                    cardItem.X = originalItemRectangle.X + originalItemRectangle.Width -
                        cardItem.Width;
                    cardItem.Y = originalItemRectangle.Y + originalItemRectangle.Height -
                        cardItem.Height;
                    break;
                case CardWFItem.RelativeLocations.NE:
                    width = originalItemRectangle.Width - cursorDownLocation.X + x;
                    cardItem.Width = (width > minWidth) ? width : minWidth;
                    cardItem.Height = (int)(cardItem.Width / ratio);
                    cardItem.Y = originalItemRectangle.Y + originalItemRectangle.Height -
                        cardItem.Height;
                    break;
                case CardWFItem.RelativeLocations.SW:
                    width = originalItemRectangle.Width + cursorDownLocation.X - x;
                    cardItem.Width = (width > minWidth) ? width : minWidth;
                    cardItem.Height = (int)(cardItem.Width / ratio);
                    cardItem.X = originalItemRectangle.X + originalItemRectangle.Width -
                        cardItem.Width;
                    break;
                case CardWFItem.RelativeLocations.SE:
                    width = originalItemRectangle.Width - cursorDownLocation.X + x;
                    cardItem.Width = (width > minWidth) ? width : minWidth;
                    cardItem.Height = (int)(cardItem.Width / ratio);
                    break;
                case CardWFItem.RelativeLocations.E:
                    width = originalItemRectangle.Width - cursorDownLocation.X + x;
                    cardItem.Width = width > BoxMinimumWidth ? width : BoxMinimumWidth;
                    break;
                case CardWFItem.RelativeLocations.W:
                    width = originalItemRectangle.Width + cursorDownLocation.X - x;
                    cardItem.Width = width > BoxMinimumWidth ? width : BoxMinimumWidth;
                    cardItem.X = originalItemRectangle.X + originalItemRectangle.Width -
                        cardItem.Width;
                    break;

            }
            if(relativeLocation != CardWFItem.RelativeLocations.Outside)
            {
                QslCard.IsDirty = true;
            }
            this.Invalidate();
        }
예제 #6
0
 /// <summary>
 /// Get the cursor to display when an image card item is selected. The cursor
 /// that is returned is determined by the location of the mouse relative
 /// to the card item.
 /// </summary>
 /// <param name="imageItem">Image card item that is selected</param>
 /// <param name="x">Card relative X coordinate</param>
 /// <param name="y">Card relative Y coordinate</param>
 /// <returns>Cursor to display</returns>
 private Cursor GetCardItemCursor(CardWFItem cardItem, int x, int y)
 {
     Cursor cursor;
     switch(cardItem.GetRelativeLocation(x, y))
     {
         case CardWFItem.RelativeLocations.NW:
         case CardWFItem.RelativeLocations.SE:
             cursor = Cursors.SizeNWSE;
             break;
         case CardWFItem.RelativeLocations.NE:
         case CardWFItem.RelativeLocations.SW:
             cursor = Cursors.SizeNESW;
             break;
         case CardWFItem.RelativeLocations.W:
         case CardWFItem.RelativeLocations.E:
             cursor = Cursors.SizeWE;
             break;
         case CardWFItem.RelativeLocations.Inside:
             cursor = Cursors.SizeAll;
             break;
         default:
             cursor = Cursors.Arrow;
             break;
     }
     return cursor;
 }
예제 #7
0
 /// <summary>
 /// Handler for context menu's opened event
 /// </summary>
 /// <param name="sender">not used</param>
 /// <param name="e">not used</param>
 private void OnContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
 {
     highlightedCardItem = QslCard.GetHighlightedItem();
     CardWFItem selectedCardItem = QslCard.GetSelectedItem();
     // determine the IsEnabled property for each menu item
     foreach(System.Windows.Controls.Control ctrl in contextMenu.Items)
     {
         System.Windows.Controls.MenuItem mi = ctrl as System.Windows.Controls.MenuItem;
         if(mi != null)
         {
             switch(mi.Name)
             {
                 case "SelectItem":
                     mi.IsEnabled = highlightedCardItem != null;
                     break;
                 case "DeselectItem":
                     mi.IsEnabled = selectedCardItem != null;
                     break;
                 case "ClearBackgroundItem":
                     mi.IsEnabled = QslCard.BackgroundImage.ImageFileName != null &&
                         QslCard.BackgroundImage.ImageFileName != string.Empty &&
                         (selectedCardItem == null ||
                          selectedCardItem == QslCard.BackgroundImage);
                     break;
                 case "AddImage":
                     mi.IsEnabled = selectedCardItem == null;
                     break;
                 case "AddText":
                     mi.IsEnabled = selectedCardItem == null;
                     break;
                 case "AddQsosBox":
                     mi.IsEnabled = selectedCardItem == null &&
                         QslCard.QsosBox == null;
                     break;
                 case "DeleteItem":
                     mi.IsEnabled = selectedCardItem != null &&
                         selectedCardItem.GetType() !=
                         typeof(BackgroundWFImage);
                     break;
             }
         }
     }
 }
예제 #8
0
 /// <summary>
 /// Copy the CardWFItem properties from one CardWFItem to this one.
 /// </summary>
 /// <param name="cItem">CardWFItem object whose properties are to be copied</param>
 protected void CopyBaseProperties(CardWFItem cItem)
 {
     ItemSize = new System.Drawing.Size(cItem.Width, cItem.Height);
     Location = new System.Drawing.Point(cItem.X, cItem.Y);
 }