/// <summary> /// Binds the CardViewControl content of this window to its data. /// </summary> internal void Bind(Card card, Action refreshMurmurs) { var window = (CardViewControl) base.Content; Caption = string.Format(CultureInfo.CurrentCulture, Resources.CardWindowCaption, card.Number, card.Name); window.Bind(card); window.RefreshMurmurs = refreshMurmurs; }
/// <summary> /// Binds the fields of the control to data. /// </summary> internal void Bind(Card card) { _thisCard = card; Bind(); }
private void LoadCardFromMingle() { _thisCard = _thisCard.Model.GetOneCard(_thisCard.Number); }
private TextBox MakeTextBox(CardProperty cardProperty, Card thisCard) { var tb = new TextBox { MinWidth = 50, Name = cardProperty.ColumnName, DataContext = cardProperty, FontWeight = _normalFontWeight }; var cardinfo = cardProperty.Value as string; if (!string.IsNullOrEmpty(cardProperty.Value as string) && cardProperty.IsCardValued) { string name = thisCard.Model.GetOneCard(Convert.ToInt32(cardProperty.Value, CultureInfo.InvariantCulture)).Name; cardinfo = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", cardProperty.Value as string, name); } tb.Text = cardinfo; tb.Tag = cardProperty; if (cardProperty.IsTransitionOnly || cardProperty.IsFormula) tb.Background = _darkThemeBackground; return tb; }
internal StackPanel InnerPanel(CardProperty cardProperty, Card thisCard, RoutedEventHandler onButtonChooseCardClick, RoutedEventHandler onPropertyTextBoxLostFocus, SelectionChangedEventHandler onPropertyComboBoxSelectionChanged, RoutedEventHandler onButtonNotSetClick) { // A StackPanel to hold the label and data controls for a single property. Each property gets one. // The enclosing WrapPanel (see XAML source) handles automatic layout on resize events. var panel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(6, 6, 0, 0), Tag = cardProperty }; var label = new Label { Content = cardProperty.Name, Background = _darkThemeBackground, FontWeight = FontWeights.ExtraBlack }; // Make labels for hidden properties italic. if (cardProperty.Hidden) label.FontStyle = FontStyles.Italic; panel.Children.Add(label); FrameworkElement uiElement; switch (cardProperty.IsManagedListOfScalars) { case false: { if (cardProperty.IsTeamValued) { uiElement = MakeComboBox(cardProperty); if (!cardProperty.IsTransitionOnly && !cardProperty.IsFormula) (uiElement as ComboBox).SelectionChanged += onPropertyComboBoxSelectionChanged; panel.Children.Add(uiElement); break; } uiElement = MakeTextBox(cardProperty, thisCard); if (!cardProperty.IsTransitionOnly && !cardProperty.IsFormula) { uiElement.LostFocus += onPropertyTextBoxLostFocus; } panel.Children.Add(uiElement); if (PropertyIsEditable(cardProperty) && cardProperty.IsCardValued) { // Add a 'click to choose' button Button a = MakeChooseCardButton(cardProperty); a.Click += onButtonChooseCardClick; a.Tag = uiElement; panel.Children.Add(a); var b = ValueNotSetButton(cardProperty, panel); b.Click += onButtonNotSetClick; panel.Children.Add(b); } break; } case true: { uiElement = MakeComboBox(cardProperty); (uiElement as ComboBox).SelectionChanged += onPropertyComboBoxSelectionChanged; panel.Children.Add(uiElement); break; } } return panel; }
/// <summary> /// Returns the card for cardNo /// </summary> /// <param name="cardNo"></param> /// <returns>Card object</returns> public Card GetOneCard(int cardNo) { string cardStr = Mingle.Get(MingleSettings.Project, string.Format(CultureInfo.InvariantCulture, "/cards/{0}.xml", cardNo)); CurrentCardNumber = cardNo; CurrentCard = new Card(new MingleCard(cardStr, Project().MingleProject), this); return CurrentCard; }
/// <summary> /// Creates a new Card /// </summary> /// <param name="type"></param> /// <param name="name">One line card name</param> /// <returns></returns> public Card CreateCard(string type, string name) { var card = new Card(Project().MingleProject.CreateCard(type, name), this); return card; }
private void ShowCardViewToolWindow(Card mingleCard) { try { var window = (CardViewWindowPane) Package.FindToolWindow(typeof (CardViewWindowPane), 0, true); if ((null == window) || (null == window.Frame)) throw new NotSupportedException(VisualStudio.Resources.CanNotCreateWindow); window.Bind(mingleCard, RefreshMurmurs); var windowFrame = (IVsWindowFrame) window.Frame; ErrorHandler.ThrowOnFailure(windowFrame.Show()); } catch (Exception ex) { TraceLog.Exception(new StackFrame().GetMethod().Name, ex); MessageBox.Show(ex.Message.Contains("404") ? string.Format(CultureInfo.CurrentCulture, "{0} {1}", VisualStudio.Resources.CardNotFound, mingleCard.Number) : ex.Message); } }