Moving back to trunk!

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-01-24 19:24:36 +00:00
commit 8d458998a1
332 changed files with 17647 additions and 9466 deletions

View file

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

View file

@ -0,0 +1,46 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Windows;
namespace GreenshotConfluencePlugin {
/// <summary>
/// Interaction logic for ConfluenceConfigurationForm.xaml
/// </summary>
public partial class ConfluenceConfigurationForm : Window {
private ConfluenceConfiguration config;
public ConfluenceConfiguration Config {
get {
return config;
}
}
public ConfluenceConfigurationForm(ConfluenceConfiguration config) {
this.DataContext = config;
this.config = config;
InitializeComponent();
}
void Button_Click(object sender, RoutedEventArgs e) {
DialogResult = true;
}
}
}

View file

@ -1,153 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace GreenshotConfluencePlugin {
partial class ConfluenceForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.textBox_space = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox_page = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox_filename = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox_space
//
this.textBox_space.Location = new System.Drawing.Point(180, 30);
this.textBox_space.Name = "textBox_space";
this.textBox_space.Size = new System.Drawing.Size(100, 20);
this.textBox_space.TabIndex = 0;
this.textBox_space.Text = "dev";
//
// label1
//
this.label1.Location = new System.Drawing.Point(12, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(162, 23);
this.label1.TabIndex = 1;
this.label1.Text = "Space key";
//
// label2
//
this.label2.Location = new System.Drawing.Point(12, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(162, 23);
this.label2.TabIndex = 3;
this.label2.Text = "Page title";
//
// textBox_page
//
this.textBox_page.Location = new System.Drawing.Point(180, 53);
this.textBox_page.Name = "textBox_page";
this.textBox_page.Size = new System.Drawing.Size(100, 20);
this.textBox_page.TabIndex = 2;
this.textBox_page.Text = "15 Developer JF";
//
// label3
//
this.label3.Location = new System.Drawing.Point(12, 76);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(162, 23);
this.label3.TabIndex = 5;
this.label3.Text = "Filename";
//
// textBox_filename
//
this.textBox_filename.Location = new System.Drawing.Point(180, 76);
this.textBox_filename.Name = "textBox_filename";
this.textBox_filename.Size = new System.Drawing.Size(100, 20);
this.textBox_filename.TabIndex = 4;
//
// button1
//
this.button1.Location = new System.Drawing.Point(44, 125);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.ButtonOKClick);
//
// button2
//
this.button2.Location = new System.Drawing.Point(180, 125);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 7;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.ButtonCancelClick);
//
// ConfluenceForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 175);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox_filename);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox_page);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox_space);
this.Name = "ConfluenceForm";
this.Text = "ConfluenceForm";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.TextBox textBox_space;
private System.Windows.Forms.TextBox textBox_page;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox_filename;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
}
}

View file

@ -1,69 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using Confluence;
using GreenshotPlugin.Core;
namespace GreenshotConfluencePlugin {
/// <summary>
/// Description of ConfluenceForm.
/// </summary>
public partial class ConfluenceForm : Form {
private ConfluenceConnector confluenceConnector;
private ILanguage language = Language.GetInstance();
public ConfluenceForm(ConfluenceConnector confluenceConnector) {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.confluenceConnector = confluenceConnector;
try {
if (!confluenceConnector.isLoggedIn()) {
confluenceConnector.login();
}
} catch (Exception e) {
MessageBox.Show(language.GetFormattedString(LangKey.login_error, e.Message));
}
}
public void setFilename(string filename) {
textBox_filename.Text = filename;
}
public void upload(byte [] buffer) {
Page page = confluenceConnector.getPage(textBox_space.Text, textBox_page.Text);
confluenceConnector.addAttachment(page.id, " image/png", "HALLO", textBox_filename.Text, buffer);
}
void ButtonCancelClick(object sender, EventArgs e) {
this.DialogResult = DialogResult.Cancel;
}
void ButtonOKClick(object sender, EventArgs e) {
this.DialogResult = DialogResult.OK;
}
}
}

View file

@ -0,0 +1,12 @@
<Page x:Class="GreenshotConfluencePlugin.ConfluencePagePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:TranslationByMarkupExtension" Loaded="Page_Loaded">
<ListView Name="PageListView" SelectionMode="Single" ItemsSource="{Binding}" SelectionChanged="PageListView_SelectionChanged" Width="480" Height="500">
<ListView.ItemTemplate>
<DataTemplate>
<Label Content="{Binding Title}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Page>

View file

@ -0,0 +1,59 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using Confluence;
namespace GreenshotConfluencePlugin {
/// <summary>
/// Interaction logic for ConfluencePagePicker.xaml
/// </summary>
public partial class ConfluencePagePicker : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluencePagePicker));
private ConfluenceUpload confluenceUpload = null;
public ConfluencePagePicker(ConfluenceUpload confluenceUpload) {
this.confluenceUpload = confluenceUpload;
this.DataContext = ConfluenceUtils.GetCurrentPages();
InitializeComponent();
}
void Upload_Click(object sender, System.Windows.RoutedEventArgs e) {
ConfluenceUpload confluenceUpload = (ConfluenceUpload)Parent;
confluenceUpload.DialogResult = true;
}
void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {
SelectionChanged();
}
void SelectionChanged() {
if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem;
} else {
confluenceUpload.SelectedPage = null;
}
}
void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) {
SelectionChanged();
}
}
}

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Page x:Class="GreenshotConfluencePlugin.ConfluenceSearch"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:TranslationByMarkupExtension" Loaded="Page_Loaded">
<Grid MaxHeight="500">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<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"/>
<Label Grid.Row="1" Grid.Column="0" Content="Search text" />
<TextBox Grid.Row="1" Grid.Column="1" Name="searchText" Text="" KeyDown="SearchText_KeyDown"/>
<Button Grid.Row="2" Grid.ColumnSpan="2" Name="Search" Content="Search" Click="Search_Click" />
<ListView Grid.Row="3" Grid.ColumnSpan="2" Name="PageListView" SelectionMode="Single" ItemsSource="{Binding Path=Pages}" SelectionChanged="PageListView_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<Label Content="{Binding Title}" Foreground="DarkBlue" />
<TextBlock Text="{Binding Content}" Foreground="DarkGray" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>

View file

@ -0,0 +1,102 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using Confluence;
using GreenshotPlugin.Core;
using IniFile;
namespace GreenshotConfluencePlugin {
public partial class ConfluenceSearch : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceSearch));
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
private ILanguage language = GreenshotConfluencePlugin.Language.GetInstance();
private ConfluenceConnector confluenceConnector;
private ConfluenceUpload confluenceUpload;
public List<Confluence.Space> Spaces {
get {
return confluenceUpload.Spaces;
}
}
private ObservableCollection<Confluence.Page> pages = new ObservableCollection<Confluence.Page>();
public ObservableCollection<Confluence.Page> Pages {
get {
return pages;
}
}
public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
this.confluenceConnector = ConfluencePlugin.ConfluenceConnector;
this.confluenceUpload = confluenceUpload;
this.DataContext = this;
InitializeComponent();
if (config.SearchSpaceKey == null) {
this.SpaceComboBox.SelectedItem = Spaces[0];
} else {
foreach(Confluence.Space space in Spaces) {
if (space.Key.Equals(config.SearchSpaceKey)) {
this.SpaceComboBox.SelectedItem = space;
}
}
}
}
void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {
SelectionChanged();
}
void SelectionChanged() {
if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
confluenceUpload.SelectedPage = (Confluence.Page)PageListView.SelectedItem;
} else {
confluenceUpload.SelectedPage = null;
}
}
void Search_Click(object sender, RoutedEventArgs e) {
doSearch();
}
void doSearch() {
string spaceKey = (string)SpaceComboBox.SelectedValue;
config.SearchSpaceKey = spaceKey;
List<Confluence.Page> searchResult = confluenceConnector.searchPages(searchText.Text, spaceKey);
pages.Clear();
foreach(Confluence.Page page in searchResult) {
pages.Add(page);
}
}
void SearchText_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == System.Windows.Input.Key.Return) {
doSearch();
e.Handled = true;
}
}
void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) {
SelectionChanged();
}
}
}

View file

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

View file

@ -0,0 +1,129 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using Confluence;
using GreenshotPlugin.Core;
namespace GreenshotConfluencePlugin {
/// <summary>
/// Interaction logic for ConfluenceTreePicker.xaml
/// </summary>
public partial class ConfluenceTreePicker : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceTreePicker));
private ILanguage language = GreenshotConfluencePlugin.Language.GetInstance();
private ConfluenceConnector confluenceConnector;
private ConfluenceUpload confluenceUpload;
private bool isInitDone = false;
public ConfluenceTreePicker(ConfluenceUpload confluenceUpload) {
this.confluenceConnector = ConfluencePlugin.ConfluenceConnector;
this.confluenceUpload = confluenceUpload;
InitializeComponent();
}
void pageTreeViewItem_DoubleClick(object sender, MouseButtonEventArgs eventArgs) {
LOG.Debug("spaceTreeViewItem_MouseLeftButtonDown is called!");
TreeViewItem clickedItem = eventArgs.Source as TreeViewItem;
if (clickedItem ==null) {
return;
}
Confluence.Page page = clickedItem.Tag as Confluence.Page;
if (page == null) {
return;
}
if (!clickedItem.HasItems) {
LOG.Debug("Loading pages for page: " + page.Title);
(new Thread(() => {
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {ShowBusy.Visibility = Visibility.Visible;}));
List<Confluence.Page> pages = confluenceConnector.getPageChildren(page);
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
foreach(Confluence.Page childPage in pages) {
LOG.Debug("Adding page: " + childPage.Title);
TreeViewItem pageTreeViewItem = new TreeViewItem();
pageTreeViewItem.Header = childPage.Title;
pageTreeViewItem.Tag = childPage;
clickedItem.Items.Add(pageTreeViewItem);
pageTreeViewItem.PreviewMouseDoubleClick += new MouseButtonEventHandler(pageTreeViewItem_DoubleClick);
pageTreeViewItem.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(pageTreeViewItem_Click);
}
ShowBusy.Visibility = Visibility.Collapsed;
}));
}
) { Name = "Loading childpages for confluence page " + page.Title }).Start();
}
}
void pageTreeViewItem_Click(object sender, MouseButtonEventArgs eventArgs) {
LOG.Debug("pageTreeViewItem_PreviewMouseDoubleClick is called!");
TreeViewItem clickedItem = eventArgs.Source as TreeViewItem;
if (clickedItem ==null) {
return;
}
Confluence.Page page = clickedItem.Tag as Confluence.Page;
confluenceUpload.SelectedPage = page;
if (page != null) {
LOG.Debug("Page selected: " + page.Title);
}
}
void Page_Loaded(object sender, RoutedEventArgs e) {
confluenceUpload.SelectedPage = null;
if (isInitDone) {
return;
}
ShowBusy.Visibility = Visibility.Visible;
(new Thread(() => {
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
List<Space> spaces = confluenceUpload.Spaces;
foreach (Space space in spaces) {
TreeViewItem spaceTreeViewItem = new TreeViewItem();
spaceTreeViewItem.Header = space.Name;
spaceTreeViewItem.Tag = space;
// Get homepage
try {
Confluence.Page page = confluenceConnector.getSpaceHomepage(space);
TreeViewItem pageTreeViewItem = new TreeViewItem();
pageTreeViewItem.Header = page.Title;
pageTreeViewItem.Tag = page;
pageTreeViewItem.PreviewMouseDoubleClick += new MouseButtonEventHandler(pageTreeViewItem_DoubleClick);
pageTreeViewItem.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(pageTreeViewItem_Click);
spaceTreeViewItem.Items.Add(pageTreeViewItem);
ConfluenceTreeView.Items.Add(spaceTreeViewItem);
} catch (Exception ex) {
LOG.Error("Can't get homepage for space : " + space.Name + " (" + ex.Message + ")");
}
}
ShowBusy.Visibility = Visibility.Collapsed;
isInitDone = true;
}));
}
) { Name = "Loading spaces for confluence"}).Start();
}
}
}

View file

@ -0,0 +1,34 @@
<Window x:Class="GreenshotConfluencePlugin.ConfluenceUpload"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:TranslationByMarkupExtension"
Title="Upload to confluence" Height="640" Width="500" Icon="/GreenshotConfluencePlugin;component/Images/Confluence.ico">
<StackPanel>
<TabControl >
<TabItem Header="Open pages">
<Frame NavigationUIVisibility="Hidden" Content="{Binding Path=PickerPage}" Height="500"/>
</TabItem>
<TabItem Header="Search pages">
<Frame NavigationUIVisibility="Hidden" Content="{Binding Path=SearchPage}" Height="500"/>
</TabItem>
<TabItem Header="Browse pages">
<Frame NavigationUIVisibility="Hidden" Content="{Binding Path=BrowsePage}" Height="500"/>
</TabItem>
</TabControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{l:Translate filename}" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Filename}" />
</Grid>
<StackPanel Orientation="Horizontal">
<Button Name="Upload" Content="Upload" IsDefault="True" IsEnabled="False" Click="Upload_Click" />
<Button Name="Cancel" Content="Cancel" IsCancel="True" />
</StackPanel>
</StackPanel>
</Window>

View file

@ -0,0 +1,119 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
namespace GreenshotConfluencePlugin {
/// <summary>
/// Interaction logic for ConfluenceUpload.xaml
/// </summary>
public partial class ConfluenceUpload : Window {
private Page pickerPage = null;
public Page PickerPage {
get {
if (pickerPage == null) {
pickerPage = new ConfluencePagePicker(this);
}
return pickerPage;
}
}
private Page searchPage = null;
public Page SearchPage {
get {
if (searchPage == null) {
searchPage = new ConfluenceSearch(this);
}
return searchPage;
}
}
private Page browsePage = null;
public Page BrowsePage {
get {
if (browsePage == null) {
browsePage = new ConfluenceTreePicker(this);
}
return browsePage;
}
}
private Confluence.Page selectedPage = null;
public Confluence.Page SelectedPage {
get {
return selectedPage;
}
set {
selectedPage = value;
if (selectedPage != null) {
Upload.IsEnabled = true;
} else {
Upload.IsEnabled = false;
}
}
}
public string Filename {
get;
set;
}
private static DateTime lastLoad = DateTime.Now;
private static List<Confluence.Space> spaces;
public List<Confluence.Space> Spaces {
get {
updateSpaces();
while (spaces == null) {
Thread.Sleep(300);
}
return spaces;
}
}
public ConfluenceUpload(string filename) {
this.Filename = filename;
InitializeComponent();
this.DataContext = this;
updateSpaces();
}
void updateSpaces() {
if (spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(lastLoad) > 0) {
// Reset
spaces = null;
}
// Check if load is needed
if (spaces == null) {
(new Thread(() => {
spaces = ConfluencePlugin.ConfluenceConnector.getSpaceSummaries();
lastLoad = DateTime.Now;
}) { Name = "Loading spaces for confluence"}).Start();
}
}
void Upload_Click(object sender, RoutedEventArgs e) {
DialogResult = true;
}
}
}

View file

@ -1,135 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace GreenshotConfluencePlugin {
partial class SettingsForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.label_url = new System.Windows.Forms.Label();
this.textBoxUrl = new System.Windows.Forms.TextBox();
this.combobox_uploadimageformat = new System.Windows.Forms.ComboBox();
this.label_upload_format = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.Location = new System.Drawing.Point(222, 139);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 2;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.ButtonOKClick);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(303, 139);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
//
// label_url
//
this.label_url.Location = new System.Drawing.Point(12, 21);
this.label_url.Name = "label_url";
this.label_url.Size = new System.Drawing.Size(84, 20);
this.label_url.TabIndex = 7;
this.label_url.Text = "Url";
//
// textBoxUrl
//
this.textBoxUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.textBoxUrl.Location = new System.Drawing.Point(102, 21);
this.textBoxUrl.Name = "textBoxUrl";
this.textBoxUrl.Size = new System.Drawing.Size(276, 20);
this.textBoxUrl.TabIndex = 6;
//
// combobox_uploadimageformat
//
this.combobox_uploadimageformat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.combobox_uploadimageformat.FormattingEnabled = true;
this.combobox_uploadimageformat.Location = new System.Drawing.Point(102, 47);
this.combobox_uploadimageformat.Name = "combobox_uploadimageformat";
this.combobox_uploadimageformat.Size = new System.Drawing.Size(276, 21);
this.combobox_uploadimageformat.TabIndex = 8;
//
// label_upload_format
//
this.label_upload_format.Location = new System.Drawing.Point(12, 50);
this.label_upload_format.Name = "label_upload_format";
this.label_upload_format.Size = new System.Drawing.Size(84, 20);
this.label_upload_format.TabIndex = 9;
this.label_upload_format.Text = "Upload format";
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(387, 174);
this.Controls.Add(this.label_upload_format);
this.Controls.Add(this.combobox_uploadimageformat);
this.Controls.Add(this.label_url);
this.Controls.Add(this.textBoxUrl);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Name = "SettingsForm";
this.Text = "Please enter your Confluence data";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ComboBox combobox_uploadimageformat;
private System.Windows.Forms.Label label_upload_format;
private System.Windows.Forms.TextBox textBoxUrl;
private System.Windows.Forms.Label label_url;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
}
}

View file

@ -1,73 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace GreenshotConfluencePlugin {
/// <summary>
/// Description of PasswordRequestForm.
/// </summary>
public partial class SettingsForm : Form {
private ILanguage lang = Language.GetInstance();
public SettingsForm() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
InitializeTexts();
combobox_uploadimageformat.Items.Clear();
foreach(OutputFormat format in Enum.GetValues(typeof(OutputFormat))) {
combobox_uploadimageformat.Items.Add(format.ToString());
}
}
private void InitializeTexts() {
this.label_url.Text = lang.GetString(LangKey.label_url);
this.buttonOK.Text = lang.GetString(LangKey.OK);
this.buttonCancel.Text = lang.GetString(LangKey.CANCEL);
this.Text = lang.GetString(LangKey.login_title);
this.label_upload_format.Text = lang.GetString(LangKey.label_upload_format);
}
public string Url {
get {return textBoxUrl.Text;}
set {textBoxUrl.Text = value;}
}
public string UploadFormat {
get {return combobox_uploadimageformat.Text;}
set {combobox_uploadimageformat.Text = value;}
}
void ButtonOKClick(object sender, EventArgs e) {
this.DialogResult = DialogResult.OK;
}
void ButtonCancelClick(object sender, System.EventArgs e) {
this.DialogResult = DialogResult.Cancel;
}
}
}