|
@Ken-Guru I think I've found a way to get you somewhat there: this works for me in VS 2017 using .NET 4.7. I set the Form 'WindowState to 'Normal, and the 'StartPosition to 'Manual because ... those settings "worked."
I tried using the old P/Invokes ... FindWindow and IsWindowVisible ... to try to get the state of TaskBar visibility, but kept getting a 'visible result even when the TaskBar was hidden.
Hopefully, you can take it from here, and please do post any better technique you may come up with.
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Win32;
namespace MaxonTBarChange
{
public partial class Form1 : Form
{
public Rectangle AppBounds;
public Form1()
{
InitializeComponent();
AppBounds = Screen.PrimaryScreen.WorkingArea;
this.Bounds = AppBounds;
SystemEvents.UserPreferenceChanged += SystemEventsOnUserPreferenceChanged;
this.Closing += OnClosing;
}
private void OnClosing(object sender, CancelEventArgs e)
{
SystemEvents.UserPreferenceChanged -= SystemEventsOnUserPreferenceChanged;
}
private void SystemEventsOnUserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
{
var bnds = Screen.PrimaryScreen.WorkingArea;
if (AppBounds != bnds)
{
AppBounds = bnds;
this.Bounds = AppBounds;
}
}
}
}
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
modified 31-May-19 2:17am.
|
|
|
|
|
Can you send me dll code in how to download pdf file link in mail.
|
|
|
|
|
No.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The only code you get is the code YOU write.
We're not here to do your work for you.
modified 28-May-19 14:01pm.
|
|
|
|
|
Note: to use the code shown here, you must enable C# 8 preview in VS 2019; see: [^]
Good grief: infix notation for a 'switch that returns something; expression bodies; no use of 'default. I find the necessity to declare a new explicitly typed variable before using 'when tedious, but, thank the godz you can't use 'var !
int offset = '9' + '0';
public char EncodeChar(char ch)
{
return ch switch
{
Char c when Char.IsDigit(ch) =>
(char) (offset - ch),
Char c when Char.IsUpper(ch) =>
ch == 'Z' ? 'Y' : (char) (ch - 1),
Char c =>
ch == 'z' ? 'a' : (char) (ch + 1)
};
}
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
modified 3-Jun-19 8:03am.
|
|
|
|
|
It's ugly, isn't it?
I think they are trying to convert it into C++ myself - the recent additions don't seem to improve the language, just complicate the code and make it less readable.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Well, I experience it as weird, as potentially high risk in terms of code maintenance, but I wouldn't say "ugly." Wonder what Grady Booch ... "The function of good software is to make the complex appear to be simple." ... would think.
I find even weirder the use of an underscore character as a "finalizer" in 'switch, as in this example:
string Display(object o)
{
return o switch
{
Point p => $"({p.X}, {p.Y})",
_ => "unknown"
};
} source: [^]
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
As long as they don't take away the old way to do stuff, I don't give a pair of flyin' donkey testicles what kinda bullsh*t they add to the language.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
The problem is that the "new boys" will use the new stuff, even if the older way is more appropriate.
Which means that we will have to deal with it as maintenance in future...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm fairly close to retirement.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
OriginalGriff wrote: Which means that we will have to deal with it as maintenance in future... You mean rewrite it to resemble something that is remotely acceptable
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
"refactoring"
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Which is what is called if the CEO don't disagree. You still have to fix it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi there
i am using ASP.Core Razor pages and i want to get the number or count of visitors like 22 visitor has been visiting this webpage .
How is the idea of that !
i will be so glad for a help .
thanks
|
|
|
|
|
Each time one visits, increment a counter in your DB.
When you show the page, retrieve the current count, and show it ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi man
that is my query in DB SqlCommand command = new SqlCommand("select *from BranchSale_all WHERE bestellt_am > DATEADD (day, -3, GetDate())",connection);
using (SqlDataReader reader = command.ExecuteReader())
{
while(reader.Read())
{
BranchSales branch = new BranchSales();
branch.bestellt_am = Convert.ToDateTime(reader["bestellt_am"]);
branch.Anz_Versandbestätigt = Convert.ToInt16(reader["versandbestätigt"]);
elements.Add(branch);
}
return elements;
here should increment the counter ?!
|
|
|
|
|
Have you considered an UPDATE command?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
no . i just wanted to display data with some infos on razor page with counter of visitors the webpage
|
|
|
|
|
Then just make up a number ... like the Julian day + 42.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
This doesn't just automagically happen. Without saving each visit to a database, there's no way you'll be able to display it.
Here's another tidbit - the only person that cares about usage metrics are admins. Every-day users don't give a rat's ass about anything that doesn't directly affect their access to the web site.
So, this feature is for a very restricted/small set of users. If you're sure you really want to do this, plan ahead, and finger out and implement the mechanisms involved BEFORE coding the rest of the web site. I would recommend that you use the session ID so that you don't artificially add "connections" from the same user's session.
I had to do something similar recently, but for a single database that supports about 20 applications.
Lastly, you should have posted this in the Web developemnt forum instead of this one. It's too late now, but remember for the next question you'll inevitably have, to post it in the most appropriate forum.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I need to replace every 'a' char with 'b' char, every 'b' char with 'c' char and so on. I've tried to make this with if but code is very very long for every char. Exists a method how mo make this without if or switch or something like that?
This how i tried but i want a good method:
char[] chars = new char[inputString.Length];
for (int i = 0; i < inputString.Length; i++)
{
if (inputString[i] == 'a')
chars[i] = 'b';
else if (inputString[i] == 'b')
chars[i] = 'c';
else if (inputString[i] == 'c')
chars[i] = 'd';
else if (inputString[i] == 'd')
chars[i] = 'e';
else if (inputString[i] == 'e')
chars[i] = 'f';
else if (inputString[i] == 'f')
chars[i] = 'g';
else if (inputString[i] == 'g')
chars[i] = 'h';
else
{
chars[i] = inputString[i];
}
}
string outputString = new string(chars);
|
|
|
|
|
You can use the collating sequence of alphabetic and numeric characters to test whether they are in a certain range, and also to increment them to the next character, as follows:
string inputString = "The quick brown fox jumps over the lazy dog";
char[] chars = new char[inputString.Length];
for (int i = 0; i < inputString.Length; i++)
{
if (inputString[i] >= 'a' && inputString[i] < 'h')
chars[i] = (char)(inputString[i] + 1);
else
chars[i] = inputString[i];
}
Console.WriteLine(chars);
|
|
|
|
|
Richard's solution will work fine, but a better solution is to have two "translation arrays":
private const string transA = "abcdefghijklmnopqurstuvwxyz";
private const string transB = "bcdefghijklmnopqurstuvwxyza";
And then index them:
char[] chars = new char[inputString.Length];
for (int i = 0; i < inputString.Length; i++)
{
int index = transA.IndexOf(inputString[i]);
chars[i] = index >= 0 ? transB[index] : inputString[i];
}
string outputString = new string(chars);
That way, you aren't forced to use a "simple one character shift" on your Caesar Cipher - you can get more creative.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Richard's solution will work fine, but a better solution is to have two "translation arrays": WHAT?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|