本文整理汇总了C#中MainWindow.OpenSaveDialog方法的典型用法代码示例。如果您正苦于以下问题:C# MainWindow.OpenSaveDialog方法的具体用法?C# MainWindow.OpenSaveDialog怎么用?C# MainWindow.OpenSaveDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWindow
的用法示例。
在下文中一共展示了MainWindow.OpenSaveDialog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveNewQuery
public void SaveNewQuery(CloseableTabItem tabItem, SelectQueryBuilder QueryBulder)
{
string messageBoxText = "Do you want to save current query?";
string caption = "Current Query";
MessageBoxButton button = MessageBoxButton.YesNoCancel;
MessageBoxImage icon = MessageBoxImage.Question;
MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon);
switch (result)
{
case MessageBoxResult.Yes:
// User pressed Yes button
//save save query
ResultViewModel rv = (ResultViewModel)this.result;
string FileName1 = System.String.Empty;
if (rv.isNew == false)
{
FileName1 = rv.directoryPath + tabItem.Header.ToString() + ".xml";
}
else
{
MainWindow mw = new MainWindow();
FileName1 = mw.OpenSaveDialog(tabItem.Name);
}
if (FileName1 != System.String.Empty)
{
XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
StreamWriter swriter = new StreamWriter(FileName1);
SerializerObj.Serialize(swriter, QueryBulder);
swriter.Flush();
swriter.Close();
string[] splitedArray = FileName1.Split('\\');
string tabItemHeader = splitedArray[splitedArray.Length - 1].Remove((splitedArray[splitedArray.Length - 1]).Length - 4, 4);
tabItem.Header = tabItemHeader;
//we saved the query change isModified to false
rv.isModified = false;
tabItem.labelStar.Content = "";
MessageBox.Show("query saved successfully");
/**************************/
this.result.directoryPath = FileName1.Replace(splitedArray[splitedArray.Length - 1], "");
/**************************/
}
break;
case MessageBoxResult.No:
// User pressed No button
TabControl tabControl = tabItem.Parent as TabControl;
if (tabControl != null)
tabControl.Items.Remove(tabItem);
break;
case MessageBoxResult.Cancel:
// User pressed Cancel button
break;
}
}
示例2: CheckQueryNeededToBeSaved
public void CheckQueryNeededToBeSaved(CloseableTabItem tabItem, String caller)
{
/*****************To Save Modified Query***********/
string directoryPath = this.result.directoryPath;
MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.ShortCutsToolBar);
mainWindow.ValidateAllTabCntrls(this);
SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(this);
MainGirdViewControl mainGridView1 = new MainGirdViewControl(queryBuilder, mainWindow.CurrentDatabaseName);
this.result = mainGridView1.result;
if (directoryPath != null)
{
this.result.isModified = true;
this.result.isNew = false;
this.result.directoryPath = directoryPath;
}
else
{
this.result.isModified = true;
this.result.isNew = true;
}
/********************************************/
ResultViewModel rv = (ResultViewModel)this.result;
if (this.Content != null)
{
if (rv.isModified)
{
if (rv.isNew == false)
{
switch (caller)
{
case "Save":
string FileName = rv.directoryPath + tabItem.Header.ToString() + ".xml";
if (FileName != System.String.Empty)
{
XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
StreamWriter swriter = new StreamWriter(FileName);
SerializerObj.Serialize(swriter, rv.QueryBulder);
swriter.Flush();
swriter.Close();
tabItem.Header = tabItem.Header.ToString();
//we saved the query change isModified to false
rv.isModified = false;
tabItem.labelStar.Content = "";
MessageBox.Show("query saved successfully");
}
break;
case "SaveAs":
MainWindow mw = new MainWindow();
string FileName1 = mw.OpenSaveDialog(tabItem.Name);
if (FileName1 != System.String.Empty)
{
XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
StreamWriter swriter = new StreamWriter(FileName1);
SerializerObj.Serialize(swriter, rv.QueryBulder);
swriter.Flush();
swriter.Close();
string[] splitedArray = FileName1.Split('\\');
string tabItemHeader = splitedArray[splitedArray.Length - 1].Remove((splitedArray[splitedArray.Length - 1]).Length - 4, 4);
tabItem.Header = tabItemHeader;
//we saved the query change isModified to false
rv.isModified = false;
tabItem.labelStar.Content = "";
MessageBox.Show("query saved successfully");
}
break;
case "SaveXML":
FileName = ConfigurationManager.AppSettings["DerivedTablesPath"].ToString() + flName + ".xml";
if (File.Exists(FileName))
{
MessageBox.Show("File already exists....");
}
else
{
if (FileName != System.String.Empty)
{
XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
StreamWriter swriter = new StreamWriter(FileName);
SerializerObj.Serialize(swriter, rv.QueryBulder);
swriter.Flush();
swriter.Close();
tabItem.Header = tabItem.Header.ToString();
rv.isModified = false;
tabItem.labelStar.Content = "";
MessageBox.Show("query saved successfully");
//.........这里部分代码省略.........