Наследование: System.Windows.Forms.IWin32Window
Пример #1
0
        void BtnBrowseClick(object sender, EventArgs e)
        {
            WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle);

            System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title       = "Open object file";
            dlg.Filter      = "XML file (*.xml)|*.xml";
            dlg.Multiselect = false;
            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }
            txtFileName.Text = dlg.FileName;
            ValidateFileName();
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Form.ActiveForm == null)
            {
                return;
            }
            WindowWrapper  mainWindow = new WindowWrapper(Form.ActiveForm.Handle);
            SaveFileDialog dlg        = new SaveFileDialog
            {
                AddExtension     = true,
                RestoreDirectory = true,
                Title            = "Save object as...",
                Filter           = "XML file (*.xml)|*.xml"
            };
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                Thread t = new Thread(delegate()
                {
                    try
                    {
                        PrimSerializer s = new PrimSerializer(client);
                        string primsXmls =
                            s.GetSerializedAttachmentPrims(client.Network.CurrentSim, attachment.LocalID);
                        System.IO.File.WriteAllText(dlg.FileName, primsXmls);
                        s.CleanUp();
                        s = null;
                        MessageBox.Show(mainWindow, "Successfully saved " + dlg.FileName, "Success",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception excp)
                    {
                        MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                })
                {
                    IsBackground = true
                };
                t.Start();
            }
        }
Пример #3
0
        public static void ImportFromFile(GridClient client)
        {
            if (Form.ActiveForm == null)
            {
                return;
            }
            WindowWrapper  mainWindow = new WindowWrapper(Form.ActiveForm.Handle);
            OpenFileDialog dlg        = new OpenFileDialog
            {
                Title       = "Open object file",
                Filter      = "XML file (*.xml)|*.xml",
                Multiselect = false
            };
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                Thread t = new Thread(delegate()
                {
                    try
                    {
                        PrimDeserializer d = new PrimDeserializer(client);
                        string primsXmls   = System.IO.File.ReadAllText(dlg.FileName);
                        d.CreateObjectFromXml(primsXmls);
                        d.CleanUp();
                        d = null;
                        MessageBox.Show(mainWindow, $"Successfully imported {dlg.FileName}", "Success",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception excp)
                    {
                        MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                })
                {
                    IsBackground = true
                };

                t.Start();
            }
        }
Пример #4
0
        void BtnBrowseClick(object sender, EventArgs e)
        {
            if (Form.ActiveForm != null)
            {
                WindowWrapper mainWindow = new WindowWrapper(Form.ActiveForm.Handle);
            }
            OpenFileDialog dlg = new OpenFileDialog
            {
                Title       = "Open object file",
                Filter      = "XML file (*.xml)|*.xml",
                Multiselect = false
            };
            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }
            txtFileName.Text = dlg.FileName;
            ValidateFileName();
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle);

            System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog();
            dlg.AddExtension     = true;
            dlg.RestoreDirectory = true;
            dlg.Title            = "Save animation as...";
            dlg.Filter           = "Second Life Animation (*.sla)|*.sla";
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                try
                {
                    File.WriteAllBytes(dlg.FileName, animData);
                }
                catch (Exception ex)
                {
                    Logger.Log("Saving animation failed: " + ex.Message, Helpers.LogLevel.Debug);
                }
            }
        }