Esempio n. 1
0
        public void LoadCardLayout(String dir)
        {
            configFileDir = Path.Combine(Environment.CurrentDirectory, dir);
            if (File.Exists(configFileDir))
            {
                StreamReader reader   = new StreamReader(configFileDir);
                String       nextLine = "";
                while ((nextLine = reader.ReadLine()) != null)
                {
                    LoadingCard readCard = JsonConvert.DeserializeObject <LoadingCard>(nextLine);
                    int         zindex   = 0;
                    if (readCard.userID == "Alex" && STATICS.ALEX_ACTIVE ||
                        readCard.userID == "Ben" && STATICS.BEN_ACTIVE ||
                        readCard.userID == "Chris" && STATICS.CHRIS_ACTIVE ||
                        readCard.userID == "Danny" && STATICS.DANNY_ACTIVE)
                    {
                        News_Card myCard = new News_Card(loader.MainWindow.Controlers.CardControler, readCard.userID);
                        myCard.UUID  = readCard.cardID;
                        myCard.Owner = readCard.userID;
                        My_News news = new My_News();
                        news.Author   = readCard.author;
                        news.Title    = readCard.title;
                        news.Content  = readCard.content;
                        myCard.News   = news;
                        myCard.NewsID = readCard.newsID;
                        System.Windows.Media.Color color = System.Windows.Media.Colors.White;
                        switch (readCard.userID)
                        {
                        case "Alex":
                            color = STATICS.USER_COLOR_CODE[0];
                            break;

                        case "Ben":
                            color = STATICS.USER_COLOR_CODE[1];
                            break;

                        case "Chris":
                            color = STATICS.USER_COLOR_CODE[2];
                            break;

                        case "Danny":
                            color = STATICS.USER_COLOR_CODE[3];
                            break;
                        }
                        myCard.InitializeCard(color, new Point(readCard.position[0], readCard.position[1]), readCard.rotate, 1, zindex++);
                        Card_List.AddCard(myCard);
                        loader.MainWindow.Controlers.UserControler.ReceiveCard(readCard.userID, myCard);
                        loader.MainWindow.CardLayer.AddCard(myCard);
                        Canvas.SetZIndex(myCard, myCard.ZIndex);
                    }
                }
            }
        }
Esempio n. 2
0
        public Card CopyCard(Card card)
        {
            Card cardToBeAdd = null;

            Control.MainWindow.Dispatcher.BeginInvoke(new Action(() =>
            {
                Card cardToBeCyp = card;
                cardToBeAdd      = new Card(this);
                cardToBeAdd.InitializeCard(
                    cardToBeCyp.BackgroundColor,
                    cardToBeCyp.CurrentPosition,
                    cardToBeCyp.CurrentRotation,
                    cardToBeCyp.CurrentScale,
                    cardToBeCyp.ZIndex);
                cardToBeAdd.UUID  = cardToBeCyp.UUID + "_Copy";
                cardToBeAdd.Owner = cardToBeCyp.Owner;
                Card_List.AddCard(cardToBeAdd);
                Control.UserControler.ReceiveCard(cardToBeAdd.Owner, cardToBeAdd);
                Canvas.SetZIndex(cardToBeCyp, Card_List.CardList.Count);
                Canvas.SetZIndex(cardToBeAdd, cardToBeAdd.ZIndex);
                Control.MainWindow.CardLayer.AddCard(cardToBeAdd);
            }));
            return(cardToBeAdd);
        }