Changeset 11922
- Timestamp:
- Aug 8, 2011, 6:57:56 PM (13 years ago)
- Location:
- extensions/PiwigoLib
- Files:
-
- 2 added
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/Service/PwgSessionService.cs
r11911 r11922 44 44 { 45 45 ConvertProxyResponseToDTO(response, ref PwgSession); 46 PwgSession.IsConnected = true;47 46 } 48 47 } catch (PwgProxyException ex) … … 64 63 { 65 64 PwgSession = null; 65 Boolean isConnected = false; 66 66 try 67 67 { 68 68 PwgSessionProxyResponse response = PwgSessionProxy.pwg_session_login(UserName, Password); 69 69 70 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok 70 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) 71 71 { 72 72 73 if (response.Erreur != null) 73 74 { 74 throw new PwgServiceException("Login, the server has return the error.", 75 response.Erreur.Code, 75 throw new PwgServiceException("Login, the server has return the error.", 76 response.Erreur.Code, 76 77 response.Erreur.Message); 77 78 } … … 81 82 } 82 83 } 84 else 85 { 86 isConnected = true; 87 } 83 88 } 84 89 catch (PwgProxyException ex) … … 87 92 } 88 93 89 return GetPwgSession(); 94 PwgSession sess= GetPwgSession(); 95 sess.IsConnected = isConnected; 96 return sess; 90 97 } 91 98 … … 93 100 { 94 101 PwgSession = null; 102 Boolean isConnected = false; 95 103 try 96 104 { … … 116 124 } 117 125 118 return GetPwgSession(); 126 PwgSession sess = GetPwgSession(); 127 sess.IsConnected = isConnected; 128 return sess; 119 129 } 120 130 /// <summary> -
extensions/PiwigoLib/PiwigoWpf/App.xaml
r11911 r11922 9 9 <ObjectDataProvider x:Name="SessionODP" x:Key="Session" ObjectType="{x:Type piwigo:PwgSessionWPF}" /> 10 10 <ObjectDataProvider x:Name="CategoriesODP" x:Key="Categories" ObjectType="{x:Type piwigo:PwgCategoryListWPF}"/> <!--IsAsynchronous="True"--> 11 11 <!--IsAsynchronous="True"--> 12 12 <ResourceDictionary x:Key="VisualStyleApp" Source="VisualStyleApp.xaml"/> 13 13 </Application.Resources> -
extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdConnect.cs
r11911 r11922 10 10 namespace Com.Piwigo.Wpf.Command 11 11 { 12 public sealed class PwgCmdConnect : PwgCmdBase12 public sealed class PwgCmdConnect : AsyncCommand 13 13 { 14 public override void Execute(object parameter) 14 public override string Text { get { return "Connect to server"; } } 15 16 protected override void OnExecute(object parameter) 15 17 { 16 18 try { 17 IsRunning = true;18 19 Uri uriServer = new Uri(PwgModelManager.Instance.Session.ServeurName); 19 20 SendUiInfo("Setting up server..."); 20 21 PwgServiceProvider.Instance.PwgSetupService.Setup(null, null, uriServer); 21 22 PwgSessionWPF sesWPF = PwgModelManager.Instance.Session; 22 23 SendUiInfo("Connecting to server..."); 23 24 PwgSession sess = null; 24 25 if (String.IsNullOrWhiteSpace(sesWPF.UserName) && String.IsNullOrWhiteSpace(sesWPF.Password)) … … 32 33 } 33 34 35 SendUiInfo("Retriving list of Category from server..."); 34 36 PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF); 35 37 … … 39 41 PwgCategoryListWPFHelper.ConvertPwgCategoryListToPwgCategoryListWPF(lstCat, ref lstCatWPF); 40 42 43 SendUiInfo("Setting up cache data ..."); 41 44 ImageCacheManager.Instance.SetCurrentServer(uriServer.AbsoluteUri); 45 42 46 43 IsRunning = false;44 47 } 45 48 catch (PwgServiceException ex) 46 49 { 47 Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr); 48 Console.WriteLine(ex.Message); 50 SendUiInfo("Error " + ex.NumeroErr + " " + ex.MessageErr); 49 51 } 50 52 51 53 } 52 54 } -
extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdDisconnect.cs
r11911 r11922 10 10 namespace Com.Piwigo.Wpf.Command 11 11 { 12 public sealed class PwgCmdDisconnect : PwgCmdBase12 public sealed class PwgCmdDisconnect : AsyncCommand 13 13 { 14 public override void Execute(object parameter) 14 public override string Text { get { return "Disconnect from server"; } } 15 16 protected override void OnExecute(object parameter) 15 17 { 16 18 try { 17 IsRunning = true;18 19 PwgSessionWPF sesWPF = PwgModelManager.Instance.Session; 19 20 21 SendUiInfo("Logging out ..."); 22 20 23 PwgSession sess = null; 21 24 sess = PwgServiceProvider.Instance.PwgSessionService.Logout(); 22 25 23 26 PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF); 24 27 28 SendUiInfo("Removing Image and Category ..."); 29 if (PwgModelManager.Instance.ImageList != null) 30 { 31 PwgModelManager.Instance.ImageList.Clear(); 32 } 33 25 34 if (PwgModelManager.Instance.CategoryList != null) 26 35 { … … 28 37 } 29 38 39 SendUiInfo("Unset cache data ..."); 30 40 ImageCacheManager.Instance.UnsetCurrentServer(); 31 32 IsRunning = false;33 41 } 34 42 catch (PwgServiceException ex) 35 43 { 36 Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr); 37 Console.WriteLine(ex.Message); 44 SendUiInfo("Error " + ex.NumeroErr + " " + ex.MessageErr); 38 45 } 39 40 46 } 41 47 } -
extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdGetImageforCategory.cs
r11911 r11922 10 10 namespace Com.Piwigo.Wpf.Command 11 11 { 12 public sealed class PwgCmdGetImageforCategory : PwgCmdBase12 public sealed class PwgCmdGetImageforCategory : AsyncCommand 13 13 { 14 public override void Execute(object parameter) 14 public override string Text { get { return "Get images for a category"; } } 15 16 protected override void OnExecute(object parameter) 15 17 { 16 18 PwgCategoryWPF catParam; … … 19 21 Int32 acount = 0; 20 22 21 try { 23 try 24 { 22 25 Uri uriServer = new Uri(PwgModelManager.Instance.Session.ServeurName); 23 26 if (parameter is PwgCategoryWPF) 24 27 { 28 PwgImageListWPF lstImgWPF = PwgModelManager.Instance.ImageList; 29 SendUiInfo("Removing image..."); 30 if (lstImgWPF != null) 31 { 32 lstImgWPF.Clear(); 33 } 34 25 35 catParam = (PwgCategoryWPF)parameter; 36 SendUiInfo("Setting up cache data..."); 26 37 ImageCacheManager.Instance.SetCurrentCategory(catParam.Id.ToString()); 27 38 39 SendUiInfo("Retriving images list from server..."); 28 40 List<PwgImage> lstImg = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfImagesFormCategory(catParam.Id, false, null, null, null, null, null, null, null, null, null, null, null, null, null, true, ref aPage, ref aPerPage, ref acount); 29 PwgImageListWPF lstImgWPF = PwgModelManager.Instance.ImageList; 30 41 31 42 PwgImageListWPFHelper.ConvertPwgImageListToPwgImageListWPF(lstImg, ref lstImgWPF); 32 43 } 33 34 44 } 35 45 catch (PwgServiceException ex) 36 46 { 37 Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr); 38 Console.WriteLine(ex.Message); 47 SendUiInfo("Error " + ex.NumeroErr + " " + ex.MessageErr); 39 48 } 40 41 49 } 42 50 } -
extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdProvider.cs
r11911 r11922 9 9 public static class PwgCmdProvider 10 10 { 11 public static PwgCmdBaseGetByType<T>()11 public static AsyncCommand GetByType<T>() 12 12 { 13 PwgCmdBaseobjICom;13 AsyncCommand objICom; 14 14 15 15 switch (typeof(T).Name) … … 32 32 } 33 33 34 public static PwgCmdBase_pwgCmdConnect;35 public static PwgCmdBasePwgCmdConnect34 public static AsyncCommand _pwgCmdConnect; 35 public static AsyncCommand PwgCmdConnect 36 36 { 37 37 get … … 45 45 } 46 46 47 public static PwgCmdBase_pwgCmdDisconnect;48 public static PwgCmdBasePwgCmdDisconnect47 public static AsyncCommand _pwgCmdDisconnect; 48 public static AsyncCommand PwgCmdDisconnect 49 49 { 50 50 get … … 58 58 } 59 59 60 public static PwgCmdBase_pwgCmdGetImageforCategory;61 public static PwgCmdBasePwgCmdGetImageforCategory60 public static AsyncCommand _pwgCmdGetImageforCategory; 61 public static AsyncCommand PwgCmdGetImageforCategory 62 62 { 63 63 get -
extensions/PiwigoLib/PiwigoWpf/DTO/PwgImageWPF.cs
r7150 r11922 12 12 public class PwgImageWPF : INotifyPropertyChanged 13 13 { 14 private String _imgSource; 15 public String ImgSource 16 { 17 set { _imgSource = value; OnPropertyChanged("ImgSource"); } 18 get 19 { 20 if (_imgSource == null) 21 { 22 _imgSource = Com.Piwigo.Wpf.Service.ImageCacheManager.Instance.GetImageFilename(this); 23 } 24 return _imgSource; 25 } 26 } 27 28 14 29 private Int32 _id; 15 30 public Int32 Id -
extensions/PiwigoLib/PiwigoWpf/DTO/PwgModelManager.cs
r11905 r11922 27 27 public class PwgModelManagerBase 28 28 { 29 private AsyncObservableCollection<String> _lstMsgInfo = new AsyncObservableCollection<String>(); 30 public AsyncObservableCollection<String> lstMsgInfo 31 { 32 set { _lstMsgInfo = value; OnPropertyChanged("lstMsgInfo"); } 33 get { return _lstMsgInfo; } 34 } 35 36 private Boolean _booCmdRunning = false; 37 public Boolean booCmdRunning 38 { 39 set { _booCmdRunning = value; OnPropertyChanged("booCmdRunning"); } 40 get { return _booCmdRunning; } 41 } 42 29 43 private PwgImageListWPF _imageList; 30 44 public PwgImageListWPF ImageList … … 49 63 50 64 public event PropertyChangedEventHandler PropertyChanged; 51 privatevoid OnPropertyChanged(String info)65 internal void OnPropertyChanged(String info) 52 66 { 53 67 if (PropertyChanged != null) -
extensions/PiwigoLib/PiwigoWpf/Helper/AppHelper.cs
r11911 r11922 52 52 } 53 53 54 static public void ExecuteCommand<T>(object parameter) where T : PwgCmdBase54 static public void ExecuteCommand<T>(object parameter) where T : AsyncCommand 55 55 { 56 PwgCmdBasecmd = PwgCmdProvider.GetByType<T>();56 AsyncCommand cmd = PwgCmdProvider.GetByType<T>(); 57 57 if (cmd.CanExecute(parameter)) 58 58 { -
extensions/PiwigoLib/PiwigoWpf/Helper/ImageUrlCachedConverter.cs
r11904 r11922 21 21 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 22 22 { 23 String src ;23 String src = string.Empty; 24 24 if (value == null) return null; 25 25 PwgImageWPF someObj = value as PwgImageWPF; 26 26 27 src = ImageCacheManager.Instance.GetImageFilename(someObj);27 //src = ImageCacheManager.Instance.GetImageFilename(someObj); 28 28 29 29 return src; -
extensions/PiwigoLib/PiwigoWpf/MainWindow.xaml
r11911 r11922 7 7 xmlns:pwgcmd="clr-namespace:Com.Piwigo.Wpf.Command" 8 8 xmlns:pwgsrv="clr-namespace:Com.Piwigo.Wpf.Service" 9 xmlns:pwghlp="clr-namespace:Com.Piwigo.Wpf.Helper" 9 10 Title="PiwigoWpf" 10 11 WindowState="Maximized" 11 12 MinHeight="600" MinWidth="800"> 12 13 <Window.Resources> 13 <ObjectDataProvider x:Key="listCat" IsAsynchronous="True" /> 14 <ObjectDataProvider x:Key="listImg" IsAsynchronous="True" /> 15 16 <!-- DATA TEMPLATES --> 14 <pwghlp:AdvBooltoVisibilityConverter x:Key="AdvBooltoVisibilityConverter" Collapse="False" Reverse="False" /> 15 <pwghlp:AdvBooltoVisibilityConverter x:Key="AdvBooltoVisibilityConverterReversal" Collapse="False" Reverse="True" /> 16 <!-- DATA TEMPLATES --> 17 17 18 18 <DataTemplate DataType="{x:Type pwgdto:PwgImageWPF}"> … … 21 21 <Image ToolTip="{Binding File}" > 22 22 <Image.Source> 23 <PriorityBinding> 24 <Binding IsAsync="True" Converter="{x:Static pwgsrv:ImageCacheManager.ImageUrlCachedConverter}"/> 25 <Binding Source="pack://application:,,,/Pictures/Globe.png" /> 26 </PriorityBinding> 23 <Binding Path="ImgSource" /> <!--Converter="{x:Static pwgsrv:ImageCacheManager.ImageUrlCachedConverter}"--> 27 24 </Image.Source> 28 25 </Image> … … 197 194 <DockPanel Name="mainDockPanel" Margin="5"> 198 195 <StackPanel Name="headerStackPanel" DockPanel.Dock="Top" Orientation="Vertical"> 199 <Image Name="ImgPiwigoLogo" MinHeight="50" MinWidth="50" 196 <StackPanel Name="headerStackPanelLogo" Orientation="Horizontal" > 197 <Image Name="ImgPiwigoLogo" MinHeight="50" MinWidth="50" 200 198 Source="pack://application:,,,/Pictures/PiwigoLogo.png" 201 199 ToolTip="www.piwigo.org" Stretch="None" HorizontalAlignment="Left" /> 200 <Image Name="ImgGlobe" 201 Visibility="{Binding Source={x:Static pwgdto:PwgModelManager.Instance}, Path=booCmdRunning, Converter={StaticResource AdvBooltoVisibilityConverterReversal}}" 202 Source="pack://application:,,,/Pictures/Globe.png" 203 ToolTip="www.piwigo.org" Stretch="None" HorizontalAlignment="Right"/> 204 </StackPanel> 202 205 <StackPanel Name="connectStackPanel" Orientation="Horizontal" VerticalAlignment="Center" Margin="5" 203 206 DataContext="{Binding Source={StaticResource Session}}"> … … 210 213 <TextBox Height="23" Name="TbUrl" Width="300" Text="{Binding Path=ServeurName, Mode=TwoWay}"/> 211 214 <CheckBox Margin="2" VerticalAlignment="Center" IsChecked="{Binding Path=SaveSetting, Mode=TwoWay}">Save settings</CheckBox> 212 <Button Margin="2" Command="{x:Static pwgcmd:PwgCmdProvider.PwgCmdConnect}" Visibility="{ pwgui:SwitchBinding IsConnected, Hidden, Visible}">Conect</Button>213 <Button Margin="2" Command="{x:Static pwgcmd:PwgCmdProvider.PwgCmdDisconnect}" Visibility="{ pwgui:SwitchBinding IsConnected, Visible, Hidden}">Disconect</Button>215 <Button Margin="2" Command="{x:Static pwgcmd:PwgCmdProvider.PwgCmdConnect}" Visibility="{Binding Path=IsConnected, Converter={StaticResource AdvBooltoVisibilityConverterReversal}}">Conect</Button> 216 <Button Margin="2" Command="{x:Static pwgcmd:PwgCmdProvider.PwgCmdDisconnect}" Visibility="{Binding Path=IsConnected, Converter={StaticResource AdvBooltoVisibilityConverter}}">Disconect</Button> 214 217 </StackPanel> 215 <ProgressBar IsIndeterminate="True" />216 218 </StackPanel> 219 <ListView Name="listViewLogUiInfo" DockPanel.Dock="Bottom" 220 DataContext="{Binding Source={x:Static pwgdto:PwgModelManager.Instance}, Path=lstMsgInfo}" 221 ItemsSource="{Binding }" /> 217 222 218 223 <ListView Name="listViewCategory" DockPanel.Dock="Left" MinWidth="100" … … 221 226 DataContext="{Binding Source={StaticResource Categories}}" 222 227 ItemsSource="{Binding }" MouseDoubleClick="listViewCategory_MouseDoubleClick" /> 228 223 229 <ListView Name="listViewImage" DockPanel.Dock="Right" MinWidth="500" 224 230 Style="{DynamicResource PhotoListStyle}" -
extensions/PiwigoLib/PiwigoWpf/MainWindow.xaml.cs
r11904 r11922 25 25 { 26 26 InitializeComponent(); 27 PwgCmdEvents.CmdRunningChanged += new PwgCmdEvents.CmdRunningChangedHandler(PwgCmdEventsConsumer.PwgCmdEvents_CmdRunningChanged); 28 PwgCmdEvents.CmdSendUiInfo += new PwgCmdEvents.CmdSendUiInfoHandler(PwgCmdEventsConsumer.PwgCmdEvents_CmdSendUiInfo); 27 29 } 28 30 29 31 private void listViewCategory_MouseDoubleClick(object sender, MouseButtonEventArgs e) 30 32 { -
extensions/PiwigoLib/PiwigoWpf/PiwigoWpf.csproj
r11920 r11922 78 78 </ApplicationDefinition> 79 79 <Compile Include="Command\PwgCmdDisconnect.cs" /> 80 <Compile Include="Command\PwgCmdEventsConsumer.cs" /> 80 81 <Compile Include="Command\PwgCmdGetImageforCategory.cs" /> 81 82 <Compile Include="Command\PwgCmdProvider.cs" /> 82 83 <Compile Include="Command\PwgCmdConnect.cs" /> 83 <Compile Include="Command\PwgCmdBase.cs" /> 84 <Compile Include="Command\AsyncCommand.cs" /> 85 <Compile Include="Command\PwgCommandEvents.cs" /> 84 86 <Compile Include="DTO\Helper\PwgImageListWPFHelper.cs" /> 85 87 <Compile Include="DTO\Helper\PwgImageWPFHelper.cs" /> … … 88 90 <Compile Include="DTO\Helper\PwgSessionWPFHelper.cs" /> 89 91 <Compile Include="DTO\PwgModelManager.cs" /> 92 <Compile Include="Helper\AdvBooltoVisibilityConverter.cs" /> 90 93 <Compile Include="Helper\AppHelper.cs" /> 91 94 <Compile Include="DTO\AsyncObservableCollection.cs" /> -
extensions/PiwigoLib/PiwigoWpf/Services/ImageCacheManager.cs
r11911 r11922 39 39 static ImageCacheManager() 40 40 { 41 Int32 a, b; 42 ThreadPool.GetMaxThreads(out a, out b); 43 if (a>20) a = 20; 44 ThreadPool.SetMaxThreads(a, b); 41 45 } 42 46 … … 211 215 public String GetImageFilename(PwgImageWPF aImageWPF) 212 216 { 213 String ret Value= String.Empty;217 String retImgSrc = String.Empty; 214 218 if (aImageWPF == null) 215 219 { 216 return ret Value;220 return retImgSrc; 217 221 } 218 222 … … 223 227 if (!File.Exists(localFile)) 224 228 { 229 retImgSrc = GetDefaultImage(); 230 225 231 ThreadPool.QueueUserWorkItem((WaitCallback)delegate 226 232 { … … 240 246 image.Save(localFile); 241 247 248 aImageWPF.ImgSource = localFile; 242 249 }); 243 244 retValue = localFile; 245 } 250 } 251 else 252 { 253 retImgSrc = localFile; 254 } 255 return retImgSrc; 246 256 } 247 257 else … … 249 259 throw new ApplicationException("Current category not set before using image cache."); 250 260 } 251 return retValue;252 261 } 253 262
Note: See TracChangeset
for help on using the changeset viewer.