private void buttonSalvar_Click(object sender, EventArgs e)
        {
            //Salva os arquivos gerados para relatorio
            SaveFileDialog SFD = new SaveFileDialog();

            //Extensões possíveis de salvar o relatório
            SFD.Filter = "Texto|*.txt|Word|*.doc|planilha|*.ods|html|*.html|PDF|*.pdf|Todos os Arquivos|*.*";
            SFD.FilterIndex = 2;
            SFD.FileName = "Historico1";
            if (SFD.ShowDialog() == DialogResult.OK)
            {
                FileStream fs = new FileStream(SFD.FileName, FileMode.Create);
                StreamWriter writer = new StreamWriter(fs);
                writer.WriteLine("\tHistorico");
                writer.WriteLine();
                int i = 0;
                while (i < listViewHistorico.Items.Count)
                {
                    //salva os dados que estão no listview
                    writer.Write(listViewHistorico.Items[i].Text + " - ");
                    writer.Write(listViewHistorico.Items[i].SubItems[1].Text + " - ");
                    writer.Write(listViewHistorico.Items[i].SubItems[2].Text + " - ");
                    writer.Write(listViewHistorico.Items[i].SubItems[3].Text + " - ");
                    writer.Write(listViewHistorico.Items[i].SubItems[4].Text);
                    writer.WriteLine();
                    writer.WriteLine();
                    i++;
                }
                writer.Close();
                SFD.Dispose();
            }
        }
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1;
            saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Title = "Guardar Archivo de Texto";
            saveFileDialog1.Filter = "Archivo de Texto (.txt) |*.txt";

            saveFileDialog1.DefaultExt = "txt";
            saveFileDialog1.AddExtension = true;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.InitialDirectory = @"H:\LO DEL ESCRITORIO";

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string ruta = saveFileDialog1.FileName;

                StreamWriter fichero = new StreamWriter(ruta);
                fichero.Write(txt_error.Text);
                fichero.Close();

            }
            else
            {

            }
            saveFileDialog1.Dispose();
            saveFileDialog1 = null;
        }
        public void Execute(IMenuCommand command)
        {
            var dslDiagram = DiagramContext.CurrentDiagram.GetObject<Diagram>();

            if (dslDiagram == null)
                return;

            var dialog = new SaveFileDialog
                             {
                                 AddExtension = true,
                                 DefaultExt = "image.bmp",
                                 Filter = "Bitmap ( *.bmp )|*.bmp|JPEG File ( *.jpg )|*.jpg|Enhanced Metafile (*.emf )|*.emf|Portable Network Graphic ( *.png )|*.png",
                                 FilterIndex = 1,
                                 Title = "Save Diagram to Image"
                             };

            if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.FileName))
            {
                var bitmap = dslDiagram.CreateBitmap(dslDiagram.NestedChildShapes, Diagram.CreateBitmapPreference.FavorClarityOverSmallSize);
                bitmap.Save(dialog.FileName, GetImageType(dialog.FilterIndex));
                bitmap.Dispose();
            }

            dialog.Dispose();
        }
Example #4
0
		public override void Run()
		{
			ResourceEditorControl editor = ((ResourceEditWrapper)SD.Workbench.ActiveViewContent).ResourceEditor;
			ResourceList list = editor.ResourceList;
			
			if(list.SelectedItems.Count != 1) {
				return;
			}
			
			string key = list.SelectedItems[0].Text;
			if(! list.Resources.ContainsKey(key)) {
				return;
			}
			
			ResourceItem item = list.Resources[key];
			SaveFileDialog sdialog 	= new SaveFileDialog();
			sdialog.AddExtension = true;
			sdialog.FileName = key;
			
			if (item.ResourceValue is Bitmap) {
				sdialog.Filter 		= StringParser.Parse("${res:SharpDevelop.FileFilter.ImageFiles} (*.png)|*.png");
				sdialog.DefaultExt 	= ".png";
			} else if (item.ResourceValue is Icon) {
				sdialog.Filter 		= StringParser.Parse("${res:SharpDevelop.FileFilter.Icons}|*.ico");
				sdialog.DefaultExt 	= ".ico";
			} else if (item.ResourceValue is Cursor) {
				sdialog.Filter 		= StringParser.Parse("${res:SharpDevelop.FileFilter.CursorFiles} (*.cur)|*.cur");
				sdialog.DefaultExt 	= ".cur";
			} else if (item.ResourceValue is byte[]){
				sdialog.Filter      = StringParser.Parse("${res:SharpDevelop.FileFilter.BinaryFiles} (*.*)|*.*");
				sdialog.DefaultExt  = ".bin";
			} else {
				return;
			}
			
			DialogResult dr = sdialog.ShowDialog(SD.WinForms.MainWin32Window);
			sdialog.Dispose();
			if (dr != DialogResult.OK) {
				return;
			}
			
			try {
				if (item.ResourceValue is Icon) {
					FileStream fstr = new FileStream(sdialog.FileName, FileMode.Create);
					((Icon)item.ResourceValue).Save(fstr);
					fstr.Close();
				} else if(item.ResourceValue is Image) {
					Image img = (Image)item.ResourceValue;
					img.Save(sdialog.FileName);
				} else {
					FileStream fstr = new FileStream(sdialog.FileName, FileMode.Create);
					BinaryWriter wr = new BinaryWriter(fstr);
					wr.Write((byte[])item.ResourceValue);
					fstr.Close();
				}
			} catch(Exception ex) {
				MessageBox.Show(ex.Message, "Can't save resource to " + sdialog.FileName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}
 public void saveBitmapAs(MyBitmap myBitmap)
 {
     if (myBitmap != null)
     {
         SaveFileDialog saveDialog = new SaveFileDialog();
         saveDialog.FileName = "moj_plik";
         saveDialog.Filter = "Plik graficzny (*.bmp)|*.BMP; *.bmp";
         saveDialog.ShowDialog();
         myBitmap.CurrentBitmap.Save(saveDialog.FileName);
         saveDialog.Dispose();
     }
 }
Example #6
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.CheckFileExists = false;
     sfd.FileName = txtFileLocation.Text;
     sfd.Filter = "txt files (*.txt)|*.txt";
     if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         txtFileLocation.Text = sfd.FileName;
     }
     sfd.Dispose();
 }
 private void btnCSV_Click(object sender, EventArgs e)
 {
     SaveFileDialog sFd = new SaveFileDialog();
     sFd.DefaultExt = ".csv";
     sFd.Filter = "Text|*.csv";
     sFd.Title = "Save CSV to";
     sFd.AddExtension = true;
     if (sFd.ShowDialog(this) == DialogResult.OK)
     {
         txtCSV.Text = sFd.FileName;
     }
     sFd.Dispose();
 }
Example #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.CheckPathExists = true;
     saveFileDialog.OverwritePrompt = true;
     saveFileDialog.RestoreDirectory = true;
     saveFileDialog.Filter = "Shapefile(*.shp)|*.shp";
     saveFileDialog.Title = "输出图层位置";
     saveFileDialog.ShowDialog();
     saveFileDialog.Dispose();
     textBoxLocation.Text = saveFileDialog.FileName;
     strFullPath = saveFileDialog.FileName;
 }
Example #9
0
        /// <summary>
        /// Creates a Save File Dialog box with default name and filters applied. Automatically adds correct file extension to returned path.
        /// </summary>
        /// <param name="fileExtension">The file extension to filter for and apply.</param>
        /// <param name="typeName">The full name description of the file type.</param>
        /// <param name="defaultFileName">Default save name for the file.</param>
        /// <param name="initialDirectory">The initial directory to open to.</param>
        /// <returns>The full String path of the file save location, with file extension, or null on Cancel.</returns>
        public static String SaveFileDialogBox(String fileExtension, String typeName, String defaultFileName, String initialDirectory)
        {
            // This little function is here because for some reason AddExtension = false doesn't seem to do shit.
            // So basically I just check it manually.

            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                AddExtension = false,
                DefaultExt = fileExtension,
                FileName = defaultFileName,
                Filter = String.Format("{1} File(s) (*.{0})|*.{0}", fileExtension, typeName),
                InitialDirectory = initialDirectory
            };

            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                saveFileDialog.Dispose();
                return null;
            }
            String filePath = saveFileDialog.FileName;
            saveFileDialog.Dispose();

            // since AddExtension = false doesn't seem to do shit
            string replaceExtension = "." + fileExtension;
            while (filePath.Contains(replaceExtension))
            {
                filePath = filePath.Replace(replaceExtension, "");
            }
            filePath += replaceExtension;

            if (!filePath.Contains(fileExtension))
            {
                filePath += fileExtension;
            }

            return filePath;
        }
Example #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            SaveFileDialog sfd = new SaveFileDialog();

            ofd.Multiselect = true;
            var oResult= ofd.ShowDialog();
            if (oResult==DialogResult.OK)
            {
                var files = ofd.FileNames;
                var temp1 = files.ToList();
                temp1.Sort();
                files = temp1.ToArray();

                Bitmap[] bitmaps = new Bitmap[files.Length];

                for (int i = 0; i < files.Length; i++)
                {
                    bitmaps[i] = new Bitmap(files[i]);
                }

                Bitmap output = new Bitmap(bitmaps[0].Width, bitmaps.Select(temp=>temp.Height).Sum());

                int yy = 0;

                for (int i = 0; i < bitmaps.Length; i++)
                {
                    for (int y = 0; y < bitmaps[i].Height; y++)
                    {
                        for (int x = 0; x < bitmaps[i].Width; x++)
                        {
                            var c = bitmaps[i].GetPixel(x, y);

                            output.SetPixel(x,yy, c);
                        }

                        yy++;
                    }
                }

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    output.Save(sfd.FileName, ImageFormat.Jpeg);
                }
            }

            sfd.Dispose();
            ofd.Dispose();
        }
 public void Export(object sender, EventArgs e)
 {
     String expfilter = StringValue.ExportFormats;
     SaveFileDialog dlgExport = new SaveFileDialog();
     dlgExport.Filter = expfilter;
     dlgExport.CheckFileExists = false;
     dlgExport.CheckPathExists = true;
     dlgExport.Title = "Export As...";
     if (dlgExport.ShowDialog() == DialogResult.OK)
     {
         ExportObject((EnumValues.FilterType)dlgExport.FilterIndex, dlgExport.FileName);
     }
     dlgExport.Dispose();
     dlgExport = null;
 }
 public void Export(object sender, EventArgs e)
 {
     String expfilter = "Extensible Markup Language (*.xml)|*.xml|Comma Separate Values (*.csv)|*.csv|Tabbed Delimited (*.txt)|*.txt";
     SaveFileDialog dlgExport = new SaveFileDialog();
     dlgExport.Filter = expfilter;
     dlgExport.CheckFileExists = false;
     dlgExport.CheckPathExists = true;
     dlgExport.Title = "Export As...";
     if (dlgExport.ShowDialog() == DialogResult.OK)
     {
         ExportObject((FilterType)dlgExport.FilterIndex, dlgExport.FileName);
     }
     dlgExport.Dispose();
     dlgExport = null;
 }
 public override void Run()
 {
     TempletPrintNode owner = (TempletPrintNode) this.Owner;
     if (owner != null)
     {
         TempletPrint domainObject = owner.DomainObject;
         SaveFileDialog dialog = new SaveFileDialog();
         dialog.FileName = domainObject.TempletFile;
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             File.WriteAllBytes(dialog.FileName, domainObject.Data);
         }
         dialog.Dispose();
     }
 }
Example #14
0
 public static bool ShowSaveDialog(out string path)
 {
     path = null;
     var result = false;
     var saver = new SaveFileDialog
     {
         AddExtension = true,
         AutoUpgradeEnabled = true,
         DefaultExt = "pcdb",
         Filter = fileNameFilter
     };
     if (saver.ShowDialog() == DialogResult.OK)
     {
         path = saver.FileName;
         result = true;
     }
     saver.Dispose();
     return result;
 }
Example #15
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.RestoreDirectory = true;
            Application.DoEvents();
            try
            {
                string strFilter = "Excel�ļ�(*.xls)|*.xls";
                if (xtraTabControl1.SelectedTabPageIndex == 0)
                {
                    ExportXls();
                }
                else
                {
                    strFilter = "ͼƬ�ļ�(*.jpeg)|*.jpeg";
                    saveFileDialog1.Filter = strFilter;
                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        try
                        {
                            chartControl1.ExportToImage(saveFileDialog1.FileName, ImageFormat.Jpeg);
                            XtraMessageBox.Show("����ͼƬ�ɹ�!", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        catch (Exception ex)
                        {
                            XtraMessageBox.Show("����ͼƬʧ��!", "����", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        saveFileDialog1.FileName = "";
                        saveFileDialog1.Dispose();
                    }
                }
            }
            catch
            {

            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            string path = "";
            string text = "";
            string[] textArray;

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "Text File|*.txt";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                path = sfd.FileName;
                sfd.Dispose();
            }
            StreamWriter sw = new StreamWriter(File.Create(path));
            sw.WriteLine(textBox1.Text + ":" + textBox4.Text + ":" + textBox2.Text + ":" + textBox3.Text + ":");
            sw.Dispose();

            StreamReader sr = new StreamReader(File.OpenRead(path));
            text = sr.ReadLine();
            textArray = text.Split(':');
        }
Example #17
0
 private void btSave_Click(object sender, EventArgs e)
 {
     SaveFileDialog saveDialog = new SaveFileDialog();
     saveDialog.DefaultExt = "txt";
     saveDialog.AddExtension = true;
     saveDialog.FileName = articleID;
     saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     saveDialog.OverwritePrompt = true;
     saveDialog.Title = "保存到本地";
     saveDialog.ValidateNames = true;
     if (saveDialog.ShowDialog() == DialogResult.OK)
     {
         StreamWriter writer = new StreamWriter(saveDialog.FileName);
         writer.WriteLine(srcRtbText );
         writer.WriteLine(dstRtbText );
         writer.Close();
         MessageBox.Show("保存成功!");
         writer.Close();
         saveDialog.Dispose();
         this.Close();
     }
 }
		private void bGetFilename_Click(object sender, System.EventArgs e)
		{
			SaveFileDialog sfd = new SaveFileDialog();
			sfd.Filter = Strings.DialogDataSourceRef_bGetFilename_Click_DSRFilter;
			sfd.FilterIndex = 1;
			if (tbFilename.Text.Length > 0)
				sfd.FileName = tbFilename.Text;
			else
				sfd.FileName = "*.dsr";

			sfd.Title = Strings.DialogDataSourceRef_bGetFilename_Click_DSRTitle;
			sfd.OverwritePrompt = true;
			sfd.DefaultExt = "dsr";
			sfd.AddExtension = true;
            try
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                    tbFilename.Text = sfd.FileName;
            }
            finally
            {
                sfd.Dispose();
            }
		}
Example #19
0
 private void MenuFileSaveAs_Click(object sender, EventArgs e)
 {
     if (_workingBitmap == null) return;
     var dialog = new SaveFileDialog {
         Filter = @"Jpeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|Png Image|*.png",
         Title  = @"Save an Image File"
     };
     if (dialog.ShowDialog() != DialogResult.OK || dialog.FileName.Equals("")) return;
     var format = ImageFormat.Bmp;
     switch (dialog.FilterIndex) {
         case 1: format = ImageFormat.Jpeg; break;
         case 2: format = ImageFormat.Bmp; break;
         case 3: format = ImageFormat.Gif; break;
         case 4: format = ImageFormat.Png; break;
     }
     dialog.Dispose();
     SaveImage(dialog.FileName, format);
 }
Example #20
0
        private void SaveImageOld(SaveFileDialog dlg, Image img)
        {
            // Create a MemoryStream that will be minimally scoped
            using (MemoryStream memStream = new MemoryStream())
            {
                // Save the image to the memorystream in it's native format
                img.Save(memStream, listLoadedImg[curImgIndex].GetOriginalFormat());

                // Creating an Image that can actually be saved - Should probably make everything up to this point a method
                // Should also incorporate some kind of using statement to close off the MemoryStream
                Image imgToSave = Image.FromStream(memStream);

                // FilterIndex appears to record which filetype is arrIsProcessed
                switch (dlg.FilterIndex)
                {
                    case 1:
                        imgToSave.Save(dlg.FileName, ImageFormat.Jpeg);
                        break;
                    case 2:
                        imgToSave.Save(dlg.FileName, ImageFormat.Bmp);
                        break;
                    case 3:
                        imgToSave.Save(dlg.FileName, ImageFormat.Png);
                        break;
                    case 4:
                        imgToSave.Save(dlg.FileName, ImageFormat.Tiff);
                        break;
                }
            } dlg.Dispose();
        }
Example #21
0
        /// <summary>
        /// Export Global Settings
        /// </summary>
        private void ExportSelectedSettingsButton_Click(object sender, EventArgs e)
        {
            if (GlobalSettings_ListView.SelectedItems.Count == 1)
              {
            string settingsName = GlobalSettings_ListView.SelectedItems[0].Tag as string;
            System.Diagnostics.Debug.Assert(settingsName != null);

            HavokNavMeshGlobalSettings settingsToExported = GetGlobalSettings(settingsName);
            System.Diagnostics.Debug.Assert(settingsToExported != null);

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = EditorManager.Project.ProjectDir;
            dlg.FileName = null;
            dlg.Filter = "Nav Mesh Global Settings|*.*";
            dlg.Title = "Save nav mesh global settings to editor format";

            if (dlg.ShowDialog(this) != DialogResult.OK)
              return;

            string filename = dlg.FileName;
            dlg.Dispose();

            try
            {
              BinaryFormatter fmt = SerializationHelper.BINARY_FORMATTER;
              FileStream fs = new FileStream(filename, FileMode.Create);
              fmt.Serialize(fs, settingsToExported);
              fs.Close();
            }
            catch (Exception ex)
            {
              EditorManager.ShowMessageBox("Failed to save nav mesh global settings to file:\n\n" + ex.Message, "Error saving file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
              }
        }
Example #22
0
 /// <summary>
 /// Saves the file to disk, asking for location if the file is unsaved
 /// </summary>
 public void SaveFile()
 {
     if (currentFile == null) {
         SaveFileDialog dlg = new SaveFileDialog ();
         if (dlg.ShowDialog (this) != DialogResult.OK)
             return;
         currentFile = dlg.FileName;
         dlg.Dispose ();
     }
     SaveFile (currentFile);
 }
Example #23
0
        /// <summary>
        /// Saves the players current safe items into an xml file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveSafeItems_Click(object sender, EventArgs e)
        {
            // Ask where to save to..
            var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    CheckPathExists = true,
                    DefaultExt = "xml",
                    Filter = "TSGE Safe Files (*.xml)|*.xml|All files (*.*)|*.*",
                    InitialDirectory = Application.StartupPath,
                    ValidateNames = true,
                };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show("Failed to save safe!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create the new xml document..
            var xml = new XDocument(new XElement("BankSafe"));
            if (xml.Root == null)
            {
                sfd.Dispose();
                MessageBox.Show("Failed to save safe!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Loop each item in the players safe..
            foreach (var i in this.Player.Bank2)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("item", new object[]
                    {
                        new XAttribute("id", i.NetID),
                        new XAttribute("count", i.Count),
                        new XAttribute("prefix", i.Prefix)
                    }));
            }

            // Attempt to save the document..
            xml.Save(sfd.FileName);
            sfd.Dispose();
        }
Example #24
0
        /// <summary>
        /// Saves the current players gear to an xml file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveEquipmentSet_Click(object sender, EventArgs e)
        {
            // Ask where to save to..
            var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    CheckPathExists = true,
                    DefaultExt = "xml",
                    Filter = "TSGE Equipment Files (*.xml)|*.xml|All files (*.*)|*.*",
                    InitialDirectory = Application.StartupPath,
                    ValidateNames = true,
                };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show("Failed to save equipment!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create the new xml document..
            var xml = new XDocument(new XElement("Equipment"));
            if (xml.Root == null)
            {
                sfd.Dispose();
                MessageBox.Show("Failed to save equipment!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Loop each armor piece..
            foreach (var i in this.Player.Armor)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("armor", new object[]
                    {
                        new XAttribute("id", i.NetID),
                        new XAttribute("prefix", i.Prefix)
                    }));
            }

            // Loop each accessory piece..
            foreach (var i in this.Player.Accessories)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("accessory", new object[]
                    {
                        new XAttribute("id", i.NetID),
                        new XAttribute("prefix", i.Prefix)
                    }));
            }

            // Loop each vanity piece..
            foreach (var i in this.Player.Vanity)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("vanity", new object[]
                    {
                        new XAttribute("id", i.NetID),
                        new XAttribute("prefix", i.Prefix)
                    }));
            }

            // Loop each social accessory piece..
            foreach (var i in this.Player.SocialAccessories)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("socialaccessory", new object[]
                    {
                        new XAttribute("id", i.NetID),
                        new XAttribute("prefix", i.Prefix)
                    }));
            }

            // Loop each dye piece..
            foreach (var i in this.Player.Dye)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("dye", new object[]
                    {
                        new XAttribute("id", i.NetID),
                        new XAttribute("prefix", i.Prefix)
                    }));
            }

            // Attempt to save the document..
            xml.Save(sfd.FileName);
            sfd.Dispose();
        }
Example #25
0
        /// <summary>
        /// Exports the current players hair type and colors.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveColorHair_Click(object sender, EventArgs e)
        {
            // Ask where to save to..
            var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    CheckPathExists = true,
                    DefaultExt = "xml",
                    Filter = "TSGE Hair and Color Files (*.xml)|*.xml|All files (*.*)|*.*",
                    InitialDirectory = Application.StartupPath,
                    ValidateNames = true,
                };

            var ret = sfd.ShowDialog();
            if (ret != DialogResult.OK)
            {
                if (ret == DialogResult.Cancel || ret == DialogResult.Abort)
                    return;
                MessageBox.Show("Failed to save hair and color!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create the new xml document..
            var xml = new XDocument(new XElement("HairColor"));
            if (xml.Root == null)
            {
                sfd.Dispose();
                MessageBox.Show("Failed to save hair and color!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Add the hair id element..
            xml.Root.Add(new XElement("hair", new object[]
                {
                    new XAttribute("id", this.Player.Hair)
                }));

            // Add the color elements..
            xml.Root.Add(new XElement("HairColor", new object[]
                {
                    new XAttribute("a", this.Player.HairColor.A),
                    new XAttribute("r", this.Player.HairColor.R),
                    new XAttribute("g", this.Player.HairColor.G),
                    new XAttribute("b", this.Player.HairColor.B)
                }));
            xml.Root.Add(new XElement("SkinColor", new object[]
                {
                    new XAttribute("a", this.Player.SkinColor.A),
                    new XAttribute("r", this.Player.SkinColor.R),
                    new XAttribute("g", this.Player.SkinColor.G),
                    new XAttribute("b", this.Player.SkinColor.B)
                }));
            xml.Root.Add(new XElement("EyeColor", new object[]
                {
                    new XAttribute("a", this.Player.EyeColor.A),
                    new XAttribute("r", this.Player.EyeColor.R),
                    new XAttribute("g", this.Player.EyeColor.G),
                    new XAttribute("b", this.Player.EyeColor.B)
                }));
            xml.Root.Add(new XElement("ShirtColor", new object[]
                {
                    new XAttribute("a", this.Player.ShirtColor.A),
                    new XAttribute("r", this.Player.ShirtColor.R),
                    new XAttribute("g", this.Player.ShirtColor.G),
                    new XAttribute("b", this.Player.ShirtColor.B)
                }));
            xml.Root.Add(new XElement("UndershirtColor", new object[]
                {
                    new XAttribute("a", this.Player.UndershirtColor.A),
                    new XAttribute("r", this.Player.UndershirtColor.R),
                    new XAttribute("g", this.Player.UndershirtColor.G),
                    new XAttribute("b", this.Player.UndershirtColor.B)
                }));
            xml.Root.Add(new XElement("PantsColor", new object[]
                {
                    new XAttribute("a", this.Player.PantsColor.A),
                    new XAttribute("r", this.Player.PantsColor.R),
                    new XAttribute("g", this.Player.PantsColor.G),
                    new XAttribute("b", this.Player.PantsColor.B)
                }));
            xml.Root.Add(new XElement("ShoesColor", new object[]
                {
                    new XAttribute("a", this.Player.ShoesColor.A),
                    new XAttribute("r", this.Player.ShoesColor.R),
                    new XAttribute("g", this.Player.ShoesColor.G),
                    new XAttribute("b", this.Player.ShoesColor.B)
                }));

            // Attempt to save the document..
            xml.Save(sfd.FileName);
            sfd.Dispose();
        }
Example #26
0
        /// <summary>
        /// Saves the current buff list to an xml file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveBuffs_Click(object sender, EventArgs e)
        {
            // Ask where to save to..
            var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    CheckPathExists = true,
                    DefaultExt = "xml",
                    Filter = "TSGE Buff Files (*.xml)|*.xml|All files (*.*)|*.*",
                    InitialDirectory = Application.StartupPath,
                    ValidateNames = true,
                };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show("Failed to save buffs!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create the new xml document..
            var xml = new XDocument(new XElement("Buffs"));
            if (xml.Root == null)
            {
                sfd.Dispose();
                MessageBox.Show("Failed to save buffs!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Loop each buff in the players buff list..
            foreach (var b in this.Player.Buffs)
            {
                // Add each item to the xml document..
                xml.Root.Add(new XElement("buff", new object[]
                    {
                        new XAttribute("id", b.Id),
                        new XAttribute("duration", b.Duration)
                    }));
            }

            // Attempt to save the document..
            xml.Save(sfd.FileName);
            sfd.Dispose();
        }
        public bool FileSaveAs()
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "RDL files (*.rdl)|*.rdl|All files (*.*)|*.*";
            sfd.FilterIndex = 1;

            Uri file = SourceFile;

            sfd.FileName = file == null ? "*.rdl" : file.LocalPath;
            try
            {
                if (sfd.ShowDialog(this) != DialogResult.OK)
                    return false;

                // User wants to save!
                string rdl = GetRdlText();
                if (FileSave(new Uri(sfd.FileName), rdl))
                {	// Save was successful
                    Text = sfd.FileName;
                    _SourceFile = new Uri(sfd.FileName);
                    return true;
                }
            }
            finally
            {
                sfd.Dispose();
            }
            return false;
        }
        public bool Export(fyiReporting.RDL.OutputPresentationType type)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "Export to " + type.ToString().ToUpper();
            switch (type)
            {
                case OutputPresentationType.CSV:
                    sfd.Filter = "CSV file (*.csv)|*.csv|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.XML:
                    sfd.Filter = "XML file (*.xml)|*.xml|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.PDF:
                case OutputPresentationType.PDFOldStyle:
                    sfd.Filter = "PDF file (*.pdf)|*.pdf|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.TIF:
                    sfd.Filter = "TIF file (*.tif, *.tiff)|*.tiff;*.tif|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.RTF:
                    sfd.Filter = "RTF file (*.rtf)|*.rtf|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.Word:
                    sfd.Filter = "DOC file (*.doc)|*.doc|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.Excel:
                    sfd.Filter = "Excel file (*.xlsx)|*.xlsx|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.HTML:
                    sfd.Filter = "Web Page (*.html, *.htm)|*.html;*.htm|All files (*.*)|*.*";
                    break;
                case OutputPresentationType.MHTML:
                    sfd.Filter = "MHT (*.mht)|*.mhtml;*.mht|All files (*.*)|*.*";
                    break;
                default:
                    throw new Exception("Only HTML, MHT, XML, CSV, RTF, DOC, Excel, TIF and PDF are allowed as Export types.");
            }
            sfd.FilterIndex = 1;

            if (SourceFile != null)
            {
                sfd.FileName = Path.GetFileNameWithoutExtension(SourceFile.LocalPath) + "." + type;
            }
            else
            {
                sfd.FileName = "*." + type;
            }

            try
            {
                if (sfd.ShowDialog(this) != DialogResult.OK)
                    return false;

                // save the report in the requested rendered format
                bool rc = true;
                // tif can be either in color or black and white; ask user what they want
                if (type == OutputPresentationType.TIF)
                {
                    DialogResult dr = MessageBox.Show(this, "Do you want to display colors in TIF?", "Export", MessageBoxButtons.YesNoCancel);
                    if (dr == DialogResult.No)
                        type = OutputPresentationType.TIFBW;
                    else if (dr == DialogResult.Cancel)
                        return false;
                }
                try { SaveAs(sfd.FileName, type); }
                catch (Exception ex)
                {
                    MessageBox.Show(this,
                        ex.Message, "Export Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    rc = false;
                }
                return rc;
            }
            finally
            {
                sfd.Dispose();
            }
        }
Example #29
0
 /// <summary>
 /// Вызов пункта меню Сохранить файл
 /// </summary>
 private void SaveExecute(object sender, EventArgs e)
 {
     SaveFileDialog dg = new SaveFileDialog();
     dg.Title = "Введите название файла для сохранения списка задач";
     dg.Filter = "XML файлы|*.xml";
     dg.ShowDialog();
     if (dg.FileName != "")
     {
         // сохранение списка в файл
         SaveList(dg.FileName);
     }
     dg.Dispose();
 }
Example #30
0
 /// <summary>
 /// Asks user for file name and sets the map file name to user specified one
 /// </summary>
 /// <returns></returns>
 private bool SaveAs()
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.DefaultExt = "xml";
     sfd.Filter = "RDL Map files (*.xml)|*.xml|" +
         "All files (*.*)|*.*";
     sfd.FilterIndex = 1;
     sfd.CheckFileExists = false;
     bool rc = false;
     try
     {
         if (sfd.ShowDialog(this) == DialogResult.OK)
         {
             map.File = sfd.FileName;
             rc = true;
         }
     }
     finally
     {
         sfd.Dispose();
     }
     return rc;
 }