|
I am trying to automate conversion of powerpoint files to html. I have developed this as a windows service and here is the conversion code:
<br />
...<br />
PowerPoint.Application ppApp = new PowerPoint.Application(); <br />
PowerPoint.Presentation prsPres = <br />
ppApp.Presentations.Open(targetFile, Microsoft.Office.Core.MsoTriState.msoTrue, <br />
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);<br />
string testStr = prsPres.Name;<br />
string fileHTM = filePath.Replace(".ppt", ".html");<br />
prsPres.SaveCopyAs(fileHTM, PowerPoint.PpSaveAsFileType.ppSaveAsHTML, Microsoft.Office.Core.MsoTriState.msoTrue);<br />
prsPres.Close();<br />
ppApp.Quit();<br />
...<br />
The problem is that if i am not the original author of the application, the application will ask me for a confirmation to save changes as revisions.
Is there a way to disable revisions programatically since this application is running as a service.
|
|
|
|
|
You'll be lucky if someone here has some experience with this. This place is specifically for C#. Although you are using C# lang its still a PPT question.
My suggestion is to post at MS newsgroups
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
hi every 1,
i'm trying to do some program that drow a clock like the pressure clock : three colors red for danger, yellow for miduim danger and green for no danger. i'll read three values from an excell sheet : 1- danger level 2- target
3- actual level.
these values will help me to drow the clock and the actual value will be pointed on the graph using an arrow..
can any 1 give me a hint of what can be done in here ????
thanx inadvanced
|
|
|
|
|
This is straight forward painting problem. First you have to create a design. Do you want something elaborate or something simple?
Next step is to use System.Drawing namespace and Graphics object to do FillRectangle, DrawLine and so forth. If you have something more complex you might want to use DrawImage. See MSDN for more information
Do you have a more specific question?
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
hi thanx 4 ur help here is my code :
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace mesure
{
///
/// Summary description for Form1.
///
///
public class Form1 : System.Windows.Forms.Form
{
Graphics g ;
int x=0;
/*SolidBrush b1 = new SolidBrush(Color.Red);
Pen p1 = new Pen(b1,5);
SolidBrush b2 = new SolidBrush(Color.Green);
Pen p2 = new Pen(b2,5);
SolidBrush b3 = new SolidBrush(Color.Yellow);
Pen p3 = new Pen(b3,5);
SolidBrush b4 = new SolidBrush(Color.Black);
Pen p4 = new Pen(b4,2);*/
Rectangle rect1 = new Rectangle(15,35,100,100);
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox Green;
private System.Windows.Forms.TextBox Red;
///
/// Required designer variable.
///
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.Green = new System.Windows.Forms.TextBox();
this.Red = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 296);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(128, 248);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 168);
this.label1.Name = "label1";
this.label1.TabIndex = 2;
this.label1.Text = "Red Value";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 200);
this.label2.Name = "label2";
this.label2.TabIndex = 3;
this.label2.Text = "Green Value";
//
// Green
//
this.Green.Location = new System.Drawing.Point(136, 200);
this.Green.Name = "Green";
this.Green.TabIndex = 5;
this.Green.Text = "";
//
// Red
//
this.Red.Location = new System.Drawing.Point(136, 168);
this.Red.Name = "Red";
this.Red.TabIndex = 7;
this.Red.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 326);
this.Controls.Add(this.Red);
this.Controls.Add(this.Green);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
double pi = 22.0 / 7.0;
double a = 50*Math.Cos(x*pi/10);
double b = 50*Math.Sin(x*pi/10);
int red = int.Parse(Red.Text.ToString());
int green = int.Parse(Green.Text.ToString());
x = int.Parse( textBox1.Text.ToString());
float x1 = 64+float.Parse(a.ToString()) ;
float y1 = 85-float.Parse(b.ToString());
g.FillPie(new SolidBrush(Color.Red),rect1,-(180-((18*red)+(18*green))),18*red);
g.FillPie(new SolidBrush(Color.Green),rect1,180,(18*green));
g.FillPie(new SolidBrush(Color.Yellow),rect1,(-18*red),-(180-((18*red)+(18*green))));
g.DrawLine(new Pen(Color.Black,2),x1,y1,64,85);
// drowPie();
}
private void Form1_Load(object sender, System.EventArgs e)
{
g = this.CreateGraphics();
drowPie();
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// drowPie();
}
private void drowPie()
{
}
}
}
the problem is how to get the data from an excell sheet not from the text box's like i did.
any thing will help to update this code
help is realy need.
|
|
|
|
|
You shouldn't create a new Graphics object to do painting. You need to go with the standard way of painting and that is... either override the OnPaint of a control or handle the Paint event. It looks like you started something in the Form's Paint event handler I dont now why you dropped that
Getting data from excell is a different question. I dont have time for a detailed answer so I suggest you search the forum and google.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Q: I have an app which reads in an XML doc of services to start up when they go down.
I see that the ServiceController class has the method WaitForStatus, and it can take a TimeSpan param.
If the service has not started , the method throws the TimeoutException exception.
If I have the method inside of a TRY-CATCH-FINALLY block, does that mean that code execution will stop untill either the service starts up or the time expires? Or will the code proceed to the FINALLY block if there is no error before the TimeSpan expires?
thanks,
sprout
|
|
|
|
|
If an exception is not thrown your try block will be executed sequentially until finished, then the finally block is executed. If an exception is thrown, the appropriate catch block is executed, then the finally block is executed.
The finally is always executed except when you terminate the CLR using Environment.Exit .
See the C# language specification in the VS.NET product documentation or online at http://msdn.microsoft.com/library[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you for the reply!
So that means that even if the method WaitForStatus has a time span of say 3 minutes, the code in the try block will not execute the FINALLY block untill the either the servie has started successfully or the time has expired and then the exception is throw, which is handled in the CATCH?
So the program will pause until the the service starts or an exception is thrown?
Thanks for all the help!!
|
|
|
|
|
|
Hi,
I've a FTP server, which is a Unix box, and here are some 100s of log files reside.
Also, I'm trying to develope an application in C# where at one point i need these log files to be copied to the developement machine [which on the later date going to be small App Server, anyways,].
Now, my problem is these log files are going to be updated daily and I need to analyze them on daily basis. It would be awesome if I could just write a small program in C# which will just transfer these files on the developemtn machine on the back-ground.
Although I think .net remoting or .net's System.net might be usefull I have no idea about that.
I would really apreciate if you could tell me 2 things...
1) If it is at all possible [withought user intervention, coz path and file name convesion n everything is all fixed, and its not going to change]
2) If it is possible, I would appreciate if i could get a little push towards the right direction
thanks
|
|
|
|
|
There is no direct support for FTP in the .NET BCL (base class library), but there is for network copying and downloading via HTTP. This means you could use Samba or Apache (or any other HTTP daemon), respectively, with much better results. FTP is insecure. It base64-encodes your passwords, which is not strong encryption (all you need to do is base64-decode it).
If you want to stick with FTP, however, just search this site for "FTP" using the search box under the logo. There are several good articles on FTP using managed code (C#, VB.NET, and perhaps some Managed C++). There are also class libraries available for free and commercially, like that from Xceed[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
thanks, but since server is an inter-network machine I'm not too worried about the security part, and also there r few other reasons, but ayways, I would really like to stick to FTP.
|
|
|
|
|
Overlooking internal security is a big mistake. Attacks can come from within, as well, and it does happen.
If you want to use FTP you will either need to implement it yourself or use a free or commercial library.
My other suggestions are still viable.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Can somebody tell me how can i use the modem port to build a 'Phone Dailer' program.
I cann't understend how to use the modem port in c# to dial a call and recive a call.
Alex
|
|
|
|
|
Click "Search comments" directly above this message board and search for "TAPI". You can also search the Internet for "C# TAPI" for relevant articles (some of which should be on this site as well).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I know there must be a better way to do this. I have a project that references another project. The second project needs to access the first projects app.config file. I could do this just by calling the file by name and accessing it as an XML file but before I go and do all that is there a better way out there somewhere that I just haven't found???
-Richard
|
|
|
|
|
|
Hey Nick, thanks for the reply but at a quick glance it looked like your manager only handled the current projects config file? Even if I missed the way to access another config file it really ends up being more code than I want to add. If I just open the xml document it will only take like 5 lines of code. I was really just interested in seeing if I had missed some .Net method along the way that would be easier or faster
-Richard
|
|
|
|
|
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml.Xsl;
using System.Xml;
namespace PDM.excel
{
///
/// Summary description for WebForm3.
///
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
public SqlConnection conDB = new SqlConnection();
static public string[] LanguageStr =
{
"English","French","Spanish"};
static public string[] DropDownListStr =
{
"Language_DropDownList"};
protected System.Web.UI.WebControls.DropDownList Language_DropDownList;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
static public string[][] AddStrArray =
{
LanguageStr};
private void Fill_DropDownList()
{
for (int i = 0; i < DropDownListStr.Length; i++)
{
string CtrlName= DropDownListStr[i];
DropDownList MyList = (DropDownList)Page.FindControl(CtrlName);
// Populate all the checkboxes
string[] ToPopulate = AddStrArray[i];
for (int j = 0; j < ToPopulate.Length; j++)
{
MyList.Items.Add(new ListItem(ToPopulate[j], j.ToString()));
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
Fill_DropDownList();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Language_DropDownList.SelectedIndexChanged += new System.EventHandler(this.Language_DropDownList_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public DataSet DataToExcel = new DataSet();
public void BindGrid (int index)
{
conDB.ConnectionString = "data source=10.195.17.7;database=devnew;uid=bounaajak;pwd=ehsfirst;packet size=4096";
SqlDataAdapter da = new SqlDataAdapter("Select string_id, string from pdm_translations where language_id = 1 and string_id not in (select string_id from pdm_translations where language_id = " + index.ToString() + ") ", conDB);
da.Fill(DataToExcel, "DataToExcel");
Session["Tabla"] = Language_DropDownList.SelectedItem.Text;
DataToExcel.WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
DataGrid1.DataSource = DataToExcel;
DataGrid1.DataBind();
// Get row count
int nRowCount = DataToExcel.Tables["DataToExcel"].Rows.Count;
// Store Row count in Session variable
Session["RowCount"] = nRowCount;
}
private void Language_DropDownList_SelectedIndexChanged(object sender, System.EventArgs e)
{
int getSelectedIndex = Language_DropDownList.SelectedIndex+1;
BindGrid(getSelectedIndex);
}
public void DataGridToExcel(DataGrid Export,HttpResponse Response)
{
// Set the Response mime type for excel
Response.ContentType = "application/vnd.ms-excel";
// Create a String Writer
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
private void Button1_Click(object sender, System.EventArgs e)
{
DataGridToExcel (DataGrid1, Response);
}
}
}
|
|
|
|
|
This question belongs in the ASP.NET[^] forum.
|
|
|
|
|
Hi, iv got a program which has a networkstream for exchangin messages between a server and client......
The problem i had was that the client needs to keep checking the data stream for new messages sent from the server......as im no expert i originally implemented a endless while loop which checked for data in the incoming data buffer but obviously this caused my computer to crash with the number of checks it was doing..........
so i found out about the BeginRead() method which allowed me to create a seperate execution thread using a delegate and callback method......so then i could re call the beginRead() with in the thread so it continously read in formation from the stream............
Now, i dont think i understand how to implement them, as it seems to work one time round and then crashes, or reads data into the buffer that looks like \0\0\0\0\0\0\0\0\0\0\0 (what eva that means)..........i think i need some one to shed some light on these methods so i can get it to work??
cheers
sorry for the long message....
mike
|
|
|
|
|
mikeyhardingboyo wrote:
i originally implemented a endless while loop which checked for data in the incoming data buffer but obviously this caused my computer to crash with the number of checks it was doing
That's hardly obvious. I've done a lot of checks in programs and they've never crashed the app or the computer. So have many other developers. It's what applications do.
Understand that when you use BeginRead a read is started on another thread. The read itself is a blocking call. It does not return until there's data to actually read. If you keep calling BeginRead and there's never any data, then you've got many threads piling up, wasting memory, and doing nothing. Now all of a sudden when data arrives you've got a race condition.
Never use asynchronous Begin* methods without ever calling their corresponding End* functions. The mess you got into is the mess that will happen when you don't use asynchronous methods correctly.
If you want to know if data is available for a NetworkStream , check the NetworkStream.DataAvailable property. If you had checked the documentation - especially important if you're new to .NET development - you should've noticed this obviously named method.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I do use the DataAvailable property. My point is that when i initially call BeginRead() from my main thread, there is always data to read....thus is returns and allows the main thread to continue....
Thus in the seperate thread that the initial BeginRead call created I want it to block in that thread if there is no data to read, until data becomes available.....
Thus I have to have a form of iteration where the BeginRead() is called in the seperate thread so it can continue to check for data as long as the program is running.
As the seperate thread is executed i do call the EndRead() on each result of a BeginRead() call.
The method that the seperate thread executes looks like this...so are you telling me this is not possible?
public void myReadCallBack(IAsyncResult result)
{
NetworkStream str = (NetworkStream) result.AsyncState;
byte[] myReadBuffer = new byte[2048];
int numberOfBytesRead = 0;
numberOfBytesRead = str.EndRead(result);
myCompleteMessage = String.Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
TokenizeCommands(myCompleteMessage);
myCompleteMessage = "";
stream.BeginRead(myReadBuffer, 0, myReadBuffer.Length, new AsyncCallback(myReadCallBack),stream);
}
mike
|
|
|
|
|
I'm not sure I follow you completely. All you need to do is use BeginRead once while your main thread of execution continues (to update an animated "wait" graphics or something). In your AsyncCallback you call EndRead as you're doing and you've call the data.
Take a look in the .NET Framework SDK documentation at the NetworkStream.BeginRead and EndRead methods. The two together form a complete solution (i.e., a callback is created in the docs for BeginRead that is defined in the example for EndRead ). What you have is similar, but the examples - and the documentation itself - may help you discover what the problem is.
Otherwise, please post your complete solution (minus any code that actually acts on the data or updates a UI, etc., for brevity's sake).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|