]> O.S.I.I.S - jp/crowedit.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 30 Aug 2021 05:02:05 +0000 (07:02 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 30 Aug 2021 05:02:05 +0000 (07:02 +0200)
12 files changed:
CrowEditBase/icons/startup.svg [new file with mode: 0644]
CrowEditBase/src/CrowEditBase.cs
CrowEditBase/src/CrowEditComponent.cs
CrowEditBase/src/Document.cs
CrowEditBase/src/Project.cs
CrowEditBase/src/TreeNode.cs
plugins/CECrowPlugin/src/CrowService.cs
plugins/CECrowPlugin/ui/winConfiguration.crow
plugins/CERoslynPlugin/src/MSBuildProject.cs
plugins/CERoslynPlugin/src/SolutionProject.cs
plugins/CERoslynPlugin/ui/MSBuildProjectNode.template [new file with mode: 0644]
ui/windows/winProjects.crow

diff --git a/CrowEditBase/icons/startup.svg b/CrowEditBase/icons/startup.svg
new file mode 100644 (file)
index 0000000..6605f3c
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#dddddd" d="M0 8l4.9 1.4h0.1v-0.1l7.1-5.3-1.1 1.2-6.2 6.6 0.2 3.2 2.9-3.2 2.1 4.2 6-16z"></path>
+</svg>
index e823f4054a9dc6ee981a61882486312e6505b49f..f79a532ab689a4a0c8907501513c4ec0cfebfe93 100644 (file)
@@ -96,6 +96,11 @@ namespace CrowEditBase
                        proj = FlattenProjects.FirstOrDefault (p=>p.FullPath == projectFullPath);
                        return proj != null;
                }
+               public bool TryGetContainingProject (string fullPath, out Project containingProject) {
+                       containingProject = FlattenProjects.FirstOrDefault (p => p.ContainsFile (fullPath));
+                       return containingProject != null;
+               }
+
 
                public Document CurrentDocument {
                        get => currentDocument;
@@ -257,7 +262,7 @@ namespace CrowEditBase
                protected void loadPlugins () {
                        if (string.IsNullOrEmpty (PluginsDirecory))                     
                                PluginsDirecory = Path.Combine (
-                                       Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), ".config", "CrowEdit", "Plugins");
+                                       Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), ".config", "CrowEdit", "plugins");
 
                        foreach (string pluginDir in Directory.GetDirectories (PluginsDirecory)) {
                                Plugin plugin = new Plugin (pluginDir);
index c667c73abf7659967bef73f9584a580a895684f8..9f0147a91b30b3d255082091468ed0af3e23915e 100644 (file)
@@ -28,7 +28,7 @@ namespace CrowEditBase
                public event EventHandler Unselected;   
 
                public virtual bool IsSelected {
-                       get { return isSelected; }
+                       get => isSelected;
                        set {
                                if (value == isSelected)
                                        return;
index a823a2774b4b4d694ae174fb773071161e015572..1c3646e12fccf2364779648928f9d271232baec1 100644 (file)
@@ -13,9 +13,11 @@ using static CrowEditBase.CrowEditBase;
 namespace CrowEditBase
 {
        public abstract class Document : CrowEditComponent {
+               protected Project project;
                public Document (string fullPath) {
                        initCommands ();
                        FullPath = fullPath;
+                       App.TryGetContainingProject (FullPath, out project);
                }
                public event EventHandler CloseEvent;
                public void SelectDocument () => IsSelected = true;
index 82c1e6784b12c0f4dd464967cb9152db370b3b6d..847b629d9eceefa6dffd27ce8c500be753ab2030 100644 (file)
@@ -30,6 +30,7 @@ namespace CrowEditBase
                                }
                        }
                }
+               public virtual bool ContainsFile (string fullPath) => false;
                public bool HasChildren => subProjects?.Count > 0;
 
                public string FullPath { get ; private set; }
index 8786a6ef02dafb43d5d7bf787eb7a04628a8ee08..77ab2b7dc674f7d184edcffc28b1083e87f91b73 100644 (file)
@@ -64,7 +64,19 @@ namespace CrowEditBase
                        pn.Parent = null;
                        children.Remove (pn);
                }
-
+               /*public override bool IsSelected {
+                       get => base.IsSelected;
+                       set {
+                               base.IsSelected = value;
+                               if (isSelected) {
+                                       TreeNode pn = Parent;
+                                       while (pn != null) {
+                                               pn.IsExpanded = true;
+                                               pn = pn.Parent;
+                                       }
+                               }
+                       }
+               }*/
                public virtual bool IsExpanded {
                        get { return isExpanded; }
                        set {
index 615435d85d01cc774863dd811c0e62b03abe87df..8af268725b638d74b3ace3bc2952d1effbed773e 100644 (file)
@@ -81,17 +81,6 @@ namespace Crow
                        CMDEventHistoryBackward = new Command("back.", currentEventHistoryGoBack, "#icons.previous.svg", false);
                        CMDEventHistoryForward = new Command("forw.", currentEventHistoryGoForward, "#icons.forward-arrow.svg", false);
                }
-
-               public Command CMDOptions_SelectCrowAssemblyLocation => new Command ("...",
-                       () => {
-                               FileDialog dlg = App.LoadIMLFragment<FileDialog> (@"
-                               <FileDialog Caption='Select Crow.dll assembly' CurrentDirectory='{CrowDbgAssemblyLocation}'
-                                                       ShowFiles='true' ShowHidden='true' />");
-                               dlg.OkClicked += (sender, e) => CrowDbgAssemblyLocation = (sender as FileDialog).SelectedFileFullPath;
-                               dlg.DataSource = this;
-                       }
-               );
-
                public void LoadIML (string imlSource) {
                        if (CurrentState == Status.Running)
                                delSetSource (imlSource);                       
@@ -336,15 +325,16 @@ namespace Crow
                        CurrentState = Status.Paused;
                }
                public override string ConfigurationWindowPath => "#CECrowPlugin.ui.winConfiguration.crow";
-               public Command CMDOptions_SelectCrowDbgAssemblyLocation => new Command ("...",
-                       () => {                         
+               public Command CMDOptions_SelectCrowAssemblyLocation => new Command ("...",
+                       () => {
                                FileDialog dlg = App.LoadIMLFragment<FileDialog> (@"
-                               <FileDialog Caption='Select Crow dll' CurrentDirectory='{CrowDbgAssemblyLocation}'
+                               <FileDialog Caption='Select Crow.dll assembly' CurrentDirectory='{CrowDbgAssemblyLocation}'
                                                        ShowFiles='true' ShowHidden='true' />");
                                dlg.OkClicked += (sender, e) => CrowDbgAssemblyLocation = (sender as FileDialog).SelectedFileFullPath;
                                dlg.DataSource = this;
                        }
                );
+
                protected override void onStateChange(Status previousState, Status newState)
                {
                        base.onStateChange(previousState, newState);
index c282f23697d94a9310e076dc77ebc3b5c3759bef..f2814a8015f62967020a2af9b729d777b0566a59 100644 (file)
@@ -16,7 +16,7 @@
                </HorizontalStack>
                <HorizontalStack Height="Fit">
                        <TextBox Height="Fit" Text="{²CrowDbgAssemblyLocation}" Margin="2"/>
-                       <Button Command="{CMDOptions_SelectCrowDbgAssemblyLocation}" MinimumSize="0,0"/>
+                       <Button Command="{CMDOptions_SelectCrowAssemblyLocation}" MinimumSize="0,0"/>
                </HorizontalStack>              
                <Label Background="Red" Foreground="White" Margin="5" Width="Stretched" Text="{ServiceErrorMessage}"
                        IsVisible="{ServiceIsInError}"/>
index 6c6a8d1722a9606324c679eb05ed3a40180db871..5099e89bbfb5edd4178359d447d4ed77f86c1ccc 100644 (file)
@@ -44,11 +44,15 @@ namespace CERoslynPlugin
                        Load ();
 
                        commands = new CommandGroup (CMDLoad, CMDUnload, CMDReload);
+                       if (OutputKind != OutputKind.DynamicallyLinkedLibrary)
+                               commands.Add (new Command ("Set as startup",() => solutionProject.StartupProject = this));
+                       
                        foreach (string target in defaultTargets)
                                Commands.Add (new Crow.Command (target, () => Build (target)));
                }
 
                CommandGroup commands;
+               public Command CMDSetAsStartupProject;
 
                public override CommandGroup Commands => commands;
 
@@ -149,8 +153,10 @@ namespace CERoslynPlugin
                                }       
                                return false;                   
                        }
-               } 
-
+               }
+               public bool IsStartupProject => solutionProject.StartupProject == this;
+               public override bool ContainsFile (string fullPath) =>
+                       rootNode.Flatten.OfType<ProjectItemNode> ().Any (f => f.FullPath == fullPath);
 
                void populateTreeNodes ()
                {
index a34c85d0639f235f18a2b4dd071b588487124357..ee3025e86caaffcbf339e8be504e745e9c6fb503 100644 (file)
@@ -63,7 +63,23 @@ namespace CERoslynPlugin
                }
                public override string Name => Path.GetFileNameWithoutExtension (FullPath);
                public override string Icon => "#icons.file_type_sln2.svg";
+               public Project StartupProject {
+                       get => Flatten.FirstOrDefault (p => p.FullPath == UserConfig.Get<string> ("StartupProject")); 
+                       set {
+                               if (value == StartupProject)
+                                       return;
+
+                               StartupProject?.NotifyValueChanged ("IsStartupProject", false);
 
+                               if (value == null)
+                                       UserConfig.Set ("StartupProject", "");
+                               else {
+                                       UserConfig.Set ("StartupProject", value.FullPath);
+                                       value.NotifyValueChanged("IsStartupProject", true);
+                               }
+                               NotifyValueChanged ("StartupProject", StartupProject);
+                       }
+               }
                public override void Load () {
                        projectCollection = new ProjectCollection (
                                null,
diff --git a/plugins/CERoslynPlugin/ui/MSBuildProjectNode.template b/plugins/CERoslynPlugin/ui/MSBuildProjectNode.template
new file mode 100644 (file)
index 0000000..6c70b69
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<Expandable Caption="{Caption}" IsExpanded="{²IsExpanded}" BubbleMouseEvent="None" ContextCommands="{Commands}">
+       <HorizontalStack Height="Fit">
+               <Shape Foreground="DimGrey" Background="Transparent"
+                       Path="M 5.5,0 L 5.5,11 G" Size="11,11" Width="11" Height="Stretched" KeepProportions="false" Margin="0"/>
+               <VerticalStack Height="Fit" Name="ItemsContainer"/>
+       </HorizontalStack>
+       <Template>
+               <VerticalStack>
+                       <ListItem Margin="1" IsSelected="{²IsSelected}"
+                               Selected="{Background=RoyalBlue}"
+                               Unselected="{Background=Transparent}">
+                               <HorizontalStack Spacing="5" MouseDoubleClick="./onClickForExpand">
+                                       <Image Margin="1" Width="9" Height="9" Focusable="true" MouseClick="./onClickForExpand"                                         
+                                               Path="{./Image}"
+                                               Visible="{./IsExpandable}"
+                                               SvgSub="{./IsExpanded}"
+                                               MouseEnter="{Background=LightGrey}"
+                                               MouseLeave="{Background=Transparent}"/>
+                                       <Image Style="TreeIcon"
+                                               Path="{Icon}" SvgSub="{IconSub}"/>
+                                       <Label Style="TreeLabel" Text="{./Caption}"/>
+                                       <Image Style="TreeIcon" Path="#icons.startup.svg" IsVisible="{IsStartupProject}"/>
+                               </HorizontalStack>
+                       </ListItem>
+                       <Container Name="Content" Visible="false"/>
+               </VerticalStack>                                
+       </Template>
+</Expandable>
+
index d7d65f812e2642e005860c621b70a17bcbf10d66..74209019753184d81747a2dfb55e13ce62bb6f49 100644 (file)
@@ -32,7 +32,7 @@
 
                </ItemTemplate>
 
-               <ItemTemplate DataType="CERoslynPlugin.MSBuildProject" Data="Children" Path="#CrowEditBase.ui.TreeExpandable.template" />
+               <ItemTemplate DataType="CERoslynPlugin.MSBuildProject" Data="Children" Path="#CERoslynPlugin.ui.MSBuildProjectNode.template" />
                <ItemTemplate DataType="CrowEditBase.VirtualNode" Data="Childs" Path="#CrowEditBase.ui.TreeExpandable.template" />
 
                <ItemTemplate DataType="CrowEditBase.Project" Data="SubProjects" Path="#CrowEditBase.ui.TreeExpandable.template" />