示例#1
0
        internal void ShowGlobalSourceProperties()
        {
            //Показать свойства общего источника
            using (SourcePropertiesForm sf = new SourcePropertiesForm(globalSelectedNode.Mapping, false))
            {
                object[] resourceContexts = null;

                ISupportCustomSaveState customObject = globalSelectedNode.Mapping.ResourceInfo as ISupportCustomSaveState;
                if (customObject != null)
                {
                    customObject.GetState(out resourceContexts);
                }

                if (sf.ShowDialog() == DialogResult.OK && sf.Changed())
                {
                    globalSourceGroupBar.RefreshSourceName(globalSelectedNode);
                    SourcesController.Instance.SaveSource(globalSelectedNode.Mapping);
                    SourcePropertiesControl.Instance.RefreshProperties();
                    customObject = globalSelectedNode.Mapping.ResourceInfo as ISupportCustomSaveState;
                    if (customObject != null)
                    {
                        ((ISupportCustomSaveState)customObject).SetState(resourceContexts);
                    }

                }
            }

        }
 public void ShowProperties(object p)
 {
     Source source = p as Source;
     if (source == null || source.ResourceDescriptor == null)
         return;
     SourcePropertiesForm sf = new SourcePropertiesForm(source, true, false);
     sf.ShowDialog();
 }
示例#3
0
 internal void ShowPresentationSourceProperties()
 {
     //Показать свойства источника сценария
     using (SourcePropertiesForm sf = new SourcePropertiesForm(localSelectedNode.Mapping, false))
     {
         if (sf.ShowDialog() == DialogResult.OK && sf.Changed())
         {
             presentationSourceGroupBar.RefreshSourceName(localSelectedNode);
             SourcesController.Instance.SaveSource(localSelectedNode.Mapping);
             SourcePropertiesControl.Instance.RefreshProperties();
         }
     }
 }
示例#4
0
        public void CreateSourceInstance(string categoryName, bool Global)
        {
            var categories = (!Global ? local_categories : global_categories);
            SourceCategory cat = categories[categoryName];

            int id = FindUniqueId(cat, Global);

            ResourceInfo resource = cat.Type.CreateNewResourceInfoNumbered(id);
            ResourceFileInfo fileResource = resource as ResourceFileInfo;
            ResourceDescriptor descriptor = new ResourceDescriptor(!Global, Global ? String.Empty : m_presentation.UniqueName, resource) { Created = true };

            //указать файл для файлового ресурса и он не поддерживает доп.свойств
            if (fileResource != null && !(fileResource is ISupportCustomSaveState))
            {
                string result = ResourceFileInfoEditor.ShowFileDialog(fileResource);
                if (result == null)
                {
                    return; //ресурс не создан!
                }
                else
                {
                    try
                    {
                        fileResource.SetMasterResource(result);
                    }
                    catch (Exception ex)
                    {
                        TargetInvocationException targetInvocationException = ex as TargetInvocationException;
                        InvalidResourceException invalidResourceException;
                        if (targetInvocationException != null &&
                            targetInvocationException.InnerException != null)
                        {
                            invalidResourceException = targetInvocationException.InnerException as InvalidResourceException;
                        }
                        else
                        {
                            invalidResourceException = ex as InvalidResourceException;
                        }
                        if (invalidResourceException != null)
                        {
                            MessageBoxExt.Show(invalidResourceException.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }

                        InvalidParameterException invalidParameterException;
                        if (targetInvocationException != null &&
                            targetInvocationException.InnerException != null)
                        {
                            invalidParameterException = targetInvocationException.InnerException as InvalidParameterException;
                        }
                        else
                        {
                            invalidParameterException = ex as InvalidParameterException;
                        }
                        if (invalidParameterException != null)
                        {
                            MessageBoxExt.Show(invalidParameterException.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }

                        throw;
                    }
                }
            }
            else
            {
                //открыть окно свойств для не-файлового ресурса
                using (SourcePropertiesForm sf = new SourcePropertiesForm(descriptor, true))
                {
                    if (sf.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            if (resource != null)
            {
                CreateSourceAsync(descriptor);
            }
        }