Esempio n. 1
0
 static void RestoreMemento(IViewContent viewContent, ICSharpCode.Core.Properties memento)
 {
     if (memento != null)
     {
         ((IMementoCapable)viewContent).SetMemento(memento);
     }
 }
Esempio n. 2
0
        public object BuildItem(BuildItemArgs args)
        {
            string entityName = args.Codon.Properties["entityName"];

            string addinFileName = AppDomain.CurrentDomain.BaseDirectory + "AddIns\\" + "Related.AddIn";
            AddIn  addin         = AddIn.Load(addinFileName);

            List <Codon> subItems = GetSubItems(entityName, addin, args);

            if (subItems.Count <= 0)
            {
                return(null);
            }

            ICSharpCode.Core.Properties properies = new ICSharpCode.Core.Properties();
            properies.Set <string>("id", "RelatedGroup");
            properies.Set <string>("type", "Group");
            properies.Set <string>("label", "${res:Related}");
            properies.Set <string>("OrderNumber", "98");
            properies.Set <string>("builderid", "RibbonPageGroupBuilder");
            Codon codon = new Codon(addin, "MenuItem", properies, args.Conditions.ToArray());

            args.SubItemNode.AddCodons(subItems);
            return(new MenuItemDescriptor(args.Caller, codon, args.BuildSubItems <object>(), args.Conditions));
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a new memento from the state.
 /// </summary>
 ICSharpCode.Core.Properties IMementoCapable.CreateMemento()
 {
     ICSharpCode.Core.Properties p = properties;
     p.Set("StartupProject", startupProject);
     p.Set("ActiveConfiguration", activeConfiguration);
     p.Set("ActivePlatform", activePlatform);
     return(p);
 }
        public DisplayBindingService(IPropertyService propertyService, IMessageLoop mainThread,
            Func<ErrorDocumentDisplayBinding> errorDocDisplayBindingFactory)
        {
            main_thread = mainThread;
            error_doc_display_binding_factory = errorDocDisplayBindingFactory;

            descriptors = AddInTree.BuildItems<DisplayBindingDescriptor>(DisplayBindingPath, null, true);
            display_binding_properties = propertyService.NestedProperties("DisplayBindingService");
        }
Esempio n. 5
0
 public ICSharpCode.Core.Properties CreateMemento()
 {
     ICSharpCode.Core.Properties properties = new ICSharpCode.Core.Properties();
     properties.Set("CaretOffset", textEditorControl.ActiveTextAreaControl.Caret.Offset);
     properties.Set("VisibleLine", textEditorControl.ActiveTextAreaControl.TextArea.TextView.FirstVisibleLine);
     if (textEditorControl.HighlightingExplicitlySet)
     {
         properties.Set("HighlightingLanguage", textEditorControl.Document.HighlightingStrategy.Name);
     }
     return(properties);
 }
Esempio n. 6
0
        public void SwitchedToView(IViewContent newView)
        {
            if (newView == null)
            {
                throw new ArgumentNullException("newView");
            }
            if (currentView == newView)
            {
                return;
            }
            if (currentView != null)
            {
                if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView) ||
                    currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
                {
                    // switch without Save/Load
                    currentView.SwitchFromThisWithoutSaveLoad(this, newView);
                    newView.SwitchToThisWithoutSaveLoad(this, currentView);

                    currentView = newView;
                    return;
                }
                SaveCurrentView();
            }
            try {
                inLoadOperation = true;
                ICSharpCode.Core.Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead()) {
                    IViewContent oldView = currentView;
                    bool         success = false;
                    try {
                        currentView = newView;
                        // don't reset fileData if the file is untitled, because OpenRead() wouldn't be able to read it otherwise
                        if (this.IsUntitled == false)
                        {
                            fileData = null;
                        }
                        newView.Load(this, sourceStream);
                        success = true;
                    } finally {
                        // Use finally instead of catch+rethrow so that the debugger
                        // breaks at the original crash location.
                        if (!success)
                        {
                            // stay with old view in case of exceptions
                            currentView = oldView;
                        }
                    }
                }
                RestoreMemento(newView, memento);
            } finally {
                inLoadOperation = false;
            }
        }
Esempio n. 7
0
        private List <Codon> GetSubItems(string entityName, AddIn addin, BuildItemArgs args)
        {
            List <Codon> codonList = new List <Codon>();

            if (string.IsNullOrEmpty(entityName))
            {
                return(codonList);
            }

            var allRelationshipRoles = MetadataRepository.EntityRelationshipRoles;
            var relationshipRoles    = allRelationshipRoles.Where(role => role.Entity.PhysicalName == entityName && role.NavPanelDisplayOption == 1);

            if (relationshipRoles.Any())
            {
                foreach (var relationshipRole in relationshipRoles)
                {
                    var entityRelation = relationshipRole.EntityRelationship;
                    var relatedRole    = entityRelation.EntityRelationshipRoles
                                         .FirstOrDefault(r => r != relationshipRole &&
                                                         r.RelationshipRoleType != (int)RelationshipRoleType.Relationship);
                    if (relatedRole == null)
                    {
                        continue;
                    }
                    var commandName = relatedRole.Entity.PhysicalName;
                    if (!AuthorizationManager.CheckAccess(commandName, "Read"))
                    {
                        continue;
                    }
                    ICSharpCode.Core.Properties properies = new ICSharpCode.Core.Properties();
                    properies.Set <string>("id", commandName);
                    properies.Set <string>("type", "Item");
                    properies.Set <string>("label", "${res:" + commandName + "}");
                    properies.Set <string>("imageName", commandName);
                    properies.Set <string>("overlay", "overlay_search");
                    properies.Set <string>("Parameter", commandName);
                    properies.Set <string>("groupName", "Related");
                    properies.Set <string>("class", "Katrin.Win.RelatedModule.Commands.RelatedCommand");
                    properies.Set <string>("builderid", "BarButtonItemBuilder");
                    if (relationshipRoles.Count() > 1)
                    {
                        properies.Set <string>("RibbonStyle", "Small");
                    }

                    Codon codon = new Codon(addin, "MenuItem", properies, args.Conditions.ToArray());
                    codonList.Add(codon);
                }
            }
            return(codonList);
        }
Esempio n. 8
0
 void ReloadFromDiskInternal()
 {
     fileData = null;
     if (currentView != null)
     {
         try {
             inLoadOperation = true;
             ICSharpCode.Core.Properties memento = GetMemento(currentView);
             using (Stream sourceStream = OpenRead()) {
                 currentView.Load(this, sourceStream);
             }
             IsDirty = false;
             RestoreMemento(currentView, memento);
         } finally {
             inLoadOperation = false;
         }
     }
 }
Esempio n. 9
0
        PadContentWrapper CreateContent(PadDescriptor content)
        {
            if (contentHash.ContainsKey(content.Class))
            {
                return(contentHash[content.Class]);
            }
            ICSharpCode.Core.Properties properties = (ICSharpCode.Core.Properties)PropertyService.Get("Workspace.ViewMementos", new ICSharpCode.Core.Properties());

            PadContentWrapper newContent = new PadContentWrapper(content);

            if (content.Icon != null)
            {
                newContent.Icon = IconService.GetIcon(content.Icon);
            }
            newContent.Text            = StringParser.Parse(content.Title);
            contentHash[content.Class] = newContent;
            return(newContent);
        }
Esempio n. 10
0
        private List <Codon> GetSubItems(string entityName, AddIn addin, BuildItemArgs args)
        {
            List <Codon> codonList = new List <Codon>();

            if (string.IsNullOrEmpty(entityName))
            {
                return(codonList);
            }
            List <ColumnMapping> mappingList = MetadataRepository.MappingList
                                               .Where(c => c.SourceEntityName == entityName).ToList();
            var toConverList = mappingList.Select(c => c.TargetEntityName).Distinct();

            if (toConverList.Any())
            {
                foreach (string commandName in toConverList)
                {
                    if (!AuthorizationManager.CheckAccess(commandName, "Write"))
                    {
                        continue;
                    }
                    ICSharpCode.Core.Properties properies = new ICSharpCode.Core.Properties();
                    properies.Set <string>("id", "Convert" + commandName);
                    properies.Set <string>("type", "Item");
                    properies.Set <string>("label", "${res:" + commandName + "}");
                    properies.Set <string>("imageName", commandName);
                    properies.Set <string>("Parameter", commandName);
                    properies.Set <string>("groupName", "Convert");
                    properies.Set <string>("overlay", "overlay_convert");
                    properies.Set <string>("class", "Katrin.Win.ConvertModule.Commands.CovertCommand");
                    properies.Set <string>("builderid", "BarButtonItemBuilder");
                    if (toConverList.Count() > 1)
                    {
                        properies.Set <string>("RibbonStyle", "Small");
                    }

                    Codon codon = new Codon(addin, "MenuItem", properies, args.Conditions.ToArray());
                    codonList.Add(codon);
                }
            }
            return(codonList);
        }
Esempio n. 11
0
        public object BuildItem(BuildItemArgs args)
        {
            //string entityName = args.Codon.Properties["entityName"];

            string addinFileName = AppDomain.CurrentDomain.BaseDirectory + "AddIns\\" + "TimeTracking.AddIn";
            AddIn  addin         = AddIn.Load(addinFileName);

            ICSharpCode.Core.Properties properies = new ICSharpCode.Core.Properties();
            //properies.Set<string>("id", "TimeTracking");
            properies.Set <string>("label", "${res:TimeTracking}");
            properies.Set <string>("class", "Katrin.Win.TimeTrackingModule.TimeTracking.TimeTrackingListView");
            foreach (var codonPro in args.Codon.Properties.Elements)
            {
                if (codonPro == "label")
                {
                    continue;
                }
                properies.Set <string>(codonPro, args.Codon.Properties[codonPro]);
            }
            Codon codon = new Codon(addin, "DockPanel", properies, args.Conditions.ToArray());

            return(new DockPanelDescriptor(args.Caller, codon));
        }
Esempio n. 12
0
        public void SetMemento(ICSharpCode.Core.Properties properties)
        {
            textEditorControl.ActiveTextAreaControl.Caret.Position = textEditorControl.Document.OffsetToPosition(Math.Min(textEditorControl.Document.TextLength, Math.Max(0, properties.Get("CaretOffset", textEditorControl.ActiveTextAreaControl.Caret.Offset))));

            string highlightingName = properties.Get("HighlightingLanguage", string.Empty);

            if (!string.IsNullOrEmpty(highlightingName))
            {
                if (highlightingName == textEditorControl.Document.HighlightingStrategy.Name)
                {
                    textEditorControl.HighlightingExplicitlySet = true;
                }
                else
                {
                    IHighlightingStrategy highlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(highlightingName);
                    if (highlightingStrategy != null)
                    {
                        textEditorControl.HighlightingExplicitlySet     = true;
                        textEditorControl.Document.HighlightingStrategy = highlightingStrategy;
                    }
                }
            }
            textEditorControl.ActiveTextAreaControl.TextArea.TextView.FirstVisibleLine = properties.Get("VisibleLine", 0);
        }
Esempio n. 13
0
        /// <summary>
        /// Sets the state to the given memento.
        /// </summary>
        void IMementoCapable.SetMemento(ICSharpCode.Core.Properties memento)
        {
            SetStartupProject(memento.Get("StartupProject", ""));
            string configuration = memento.Get("ActiveConfiguration", activeConfiguration);
            string platform      = memento.Get("ActivePlatform", activePlatform);

            // validate configuration and platform:
            IList <string> available = solution.GetConfigurationNames();

            if (available.Count > 0 && !available.Contains(configuration))
            {
                configuration = available[0];
            }
            available = solution.GetPlatformNames();
            if (available.Count > 0 && !available.Contains(platform))
            {
                platform = available[0];
            }

            this.ActiveConfiguration = configuration;
            this.ActivePlatform      = platform;

            this.properties = memento;
        }
Esempio n. 14
0
 public void SetMemento(ICSharpCode.Core.Properties memento)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
		public void Set(string key, Properties value)
		{
			throw new InvalidOperationException();
		}
Esempio n. 16
0
		public static Properties Load(XElement element)
		{
			Properties properties = new Properties();
			properties.LoadContents(element.Elements());
			return properties;
		}
Esempio n. 17
0
		private Properties(Properties parent)
		{
			this.parent = parent;
			this.syncRoot = parent.syncRoot;
		}
Esempio n. 18
0
 public virtual void SetMemento(ICSharpCode.Core.Properties memento)
 {
     GetOrCreateBehavior().SetMemento(memento);
 }
 static AddInOptions()
 {
     Properties = PropertyService.Get(OptionsProperty, new ICSharpCode.Core.Properties());
 }
Esempio n. 20
0
		public Properties Get(string key, Properties defaultValue)
		{
			throw new InvalidOperationException();
		}