Example #1
0
        public void AddResource(SourceCategory category, ISourceNode node, bool selectAfterOperation)
        {
            if (category.Resources != null)
                if (!category.Resources.Contains(node))
                    category.Resources.Add(node);

            if (categories.ContainsKey(category))
            {
                categories[category].AddResourceNode(node, selectAfterOperation);
                if(!itemsByViews.ContainsKey(node))
                itemsByViews.Add(node, categories[category]);
            }
        }
Example #2
0
        public void AddCategory(SourceCategory category, bool selectFirstItem)
        {
            GroupBarItem item = new GroupBarItem { Text = category.Type.Type };
            item.Icon = category.Icon;
            this.GroupBarItems.Add(item);
            SourceResourcesView view = new SourceResourcesView(this);

            if (first == null)
                first = view;

            view.Text = category.Comment;
            item.Client = view;
            categories.Add(category, view);
            
            category.Resources.ForEach(n => AddResource(category, n, false));

            if(selectFirstItem && category.Resources.Count>0)
                SelectItem(category.Resources.First());
        }
Example #3
0
 public void RemoveNode(SourceCategory sourceCategory, ISourceNode node)
 {
     categories[sourceCategory].RemoveNode(node);
     sourceCategory.Resources.Remove(node);
 }
Example #4
0
 public void AddResourceToCategory(SourceCategory category, ISourceNode resource, bool Global)
 {
     if (!Global)
         presentationSourceGroupBar.AddResource(category, resource, true);
     else
     {
         globalSourceGroupBar.AddResource(category, resource, true);
     }
 }
Example #5
0
 public void AddSourceCategory(SourceCategory category, bool Global)
 {
     if (!Global)
         presentationSourceGroupBar.AddCategory(category, false);
     else
         globalSourceGroupBar.AddCategory(category, false);
 }
Example #6
0
 public void RemoveSourceFromCategory(SourceCategory sourceCategory, ISourceNode node, bool Global)
 {
     if (Global)
         globalSourceGroupBar.RemoveNode(sourceCategory, node);
     else
         presentationSourceGroupBar.RemoveNode(sourceCategory, node);
 }
Example #7
0
 int FindUniqueId(SourceCategory cat, bool Global)
 {
     int id = 1;
     while (cat.Resources.Any(r => r.Mapping.ResourceInfo.Name == cat.Type.CreateNewResourceInfoNumbered(id).Name)) ++id;
     return id;
 }
Example #8
0
        SourcesController(SourcesControl AView, PresentationInfo APresentation)
        {
            _instance = this;
            _view = AView;

            resourceNodes = new Dictionary<ResourceDescriptor, ISourceNode>();
            m_presentation = APresentation = new PresentationInfo(APresentation); //избавляемся от *Ext

            Dictionary<string, IList<ResourceDescriptor>> local_rd = DesignerClient.Instance.PresentationWorker.GetLocalSources(APresentation.UniqueName);
            Dictionary<string, IList<ResourceDescriptor>> common_rd = DesignerClient.Instance.PresentationWorker.GetGlobalSources();
            
            global_categories = new Dictionary<string, SourceCategory>();
            local_categories = new Dictionary<string, SourceCategory>();

            List<String> sourceTypes = new List<string>();
            foreach (SourceType t in _config.ModuleConfiguration.SourceList)
            {
                if (!sourceTypes.Contains(t.Type))
                {
                    sourceTypes.Add(t.Type);

                    if (!(t.IsHardware))
                    {
                        SourceCategory local_cat = new SourceCategory(t, false) { Icon = Properties.Resources.soft };
                        local_categories.Add(t.Type, local_cat);
                    }

                    SourceCategory global_cat = new SourceCategory(t, true) { Icon = Properties.Resources.soft };
                    global_categories.Add(t.Type, global_cat);
                }
            }

            foreach (var rd in local_rd.Union(common_rd))
            {
                foreach (var r in rd.Value)
                {
                    if (r.ResourceInfo is INonVisibleResource)
                    {
                        nonVisibleResources.Add(r);
                    }
                }
            }


            /// Сортировка источников: сперва программные, потом аппаратные, в каждой группе -- по названию.
            foreach (var category in global_categories.Union(local_categories).OrderBy(gos => gos.Value.IsHardware ? "1" + gos.Key: "0" + gos.Key))
            {
                IEnumerable<ResourceDescriptor> e = new List<ResourceDescriptor>();
                if (local_rd.ContainsKey(category.Key))
                    e = local_rd[category.Key];
                if (common_rd.ContainsKey(category.Key))
                    e = e.Union(common_rd[category.Key]);

                foreach (ResourceDescriptor resource in e/*.OrderBy(res=>res.ResourceInfo.Name)*/)
                {
                    if (!(resource is BackgroundImageDescriptor) && !(resource is INonVisibleResource))
                    {
                        ISourceNode node = null;
                        SourceType type = null;

                        if (resource.ResourceInfo.IsHardware)
                            type = _config.ModuleConfiguration.SourceList.Where(t => t.Name == resource.ResourceInfo.Name && t.Type == resource.ResourceInfo.Type).FirstOrDefault();
                        else
                            type = category.Value.Type;

                        if (type != null)
                            node = new SourceWindow(resource) { SourceType = type };


                        if (node != null)
                        {
                            if ((category.Value.Global && !resource.IsLocal) || (!category.Value.Global && resource.IsLocal))
                            {
                                category.Value.Resources.Add(node);
                                resourceNodes.Add(resource, node);
                            }


                            if (resource.ResourceInfo != null && resource.ResourceInfo.IsHardware && type != null)
                            {
                                node.IsOnline = ShowClient.Instance.IsOnLine(type);
                            }
                        }

                    }
                    else
                    {

                        if (resource.ResourceInfo is INonVisibleResource)
                        {
                            nonVisibleResources.Add(resource);
                        }

                    }
                }

                _view.AddSourceCategory(category.Value, category.Value.Global);
            }

            _view.SelectFirstGlobalSource();
            UndoService.Instance.OnHistoryChanged += new HistoryChanged(Instance_OnHistoryChanged);
            DesignerClient.Instance.PresentationNotifier.OnResourceAdded += new EventHandler<NotifierEventArg<ResourceDescriptor>>(PresentationNotifier_OnResourceAdded);
            DesignerClient.Instance.PresentationNotifier.OnResourceDeleted += new EventHandler<NotifierEventArg<ResourceDescriptor>>(PresentationNotifier_OnResourceDeleted);
            //DesignerClient.Instance.PresentationNotifier.OnObjectChanged += new EventHandler<NotifierEventArg<IList<ObjectInfo>>>(PresentationNotifier_OnObjectChanged);
            PresentationController.Instance.OnSelectedResourceChanged += new SelectedResourceChanged(Instance_OnSelectedResourceChanged);
            PresentationController.Instance.OnPresentationChangedExternally += new PresentationDataChanged(Instance_OnPresentationChangedExternally);
            PresentationController.Instance.OnHardwareStateChanged += new Action<EquipmentType, bool?>(Instance_OnHardwareStateChanged);
            PresentationController.Instance.OnSlideSelectionChanged += new SlideSelectionChanged(Instance_OnSlideSelectionChanged);
        }