Exemple #1
0
        /// <summary>
        /// Initialize page layout.
        /// </summary>
        private void Initialize()
        {
            try
            {
                //ConvertWindowToDataTemplate();
                //this.Title += " ver " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                this.toolbarManager      = new ToolbarManager();
                this.Toolbox.DataContext = toolbarManager;
                this.Toolbox.ItemsSource = toolbarManager.Items;

                //testing only
                this.pageManager = new PageManager();
                Project       project = CreateProject();
                PageViewModel page    = new PageViewModel(project);
                pageManager.Add(page);
                this.MainGrid.DataContext = pageManager;
            }
            catch (Exception ex)
            {
                Logger.Info(typeof(MainWindow), ex);
                throw ex;
            }
        }
Exemple #2
0
        /// <summary>
        /// Open setting page.
        /// </summary>
        /// <param name="parameter"></param>
        public void Execute(object parameter)
        {
            PageViewModel viewModel = new PageViewModel("Setting");

            this.pageManager.Add(viewModel);
        }
Exemple #3
0
        /// <summary>
        /// todo: use better algorithm checking during add an existing page.
        /// </summary>
        /// <param name="item"></param>
        public void Add(PageViewModel item)
        {
            /*bool found = false;
             * foreach (PageViewModel viewModel in this.items)
             * {
             *  if (viewModel.Item == null)
             *  {
             *      viewModel.IsSelected = false;
             *      continue;
             *  }
             *
             *  if (viewModel.Item.GetType() == typeof(Project))
             *  {
             *      //todo: overwrite Contains with key checking on Guid instead of whole memory stack
             *      if ((viewModel.Item as Project).Guid.ToString()
             *          .Equals((item.Item as Project).Guid.ToString()))
             *      {
             *          found = true;
             *          viewModel.IsSelected = true;
             *          this.currentPage = viewModel;
             *      }
             *      else
             *          viewModel.IsSelected = false;
             *  }
             *  else if (viewModel.Item.GetType() == item.Item.GetType())
             *  {
             *      found = true;
             *      viewModel.IsSelected = true;
             *      this.currentPage = viewModel;
             *  }
             *  else
             *      viewModel.IsSelected = false;
             * }
             *
             * if (!found)
             * {
             *  this.items.Add(item);
             *  this.items[this.items.Count - 1].IsSelected = true;
             *  this.currentPage = item;
             * }*/



            if (item.Item is DatabaseObject)
            {
                bool found = false;
                foreach (PageViewModel viewModel in this.Items)
                {
                    if (viewModel.Item == null)
                    {
                        viewModel.IsSelected = false;
                        continue;
                    }

                    if (item.Item.GetType() == viewModel.Item.GetType())
                    {
                        found = true;
                        viewModel.IsSelected = true;
                        this.currentPage     = item;
                    }
                    else
                    {
                        viewModel.IsSelected = false;
                    }
                }

                if (!found)
                {
                    this.items.Add(item);
                    this.currentPage = this.items[this.items.Count - 1];
                    this.items[this.items.Count - 1].IsSelected = true;
                }
            }
            else if (this.items.Contains(item)) //todo: check uniqueness - this.items.Contains(item)
            //else if(item.Item.GetType() == typeof(Project))
            {
                this.currentPage = item;
                foreach (PageViewModel viewModel in this.items)
                {
                    viewModel.IsSelected = false;
                }
                int index = this.items.IndexOf(item);
                if (index > -1)
                {
                    this.items[index].IsSelected = true;
                }
            }
            else
            {
                this.items.Add(item);
                this.currentPage = item;
                this.items[this.items.Count - 1].IsSelected = true;
            }


            System.Diagnostics.Debug.WriteLine("currentPage: " + this.currentPage.ToString());
        }