/// <summary>
        /// Check Base Adaptive when load.
        /// </summary>
        private void CheckBaseNode()
        {
            if (_document == null)
            {
                return;
            }

            AdaptivVieweNode baseNode = _adaptiveModel.AdaptiveViewsList.FirstOrDefault(x => x.Name == @"Base");

            if (baseNode != null)
            {
                baseNode.IsChecked  = true;
                baseNode.IsRoot     = true;
                _curAdaptiveViewGID = baseNode.Guid;
            }
            else
            {
                //Hide adaptive box, check a initial node
                baseNode = new AdaptivVieweNode();

                _curAdaptiveViewGID = _document.AdaptiveViewSet.Base.Guid;
                //refresh base view in case delete all other views.
            }

            UpdateAdaptiveView(baseNode);
            UpdatePageView(_curAdaptiveViewGID);
            _model.SetActivePageView(_curAdaptiveViewGID);
        }
        private void LoadAdaptiveView(AdaptivVieweNode parent, IAdaptiveView curView)
        {
            //==============load current view================//

            //Set all Condition to LessOrEqual
            if (curView.Condition != AdaptiveViewCondition.LessOrEqual)
            {
                curView.Condition = AdaptiveViewCondition.LessOrEqual;
            }
            AdaptivVieweNode adaptive = new AdaptivVieweNode(curView);

            adaptive.ParentNode = parent;

            if (parent != null)
            {
                parent.Add(adaptive);
            }

            _adaptiveModel.AdaptiveViewsList.Add(adaptive);

            //==============load children views================//
            foreach (IAdaptiveView view in curView.ChildViews)
            {
                LoadAdaptiveView(adaptive, view);
            }
        }
Exemplo n.º 3
0
        private void AddViewExecute(object obj)
        {
            AdaptivVieweNode node = new AdaptivVieweNode();

            node.Name = GetAdaptiveViewName();

            //all parent node is base now.
            node.ParentNode = RootNode;
            RootNode.Add(node);

            /*
             * if (null == SelectValue)
             * {
             *  node.ParentNode = RootNode;
             *  RootNode.Add(node);
             * }
             * else
             * {
             *  node.ParentNode = SelectValue;
             *  SelectValue.Add(node);
             * }
             * */
            SelectValue = node;
            LoadInherit();

            RootNode.Fire();
            UpdateUI();
        }
Exemplo n.º 4
0
        private void SaveAdaptive2Document(AdaptivVieweNode parent)
        {
            foreach (AdaptivVieweNode node in parent.Children)
            {
                IAdaptiveView view;
                if (node.AdaptiveView == null)//add node created
                {
                    view = AdaptiveViewSet.CreateAdaptiveView(node.Name, parent.AdaptiveView);
                }
                else //edit node
                {
                    if (!node.IsEdited)//nothing changed
                    {
                        SaveAdaptive2Document(node);
                        continue;
                    }
                    view      = node.AdaptiveView;
                    view.Name = node.Name;
                    //AdaptiveViewSet.ChangeParent(view, node.ParentNode.AdaptiveView);
                }

                AdaptiveViewSet.MoveAdaptiveViewTo(view, node.IndexInParent);
                view.Width        = node.Width;
                view.Height       = node.Height;
                view.Condition    = node.Condition;
                node.AdaptiveView = view;

                SaveAdaptive2Document(node);
            }
        }
Exemplo n.º 5
0
        private void CloneViewExecute(object obj)
        {
            AdaptivVieweNode node = selectValue.Clone();

            SelectValue = node;

            RootNode.Fire();
        }
Exemplo n.º 6
0
 private void LoadAdaptiveView()
 {
     RootNode        = new AdaptivVieweNode(AdaptiveViewSet.Base);
     RootNode.IsRoot = true;
     LoadAdaptiveFromDocument(RootNode, RootNode.AdaptiveView);
     if (RootNode.Children.Count < 1)
     {
         AddViewExecute(null);
     }
 }
        /// <summary>
        /// Load adaptive views form document.
        /// </summary>
        /// <param name="obj"></param>
        private void LoadAdaptiveViewsHandler(AdaptiveLoadType type)
        {
            //If edit adaptive view in set adaptive widow, clear all undo operation.
            if (type == AdaptiveLoadType.Edit)
            {
                UndoManager.Clear();
            }
            _adaptiveModel.AdaptiveViewsList.Clear();
            if (_document != null)
            {
                if (_document.AdaptiveViewSet.Base.ChildViews.Count > 0)
                {
                    // Load adaptive view only if base has child views
                    LoadAdaptiveView(null, _document.AdaptiveViewSet.Base);

                    if (_curAdaptiveViewGID == Guid.Empty)
                    {
                        //Initial loading
                        CheckBaseNode();
                    }
                    else
                    {
                        AdaptivVieweNode checkNode = _adaptiveModel.AdaptiveViewsList.FirstOrDefault(x => x.Guid == _curAdaptiveViewGID);
                        if (checkNode == null)
                        {
                            //Current adaptive-view has be removed
                            CheckBaseNode();
                        }
                        else
                        {
                            //Keep original adaptive-view
                            checkNode.IsChecked = true;
                            _curAdaptiveViewGID = checkNode.Guid;
                            UpdateAdaptiveView(checkNode);
                        }
                    }
                }
                else
                {
                    if (_curAdaptiveViewGID == Guid.Empty)
                    {
                        //Current adaptive-view has be removed
                        CheckBaseNode();
                    }
                    else if (_curAdaptiveViewGID != _document.AdaptiveViewSet.Base.Guid)
                    {
                        //Only base adaptive view
                        CheckBaseNode();
                    }
                }
            }

            FirePropertyChanged("AdaptiveViewsList");
            FirePropertyChanged("IsAdaptiveListVisible");
        }
Exemplo n.º 8
0
        private void LoadAdaptiveFromDocument(AdaptivVieweNode parentNode, IAdaptiveView parentView)
        {
            foreach (IAdaptiveView view in parentView.ChildViews)
            {
                AdaptivVieweNode node = new AdaptivVieweNode(view);
                parentNode.Add(node);

                node.ParentNode = parentNode;
                LoadAdaptiveFromDocument(node, view);
            }
        }
Exemplo n.º 9
0
 private void LoadInheritNodes(AdaptivVieweNode beLoad, AdaptivVieweNode node)
 {
     if (beLoad != node)
     {
         InheritFromCollection.Add(node);
         foreach (var item in node.Children)
         {
             LoadInheritNodes(beLoad, item);
         }
     }
 }
        private void UpdateAdaptiveView(AdaptivVieweNode node)
        {
            if (node == null)
            {
                return;
            }

            AdaptiveWidth  = node.Width;
            AdaptiveHeight = node.Height;
            AdaptiveName   = node.Name;
        }
Exemplo n.º 11
0
        /// <summary>
        /// change selected parent
        /// </summary>
        /// <param name="parent">seleted parent</param>
        private void ChangeInherit(AdaptivVieweNode parent)
        {
            if (null == parent || parent == selectValue.ParentNode)
            {
                return;
            }

            SelectValue.ParentNode.Children.Remove(SelectValue);
            parent.Children.Add(SelectValue);
            SelectValue.ParentNode = parent;
            RootNode.Fire();
        }
Exemplo n.º 12
0
        public AdaptivVieweNode Clone()
        {
            AdaptivVieweNode node = new AdaptivVieweNode();

            node.Name        = this._name;
            node.Width       = this._width;
            node.Height      = this._height;
            node.LeftSpacing = this._leftSpacing;
            node.ParentNode  = this._parentNode;
            ParentNode.Children.Add(node);
            return(node);
        }
Exemplo n.º 13
0
        private AdaptivVieweNode GetLastNode(ObservableCollection <AdaptivVieweNode> children)
        {
            AdaptivVieweNode lastnode = children.ElementAt(children.Count - 1);

            if (lastnode.Children.Count <= 0)
            {
                return(lastnode);
            }
            else
            {
                return(GetLastNode(lastnode.Children));
            }
        }
Exemplo n.º 14
0
        private void MoveUpExecute(object obj)
        {
            var idx = selectValue.IndexInParent;

            if (idx > 0)
            {
                AdaptivVieweNode parent = selectValue.ParentNode;
                parent.Children.Remove(selectValue);
                parent.Children.Insert(--idx, selectValue);
                selectValue.IsEdited = true;
            }
            RefreshCommands();
            RootNode.Fire();
        }
Exemplo n.º 15
0
        private void MoveDownExecute(object obj)
        {
            var idx = selectValue.IndexInParent;
            AdaptivVieweNode parent = selectValue.ParentNode;

            if (idx < parent.Children.Count - 1)
            {
                parent.Children.Remove(selectValue);
                parent.Children.Insert(++idx, selectValue);
                selectValue.IsEdited = true;
            }
            RefreshCommands();
            RootNode.Fire();
        }
        /// <summary>
        /// check one adaptive view
        /// </summary>
        /// <param name="obj">the adaptive view ndoe</param>
        private void CheckAdaptiveExecute(object obj)
        {
            AdaptivVieweNode node = obj as AdaptivVieweNode;

            if (node == null)
            {
                return;
            }

            //Click the same node again
            if (node.IsChecked == false)
            {
                node.IsChecked = true;
                return;
            }

            CheckAdaptiveView(node.Guid);
            EditorCanvas.Focus();
        }
        virtual protected void CheckAdaptiveView(Guid guid)
        {
            AdaptivVieweNode node = null;

            //check the same view and uncheck others
            foreach (var item in _adaptiveModel.AdaptiveViewsList)
            {
                if (item.Guid == guid)
                {
                    node                = item;
                    item.IsChecked      = true;
                    _curAdaptiveViewGID = item.Guid;
                    _model.SetActivePageView(_curAdaptiveViewGID);
                }
                else
                {
                    item.IsChecked = false;
                }
            }

            if (node != null)
            {
                //Update Canvas and Adaptive UI
                UpdateAdaptiveView(node);
                UpdatePageView(node.Guid);

                _adaptiveModel.PageAdaptiveList.Add(this.PageGID, node);
            }

            //refresh guide when change adaptive view.
            _ListEventAggregator.GetEvent <UpdateGridGuide>().Publish(GridGuideType.Guide);


            //keep the checked adaptive vew in model, loading it when open page next time
            AdaptivVieweNode adapnode = _adaptiveModel.PageAdaptiveList.FirstOrDefault(x => x.Key == this.PageGID).Value;

            //if the view already exists, remove it first.
            if (adapnode != null)
            {
                _adaptiveModel.PageAdaptiveList.Remove(this.PageGID);
            }
        }
Exemplo n.º 18
0
 public void Add(AdaptivVieweNode node)
 {
     Children.Add(node);
 }