コード例 #1
0
 //public event NavigatedEventHandler OnNavigated;
 public PModelObjectNavigator(PBaseObject owner)
 {
     _owner = owner;
     //levels = new List<string>();
     // _positionInLevel = new List<int>();
     _path = new PNavigatorPath();
 }
コード例 #2
0
 public int IndexOf(PBaseObject obj)
 {
     if (obj != null)
         return _items.IndexOf(obj);
     else
         return -1;
 }
コード例 #3
0
 public RCollection(PBaseObject owner, string name, bool deferredLoad, IDataModel model)
 {
     _items = new List<PBaseObject>();
     Owner = owner;
     Name = name;
     _deferredLoad = deferredLoad;
     _loaded = false;
     _model = model;
 }
コード例 #4
0
        //private Dictionary<string, string> _items;
        public PTemplates(PBaseObject ownerObject)
        {
            NotFoundMarks = new PNotFoundMarks();
            //_loadFiles(Directory.GetCurrentDirectory());
            OwnerObject = ownerObject;

            // шаблонизатор пренадлежит объекту?
            //if (ownerObject != null)
            //{
            //    // подпишемся на ответ от Api
            //    ownerObject.Model.HostRersponse += new EventHandler<HostQueryEventArgs>(ProcessHostResponse);
            //}
        }
コード例 #5
0
 public bool IsChildOf(PBaseObject obj)
 {
     if (obj == null)
         return false;
     PCollection coll = this._ownerCollection;
     while (coll != null)
     {
         if (coll.Owner == obj)
             return true;
         coll = coll.Owner._ownerCollection;
     }
     return false;
 }
コード例 #6
0
        //public List<int> GetPathTo(PBaseObject toObject)
        //{
        //    List<int> path = new List<int>();
        //    if (toObject._ownerCollection == null)
        //        return null;
        //    PBaseObject obj = toObject;
        //    while (obj._ownerCollection.Owner != null)
        //    {
        //        path.Insert(0, obj._ownerCollection.IndexOf(obj));
        //        if (obj._ownerCollection.Owner == this)
        //        {
        //            return path;
        //        }
        //        obj = obj._ownerCollection.Owner;
        //    }
        //    return null;
        //}
        public PNavigatorPath GetPathTo(PBaseObject toObject)
        {
            PNavigatorPath path = new PNavigatorPath();

            if (toObject._ownerCollection == null)
                return null;

            PBaseObject obj = toObject;
            while (obj._ownerCollection.Owner != null)
            {
                path.Parts.Insert(0, new PNavigatorPartPath(obj._ownerCollection.Name, obj._ownerCollection.IndexOf(obj)));
                if (obj._ownerCollection.Owner == this)
                {
                    return path;
                }

                obj = obj._ownerCollection.Owner;
            }
            return null;
        }
コード例 #7
0
 public bool GetAttrWithObject(string name, bool findInOwners, out string val, out PBaseObject obj)
 {
     if (_attrs.TryGetValue(name.ToLower(), out val))
     {
         obj = this;
         return true;
     }
     else if (this._ownerCollection != null && findInOwners) // рекурсивно ищем во всех владельцах
     {
         obj = this._ownerCollection.Owner;
         return this._ownerCollection.Owner.GetAttr(name, true, out val);
     }
     else
     {
         obj = null;
         return false;
     }
 }
コード例 #8
0
        //public void SetObject(PBaseObject obj)
        //{
        //    this._current = obj;
        //    foreach (PModelObjectNavigatorPathLevel level in Levels)
        //    {
        //        level.Index = 0;
        //    }
        //    if (this._current == null)
        //    {
        //        this.Pointer = null;
        //    }
        //    else
        //    {
        //        _updatePointer();
        //    }
        //    //_enableControls((this._current != null));
        //}
        //private void _enableControls(bool e)
        //{
        //    foreach (PModelObjectNavigatorPathLevel lvl in Levels)
        //    {
        //        lvl.UiControl.Enabled = e;
        //    }
        //}
        //public string GetPathString()
        //{
        //    string ret = "";
        //    foreach (string lvl in _levels)
        //    {
        //        ret += ((ret != "") ? "/" : "") + lvl + "[" + lvl.ToString() + "]";
        //    }
        //    return ret;
        //}
        //private void _updatePointer()
        //{
        //    if (this._current == null)
        //        throw new Exception("Текущий объект не задан");
        //    RBaseObject o = this._current;
        //    foreach (RModelObjectNavigatorPathLevel lvl in _levels)
        //    {
        //        RCollection coll = o.GetCollection(lvl.CollectionName, false);
        //        if (coll == null)
        //        {
        //            throw new Exception("Указанная в конфигурации коллекция '" + lvl.CollectionName + "' не описана в переданном объекте");
        //        }
        //        else
        //        {
        //            int index = lvl.Index;
        //            if (index < 0)
        //            {
        //                index = coll.Count() - 1;
        //                lvl.Index = index;
        //            }
        //            o = coll.GetObject(index);
        //            if (o != null)
        //            {
        //                this.Pointer = o;
        //            }
        //            else
        //            {
        //                break;
        //            }
        //        }
        //    }
        //    OnNavigated(this, this.Pointer);
        //}
        //private void _updatePointer()
        //{
        //    if (_owner == null)
        //    {
        //        throw new Exception("Текущий объект не задан");
        //    }
        //    PBaseObject owner = _owner;
        //    for (int ii = 0; ii < _levels.Count(); ii++)
        //    {
        //        string level = _levels[ii];
        //        int position = _positionInLevel[ii];
        //        PCollection collection = owner.GetCollection(level, false);
        //        if (collection == null)
        //        {
        //            throw new Exception("Указанная в конфигурации коллекция '" + level + "' не описана в переданном объекте");
        //        }
        //        else
        //        {
        //            if (position < 0)
        //            {
        //                position = collection.Count() - 1;
        //                _positionInLevel[ii] = position;
        //            }
        //            PBaseObject obj = collection.GetObject(position);
        //            if (obj != null)
        //            {
        //                this.Pointer = obj;
        //                owner = obj;
        //            }
        //            else
        //            {
        //                break;
        //            }
        //        }
        //    }
        //}
        private void _updatePointer()
        {
            if (_owner == null)
            {
                throw new Exception("Текущий объект не задан");
            }

            PBaseObject owner = _owner;
            for (int ii = 0; ii < _path.Parts.Count(); ii++)
            {
                string level = _path.Parts[ii].Level;
                int position = _path.Parts[ii].PositionInLevel;

                PCollection collection = owner.GetCollection(level, false);
                if (collection == null)
                {
                    throw new Exception("Указанная в конфигурации коллекция '" + level + "' не описана в переданном объекте");
                }
                else
                {
                    if (position < 0)
                    {
                        position = collection.Count() - 1;
                        _path.Parts[ii].PositionInLevel = position;
                    }
                    PBaseObject obj = collection.GetObject(position);
                    if (obj != null)
                    {
                        this.Pointer = obj;
                        owner = obj;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
コード例 #9
0
 public PBaseObject NextSibling(PBaseObject obj)
 {
     int i = this._items.IndexOf(obj) + 1;
     return (i >= this._items.Count()) ? null : this._items[i];
 }
コード例 #10
0
 public PBaseObject InsertObject(PBaseObject obj)
 {
     _items.Add(obj);
     return obj;
 }
コード例 #11
0
 public PBaseObject PrevSibling(PBaseObject obj)
 {
     int i = this._items.IndexOf(obj) - 1;
     return (i < 0) ? null : this._items[i];
 }
コード例 #12
0
ファイル: PModel.cs プロジェクト: kindprojects/workstation
 // запрос
 //public void RiseHostRequest(string textRequest)
 //{
 //    HostRequest(this, new HostQueryEventArgs()
 //    {
 //        Text = textRequest
 //    });
 //}
 //// ответ
 //public void RiseHostResponse(string textResponse)
 //{
 //    HostRersponse(this, new HostQueryEventArgs()
 //    {
 //        Text = textResponse
 //    });
 //}
 public PBaseObject FindObjectById(int id, PBaseObject where)
 {
     PBaseObject ret = null;
     if (_listObjects.TryGetValue(id, out ret))
     {
         //return ret.IsChildOf(where) ? ret : null;
         return ret;
     }
     else
         return null;
 }
コード例 #13
0
ファイル: PModel.cs プロジェクト: kindprojects/workstation
        private PBaseObject LoadNewObject(int id, PCollection ownerCollection)
        {
            PBaseObject obj = new PBaseObject(id, ownerCollection, this);

            if (ownerCollection != null)
                ownerCollection.InsertObject(obj);
            Dictionary<string, string> attrs = this._db.ListAttributes(id);
            foreach (KeyValuePair<string, string> p in attrs)
            {
                obj.SetAttr(p.Key, p.Value);
            }

            List<string> listColl = this._db.ListCollections(id);

            foreach (string coll in listColl)
            {
                obj.GetCollection(coll, true);
            }

            _listObjects.Add(obj.Id, obj);
            return obj;
        }
コード例 #14
0
ファイル: PModel.cs プロジェクト: kindprojects/workstation
        public PCollection NewCollection(PBaseObject owner, string name)
        {
            PCollection col = new PCollection(owner, name, this.DeferredLoad, this);
            if (!this.DeferredLoad)
            {
                this.FillCollection(col);
            }

            return col;
        }
コード例 #15
0
ファイル: PModel.cs プロジェクト: kindprojects/workstation
        public void LoadModel()
        {
            //this.Templates.Clear();
            //Dictionary<string, string> tList = this._db.ListTemplates(this._modelCode);
            //foreach (KeyValuePair<string, string> p in tList)
            //{
            //    this.Templates.AddTemplate(p.Key, p.Value);
            //}

            this.Data = this.GetRootObject();
        }