예제 #1
0
 public SourceWindow(SourceWindow src)
     : base(src)
 {
     this.EnableShading = src.EnableShading;
     CheckAspectRatio(src);
 }
예제 #2
0
        public override object Clone()
        {
            SourceWindow node = new SourceWindow(this);

            node.Image = Image;

            if (Window != null)
                node.Window = this.Window;
            else
                node.Mapping = Mapping;

            node.SourceType = SourceType;
            CreateLabel(node);

            return node;
        }
예제 #3
0
 public bool IntersectsWith(SourceWindow wnd)
 {
     PointF pos = wnd.GetPosition();
     RectangleF rect = new RectangleF(pos, wnd.Size);
     return rect.IntersectsWith(new RectangleF(this.GetUpperLeftPoint(MeasurementUnit), this.GetBoundsInfo().Size));
 }
예제 #4
0
 private void CheckAspectRatio(SourceWindow src)
 {
     if (src.Window != null && src.Window.Source != null)
     {
         IAspectLock original = (src.Window.Source as IAspectLock);
         if (original != null && original.AspectLock)
             this.EditStyle.AspectRatio = true;
         else
             this.EditStyle.AspectRatio = false;
     }
 }
예제 #5
0
 static void CreateLabel(SourceWindow wnd)
 {
     wnd.lbl = new PresentationLabel(wnd, wnd, "Name", false) { IsMultiline = true };
     wnd.lbl.ForeColor = Color.White;
     wnd.lbl.FontStyle.Style = System.Drawing.FontStyle.Bold;
     wnd.lbl.FontStyle.Family = "Arial";
     wnd.lbl.FontStyle.Size = 18;
     wnd.Labels.Add(wnd.lbl);
 }
예제 #6
0
        void LoadLayout(SlideLayout layout)
        {
            internalChanging = true;
            Model.HistoryManager.Pause();
            Model.Clear();
            View.Origin = new PointF(0, 0);
            LoadBackground(layout);
            if (layout != null && !layout.IsEmpty)
            {
                if (layout.Slide.SourceList.Count > 0)
                    PresentationController.Instance.SourceID = new Identity(layout.Slide.SourceList.Max(s => Int32.Parse(s.Id)));
                else
                    PresentationController.Instance.SourceID = new Identity(0);

                Display display = layout.Display;
                this.Model.DocumentSize = new PageSize(display.Width, MeasureUnits.Pixel, display.Height, MeasureUnits.Pixel);

                float width = ((Control)Viewer).Width;
                float height = ((Control)Viewer).Height;

                this.View.Magnification = Math.Min((width - 40f) / (float)display.Width, (height - 40f) / (float)display.Height) * 100f;

                Model.BeginUpdate();
                SourceWindow last = null;
                foreach (Window w in display.WindowList.OrderBy(wnd => wnd.ZOrder))
                {
                    SourceWindow window;

                    if (w.Source != null && w.Source.ResourceDescriptor != null)
                    {
                        window = new SourceWindow(w);
                        // Для пассивного односгемнтного дисплея нельзя изменить положение окна источника на раскладке
                        ISegmentationSupport segmentSupport = display as ISegmentationSupport;
                        bool allowResize = true;
                        if ((display is PassiveDisplay) &&
                            (segmentSupport == null || (segmentSupport.SegmentColumns == 1 && segmentSupport.SegmentRows == 1)))
                            allowResize = false;

                        window.EditStyle.AllowChangeHeight = allowResize;
                        window.EditStyle.AllowChangeWidth = allowResize;
                        window.EditStyle.AllowMoveX = allowResize;
                        window.EditStyle.AllowMoveY = allowResize;

                        Model.SetZOrder(window, w.ZOrder);
                    }
                    else
                    {
                        continue;
                    }
                    Model.AppendChild(window);
                    last = window;
                    if (last != null) ProvideReferenceFor(last);
                }
                Model.EndUpdate();
                PresentationController.Instance.SendOnSelectedResourceChanged(last);
            }

            internalChanging = false;
            Model.HistoryManager.Resume();
        }
예제 #7
0
 private void ProvideReferenceFor(SourceWindow window)
 {
     if (window.Window != null && window.Window.Source != null)
     {
         IDesignInteractionSupport support = window.Window.Source as IDesignInteractionSupport;
         if (support != null)
             support.UpdateServiceReference(this);
     }
 }
예제 #8
0
        void _resourceCRUD_OnComplete(object sender, OperationStatusEventArgs<ResourceDescriptor> e)
        {
            CloseSplash();
            FileSaveStatus status = e.Status;
            lastResourceDescr = e.Resource;
            if (status == FileSaveStatus.Exists || status == FileSaveStatus.ExistsWithSameName)
            {
                ResourceInfo resource = lastResourceDescr.ResourceInfo;
                lastResourceDescr.Created = false;

                DialogResult r = DialogResult.Yes;
                PresentationDesignerForm.ActiveForm.Invoke(new MethodInvoker(() =>
                    {
                        r = ResourceExistsDialog.Show(resource.Name);
                    }));

                if (r == DialogResult.Cancel)
                    return;

                if (r == DialogResult.Yes)
                {
                    string newName = resource.Name = "Копия " + resource.Name;
                    string name = newName;
                    int itCount = 1;
                    while (true)
                    {
                        resource.Name = newName;
                        lastResourceDescr.ResourceInfo = resource;
                        if (!FindDuplicate(lastResourceDescr)) break;
                        newName = String.Format("{0}_{1}", name, itCount);
                        itCount++;
                        if (itCount == Int32.MaxValue - 1)
                            throw new OverflowException("Слишком много имен");
                    }

                    CreateSourceAsync(lastResourceDescr);
                }
                else
                {
                    //заменить ресурс
                    // если мы заменяем ресурс, то у него может поменяться айдишник на тот - который есть на сервере
                    // это может оказаться важным
                    // если ресурс заменяем, то ему нужно присвоить айдишник существующего ресурса
                    if (!string.IsNullOrEmpty(e.OtherResourceId))
                    {
                        resource.Id = e.OtherResourceId;
                    }
                    string otherResourceId;
                    ClientResourceCRUDForSave.SaveSource(lastResourceDescr, out otherResourceId);
                }
            }

            if (status == FileSaveStatus.Ok && lastResourceDescr != null)
            {
                SourceCategory cat = (lastResourceDescr.IsLocal ? local_categories : global_categories)[lastResourceDescr.ResourceInfo.Type];
                SourceWindow node = new SourceWindow(lastResourceDescr) { SourceType = cat.Type };
                if (!resourceNodes.ContainsKey(lastResourceDescr))
                {
                    //  resourceNodes[lastResourceDescr] = node;
                    //else
                    resourceNodes.Add(lastResourceDescr, node);
                    _view.AddResourceToCategory(cat, node, !lastResourceDescr.IsLocal);
                }

                lastResourceDescr = null;
            }

            if (status == FileSaveStatus.LoadInProgress)
            {
                return;
            }

            if (status == FileSaveStatus.Abort)
            {
                MessageBoxExt.Show("Передача ресурса прервана", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #9
0
        void MakeResourceCopy(ISourceNode node, bool Local)
        {
            localResourceCopying = true;
            try
            {
                ResourceDescriptor descriptor = null;
                if (Local)
                    descriptor = DesignerClient.Instance.PresentationWorker.CopySourceFromGlobalToLocal(node.Mapping, m_presentation.UniqueName);
                else
                {
                    bool isUnique = true;
                    foreach (var resource in resourceNodes)
                    {
                        if (!resource.Key.IsLocal && ResourceInfoEquals(resource.Key.ResourceInfo, node.Mapping.ResourceInfo))
                        {
                            isUnique = false;
                            break;
                        }
                    }

                    if (isUnique)
                    {
                        //SourcesController.Instance.SavePresentationSources();
                        descriptor = DesignerClient.Instance.PresentationWorker.CopySourceFromLocalToGlobal(node.Mapping);
                    }
                }

                if (descriptor != null)
                {
                    descriptor.Created = true;
                    ResourceInfo resource = descriptor.ResourceInfo;
                    SourceWindow clone = new SourceWindow(descriptor) { SourceType = node.SourceType };
                    resourceNodes.Add(descriptor, clone);
                    _view.AddResourceToCategory(Local ? local_categories[resource.Type] : global_categories[resource.Type], clone, !Local);

                }
                else
                {
                    StringBuilder sb = new StringBuilder("Источник уже добавлен к ");

                    if (Local) sb.Append("источникам сценария"); else sb.Append("общим источникам");
                    MessageBoxExt.Show(sb.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            finally
            {
                localResourceCopying = false;
            }
        }
예제 #10
0
        void PresentationNotifier_OnResourceAdded(object sender, NotifierEventArg<ResourceDescriptor> e)
        {
            if (resourceNodes.Keys.Any(r => ResourceDescriptorEquals(e.Data, r))) return;
            if (localResourceCopying) return;

            if (!e.Data.IsLocal || (e.Data.IsLocal && e.Data.PresentationUniqueName == m_presentation.UniqueName))
            {
                ResourceDescriptor rd = e.Data;

                if (!(rd is BackgroundImageDescriptor) && !(rd is INonVisibleResource))
                {
                    SourceCategory cat = (rd.IsLocal ? local_categories : global_categories)[rd.ResourceInfo.Type];
                    ISourceNode node = new SourceWindow(rd) { SourceType = cat.Type };
                    cat.Resources.Add(node);
                    _view.AddResourceToCategory(cat, node, !rd.IsLocal);
                    resourceNodes.Add(rd, node);
                }
                else
                {
                    if (rd.ResourceInfo is INonVisibleResource)
                    {
                        nonVisibleResources.Add(rd);
                    }
                }
            }
        }
예제 #11
0
        void Instance_OnSelectedResourceChanged(SourceWindow node)
        {
            if (node != null)
            {
                //update service reference
                serviceContainer = new ServiceProvidingContainer();
                serviceContainer.Add(new ResourceProvider(this));
                foreach (var r in resourceNodes.Keys)
                {
                    serviceContainer.Add(r);
                }

                serviceContainer.Add(node.Window.Source.ResourceDescriptor);
                serviceContainer.Add(node.Window.Source);
            }
        }
예제 #12
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);
        }
예제 #13
0
 public void SendOnSelectedResourceChanged(SourceWindow selected)
 {
     if (OnSelectedResourceChanged != null)
         OnSelectedResourceChanged(selected);
 }
예제 #14
0
        //void m_SourceController_OnResourceSelected(ResourceDescriptor target)
        //{
        //    if (target != null)
        //        AssignObject(target.ResourceInfo);
        //    else
        //        AssignObject(null);
        //}

        void m_controller_OnSelectedSourceChanged(SourceWindow node)
        {
            Slide slide = null;
            if (node != null)
            {
                slide = PresentationController.Instance.CurrentSlideLayout.Slide;
                AssignObject(node.Window);
                bool enabled = DesignerClient.Instance.IsStandAlone || (slide.IsLocked && PresentationController.Instance.CanUnlockSlide(slide));
                if (enabled != propertyGrid1.IsEnabled) propertyGrid1.IsEnabled = enabled;
            }
            else
                AssignObject(null);

            //propertyGrid1.IsEnabled = DesignerClient.Instance.IsStandAlone || (slide.IsLocked && PresentationController.Instance.CanUnlockSlide(slide));
        }