Esempio n. 1
0
        internal void Build(IKey inChildsKey, ILogPrinter inLogger)
        {
            SWinKeyInfo[] keys = Utils.GetWinKeyInfos(inChildsKey, _window_type_descrs, inLogger);

            List <CBaseWindow> unused_windows_cache = new List <CBaseWindow>(_childs);
            List <CBaseWindow> new_childs           = new List <CBaseWindow>();

            for (int i = 0; i < keys.Length; i++)
            {
                SWinKeyInfo window_key_info = keys[i];

                CBaseWindow window = Utils.FindMostSuitableWindow(unused_windows_cache, window_key_info);
                if (window == null)
                {
                    window = new CBaseWindow(this, window_key_info.Name, window_key_info.WinType, new Rect(0, 0, 10, 10), _gui_realization, _window_type_descrs);
                }
                else
                {
                    unused_windows_cache.Remove(window);
                }

                new_childs.Add(window);

                window.CheckChanging(window_key_info, inLogger);
            }

            for (int i = 0; i < unused_windows_cache.Count; i++)
            {
                unused_windows_cache[i].Dispose();
            }

            _childs.Clear();
            _childs = new_childs;
        }
Esempio n. 2
0
 private void AddChild(CBaseWindow inNode)
 {
     if (_childs.Contains(inNode))
     {
         return;
     }
     _childs.Add(inNode);
 }
Esempio n. 3
0
        public CBaseWindow(CBaseWindow inParent, string inName, NamedId inWindowType, Rect inBaseRect, IGUIRealization inGUIRealization, CWindowTypeDescrs window_type_descrs)
        {
            Id = ++_id_counter;

            WindowType = inWindowType;

            _window_type_descrs = window_type_descrs;

            SetParent(inParent);

            _params.Add(SWindowParamDescr.Name.Id, new CStringParam(inName));
            _params.Add(SWindowParamDescr.Indent.Id, new CPVectorParam(new PVector2(inBaseRect.left, inBaseRect.top)));
            _params.Add(SWindowParamDescr.Shift.Id, new CPVectorParam(new PVector2()));
            _params.Add(SWindowParamDescr.Size.Id, new CPVectorParam(new PVector2(inBaseRect.Width, inBaseRect.Hight)));

            _gui_realization = inGUIRealization;
            _gui_realization.OnCreateWindow(this);
        }
Esempio n. 4
0
        //public static SWinKeyInfo FindMostSuitableKey(SWinKeyInfo[] inKeys, string inName, EWindowType inWindowType, ILogPrinter inLogger)
        //{
        //    int min_dist = int.MaxValue;
        //    SWinKeyInfo res_key = new SWinKeyInfo();

        //    for (int i = 0; i < inKeys.Length; i++)
        //    {
        //        SWinKeyInfo window_key_info = inKeys[i];

        //        if (inWindowType == window_key_info.WinType)
        //        {
        //            int d = LevenshteinDistance.GetDistance(window_key_info.Name, inName, 10);
        //            if (d < min_dist)
        //            {
        //                min_dist = d;
        //                res_key = window_key_info;
        //            }
        //        }
        //    }

        //    return res_key;
        //}

        public static CBaseWindow FindMostSuitableWindow(List <CBaseWindow> unused_windows_cache, SWinKeyInfo inKeyInfo)
        {
            int         priority   = int.MaxValue;
            CBaseWindow sel_window = null;

            for (int i = 0; i < unused_windows_cache.Count; i++)
            {
                CBaseWindow window = unused_windows_cache[i];

                if (window.WindowType == inKeyInfo.WinType)
                {
                    int dist = LevenshteinDistance.GetDistance(window.Name, inKeyInfo.Name);

                    if (dist < priority)
                    {
                        sel_window = window;
                        priority   = dist;
                    }
                }
            }

            return(sel_window);
        }
Esempio n. 5
0
        void SetParent(CBaseWindow inParent)
        {
            if (inParent != null)
            {
                if (Parent == inParent)
                {
                    return;
                }

                if (Parent != null)
                {
                    Parent.RemoveChild(this);
                }

                Parent = inParent;
                Parent.AddChild(this);
            }
            else if (Parent != null)
            {
                Parent.RemoveChild(this);
                Parent = null;
            }
        }
Esempio n. 6
0
 public CGUIBuilder(IParserOwner inParserOwner, IGUIRealization inGUIRealization, Rect inBaseRect)
 {
     _parser          = new CParserManager(inParserOwner);
     _gui_realization = inGUIRealization;
     _root            = new CBaseWindow(null, "MainFrame", new NamedId(uint.MaxValue, "MainFrame"), inBaseRect, _gui_realization, _window_type_descrs);
 }
Esempio n. 7
0
 private void RemoveChild(CBaseWindow inNode)
 {
     _childs.Remove(inNode);
 }