Esempio n. 1
0
        public void Save()
        {
            if (this.IsTemporary)
            {
                this.SaveAs();
                return;
            }

            if (!this.Loaded)
            {
                return;
            }

            try
            {
                OtbWriter writer = new OtbWriter(this.serverItems);
                if (writer.Write(this.CurrentOtbFullPath))
                {
                    this.Saved = true;
                    Trace.WriteLine("Saved.");
                }
            }
            catch (UnauthorizedAccessException exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Esempio n. 2
0
        public void SaveAs()
        {
            if (!this.Loaded)
            {
                return;
            }

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = "OTB files (*.otb)|*.otb";
            dialog.Title = "Save OTB File";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.FileName.Length == 0)
                {
                    return;
                }

                try
                {
                    OtbWriter writer = new OtbWriter(this.serverItems);
                    if (writer.Write(dialog.FileName))
                    {
                        this.CurrentOtbFullPath = dialog.FileName;
                        this.IsTemporary = false;
                        this.Saved = true;
                        Trace.WriteLine("Saved.");
                    }
                }
                catch (UnauthorizedAccessException exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }
Esempio n. 3
0
        public void CreateEmptyOTB(string filePath, SupportedClient client, bool isTemporary = true)
        {
            ServerItem item = new ServerItem();
            item.SpriteHash = new byte[16];
            item.ClientId = 100;
            item.ID = 100;

            ServerItemList items = new ServerItemList();
            items.MajorVersion = 3;
            items.MinorVersion = client.OtbVersion;
            items.BuildNumber = 1;
            items.ClientVersion = client.Version;
            items.Add(item);

            if (!File.Exists(filePath))
            {
                using (File.Create(filePath))
                {
                    ////
                }
            }

            OtbWriter writer = new OtbWriter(items);
            if (writer.Write(filePath))
            {
                this.Open(filePath);
                this.IsTemporary = isTemporary;
                this.Saved = !isTemporary;
            }
        }