Ejemplo n.º 1
0
        public FormMain()
        {
            // инициализация компонентов
            InitializeComponent();
            listBoxOptimizations.DisplayMember = "Title";
            listBoxOptimizations.ValueMember = "Object";
            webControlDetails.Crashed += webControlDetails_Crashed;

            // инициализация внутренних переменных
            this.Text = "Распил " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            // загрузка конфигурации
            _conf = RAppConfig.Load(Path.GetDirectoryName(Application.ExecutablePath) + "\\config.json");

            // настройка навигации
            this.navMasterPath = new PNavigatorPath(_conf.MasterCollectionPath + ":0");

            // команды
            _createAppCommandsButtons(panelAppCommands, _conf.Commands.Buttons);
            enableChildControls(panelAppCommands, false);

            // подключаем хранилище данных
            this._modelStorage = new SStorageFB(_conf.ConnectionString);

            // загружать модель не будем. Это сделает событие таймера
        }
Ejemplo n.º 2
0
 public bool isInPath(PNavigatorPath refPath)
 {
     int refCnt = refPath.Parts.Count;
     if (this.Parts.Count > refCnt)
         return false;
     int cnt = this.Parts.Count;
     for (int i = 0; i < cnt; i++)
     {
         if (this.Parts[i].LevelName.ToLower() != refPath.Parts[i].LevelName.ToLower())
             return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 public int copyPositions(PNavigatorPath from, bool partial)
 {
     int cnt = Parts.Count;
     int cntFrom = from.Parts.Count;
     if (cntFrom > cnt && !partial)
         throw new Exception(@"Длина пути для копирования превышает длину пути для замены");
     for (int i = 0; i < cnt; i++)
     {
         if (i < cntFrom)
         {
             if (this.Parts[i].LevelName != from.Parts[i].LevelName)
                 throw new Exception(string.Format(@"Имена коллекций в путях не совпадают ({0}:{1}<>{2})", i, this.Parts[i].LevelName, from.Parts[i].LevelName));
             Parts[i].PositionInLevel = from.Parts[i].PositionInLevel;
         }else
             Parts[i].PositionInLevel = 0;
     }
     return cntFrom;
 }
Ejemplo n.º 4
0
 protected void genNavigation(Control owner, List<string> levels, List<string> captions)
 {
     if (levels != null)
     {
         for (int i = 0; i < levels.Count; i++)
         {
             if (!levels[i].EndsWith(":0"))
                 levels[i] += ":0";
         }
         this.navDetailPath = new PNavigatorPath(string.Join("/", levels.ToArray()));
     }
     // кнопки для навигации
     _createNavButtons(owner, captions);
 }
Ejemplo n.º 5
0
 public PNavigator(IPObject owner, PNavigatorPath path)
 {
     _base = owner;
     _path = path!=null?path:new PNavigatorPath(null);
     _pointer = NavigateFromObject(_base, _path, true);
 }
Ejemplo n.º 6
0
 protected static IPObject NavigateFromObject(IPObject baseObj, PNavigatorPath path, bool partialReturn)
 {
     IPObject o = baseObj;
     int cnt = path.Parts.Count;
     for (int ii = 0; ii < cnt; ii++)
     {
         PNavigatorPathPart level = path.Parts[ii];
         IPCollection collection = o.GetCollection(level.LevelName);
         if (collection == null)
             throw new Exception(string.Format(@"Коллекция {0} не найдена на уровне {1}", level.LevelName, ii));
         try
         {
             o = collection.GetObject(level.PositionInLevel);
         }
         catch
         {
             if (partialReturn)
                 return o; // если объект с запрашиваемым индексом не найден - вернём тот, что был найден последний раз
             else
                 throw;
         }
     }
     return o;
 }
Ejemplo n.º 7
0
        public IPObject Navigate(PNavigatorPath path)
        {
            _path.copyPositions(from:path, partial:true);

            this.Pointer = this.GetObjectAtPathLevel(_path.Parts.Count-1, partialReturn: true);
            return this.Pointer;
        }
Ejemplo n.º 8
0
        public PNavigatorPath GetPathTo(IPObject child)
        {
            IPObject o = child;
            if (child.Id == this._base.Id)
                throw new Exception(string.Format(@"Попытка получить путь от объекта до самого себя (id={0})", child.Id));

            int baseId = this._base.Id;
            PNavigatorPath retPath = new PNavigatorPath(null);
            while (o.onwerCollection != null)
            {
                IPCollection coll = o.onwerCollection;
                retPath.Parts.Insert(0, new PNavigatorPathPart(coll.CollectionName, coll.IndexOf(o)));
                o = coll.ownerObject;
                if (o != null && o.Id == baseId)
                    return retPath;
            }
            throw new Exception(string.Format(@"Объект id={0} не принадлежит объекту id={1}", child.Id, this._base.Id));
        }