I am creating a application that store basic database connection info like host,user, password and default database name in application settings using User Scope.
I am using .net 3.5 with Visual Studio 2008
I put 4 text boxes in a user control and bound their text property to the application settings individual properties.
//
// textBox_database
//
this.textBox_database.Location = new System.Drawing.Point(103, 101);
this.textBox_database.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_database.Name = "textBox_database";
this.textBox_database.Size = new System.Drawing.Size(255, 27);
this.textBox_database.TabIndex = 5;
this.textBox_database.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_database;
//
// textBox_password
//
this.textBox_password.Location = new System.Drawing.Point(103, 69);
this.textBox_password.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_password.Name = "textBox_password";
this.textBox_password.Size = new System.Drawing.Size(255, 27);
this.textBox_password.TabIndex = 4;
this.textBox_password.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_password;
this.textBox_password.UseSystemPasswordChar = true;
//
// textBox_user
//
this.textBox_user.Location = new System.Drawing.Point(103, 37);
this.textBox_user.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_user.Name = "textBox_user";
this.textBox_user.Size = new System.Drawing.Size(255, 27);
this.textBox_user.TabIndex = 7;
this.textBox_user.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_user;
//
// textBox_server
//
this.textBox_server.Location = new System.Drawing.Point(103, 5);
this.textBox_server.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_server.Name = "textBox_server";
this.textBox_server.Size = new System.Drawing.Size(255, 27);
this.textBox_server.TabIndex = 6;
this.textBox_server.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_server;
these text boxes will get user data from users to set their own database info. i have a button that saves the modified info back to the settings file
private void button_save_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Save();
}
but the design is not being saved. any help anyone?
regards,
Anjan
To Cyril: Yes i had the code to assign modified value in properties, but then even the scope was set to "User" it said readonly. So i removed the property assignment codes.
now i brought the code back and restarted VS, it works perfect now :D silly me, i should have try this old procedure before.
Thank you Cyril.
Hmm... I remember having the same problem a few months ago in one of my projects. Unfortunately I don't recall how I solved it.
Some checks...
Try setting the property scope to User in the Project Properties.
In the code you've listed I don't see where you set the property (only see you retrieving the property). Where have you set it?
Related
My reference is Presentations (Open XML SDK)
With the code-behind below I add the date on existing PowerPoint.
This code working and in the first slide the date is added, but it's possible customize the point on the page where to insert this date? The font and size ?
This is current output:
Thank you in advance for help.
string fileName = #"C:\\inetpub\\wwwroot\\aspnet\\Template\\01_FOCUS.pptx";
using (PresentationDocument oPDoc = PresentationDocument.Open(fileName, true))
{
PresentationPart oPPart = oPDoc.PresentationPart;
SlideIdList slideIdList = oPPart.Presentation.SlideIdList;
SlidePart sp = slideIdList.ChildElements
.Cast<SlideId>()
.Select(x => oPPart.GetPartById(x.RelationshipId))
.Cast<SlidePart>().First();
AddDateToSlidePart(sp);
}
public static void AddDateToSlidePart(SlidePart slidePart1)
{
Slide slide1 = slidePart1.Slide;
CommonSlideData commonSlideData1 = slide1.GetFirstChild<CommonSlideData>();
ShapeTree shapeTree1 = commonSlideData1.GetFirstChild<ShapeTree>();
DocumentFormat.OpenXml.Presentation.Shape shape1 =
new DocumentFormat.OpenXml.Presentation.Shape();
DocumentFormat.OpenXml.Presentation.NonVisualShapeProperties nonVisualShapeProperties1 =
new DocumentFormat.OpenXml.Presentation.NonVisualShapeProperties();
DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties nonVisualDrawingProperties1 =
new DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties() { Id = (UInt32Value)4U, Name = "Date Placeholder 3" };
DocumentFormat.OpenXml.Presentation.NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 =
new DocumentFormat.OpenXml.Presentation.NonVisualShapeDrawingProperties();
DocumentFormat.OpenXml.Drawing.ShapeLocks shapeLocks1 =
new DocumentFormat.OpenXml.Drawing.ShapeLocks() { NoGrouping = true };
nonVisualShapeDrawingProperties1.Append(shapeLocks1);
ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 =
new ApplicationNonVisualDrawingProperties();
PlaceholderShape placeholderShape1 =
new PlaceholderShape() { Type = PlaceholderValues.DateAndTime, Size = PlaceholderSizeValues.Half, Index = (UInt32Value)10U };
applicationNonVisualDrawingProperties1.Append(placeholderShape1);
nonVisualShapeProperties1.Append(nonVisualDrawingProperties1);
nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties1);
DocumentFormat.OpenXml.Presentation.ShapeProperties shapeProperties1 =
new DocumentFormat.OpenXml.Presentation.ShapeProperties();
DocumentFormat.OpenXml.Presentation.TextBody textBody1 =
new DocumentFormat.OpenXml.Presentation.TextBody();
DocumentFormat.OpenXml.Drawing.BodyProperties bodyProperties1 =
new DocumentFormat.OpenXml.Drawing.BodyProperties();
DocumentFormat.OpenXml.Drawing.ListStyle listStyle1 =
new DocumentFormat.OpenXml.Drawing.ListStyle();
DocumentFormat.OpenXml.Drawing.Paragraph paragraph1 =
new DocumentFormat.OpenXml.Drawing.Paragraph();
DocumentFormat.OpenXml.Drawing.Field field1 =
new DocumentFormat.OpenXml.Drawing.Field() { Id = "{528B97E8-8E4B-4D32-BA17-4F287283DFD6}", Type = "datetime1" };
DocumentFormat.OpenXml.Drawing.RunProperties runProperties1 =
new DocumentFormat.OpenXml.Drawing.RunProperties() { Language = "it-IT" };
DocumentFormat.OpenXml.Drawing.Text text1 =
new DocumentFormat.OpenXml.Drawing.Text();
text1.Text = DateTime.Now.ToString("dd/mm/yyyy");
field1.Append(runProperties1);
field1.Append(text1);
DocumentFormat.OpenXml.Drawing.EndParagraphRunProperties endParagraphRunProperties1 =
new DocumentFormat.OpenXml.Drawing.EndParagraphRunProperties() { Language = "it-IT" };
paragraph1.Append(field1);
paragraph1.Append(endParagraphRunProperties1);
textBody1.Append(bodyProperties1);
textBody1.Append(listStyle1);
textBody1.Append(paragraph1);
shape1.Append(nonVisualShapeProperties1);
shape1.Append(shapeProperties1);
shape1.Append(textBody1);
shapeTree1.Append(shape1);
}
The OpenXML SDK Productivity tool (downloadable from the Microsoft site) is your friend here. When I need to do something like this, I:
Create the document I want
Open it in the appropriate tool (PowerPoint in this case).
Make a tiny change (to "dirty" the document and make PowerPoint believe it needs to be changed).
Save the result
Make the changes to the document that I want to see, and save the result with a new name
Open the OpenXML Productivity Tool and click the "Compare Files" tool.
The reason I force a save (in steps 3/4) is so that PowerPoint can add all of it's PowerPoint-ness to the document I created. The second save (step 5) will necessarily have all of that, so I want the two documents as close as possible - with only the "changes to the document that I want to see" being the difference between the two documents.
At this point, you should see a path to a solution to your problem. That tool is indispensable when working with OOXML.
I have this C# code in Visual Studio 2013. It uses a third-party library but I don't know if that's a factor in this problem. The code builds and executes perfectly. But there's a variable in it that I can't examine in the debugger. Here's the entire routine . . .
private void AddGeometry()
{
var simplePositions = CreateRectShape(startPosition: new Point3D(0, 0, 0));
var simplePositionCollection = new Point3DCollection(simplePositions);
int size = simplePositionCollection.Count;
MainViewport.BeginInit();
MainViewport.Children.Clear();
var polyLineVisual3D = new Ab3d.Visuals.PolyLineVisual3D()
{
Positions = simplePositionCollection,
LineColor = Colors.DarkOrange,
LineThickness = 2,
Transform = new TranslateTransform3D(0, 0, 0)
};
MainViewport.Children.Add(polyLineVisual3D);
MainViewport.EndInit();
}
If I breakpoint at the Children.Add() statement and try to examine polyLineVisual3D or place a quickwatch on it, I get...
The name 'polyLineVisual3D' does not exist in the current context
... from Visual Studio. I have no trouble examining other local variables like simplePositions or simplePositionCollection at the same breakpoint.
I try to create a new EPT (project server 2013) using C# CSOM library.
But It has following error occurred.
"PJClientCallableException: EnterpriseProjectTypeInvalidCreatePDPUid"
Couple of article tell to change the "IsCreate=true". But it does not success for me. Here is the code what I have done.
public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
{
ProjectContext pwaContext = new ProjectContext(this.PWA_URL);
EnterpriseProjectTypeCreationInformation eptData = new EnterpriseProjectTypeCreationInformation();
eptData.Id = eptGuid;
eptData.Name = eptName;
eptData.Description = eptDescription;
eptData.IsDefault = false;
eptData.IsManaged = true;
eptData.WorkspaceTemplateName = "PROJECTSITE#0";
eptData.ProjectPlanTemplateId = Guid.Empty;
eptData.WorkflowAssociationId = Guid.Empty;
eptData.Order = 4;
List<ProjectDetailPageCreationInformation> projectDetailPages = new
List<ProjectDetailPageCreationInformation>() {
new ProjectDetailPageCreationInformation() {
Id = pwaContext.ProjectDetailPages[1].Id, IsCreate = true }
};
eptData.ProjectDetailPages = projectDetailPages;
pwaContext.Load(pwaContext.EnterpriseProjectTypes);
pwaContext.ExecuteQuery();
EnterpriseProjectType newEpt = pwaContext.EnterpriseProjectTypes.Add(eptData);
pwaContext.EnterpriseProjectTypes.Update();
pwaContext.ExecuteQuery();
}
Can anyone explain the issue or provide the working code part.
I would like to suggest the following:
Define an enterprise project type:
string basicEpt = "Enterprise Project"; // Basic enterprise project type.
int timeoutSeconds = 10; // The maximum wait time for a queue job, in seconds.
And then, when you create the new project, work like this:
ProjectCreationInformation newProj = new ProjectCreationInformation();
newProj.Id = Guid.NewGuid();
newProj.Name = "Project Name";
newProj.Description = "Test creating a project with CSOM";
newProj.Start = DateTime.Today.Date;
// Setting the EPT GUID is optional. If no EPT is specified, Project Server
// uses the default EPT.
newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt);
PublishedProject newPublishedProj = projContext.Projects.Add(newProj);
QueueJob qJob = projContext.Projects.Update();
// Calling Load and ExecuteQuery for the queue job is optional.
// projContext.Load(qJob);
// projContext.ExecuteQuery();
JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);
When the last line of that piece of code ends, the project must be created and published in order to define tasks or whatever.
I don't know what is happening to your code, seems great.
Hope it helps to you,
How can i change the proxy settings in Awesomium (c#)?
i've this simple code for now
Awesomium.Windows.Forms.WebControl browser =
new Awesomium.Windows.Forms.WebControl();
browser = new Awesomium.Windows.Forms.WebControl();
browser.Paint += browser_Paint;
browser.Location = new System.Drawing.Point(1, 1);
browser.Name = "webControl";
browser.Size = new System.Drawing.Size(1024, 768);
browser.Source = new System.Uri("http://checkip.dyndns.com/", System.UriKind.Absolute);
browser.TabIndex = 0;
WebPreferences prefs = new WebPreferences(){ ProxyConfig = "xxx.xxx.xxx.xxx:port" }
session = WebCore.CreateWebSession(prefs);
browser.WebSession = session;
browser.Source = new System.Uri("http://checkip.dyndns.com/", System.UriKind.Absolute);
check this answer for more details
You can set the proxy configuration on the WebCore that governs all of your webcontrols. Have a look at the WebCoreConfig.ProxyServer Property.
You need to create a WebCoreConfig object and then use it during WebCore construction.
Take a look at the WebCore API.
You need to add a WebSessionProvider control from the Toolbox to your form. Then set your Webcontrol's WebSessionProvider property to the one you just added.
Then, go (always in designer view) to the newly added WebSessionProvider's properties and expand the Preferences one: you will then find a ProxyConfig value to be filled with whatever proxy configuration you want to use.
Can anyone point me to an example of how to programatically create a statechart in visio?
I can create blank pages, drop shapes, open template etc, but when I try to add transitions it complains that the page is not the right type.
Can't find a sample anywhere.
Alternatively: I can save the user actions to create the chart as a macro. Can I run that programatically?
Thanks.
< edit >
Step away from the PC for 2 minutes and you realise you should have put the code snippet in the question and not try to put it in comments. Forest: meet trees...
Visio.Document umlStencil = visioApp.Documents.OpenEx(#"UMLSTA_M.vss", (short)VisOpenSaveArgs.visOpenDocked);
Visio.Page page = visioDoc.Pages.Add();
Visio.Shape s1 = page.Drop(umlStencil[#"State"], 5.0, 5.0);
Visio.Shape s2 = page.Drop(umlStencil[#"State"], 5.0, 5.0);
Visio.Shape transition = page.Drop(umlStencil[#"Transition"], 1.0, 1.0);
As you can see, pretty similar to the snippet in the answer below.
< / edit >
This is the code that I ran with Visual Studio 2010 against both Visio 2007 and Visio 2010.
var visioApp = new Visio.Application();
// Load the UML Statechart stencil (docked)
var stencil_open_flags = Visio.VisOpenSaveArgs.visOpenDocked;
var umlStencil = visioApp.Documents.OpenEx(#"UMLSTA_M.vss", (short)stencil_open_flags);
// create a new empty doc based on the UML Model Template
var doc = visioApp.Documents.AddEx("UMLMOD_U.VST", Visio.VisMeasurementSystem.visMSUS, 0, 0);
var page = doc.Pages.Add();
// Find and manually change the diagram's title
var watermark = page.Shapes["Watermark Title"];
var LockTextEdit_cell = watermark.CellsU["LockTextEdit"];
LockTextEdit_cell.FormulaForceU = "GUARD(0)";
watermark.Text = "MyTitle";
LockTextEdit_cell.FormulaForceU = "GUARD(1)";
// Find the masters we need
var state_master = umlStencil.Masters["State"];
var transition_master = umlStencil.Masters["Transition"];
// Drop the masters into the page
var s1 = page.Drop(state_master, 5.0, 5.0);
var s2 = page.Drop(state_master, 1.0, 1.0);
var transition = page.Drop(transition_master, 3.0, 3.0);