Rounding corner using GrapicMagick using convert only
Is it possible to add round corner to an existing image using convert only.
-compose and -mask seems to require the mask file prepared in advance.
Wednesday, 11 September 2013
Delphi XE4 - get your local IP in statusbar
Delphi XE4 - get your local IP in statusbar
Seen most of the examples posted here but none seem to work on XE4. I am
trying to display my IP in the status bar.
AdvOfficeStatusBar1.Panels[0].Text := GetIP;
Functions I have seen here mostly fail on xe4 as they were written in
older delphi versions.I would like to get just the local IP,not the one
behind the router. Well, for the sake of learning, it would be usefull to
know that one too...:)
Seen most of the examples posted here but none seem to work on XE4. I am
trying to display my IP in the status bar.
AdvOfficeStatusBar1.Panels[0].Text := GetIP;
Functions I have seen here mostly fail on xe4 as they were written in
older delphi versions.I would like to get just the local IP,not the one
behind the router. Well, for the sake of learning, it would be usefull to
know that one too...:)
c# convert class to query string
c# convert class to query string
Im trying to convert a few classes/objects in my application to a query
string for example:
public class LoginRequest : BaseRequest
{
public string username { get; set; }
public string password { get; set; }
public otherclass d { get; set; }
}
public class otherclass
{
public string a { get; set; }
public string b { get; set; }
}
would then become:
username=test&password=p&a=123&b=123
Which i am achieving with the following function
private string ObjectToQueryString<T>(T obj) where T: class {
StringBuilder sb = new StringBuilder();
Type t = obj.GetType();
var properties = t.GetProperties();
foreach (PropertyInfo p in properties)
{
if (p.CanRead)
{
var indexes = p.GetIndexParameters();
if (indexes.Count() > 0)
{
var pp = p.GetValue(obj, new object[] { 1 });
sb.Append(ObjectToQueryString(pp));
}
else
{
//I dont think this is a good way to do it
if (p.PropertyType.FullName != p.GetValue(obj,
null).ToString())
{
sb.Append(String.Format("{0}={1}&", p.Name,
HttpUtility.UrlEncode(p.GetValue(obj,
null).ToString())));
}
else
{
sb.Append(ObjectToQueryString(p.GetValue(obj, null)));
}
}
}
}
return sb.ToString().TrimEnd('&');
}
but If I pass a list into the function it will also include the Count and
Capacity properties and other thing I dont want. Say its a list of
List<otherclass>()
Cheers
Im trying to convert a few classes/objects in my application to a query
string for example:
public class LoginRequest : BaseRequest
{
public string username { get; set; }
public string password { get; set; }
public otherclass d { get; set; }
}
public class otherclass
{
public string a { get; set; }
public string b { get; set; }
}
would then become:
username=test&password=p&a=123&b=123
Which i am achieving with the following function
private string ObjectToQueryString<T>(T obj) where T: class {
StringBuilder sb = new StringBuilder();
Type t = obj.GetType();
var properties = t.GetProperties();
foreach (PropertyInfo p in properties)
{
if (p.CanRead)
{
var indexes = p.GetIndexParameters();
if (indexes.Count() > 0)
{
var pp = p.GetValue(obj, new object[] { 1 });
sb.Append(ObjectToQueryString(pp));
}
else
{
//I dont think this is a good way to do it
if (p.PropertyType.FullName != p.GetValue(obj,
null).ToString())
{
sb.Append(String.Format("{0}={1}&", p.Name,
HttpUtility.UrlEncode(p.GetValue(obj,
null).ToString())));
}
else
{
sb.Append(ObjectToQueryString(p.GetValue(obj, null)));
}
}
}
}
return sb.ToString().TrimEnd('&');
}
but If I pass a list into the function it will also include the Count and
Capacity properties and other thing I dont want. Say its a list of
List<otherclass>()
Cheers
Why is the compositionComplete event not called in durandaljs
Why is the compositionComplete event not called in durandaljs
Thats my sample project (8,3 MB) Visual Studio 2012 solution:
sample project zipped
My problem:
module step2 and its compositionComplete event is NOT called! module step1
is and the same event works fine!
This way you can reproduce the problem:
1.) start app
2.) click the 'Browse schoolyears' button
3.) click the 'create' button
4.) Wizard step1 is visible and its compositionComplete event is called
5.) click the 'next' button
6.) Wizard step2 is visible and its compositionComplete event is NOT called
I am posting here the important stuff only and these are 5 modules.
The SchoolyearDialog module is composed of the SchoolyearBrowser and
SchoolyearWizard module. Both modules are switched with the 'compose:
activeScreen' binding.
When the SchoolyearWizard is loaded and the user clicked the next step
button to load step2 then here is the problem see number 6.) above.
SchoolyearDialog
define(['durandal/app','plugins/dialog', 'knockout',
'services/dataservice', 'plugins/router', 'moment'], function (app,
dialog, ko, dataservice, router, moment) {
var SchoolyearDialog = function () {
var self = this;
self.activeScreen = ko.observable('viewmodels/SchoolyearBrowser');
// set the schoolyear browser as default module
app.on('activateStep1').then(function (obj) {
self.activeScreen(obj.moduleId);
});
app.on('activateStep2').then(function (obj) {
self.activeScreen(obj.moduleId);
});
app.on('dialog:close').then(function (options) {
dialog.close(self, options );
});
self.closeDialog = function () {
dialog.close(self, { isSuccess: false });
}
}
SchoolyearDialog.show = function () {
return dialog.show(new SchoolyearDialog());
};
return SchoolyearDialog;
});
SchoolyearBrowser
define(['durandal/app', 'plugins/dialog', 'knockout',
'services/dataservice', 'plugins/router', 'moment'],
function (app, dialog, ko, dataservice, router, moment) {
var SchoolyearBrowser = function () {
var self = this;
self.create = function () {
app.trigger('activateStep1', {
moduleId: 'viewmodels/SchoolyearWizard',
viewMode: 'create'
});
}
self.open = function () {
// do not open the wizard
}
self.compositionComplete = function (view) {
debugger;
}
};
return SchoolyearBrowser;
});
SchoolyearWizard
define(['durandal/activator', 'viewmodels/step1', 'viewmodels/step2',
'knockout', 'plugins/dialog','durandal/app'], function (activator, Step1,
Step2, ko, dialog, app) {
var steps = [new Step1(), new Step2()];
var step = ko.observable(0); // Start with first step
var activeStep = activator.create();
var stepsLength = steps.length;
var hasPrevious = ko.computed(function () {
return step() > 0;
});
var caption = ko.computed(function () {
if (step() === stepsLength - 1) {
return 'save';
}
else if (step() < stepsLength) {
return 'next';
}
});
activeStep(steps[step()]);
var hasNext = ko.computed(function () {
if ((step() === stepsLength - 1) && activeStep().isValid()) {
// save
return true;
} else if ((step() < stepsLength - 1) && activeStep().isValid()) {
return true;
}
});
return {
showCodeUrl: true,
steps: steps,
step: step,
activeStep: activeStep,
next: next,
caption: caption,
previous: previous,
hasPrevious: hasPrevious,
hasNext: hasNext
};
function isLastStep() {
return step() === stepsLength - 1;
}
function next() {
if (isLastStep()) {
// Corrects the button caption when the user re-visits the wizard
step(step() - 1);
// Resets the wizard init page to the first step when the user
re-visits the wizard
activeStep(steps[0]);
debugger;
// save;
}
else if (step() < stepsLength) {
step(step() + 1);
activeStep(steps[step()]);
debugger;
//app.trigger('activateStep2', {
// moduleId: 'viewmodels/step2'
//});
}
}
function previous() {
if (step() > 0) {
step(step() - 1);
activeStep(steps[step()]);
}
}
});
Step1
define(function () {
return function () {
var self = this;
self.isValid = function () {
return true;
}
self.name = 'step1';
self.compositionComplete = function (view) {
debugger;
}
};
});
Step2
define(function () {
return function () {
this.isValid = function () {
return true;
}
this.name = 'step2';
self.compositionComplete = function (view) {
// I never get here WHY ???
}
};
});
Thats my sample project (8,3 MB) Visual Studio 2012 solution:
sample project zipped
My problem:
module step2 and its compositionComplete event is NOT called! module step1
is and the same event works fine!
This way you can reproduce the problem:
1.) start app
2.) click the 'Browse schoolyears' button
3.) click the 'create' button
4.) Wizard step1 is visible and its compositionComplete event is called
5.) click the 'next' button
6.) Wizard step2 is visible and its compositionComplete event is NOT called
I am posting here the important stuff only and these are 5 modules.
The SchoolyearDialog module is composed of the SchoolyearBrowser and
SchoolyearWizard module. Both modules are switched with the 'compose:
activeScreen' binding.
When the SchoolyearWizard is loaded and the user clicked the next step
button to load step2 then here is the problem see number 6.) above.
SchoolyearDialog
define(['durandal/app','plugins/dialog', 'knockout',
'services/dataservice', 'plugins/router', 'moment'], function (app,
dialog, ko, dataservice, router, moment) {
var SchoolyearDialog = function () {
var self = this;
self.activeScreen = ko.observable('viewmodels/SchoolyearBrowser');
// set the schoolyear browser as default module
app.on('activateStep1').then(function (obj) {
self.activeScreen(obj.moduleId);
});
app.on('activateStep2').then(function (obj) {
self.activeScreen(obj.moduleId);
});
app.on('dialog:close').then(function (options) {
dialog.close(self, options );
});
self.closeDialog = function () {
dialog.close(self, { isSuccess: false });
}
}
SchoolyearDialog.show = function () {
return dialog.show(new SchoolyearDialog());
};
return SchoolyearDialog;
});
SchoolyearBrowser
define(['durandal/app', 'plugins/dialog', 'knockout',
'services/dataservice', 'plugins/router', 'moment'],
function (app, dialog, ko, dataservice, router, moment) {
var SchoolyearBrowser = function () {
var self = this;
self.create = function () {
app.trigger('activateStep1', {
moduleId: 'viewmodels/SchoolyearWizard',
viewMode: 'create'
});
}
self.open = function () {
// do not open the wizard
}
self.compositionComplete = function (view) {
debugger;
}
};
return SchoolyearBrowser;
});
SchoolyearWizard
define(['durandal/activator', 'viewmodels/step1', 'viewmodels/step2',
'knockout', 'plugins/dialog','durandal/app'], function (activator, Step1,
Step2, ko, dialog, app) {
var steps = [new Step1(), new Step2()];
var step = ko.observable(0); // Start with first step
var activeStep = activator.create();
var stepsLength = steps.length;
var hasPrevious = ko.computed(function () {
return step() > 0;
});
var caption = ko.computed(function () {
if (step() === stepsLength - 1) {
return 'save';
}
else if (step() < stepsLength) {
return 'next';
}
});
activeStep(steps[step()]);
var hasNext = ko.computed(function () {
if ((step() === stepsLength - 1) && activeStep().isValid()) {
// save
return true;
} else if ((step() < stepsLength - 1) && activeStep().isValid()) {
return true;
}
});
return {
showCodeUrl: true,
steps: steps,
step: step,
activeStep: activeStep,
next: next,
caption: caption,
previous: previous,
hasPrevious: hasPrevious,
hasNext: hasNext
};
function isLastStep() {
return step() === stepsLength - 1;
}
function next() {
if (isLastStep()) {
// Corrects the button caption when the user re-visits the wizard
step(step() - 1);
// Resets the wizard init page to the first step when the user
re-visits the wizard
activeStep(steps[0]);
debugger;
// save;
}
else if (step() < stepsLength) {
step(step() + 1);
activeStep(steps[step()]);
debugger;
//app.trigger('activateStep2', {
// moduleId: 'viewmodels/step2'
//});
}
}
function previous() {
if (step() > 0) {
step(step() - 1);
activeStep(steps[step()]);
}
}
});
Step1
define(function () {
return function () {
var self = this;
self.isValid = function () {
return true;
}
self.name = 'step1';
self.compositionComplete = function (view) {
debugger;
}
};
});
Step2
define(function () {
return function () {
this.isValid = function () {
return true;
}
this.name = 'step2';
self.compositionComplete = function (view) {
// I never get here WHY ???
}
};
});
No output in EShell
No output in EShell
test.js:
console.log('Hello world!');
process.exit(0);
I run in EShell (Emacs shell) in Emacs 24.2.1 on Windows XP:
node test.js
Output: nothing
Expected output: Hello world!
Is there a fix? (without changing test.js, of course, because that's just
a test case)
test.js:
console.log('Hello world!');
process.exit(0);
I run in EShell (Emacs shell) in Emacs 24.2.1 on Windows XP:
node test.js
Output: nothing
Expected output: Hello world!
Is there a fix? (without changing test.js, of course, because that's just
a test case)
Combining two double[] arrays into double[,]
Combining two double[] arrays into double[,]
I frequently have two arrays that I need to combine to one matrix (same
lenght and type). I was wondering whether there is a linq way that is more
elegant than:
var result = new double[dt.Count, 2];
for (int i = 0; i < dt.Count; i++)
{
result[i, 0] = dts[i];
result[i, 1] = dt[i];
}
I tried
var result = dts.zip(dt, (a,b) => new{a,b})
and:
var result = dts.Concat(dt).ToArray()
But neither do what I would like to do...
I frequently have two arrays that I need to combine to one matrix (same
lenght and type). I was wondering whether there is a linq way that is more
elegant than:
var result = new double[dt.Count, 2];
for (int i = 0; i < dt.Count; i++)
{
result[i, 0] = dts[i];
result[i, 1] = dt[i];
}
I tried
var result = dts.zip(dt, (a,b) => new{a,b})
and:
var result = dts.Concat(dt).ToArray()
But neither do what I would like to do...
Tuesday, 10 September 2013
How can i move a file with existing one
How can i move a file with existing one
How can i move a file one path to another path. I don't want to copy that
file. in the condition of copying the file it is working fine for me.But i
want to move that file don't want to copy that file. it should be move
from one path to another path and overwrite the existing one.
Please help me out.
How can i move a file one path to another path. I don't want to copy that
file. in the condition of copying the file it is working fine for me.But i
want to move that file don't want to copy that file. it should be move
from one path to another path and overwrite the existing one.
Please help me out.
Subscribe to:
Posts (Atom)