Пример #1
0
        public void SaveNewWebpage()
        {
            var newWebPage = new WepPageModel();

            newWebPage.Address     = AddedWebPageAddress;
            newWebPage.Description = AddedWebPageDescription;

            foreach (TagModel tag in AddedWebPageTags)
            {
                newWebPage.Tags.Add(tag);
            }


            var rayCarrotDataAccess = new RayRabbitDataAccess();

            rayCarrotDataAccess.SetFileNameToGenericName <WepPageModel>();
            rayCarrotDataAccess.SetPathToSolutionPath();
            // this needs to be a seperate method to add the new web page
            //CurrentWebPages.Add(newWebPage);

            List <WepPageModel> WebPageToSaveList = new List <WepPageModel>();

            WebPageToSaveList.Add(newWebPage);
            //WebPageToSaveList = ConvertBindableCollectionToList<WepPageModel>(CurrentWebPages);
            rayCarrotDataAccess.SaveObjectsToXMLFile <List <WepPageModel>, WepPageModel>(WebPageToSaveList);
            SetTheAddedInfoBoxesToBlank();
            TextBoxVisible  = false;
            CurrentWebPages = new BindableCollection <WepPageModel>();
            var receivedRecords = rayCarrotDataAccess.GetObjectsFromXMLFile <List <WepPageModel> >();

            foreach (WepPageModel webPage in receivedRecords)
            {
                CurrentWebPages.Add(webPage);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            bool mQuitProgram          = false;
            List <WepPageModel> mPages = new List <WepPageModel>();

            while (!mQuitProgram)
            {
                Console.WriteLine("Enter Web address ('END' or 'return' to quit): ");
                string mWebAddress = Console.ReadLine();

                mQuitProgram = mWebAddress.Equals("END", StringComparison.CurrentCultureIgnoreCase);
                if (!mQuitProgram)
                {
                    mQuitProgram = mWebAddress.Equals("");
                }
                if (!mQuitProgram)
                {
                    bool mQuitEnteringTags = false;

                    WepPageModel PageModel = new WepPageModel(mWebAddress);

                    while (!mQuitEnteringTags)
                    {
                        // initialize loop variables
                        int i = 1; bool emptyTag = false;
                        // loop
                        do
                        {
                            Console.WriteLine($"Enter Tag {i}: ");
                            TagModel tag = new TagModel(Console.ReadLine());

                            emptyTag = (string.IsNullOrEmpty(tag.Tagline));

                            if (!emptyTag)
                            {
                                PageModel.Tags.Add(tag);

                                i++;
                            }
                        } while (!emptyTag);

                        mQuitEnteringTags = true;
                    }

                    mPages.Add(PageModel);
                }
            }

            Console.WriteLine("finished entering webpages");

            var rayCarrotDataAccess = new RayRabbitDataAccess();

            rayCarrotDataAccess.SetFileNameToGenericName <WepPageModel>();
            rayCarrotDataAccess.SetPathToSolutionPath();
            rayCarrotDataAccess.SaveObjectsToXMLFile <List <WepPageModel>, WepPageModel>(mPages);

            List <WepPageModel> receivedPages = rayCarrotDataAccess.GetObjectsFromXMLFile <List <WepPageModel> >();
        }
Пример #3
0
        //private string mInnerText;
        //public string InnerText
        //{
        //    get
        //    {
        //        return mInnerText;
        //    }
        //    set
        //    {
        //        mInnerText = value;
        //        NotifyOfPropertyChange(() => InnerText);
        //    }
        //}
        #endregion

        //public event PropertyChangedEventHandler PropertyChanged;

        //public void RaisePropertyChanged(string propertyName)
        //{
        //    var handler = PropertyChanged;
        //    if (handler != null)
        //    {
        //        handler(this, new PropertyChangedEventArgs(propertyName));
        //    }
        //}

        #region               Constructors
        /// <summary>
        ///                Default Constructor
        /// </summary>
        public ShellViewModel()
        {
            var rrda = new RayRabbitDataAccess();

            rrda.SetFileNameToGenericName <WepPageModel>();
            rrda.SetPathToSolutionPath();
            var receivedRecords = rrda.GetObjectsFromXMLFile <List <WepPageModel> >();

            foreach (WepPageModel webPage in receivedRecords)
            {
                CurrentWebPages.Add(webPage);
            }
            TextBoxVisible    = false;
            WebPageDGExpanded = false;
            AddedWebPageTags  = new List <TagModel>();
            //var tempWebPageTag = new TagModel();
            //tempWebPageTag.Tagline = "TagIsh linish";
            //AddedWebPageTags.Add(tempWebPageTag);
            SelectedWebPageTags = new BindableCollection <TagModel>();
        }