Exemplo n.º 1
0
        public MyUserControl1(int width, int height, CardObj CardData)
        {
            this.InitializeComponent();
            this.width = width;
            this.height = height;

            if (CardData != null)
            {
                this.LoadDataOfCard(CardData);
            }
            else
            {
                addRow();
                for (int i = 0; i < 10; ++i)
                {
                    TextBox tx = new TextBox();
                    tx.BorderThickness = new Thickness(0);
                    tx.FontSize = 16;
                    tx.FontFamily = new FontFamily("Segoe UI");
                    tx.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    tx.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    tx.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                    if (i == 0)
                    {
                        tx.Foreground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 128));
                        tx.Text = "Enter Instructions";
                        tx.GotFocus += OnEnter;
                    }
                    else
                    {
                        tx.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
                        tx.Text = "";
                    }

                    tx.Width = width;
                    tx.AllowDrop = true;
                    tx.Drop += DragEventHandler;
                    tx.DragEnter += Highlight;
                    tx.DragLeave += Unhighlight;
                    tx.KeyDown += EnterNextLine;
                    this.reversePanel.Children.Add(tx);
                }
                Button SaveButt = new Button();
                //SaveButt.BorderThickness = new Thickness(0);
                SaveButt.FontSize = 16;
                
                
                SaveButt.Visibility = Visibility.Visible;
                //SaveButt.Opacity = 5000;
                SaveButt.Foreground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 128));
                SaveButt.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                SaveButt.Width = 500;
                //SaveButt.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
                SaveButt.Content = "Save";
                SaveButt.Click += SaveButt_Click;
                this.reversePanel.Children.Add(SaveButt);
            }

        }
Exemplo n.º 2
0
        public EditCard(CardObj CardData)
        {
            tagsList = new ObservableCollection<Tag>();
            categoriesList = new ObservableCollection<string>();
            //TODO: load database from memory
            tagDatabase = new TagDatabase();

            this.InitializeComponent();

            categoriesList = tagDatabase.CategoriesCollection();

            this.TagView.DataContext = tagsList;
            this.CategoryView.DataContext = categoriesList;

            /*****NEW STUFF BINDING CARDS AND DRAG AND DROP TOGETHER****/
            MyUserControl1 control = new MyUserControl1(600, 400, CardData);
            control.Width = 600;
            control.Height = 400;
            control.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
            control.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            control.DoneBuilding += control_DoneBuilding;
            this.LeftPanel.Children.Add(control);
        }
Exemplo n.º 3
0
        public void LoadDataOfCard(CardObj CardForThisPage)
        {
            //First Read 
            //SaveAndLoad DataSaverLoader = new SaveAndLoad();
            //LocalAppData AllCardsCollection = await DataSaverLoader.LoadData();

            //CardObj CardData = AllCardsCollection.AllCardData[AllCardsCollection.CardCount - 1];

            for (int i = 0; i < CardForThisPage.IngredientList.Count; i++)
            {
                if (i == 0)
                {
                    TextBox tx = (TextBox) this.recipePanel.Children[0];
                    tx.Text = CardForThisPage.IngredientList[i].ToString();
                }
                else
                {
                    TextBox tx = new TextBox();
                    tx.BorderThickness = new Thickness(0);
                    tx.FontSize = 16;
                    tx.FontFamily = new FontFamily("Segoe UI");
                    tx.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    tx.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    tx.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                    tx.Text = CardForThisPage.IngredientList[i].ToString();
                    this.recipePanel.Children.Add(tx);
                }
               
            }


            foreach (string Instruction in CardForThisPage.InstructionList)
            {
                TextBox tx = new TextBox();
                tx.BorderThickness = new Thickness(0);
                tx.FontSize = 16;
                tx.FontFamily = new FontFamily("Segoe UI");
                tx.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                tx.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                tx.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                tx.Text = Instruction;
                this.reversePanel.Children.Add(tx);
            }

        }
Exemplo n.º 4
0
        public async void SaveDataOfCard()
        {
            SaveAndLoad DataSaverLoader = new SaveAndLoad();
            CardObj DataToBeSaved = new CardObj();
            StackPanel Tmp_SP = new StackPanel();
            TextBox Tmp_TX = new TextBox();

            //First time loop through to delete and correct empty entries
            foreach (UIElement IngredientEntry in this.recipePanel.Children)
            {
               
                if (IngredientEntry.GetType() == Tmp_SP.GetType())
                {
                    
                    StackPanel ThisEntry = (StackPanel)IngredientEntry;
                    //this entry could be empty
                    NumberSelector NS = (NumberSelector)ThisEntry.Children[0];
                    UnitSelector US = (UnitSelector)ThisEntry.Children[1];
                    TextBox TX = (TextBox)ThisEntry.Children[2];
                    //non empty entry
                    if (NS.getSelectedValue() != "" && TX.Text.ToString() != "Drag and drop ingredient here")
                    {
                        TextBox FinalEntryBox = new TextBox();
                        FinalEntryBox.Text = NS.getSelectedValue() + " " + US.getSelectedValue() + " " + TX.Text;
                        /******INSERT TAG******/
                        DataToBeSaved.TagsList.Add(TX.Text);
                        /******INSERT TAG******/
                        FinalEntryBox.Width = width;
                        ThisEntry.Children.Clear();
                        StackPanel Card = (StackPanel)ThisEntry.Parent;
                        int index = Card.Children.IndexOf(ThisEntry);
                        Card.Children.Remove(ThisEntry);
                        Card.Children.Insert(index, FinalEntryBox);
                    }
                    //empty entry
                    else
                    {
                        ThisEntry.Children.Clear();
                        StackPanel Card = (StackPanel)ThisEntry.Parent;
                        Card.Children.Remove(ThisEntry);
                    }
                        
                    
                }
                
            }


            //All entries should be textboxes now 
            disableEditing();

            for (int i = 0; i < this.recipePanel.Children.Count; i++)
            {
                TextBox ThisEntry = (TextBox)this.recipePanel.Children[i];
                DataToBeSaved.IngredientList.Add(ThisEntry.Text.ToString());
                if (i == 0) //first entry is title add to tags
                {
                    DataToBeSaved.TagsList.Add(ThisEntry.Text.ToString());
                    DataToBeSaved.CardTitle = ThisEntry.Text.ToString();
                }
            }



            for (int i = 0; i < this.reversePanel.Children.Count; i++)
            {
                TextBox ThisEntry;
                if (this.reversePanel.Children[i].GetType() == Tmp_TX.GetType())
                {
                    ThisEntry = (TextBox)this.reversePanel.Children[i];
                    DataToBeSaved.InstructionList.Add(ThisEntry.Text.ToString());

                    if (i == 0) //first entry is title add to tags
                        DataToBeSaved.TagsList.Add(ThisEntry.Text.ToString());
                }

             
            }



            LocalAppData AllCardsCollection = await DataSaverLoader.LoadData();
            int ReplaceIndex = -1;
            for (int i = 0; i < AllCardsCollection.AllCardData.Count; i++)
            {
                if (DataToBeSaved.CardTitle == AllCardsCollection.AllCardData[i].CardTitle)
                {
                    ReplaceIndex = i;
                    break;
                }
            }

            if (ReplaceIndex != -1) //Replace
            {
                AllCardsCollection.AllCardData[ReplaceIndex] = DataToBeSaved;
            }
            else
            {
                AllCardsCollection.AddCard(DataToBeSaved);
            }
            
            
            //Create File name
            //string CardFileName = "CardFile" + CurrentCardCount.ToString();


            await DataSaverLoader.SaveData(AllCardsCollection);


        }
Exemplo n.º 5
0
 public void AddCard(CardObj Card)
 {
     this.AllCardData.Add(Card);
     this.CardCount += 1;
 }