Added Directory.Build.targets, this seems to help to import the target correctly. Removed chocolatey package again, as this seems to be the more stable approach (let's see if the build runs...)

This commit is contained in:
Robin Krom 2021-01-28 09:12:55 +01:00
parent 5f242a79c8
commit 6831505ead
24 changed files with 175 additions and 186 deletions

View file

@ -18,6 +18,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources> <EmbedUntrackedSources>true</EmbedUntrackedSources>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Deterministic>true</Deterministic>
</PropertyGroup> </PropertyGroup>
<!-- ILLinker and single file settings --> <!-- ILLinker and single file settings -->
@ -102,25 +103,10 @@
</Tokens> </Tokens>
</ItemGroup> </ItemGroup>
<!-- Acticate MSBuild.Community.Tasks to use the TemplateFile Task--> <!-- Add MSBuild.Community.Tasks to use the TemplateFile Task-->
<ItemGroup Condition="$(MSBuildProjectName.Contains('Plugin'))"> <ItemGroup Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
<PackageReference Include="MSBuildTasks" Version="1.5.0.235" GeneratePathProperty="true" DevelopmentDependency="true" /> <PackageReference Include="MSBuildTasks" Version="1.5.0.235" GeneratePathProperty="true" DevelopmentDependency="true" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="Exists('$(PkgTools_MSBuildTasks)MSBuild.Community.Tasks.Targets')">
<MSBuildTasksPath>$(PkgTools_MSBuildTasks)</MSBuildTasksPath>
</PropertyGroup>
<PropertyGroup Condition="Exists('$(userprofile)\.nuget\packages\msbuildtasks\1.5.0.235\tools\MSBuild.Community.Tasks.Targets')">
<MSBuildTasksPath>$(userprofile)\.nuget\packages\msbuildtasks\1.5.0.235\tools\</MSBuildTasksPath>
</PropertyGroup>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets')">
<MSBuildTasksPath>$(MSBuildExtensionsPath)\MSBuildCommunityTasks\</MSBuildTasksPath>
</PropertyGroup>
<Import Project="$(MSBuildTasksPath)MSBuild.Community.Tasks.Targets" Condition="$(MSBuildProjectName.Contains('Plugin'))"/>
<Target Name="ProcessTemplates" BeforeTargets="PrepareForBuild" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
<Message Text="Processing: $(ProjectDir)$(ProjectName).Credentials.template" Importance="high"/>
<TemplateFile Template="$(ProjectDir)$(ProjectName).Credentials.template" OutputFilename="$(ProjectDir)$(ProjectName).Credentials.cs" Tokens="@(Tokens)" />
</Target>
<Target Name="PostBuild" BeforeTargets="PostBuildEvent" Condition="$(MSBuildProjectName.Contains('Plugin')) And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))"> <Target Name="PostBuild" BeforeTargets="PostBuildEvent" Condition="$(MSBuildProjectName.Contains('Plugin')) And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
<Exec Command=" <Exec Command="

9
Directory.Build.targets Normal file
View file

@ -0,0 +1,9 @@
<Project>
<Import Project="$(PkgMSBuildTasks)\tools\MSBuild.Community.Tasks.Targets" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')"/>
<Target Name="ProcessTemplates" BeforeTargets="PrepareForBuild" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
<Message Text="Processing: $(ProjectDir)$(ProjectName).Credentials.template" Importance="high"/>
<TemplateFile Template="$(ProjectDir)$(ProjectName).Credentials.template" OutputFilename="$(ProjectDir)$(ProjectName).Credentials.cs" Tokens="@(Tokens)" />
</Target>
</Project>

View file

@ -18,15 +18,15 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotConfluencePlugin;
using GreenshotConfluencePlugin.confluence; using GreenshotConfluencePlugin.confluence;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile; using GreenshotPlugin.IniFile;
namespace Confluence { namespace GreenshotConfluencePlugin {
public class Page { public class Page {
public Page(RemotePage page) { public Page(RemotePage page) {
Id = page.id; Id = page.id;

View file

@ -25,7 +25,6 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using Confluence;
using GreenshotPlugin.Controls; using GreenshotPlugin.Controls;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile; using GreenshotPlugin.IniFile;
@ -129,7 +128,7 @@ namespace GreenshotConfluencePlugin {
bool openPage = (_page == null) && ConfluenceConfig.OpenPageAfterUpload; bool openPage = (_page == null) && ConfluenceConfig.OpenPageAfterUpload;
string filename = FilenameHelper.GetFilenameWithoutExtensionFromPattern(CoreConfig.OutputFileFilenamePattern, captureDetails); string filename = FilenameHelper.GetFilenameWithoutExtensionFromPattern(CoreConfig.OutputFileFilenamePattern, captureDetails);
if (selectedPage == null) { if (selectedPage == null) {
ConfluenceUpload confluenceUpload = new ConfluenceUpload(filename); Forms.ConfluenceUpload confluenceUpload = new Forms.ConfluenceUpload(filename);
bool? dialogResult = confluenceUpload.ShowDialog(); bool? dialogResult = confluenceUpload.ShowDialog();
if (dialogResult.HasValue && dialogResult.Value) { if (dialogResult.HasValue && dialogResult.Value) {
selectedPage = confluenceUpload.SelectedPage; selectedPage = confluenceUpload.SelectedPage;

View file

@ -19,14 +19,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using Confluence;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using System; using System;
using System.Windows; using System.Windows;
using GreenshotConfluencePlugin.Forms;
using GreenshotConfluencePlugin.Support;
using GreenshotPlugin.IniFile; using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Plugin; using GreenshotPlugin.Interfaces.Plugin;
using TranslationByMarkupExtension;
namespace GreenshotConfluencePlugin { namespace GreenshotConfluencePlugin {
/// <summary> /// <summary>

View file

@ -33,8 +33,8 @@ namespace GreenshotConfluencePlugin {
public class ConfluenceUtils { public class ConfluenceUtils {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceUtils)); private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceUtils));
public static List<Confluence.Page> GetCurrentPages() { public static List<Page> GetCurrentPages() {
List<Confluence.Page> pages = new List<Confluence.Page>(); List<Page> pages = new List<Page>();
Regex pageIdRegex = new Regex(@"pageId=(\d+)"); Regex pageIdRegex = new Regex(@"pageId=(\d+)");
Regex spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)"); Regex spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
foreach(string browserurl in GetBrowserUrls()) { foreach(string browserurl in GetBrowserUrls()) {
@ -50,7 +50,7 @@ namespace GreenshotConfluencePlugin {
long pageId = long.Parse(pageIdMatch[0].Groups[1].Value); long pageId = long.Parse(pageIdMatch[0].Groups[1].Value);
try { try {
bool pageDouble = false; bool pageDouble = false;
foreach(Confluence.Page page in pages) { foreach(Page page in pages) {
if (page.Id == pageId) { if (page.Id == pageId) {
pageDouble = true; pageDouble = true;
LOG.DebugFormat("Skipping double page with ID {0}", pageId); LOG.DebugFormat("Skipping double page with ID {0}", pageId);
@ -58,7 +58,7 @@ namespace GreenshotConfluencePlugin {
} }
} }
if (!pageDouble) { if (!pageDouble) {
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.GetPage(pageId); Page page = ConfluencePlugin.ConfluenceConnector.GetPage(pageId);
LOG.DebugFormat("Adding page {0}", page.Title); LOG.DebugFormat("Adding page {0}", page.Title);
pages.Add(page); pages.Add(page);
} }
@ -82,7 +82,7 @@ namespace GreenshotConfluencePlugin {
} }
try { try {
bool pageDouble = false; bool pageDouble = false;
foreach(Confluence.Page page in pages) { foreach(Page page in pages) {
if (page.Title.Equals(title)) { if (page.Title.Equals(title)) {
LOG.DebugFormat("Skipping double page with title {0}", title); LOG.DebugFormat("Skipping double page with title {0}", title);
pageDouble = true; pageDouble = true;
@ -90,7 +90,7 @@ namespace GreenshotConfluencePlugin {
} }
} }
if (!pageDouble) { if (!pageDouble) {
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.GetPage(space, title); Page page = ConfluencePlugin.ConfluenceConnector.GetPage(space, title);
LOG.DebugFormat("Adding page {0}", page.Title); LOG.DebugFormat("Adding page {0}", page.Title);
pages.Add(page); pages.Add(page);

View file

@ -1,33 +1,33 @@
<Window x:Class="GreenshotConfluencePlugin.ConfluenceConfigurationForm" <Window x:Class="GreenshotConfluencePlugin.Forms.ConfluenceConfigurationForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gscp="clr-namespace:GreenshotConfluencePlugin" xmlns:gscp="clr-namespace:GreenshotConfluencePlugin"
xmlns:l="clr-namespace:TranslationByMarkupExtension" xmlns:gsc="clr-namespace:GreenshotPlugin.Core;assembly=GreenshotPlugin"
xmlns:gsc="clr-namespace:GreenshotPlugin.Core;assembly=GreenshotPlugin" xmlns:support="clr-namespace:GreenshotConfluencePlugin.Support"
Title="{l:Translate plugin_settings}" SizeToContent="WidthAndHeight" ResizeMode="NoResize" Icon="/GreenshotConfluencePlugin;component/Images/Confluence.ico"> Title="{support:Translate plugin_settings}" SizeToContent="WidthAndHeight" ResizeMode="NoResize" Icon="/GreenshotConfluencePlugin;component/Images/Confluence.ico">
<Window.Resources> <Window.Resources>
<gscp:EnumDisplayer Type="{x:Type gsc:OutputFormat}" x:Key="outputFormats"/> <gscp:EnumDisplayer Type="{x:Type gsc:OutputFormat}" x:Key="outputFormats"/>
</Window.Resources> </Window.Resources>
<StackPanel> <StackPanel>
<CheckBox IsChecked="{Binding IncludePersonSpaces}" Content="{l:Translate include_person_spaces}"/> <CheckBox IsChecked="{Binding IncludePersonSpaces}" Content="{support:Translate include_person_spaces}"/>
<CheckBox IsChecked="{Binding OpenPageAfterUpload}" Content="{l:Translate open_page_after_upload}"/> <CheckBox IsChecked="{Binding OpenPageAfterUpload}" Content="{support:Translate open_page_after_upload}"/>
<CheckBox IsChecked="{Binding CopyWikiMarkupForImageToClipboard}" Content="{l:Translate copy_wikimarkup}"/> <CheckBox IsChecked="{Binding CopyWikiMarkupForImageToClipboard}" Content="{support:Translate copy_wikimarkup}"/>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Label Content="{l:Translate label_url}" /> <Label Content="{support:Translate label_url}" />
<TextBox Text="{Binding Url}"/> <TextBox Text="{Binding Url}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Label Content="{l:Translate label_timeout}" /> <Label Content="{support:Translate label_timeout}" />
<TextBox Text="{Binding Timeout}"/> <TextBox Text="{Binding Timeout}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Label Content="{l:Translate upload_format}" /> <Label Content="{support:Translate upload_format}" />
<ComboBox ItemsSource="{Binding Source={StaticResource outputFormats},Path=DisplayNames}" SelectedValue="{Binding UploadFormat, Converter={StaticResource outputFormats}}" /> <ComboBox ItemsSource="{Binding Source={StaticResource outputFormats},Path=DisplayNames}" SelectedValue="{Binding UploadFormat, Converter={StaticResource outputFormats}}" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button IsDefault="True" Content="{l:Translate OK}" Click="Button_OK_Click"/> <Button IsDefault="True" Content="{support:Translate OK}" Click="Button_OK_Click"/>
<Button IsCancel="True" Content="{l:Translate CANCEL}"/> <Button IsCancel="True" Content="{support:Translate CANCEL}"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Window> </Window>

View file

@ -21,7 +21,7 @@
using System.Windows; using System.Windows;
namespace GreenshotConfluencePlugin { namespace GreenshotConfluencePlugin.Forms {
/// <summary> /// <summary>
/// Interaction logic for ConfluenceConfigurationForm.xaml /// Interaction logic for ConfluenceConfigurationForm.xaml
/// </summary> /// </summary>

View file

@ -1,4 +1,4 @@
<Page x:Class="GreenshotConfluencePlugin.ConfluencePagePicker" <Page x:Class="GreenshotConfluencePlugin.Forms.ConfluencePagePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Page_Loaded"> Loaded="Page_Loaded">

View file

@ -19,10 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using Confluence;
using System.Collections.Generic; using System.Collections.Generic;
namespace GreenshotConfluencePlugin { namespace GreenshotConfluencePlugin.Forms {
/// <summary> /// <summary>
/// Interaction logic for ConfluencePagePicker.xaml /// Interaction logic for ConfluencePagePicker.xaml
/// </summary> /// </summary>

View file

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Page x:Class="GreenshotConfluencePlugin.ConfluenceSearch" <Page x:Class="GreenshotConfluencePlugin.Forms.ConfluenceSearch"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:TranslationByMarkupExtension" Loaded="Page_Loaded"> xmlns:support="clr-namespace:GreenshotConfluencePlugin.Support"
Loaded="Page_Loaded">
<Grid MaxHeight="500"> <Grid MaxHeight="500">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="100" /> <ColumnDefinition Width="100" />
@ -16,9 +17,9 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Space" /> <Label Grid.Row="0" Grid.Column="0" Content="Space" />
<ComboBox Grid.Row="0" Grid.Column="1" Name="SpaceComboBox" ItemsSource="{Binding Path=Spaces}" DisplayMemberPath="Name" SelectedValuePath="Key"/> <ComboBox Grid.Row="0" Grid.Column="1" Name="SpaceComboBox" ItemsSource="{Binding Path=Spaces}" DisplayMemberPath="Name" SelectedValuePath="Key"/>
<Label Grid.Row="1" Grid.Column="0" Content="{l:Translate search_text}" /> <Label Grid.Row="1" Grid.Column="0" Content="{support:Translate search_text}" />
<TextBox Grid.Row="1" Grid.Column="1" Name="searchText" Text="" KeyDown="SearchText_KeyDown" TextChanged="searchText_TextChanged"/> <TextBox Grid.Row="1" Grid.Column="1" Name="searchText" Text="" KeyDown="SearchText_KeyDown" TextChanged="SearchText_TextChanged"/>
<Button Grid.Row="2" Grid.ColumnSpan="2" Name="Search" Content="{l:Translate search}" Click="Search_Click" IsEnabled="False"/> <Button Grid.Row="2" Grid.ColumnSpan="2" Name="Search" Content="{support:Translate search}" Click="Search_Click" IsEnabled="False"/>
<ListView Grid.Row="3" Grid.ColumnSpan="2" Name="PageListView" SelectionMode="Single" ItemsSource="{Binding Path=Pages}" SelectionChanged="PageListView_SelectionChanged"> <ListView Grid.Row="3" Grid.ColumnSpan="2" Name="PageListView" SelectionMode="Single" ItemsSource="{Binding Path=Pages}" SelectionChanged="PageListView_SelectionChanged">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>

View file

@ -25,15 +25,15 @@ using System.Linq;
using System.Windows; using System.Windows;
using GreenshotPlugin.IniFile; using GreenshotPlugin.IniFile;
namespace GreenshotConfluencePlugin { namespace GreenshotConfluencePlugin.Forms {
public partial class ConfluenceSearch public partial class ConfluenceSearch
{ {
private static readonly ConfluenceConfiguration ConfluenceConfig = IniConfig.GetIniSection<ConfluenceConfiguration>(); private static readonly ConfluenceConfiguration ConfluenceConfig = IniConfig.GetIniSection<ConfluenceConfiguration>();
private readonly ConfluenceUpload _confluenceUpload; private readonly ConfluenceUpload _confluenceUpload;
public IEnumerable<Confluence.Space> Spaces => _confluenceUpload.Spaces; public IEnumerable<Space> Spaces => _confluenceUpload.Spaces;
public ObservableCollection<Confluence.Page> Pages { get; } = new ObservableCollection<Confluence.Page>(); public ObservableCollection<Page> Pages { get; } = new ObservableCollection<Page>();
public ConfluenceSearch(ConfluenceUpload confluenceUpload) { public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
_confluenceUpload = confluenceUpload; _confluenceUpload = confluenceUpload;
@ -56,7 +56,7 @@ namespace GreenshotConfluencePlugin {
private void SelectionChanged() { private void SelectionChanged() {
if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) { if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
_confluenceUpload.SelectedPage = (Confluence.Page)PageListView.SelectedItem; _confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem;
} else { } else {
_confluenceUpload.SelectedPage = null; _confluenceUpload.SelectedPage = null;
} }
@ -86,7 +86,7 @@ namespace GreenshotConfluencePlugin {
SelectionChanged(); SelectionChanged();
} }
private void searchText_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { private void SearchText_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) {
Search.IsEnabled = !string.IsNullOrEmpty(searchText.Text); Search.IsEnabled = !string.IsNullOrEmpty(searchText.Text);
} }
} }

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Page x:Class="GreenshotConfluencePlugin.ConfluenceTreePicker" <Page x:Class="GreenshotConfluencePlugin.Forms.ConfluenceTreePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:TranslationByMarkupExtension" xmlns:support="clr-namespace:GreenshotConfluencePlugin.Support"
Loaded="Page_Loaded"> Loaded="Page_Loaded">
<Grid Width="500"> <Grid Width="500">
<TreeView Name="ConfluenceTreeView" MaxHeight="500" <TreeView Name="ConfluenceTreeView" MaxHeight="500"
@ -10,7 +10,7 @@
VerticalAlignment="Top" HorizontalAlignment="Left" /> VerticalAlignment="Top" HorizontalAlignment="Left" />
<Border Name="ShowBusy" BorderBrush="Black" BorderThickness="1" Background="#80000000" Visibility="Visible"> <Border Name="ShowBusy" BorderBrush="Black" BorderThickness="1" Background="#80000000" Visibility="Visible">
<TextBlock Margin="0" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" <TextBlock Margin="0" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="18" FontWeight="Bold" Foreground="#7EFFFFFF" Text="{l:Translate loading}"/> FontSize="18" FontWeight="Bold" Foreground="#7EFFFFFF" Text="{support:Translate loading}"/>
</Border> </Border>
</Grid> </Grid>
</Page> </Page>

View file

@ -27,10 +27,7 @@ using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading; using System.Windows.Threading;
using Confluence; namespace GreenshotConfluencePlugin.Forms {
using Page = Confluence.Page;
namespace GreenshotConfluencePlugin {
/// <summary> /// <summary>
/// Interaction logic for ConfluenceTreePicker.xaml /// Interaction logic for ConfluenceTreePicker.xaml
/// </summary> /// </summary>
@ -47,10 +44,10 @@ namespace GreenshotConfluencePlugin {
InitializeComponent(); InitializeComponent();
} }
private void pageTreeViewItem_DoubleClick(object sender, MouseButtonEventArgs eventArgs) { private void PageTreeViewItem_DoubleClick(object sender, MouseButtonEventArgs eventArgs) {
Log.Debug("spaceTreeViewItem_MouseLeftButtonDown is called!"); Log.Debug("spaceTreeViewItem_MouseLeftButtonDown is called!");
TreeViewItem clickedItem = eventArgs.Source as TreeViewItem; TreeViewItem clickedItem = eventArgs.Source as TreeViewItem;
if (!(clickedItem?.Tag is Page page)) { if (clickedItem?.Tag is not Page page) {
return; return;
} }
if (clickedItem.HasItems) if (clickedItem.HasItems)
@ -70,20 +67,20 @@ namespace GreenshotConfluencePlugin {
Tag = childPage Tag = childPage
}; };
clickedItem.Items.Add(pageTreeViewItem); clickedItem.Items.Add(pageTreeViewItem);
pageTreeViewItem.PreviewMouseDoubleClick += pageTreeViewItem_DoubleClick; pageTreeViewItem.PreviewMouseDoubleClick += PageTreeViewItem_DoubleClick;
pageTreeViewItem.PreviewMouseLeftButtonDown += pageTreeViewItem_Click; pageTreeViewItem.PreviewMouseLeftButtonDown += PageTreeViewItem_Click;
} }
ShowBusy.Visibility = Visibility.Collapsed; ShowBusy.Visibility = Visibility.Collapsed;
})); }));
}) { Name = "Loading childpages for confluence page " + page.Title }.Start(); }) { Name = "Loading childpages for confluence page " + page.Title }.Start();
} }
private void pageTreeViewItem_Click(object sender, MouseButtonEventArgs eventArgs) { private void PageTreeViewItem_Click(object sender, MouseButtonEventArgs eventArgs) {
Log.Debug("pageTreeViewItem_PreviewMouseDoubleClick is called!"); Log.Debug("pageTreeViewItem_PreviewMouseDoubleClick is called!");
if (!(eventArgs.Source is TreeViewItem clickedItem)) { if (eventArgs.Source is not TreeViewItem clickedItem) {
return; return;
} }
Confluence.Page page = clickedItem.Tag as Confluence.Page; Page page = clickedItem.Tag as Page;
_confluenceUpload.SelectedPage = page; _confluenceUpload.SelectedPage = page;
if (page != null) { if (page != null) {
Log.Debug("Page selected: " + page.Title); Log.Debug("Page selected: " + page.Title);
@ -107,14 +104,14 @@ namespace GreenshotConfluencePlugin {
// Get homepage // Get homepage
try { try {
Confluence.Page page = _confluenceConnector.GetSpaceHomepage(space); Page page = _confluenceConnector.GetSpaceHomepage(space);
TreeViewItem pageTreeViewItem = new TreeViewItem TreeViewItem pageTreeViewItem = new TreeViewItem
{ {
Header = page.Title, Header = page.Title,
Tag = page Tag = page
}; };
pageTreeViewItem.PreviewMouseDoubleClick += pageTreeViewItem_DoubleClick; pageTreeViewItem.PreviewMouseDoubleClick += PageTreeViewItem_DoubleClick;
pageTreeViewItem.PreviewMouseLeftButtonDown += pageTreeViewItem_Click; pageTreeViewItem.PreviewMouseLeftButtonDown += PageTreeViewItem_Click;
spaceTreeViewItem.Items.Add(pageTreeViewItem); spaceTreeViewItem.Items.Add(pageTreeViewItem);
ConfluenceTreeView.Items.Add(spaceTreeViewItem); ConfluenceTreeView.Items.Add(spaceTreeViewItem);
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -1,17 +1,17 @@
<Window x:Class="GreenshotConfluencePlugin.ConfluenceUpload" <Window x:Class="GreenshotConfluencePlugin.Forms.ConfluenceUpload"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:TranslationByMarkupExtension" xmlns:support="clr-namespace:GreenshotConfluencePlugin.Support"
Title="{l:Translate upload_menu_item}" Height="640" Width="500" Icon="/GreenshotConfluencePlugin;component/Images/Confluence.ico"> Title="{support:Translate upload_menu_item}" Height="640" Width="500" Icon="/GreenshotConfluencePlugin;component/Images/Confluence.ico">
<StackPanel> <StackPanel>
<TabControl> <TabControl>
<TabItem Header="{l:Translate open_pages}" Name="PickerTab"> <TabItem Header="{support:Translate open_pages}" Name="PickerTab">
<Frame NavigationUIVisibility="Hidden" Content="{Binding Path=PickerPage}" Height="500"/> <Frame NavigationUIVisibility="Hidden" Content="{Binding Path=PickerPage}" Height="500"/>
</TabItem> </TabItem>
<TabItem Header="{l:Translate search_pages}" Name="SearchTab"> <TabItem Header="{support:Translate search_pages}" Name="SearchTab">
<Frame NavigationUIVisibility="Hidden" Content="{Binding Path=SearchPage}" Height="500"/> <Frame NavigationUIVisibility="Hidden" Content="{Binding Path=SearchPage}" Height="500"/>
</TabItem> </TabItem>
<TabItem Header="{l:Translate browse_pages}"> <TabItem Header="{support:Translate browse_pages}">
<Frame NavigationUIVisibility="Hidden" Content="{Binding Path=BrowsePage}" Height="500"/> <Frame NavigationUIVisibility="Hidden" Content="{Binding Path=BrowsePage}" Height="500"/>
</TabItem> </TabItem>
</TabControl> </TabControl>
@ -23,12 +23,12 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{l:Translate filename}" /> <Label Grid.Row="0" Grid.Column="0" Content="{support:Translate filename}" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Filename}" /> <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Filename}" />
</Grid> </Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="Upload" Content="{l:Translate upload}" IsDefault="True" IsEnabled="False" Click="Upload_Click" /> <Button Name="Upload" Content="{support:Translate upload}" IsDefault="True" IsEnabled="False" Click="Upload_Click" />
<Button Name="Cancel" Content="{l:Translate CANCEL}" IsCancel="True" /> <Button Name="Cancel" Content="{support:Translate CANCEL}" IsCancel="True" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Window> </Window>

View file

@ -18,23 +18,23 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls;
namespace GreenshotConfluencePlugin { namespace GreenshotConfluencePlugin.Forms {
/// <summary> /// <summary>
/// Interaction logic for ConfluenceUpload.xaml /// Interaction logic for ConfluenceUpload.xaml
/// </summary> /// </summary>
public partial class ConfluenceUpload : Window { public partial class ConfluenceUpload : Window {
private Page _pickerPage; private System.Windows.Controls.Page _pickerPage;
public Page PickerPage { public System.Windows.Controls.Page PickerPage {
get { get {
if (_pickerPage == null) { if (_pickerPage == null) {
List<Confluence.Page> pages = ConfluenceUtils.GetCurrentPages(); List<Page> pages = ConfluenceUtils.GetCurrentPages();
if (pages != null && pages.Count > 0) { if (pages != null && pages.Count > 0) {
_pickerPage = new ConfluencePagePicker(this, pages); _pickerPage = new ConfluencePagePicker(this, pages);
} }
@ -43,21 +43,19 @@ namespace GreenshotConfluencePlugin {
} }
} }
private Page _searchPage; private System.Windows.Controls.Page _searchPage;
public Page SearchPage { public System.Windows.Controls.Page SearchPage {
get { return _searchPage ??= new ConfluenceSearch(this); } get { return _searchPage ??= new ConfluenceSearch(this); }
} }
private Page _browsePage; private System.Windows.Controls.Page _browsePage;
public Page BrowsePage { public System.Windows.Controls.Page BrowsePage {
get { return _browsePage ??= new ConfluenceTreePicker(this); } get { return _browsePage ??= new ConfluenceTreePicker(this); }
} }
private Confluence.Page _selectedPage; private Page _selectedPage;
public Confluence.Page SelectedPage { public Page SelectedPage {
get { get => _selectedPage;
return _selectedPage;
}
set { set {
_selectedPage = value; _selectedPage = value;
Upload.IsEnabled = _selectedPage != null; Upload.IsEnabled = _selectedPage != null;
@ -75,8 +73,8 @@ namespace GreenshotConfluencePlugin {
} }
private static DateTime _lastLoad = DateTime.Now; private static DateTime _lastLoad = DateTime.Now;
private static IList<Confluence.Space> _spaces; private static IList<Space> _spaces;
public IList<Confluence.Space> Spaces { public IList<Space> Spaces {
get { get {
UpdateSpaces(); UpdateSpaces();
while (_spaces == null) { while (_spaces == null) {

View file

@ -18,92 +18,96 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System.Collections; using System.Collections;
using System.Windows.Forms; using System.Windows.Forms;
/// <summary> namespace GreenshotConfluencePlugin.Forms
/// This class is an implementation of the 'IComparer' interface. {
/// </summary>
public class ListViewColumnSorter : IComparer {
/// <summary> /// <summary>
/// Specifies the column to be sorted /// This class is an implementation of the 'IComparer' interface.
/// </summary> /// </summary>
private int _columnToSort; public class ListViewColumnSorter : IComparer {
/// <summary> /// <summary>
/// Specifies the order in which to sort (i.e. 'Ascending'). /// Specifies the column to be sorted
/// </summary> /// </summary>
private SortOrder _orderOfSort; private int _columnToSort;
/// <summary> /// <summary>
/// Case insensitive comparer object /// Specifies the order in which to sort (i.e. 'Ascending').
/// </summary> /// </summary>
private readonly CaseInsensitiveComparer _objectCompare; private SortOrder _orderOfSort;
/// <summary>
/// Case insensitive comparer object
/// </summary>
private readonly CaseInsensitiveComparer _objectCompare;
/// <summary> /// <summary>
/// Class constructor. Initializes various elements /// Class constructor. Initializes various elements
/// </summary> /// </summary>
public ListViewColumnSorter() { public ListViewColumnSorter() {
// Initialize the column to '0' // Initialize the column to '0'
_columnToSort = 0; _columnToSort = 0;
// Initialize the sort order to 'none' // Initialize the sort order to 'none'
_orderOfSort = SortOrder.None; _orderOfSort = SortOrder.None;
// Initialize the CaseInsensitiveComparer object
_objectCompare = new CaseInsensitiveComparer();
}
/// <summary>
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
/// </summary>
/// <param name="x">First object to be compared</param>
/// <param name="y">Second object to be compared</param>
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
public int Compare(object x, object y) {
int compareResult;
ListViewItem listviewX, listviewY;
// Cast the objects to be compared to ListViewItem objects
listviewX = (ListViewItem)x;
listviewY = (ListViewItem)y;
// Compare the two items
compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text, listviewY.SubItems[_columnToSort].Text);
// Calculate correct return value based on object comparison
if (_orderOfSort == SortOrder.Ascending) {
// Ascending sort is selected, return normal result of compare operation
return compareResult;
} else if (_orderOfSort == SortOrder.Descending) {
// Descending sort is selected, return negative result of compare operation
return (-compareResult);
} else {
// Return '0' to indicate they are equal
return 0;
}
}
/// <summary>
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
/// </summary>
public int SortColumn {
set {
_columnToSort = value;
}
get {
return _columnToSort;
}
}
/// <summary>
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
/// </summary>
public SortOrder Order {
set {
_orderOfSort = value;
}
get {
return _orderOfSort;
}
}
// Initialize the CaseInsensitiveComparer object
_objectCompare = new CaseInsensitiveComparer();
} }
/// <summary>
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
/// </summary>
/// <param name="x">First object to be compared</param>
/// <param name="y">Second object to be compared</param>
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
public int Compare(object x, object y) {
int compareResult;
ListViewItem listviewX, listviewY;
// Cast the objects to be compared to ListViewItem objects
listviewX = (ListViewItem)x;
listviewY = (ListViewItem)y;
// Compare the two items
compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text, listviewY.SubItems[_columnToSort].Text);
// Calculate correct return value based on object comparison
if (_orderOfSort == SortOrder.Ascending) {
// Ascending sort is selected, return normal result of compare operation
return compareResult;
} else if (_orderOfSort == SortOrder.Descending) {
// Descending sort is selected, return negative result of compare operation
return (-compareResult);
} else {
// Return '0' to indicate they are equal
return 0;
}
}
/// <summary>
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
/// </summary>
public int SortColumn {
set {
_columnToSort = value;
}
get {
return _columnToSort;
}
}
/// <summary>
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
/// </summary>
public SortOrder Order {
set {
_orderOfSort = value;
}
get {
return _orderOfSort;
}
}
} }

View file

@ -1,4 +1,4 @@
namespace TranslationByMarkupExtension { namespace GreenshotConfluencePlugin.Support {
public interface ITranslationProvider { public interface ITranslationProvider {
/// <summary> /// <summary>
/// Translates the specified key. /// Translates the specified key.

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Windows; using System.Windows;
namespace TranslationByMarkupExtension namespace GreenshotConfluencePlugin.Support
{ {
public class LanguageChangedEventManager : WeakEventManager public class LanguageChangedEventManager : WeakEventManager
{ {

View file

@ -1,6 +1,6 @@
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
namespace TranslationByMarkupExtension { namespace GreenshotConfluencePlugin.Support {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View file

@ -2,7 +2,7 @@
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Markup; using System.Windows.Markup;
namespace TranslationByMarkupExtension namespace GreenshotConfluencePlugin.Support
{ {
/// <summary> /// <summary>
/// The Translate Markup extension returns a binding to a TranslationData /// The Translate Markup extension returns a binding to a TranslationData

View file

@ -2,7 +2,7 @@
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
namespace TranslationByMarkupExtension { namespace GreenshotConfluencePlugin.Support {
public class TranslationData : IWeakEventListener, INotifyPropertyChanged { public class TranslationData : IWeakEventListener, INotifyPropertyChanged {
private readonly string _key; private readonly string _key;

View file

@ -1,6 +1,6 @@
using System; using System;
namespace TranslationByMarkupExtension { namespace GreenshotConfluencePlugin.Support {
public class TranslationManager { public class TranslationManager {
private static TranslationManager _translationManager; private static TranslationManager _translationManager;

View file

@ -30,10 +30,6 @@ stages:
steps: steps:
- task: NuGetToolInstaller@1 - task: NuGetToolInstaller@1
- powershell: |
choco install msbuild.communitytasks
displayName: 'Installing MSBuild community tasks'
- task: NuGetCommand@2 - task: NuGetCommand@2
displayName: NuGet restore displayName: NuGet restore
inputs: inputs: