Does anyone knows how i can resize the PhotoshopImage instance?
I don't us the UIImageView because i need to load a lot of images and the PhotoshopImage class handles it better.
Got a real shaky start for you! Photoshop has documentation on using javascript vbscript with photoshop dll's: http://www.adobe.com/devnet/photoshop/scripting.html. These same methods are exposed via COM to C# and I wonder if they're available to Objective-C (RedGate and the vs object browser can help if you dabble with it). Don't cringe at the C# code! The point is photoshop exposes dlls which can be worked with. C# ASP.NET exposes photoshop .dll's via COM. I'm new to objective-c and not a vet at C#! I got this code to work on my windows machine in C#. This code cranks up a web page and fires up my version of photoshop cs3 and goes thru my directory of files and creates an "Adobe image gallery". Good luck to you and post back what you find in objective-c...I think objective-c can run native C and I've seen some documentation of working with photoshop in native C...Shoot some code back either way...I'm a semi newbie so if this wasn't what you meant by Photoshop Image I apologize!
CDUB
PS these are all photoshop methods being exposed, nothing I made up...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GoogleTalkAPILib;
using ps = Photoshop;
using Photoshop;
namespace photoshop
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
Object ob= null;
//works!!!!!!
// co.Application.MakePDFPresentation(oaa,
"C:\Users\Photoshoptryrescl",ob);
//you can also use c# to run a javascript
// co.DoJavaScript("hey.js",e,d );
co.MakePhotoGallery(oab, "C:\\photoshopdump", ob);
}
catch (Exception ex)
{ Trace.Write(ex.Message.ToString()); }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ps = Photoshop;
using Photoshop;
using Microsoft.Win32.SafeHandles;
using Microsoft.Win32;
using Microsoft;
namespace photoshop
{
public delegate void addBlur();
public class Class1 : ApplicationClass, ArtLayer, Document
{
public Class1()
{ }
public void addBlur()
{ }
public void addBlur1(string sa)
{ }
#region ArtLayer Members
public void AdjustBrightnessContrast(int Brightness, int Contrast)
{
throw new NotImplementedException();
}
public void AdjustColorBalance(object Shadows, object Midtones, object Highlights, object PreserveLuminosity)
{
throw new NotImplementedException();
}
public void AdjustCurves(object CurveShape)
{
throw new NotImplementedException();
}
public void AdjustLevels(int InputRangeStart, int InputRangeEnd, double InputRangeGamma, int OutputRangeStart, int OutputRangeEnd)
{
throw new NotImplementedException();
}
public bool AllLocked
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void ApplyAddNoise(double Amount, PsNoiseDistribution Distribution, bool Monochromatic)
{
throw new NotImplementedException();
}
public void ApplyAverage()
{
throw new NotImplementedException();
}
public void ApplyBlur()
{
// throw new NotImplementedException();
}
public void ApplyBlurMore()
{
throw new NotImplementedException();
}
//etc... these interfaces expose a ton of methods which can be explicity implemented
//this isn't them all
Related
I can download some files in a random page (a pdf from google, for example) but in the page I need to download them from, I get "Unsuccessful Download" notification on smartphone, with no exception thrown for me. Is there a way to know why this is happening?
Code from the renderer that I use to download below.
using Android.App;
using Android.Webkit;
using MPS.Libertas.Mobile.Droid.Renderers;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using Android.Content;
using Xamarin.Essentials;
using System.IO;
using System;
using Android.Widget;
using static Android.Provider.MediaStore;
[assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(MPS_MyWebViewRenderer))]
namespace MPS.Libertas.Mobile.Droid.Renderers
{
internal class MPS_MyWebViewRenderer : WebViewRenderer
{
public MPS_MyWebViewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
Control.Download += OnDownloadStart;
}
private void OnDownloadStart(object sender, Android.Webkit.DownloadEventArgs e)
{
try
{
var url = e.Url;
string url_formatted = url.Replace("blob:", "");
DownloadManager.Request request = new DownloadManager.Request(Android.Net.Uri.Parse(url_formatted));
request.AllowScanningByMediaScanner();
request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
request.SetMimeType("application/pdf");
// if this path is not create, we can create it.
string thmblibrary = FileSystem.AppDataDirectory + "/download";
if (!Directory.Exists(thmblibrary))
Directory.CreateDirectory(thmblibrary);
request.SetDestinationInExternalFilesDir(Android.App.Application.Context, FileSystem.AppDataDirectory, "download");
DownloadManager dm = (DownloadManager)Android.App.Application.Context.GetSystemService(Android.App.Application.DownloadService);
dm.Enqueue(request);
}
catch (System.Exception ex)
{
var message = ex.Message;
throw;
}
}
}
}
The script is to move to the next scene when the "new game" button is pressed. The sound effect plays, but it does not go to the next scene and I get this error :ArgumentNullException: Value cannot be null.
Parameter name: source. I know you have to type null, but I don't know where.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundManagerScript : MonoBehaviour
{
public static AudioClip clikSound;
static AudioSource audioScr;
// Start is called before the first frame update
void Start()
{
clikSound = Resources.Load<AudioClip> ("clik");
audioScr = GetComponent<AudioSource> ();
}
// Update is called once per frame
void Update()
{
}
public static void PlaySound(string clip)
{
switch (clip)
{
case "clik":
audioScr.PlayOneShot(clikSound);
break;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MeinMenu : MonoBehaviour
{
static AudioSource audioScr;
public void NewGame()
{
SoundManagerScript.PlaySound("clik");
DontDestroyOnLoad(audioScr.gameObject);
SceneManager.LoadScene("level 1");
}
public void LoadGame()
{
SceneManager.LoadScene(PlayerPrefs.GetInt("SavedScene"));
}
}
Possible mistake: The scenes in the build are not there.
Go to File > Build Settings
Drag and drop your scenes in your Scenes folder into the Scenes in Build.
I use Visual Studio 2005 to develop a "Windows Service" using c#.net. My code requires to access the MS office Clipboard. But on trying to access the Clipboard class, the debugger throws an error
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."
during the run-time. On checking for the solutions, I found that this could be solved by adding "[STAThread]" before the main method. But on adding this, I get a compilation error
"The type or namespace name 'STAThread' could not be found (are you missing a using directive or an assembly reference?)"
Is it possible to access the clipboard with my current version of .NET(.NET 3.0)?
The main method is in a file titled "program.cs" and the logic is in a file titled "Service.cs". Clipboard is used by Service.cs.
/* Program.cs */
using System.Collections.Generic;
using System.ServiceProcess;
using System.Text;
using System.Media;
using System.Threading;
namespace WindowsService1
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
#if DEBUG
Service1 serv = new Service1();
serv.onDebug();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#else
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new Service1() };
ServiceBase.Run(ServicesToRun);
#endif
}
}
}
/* Service.cs */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Timers;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
public void onDebug()
{
OnStart(null);
}
protected override void OnStart(string[] args)
{
clear_cb();
}
protected void clear_cb()
{
Clipboard.Clear(); // This is the line where I get the exception
}
protected override void OnStop()
{
// TODO: To clear the back up Database
}
}
}
I'm trying to understand how Caliburn.Micro works with Windows Phone (and MVVM in general) so I created a basic Windows Phone Application, installed Caliburn.Micro NuGet package (v1.2.0 - the latest for now) and followed the few instructions here and there. So, I ended up with:
WMAppManifest.xml
<DefaultTask Name ="_default" NavigationPage="Views/HomeView.xaml"/>
Framework/AppBootstrapper.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using Caliburn.Micro;
using MyCaliburn.PhoneUI.ViewModels;
namespace MyCaliburn.PhoneUI.Framework
{
public class AppBootstrapper : PhoneBootstrapper
{
PhoneContainer container;
protected override void Configure()
{
container = new PhoneContainer(RootFrame);
container.RegisterPhoneServices();
container.Singleton<HomeViewModel>();
}
protected override void OnUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
Debugger.Break();
e.Handled = true;
}
else
{
MessageBox.Show("An unexpected error occured, sorry about the troubles.", "Oops...", MessageBoxButton.OK);
e.Handled = true;
}
base.OnUnhandledException(sender, e);
}
protected override object GetInstance(Type service, string key)
{
return container.GetInstance(service, key);
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return container.GetAllInstances(service);
}
protected override void BuildUp(object instance)
{
container.BuildUp(instance);
}
}
}
ViewModels/HomeViewModel.cs
using Caliburn.Micro;
namespace MyCaliburn.PhoneUI.ViewModels
{
public class HomeViewModel : Screen
{
public HomeViewModel()
{
//DisplayName = "Home";
}
}
}
View/HomeView.xaml.cs (the XAML page is the default Window Phone Portrait Page)
using Microsoft.Phone.Controls;
namespace MyCaliburn.PhoneUI.Views
{
public partial class HomeView : PhoneApplicationPage
{
public HomeView()
{
InitializeComponent();
}
}
}
App.xaml
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyCaliburn.PhoneUI.App"
xmlns:Framework="clr-namespace:MyCaliburn.PhoneUI.Framework">
<!--Application Resources-->
<Application.Resources>
<Framework:AppBootstrapper x:Key="bootstrapper" />
</Application.Resources>
</Application>
App.xaml.cs
using System.Windows;
namespace MyCaliburn.PhoneUI
{
public partial class App : Application
{
/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Standard Silverlight initialization
InitializeComponent();
}
}
}
Now, when I hit F5, the application runs and exits without showing any page or exception and doesn't hit any breakpoints that I sit.
Can anyone tells me what's missing in my code which prevents the application from running?
Thanks in advance.
Many times when I end up with an app that does not start - it turns out that due to some refactoring the App class is not the startup object any more. Right-click on the project in solution explorer, go to properties/Application and make sure Startup object is set correctly.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
namespace WindowsPhoneApplication7
{
public partial class Listbox : UserControl
{
public Listbox()
{
InitializeComponent();
}
private void listbox(object sender, MouseEventArgs e)
{
this.NavigationService.Navigate(new Uri("/home.xaml", UriKind.Relative));
}
}
}
An error is occur .......
does not contain a definition for 'NavigationService' and no extension method 'NavigationService' accepting a first argument of type ' could be found (are you missing a using directive or an assembly reference?)
NavigationService is a property on the PhoneApplicationPage class. You are not deriving from that class, you are deriving from UserControl.
You need to get the parent phone page the user control is on and get the NavigationService reference from there.
Your compiler error is because it cannot locate a definition for NavigationService on the Listbox class you have made.
What Adam said is correct. But a easy solution is to define following static utility methods in App.xaml.cs
public static PhoneApplicationFrame CurrentRootVisual
{
get
{
return (App.Current.RootVisual as PhoneApplicationFrame);
}
}
public static bool Navigate(Uri source)
{
if (CurrentRootVisual != null)
return CurrentRootVisual.Navigate(source);
return false;
}
public static void GoBack()
{
if (CurrentRootVisual != null)
CurrentRootVisual.GoBack();
}
Then you can just do:
App.Navigate(yourNavigateUri)
or
App.GoBack()
From anywhere you like!
Dispatcher.BeginInvoke(() =>
NavigationService.Navigate(new Uri("/home.xaml", UriKind.Relative)));