Beispiel #1
0
        private void RemoteEdit()
        {
            if (Folder != null && m_File != null)
            {
                string filename = System.IO.Path.Combine(Folder, m_File);
                TheBox.BoxServer.DownloadRequest msg = new DownloadRequest();
                Pandora.Profile.Server.FillBoxMessage(msg);
                msg.Filename = filename;

                BoxServerForm form = new BoxServerForm(msg);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    TheBox.BoxServer.FileTransport response = form.Response as FileTransport;

                    if (response != null)
                    {
                        // Download succesful
                        RemoteEditor f = new RemoteEditor(filename, response.Text);
                        Pandora.Localization.LocalizeControl(f);
                        f.Show();
                        f.Closed += new EventHandler(form_Closed);
                        m_Editors.Add(f);
                    }
                    else
                    {
                        sBar.Text = Pandora.Localization.TextProvider["Script.UnexpectedErr"];
                    }
                }
            }
        }
Beispiel #2
0
        private void RemoteEdit()
        {
            if (Folder != null && m_File != null)
            {
                var filename = Path.Combine(Folder, m_File);
                var msg      = new DownloadRequest();
                Pandora.Profile.Server.FillBoxMessage(msg);
                msg.Filename = filename;

                var form = new BoxServerForm(msg);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    var response = form.Response as FileTransport;

                    if (response != null)
                    {
                        // Download succesful
                        var f = new RemoteEditor(filename, response.Text);
                        Pandora.Localization.LocalizeControl(f);
                        f.Show();
                        f.Closed += form_Closed;
                        m_Editors.Add(f);
                    }
                    else
                    {
                        sBar.Text = Pandora.Localization.GetTextProvider()["Script.UnexpectedErr"];
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Sends a message to the server
 /// </summary>
 /// <param name="msg">The message being sent to the server</param>
 /// <param name="window">Specifies whether to use the connection form</param>
 /// <returns>The outcome of the transaction</returns>
 public BoxMessage ProcessMessage(BoxMessage msg, bool window)
 {
     if (window)
     {
         TheBox.Forms.BoxServerForm form = new TheBox.Forms.BoxServerForm(msg);
         form.ShowDialog();
         return(form.Response);
     }
     else
     {
         return(ProcessMessage(msg));
     }
 }
Beispiel #4
0
        /// <summary>
        ///     Downloads the selected file from the server
        /// </summary>
        private void Download()
        {
            if (Folder != null && m_File != null)
            {
                var filename = Path.Combine(Folder, m_File);

                SaveFile.Filter   = GetFilter(filename);
                SaveFile.FileName = Path.GetFileNameWithoutExtension(filename);

                if (SaveFile.ShowDialog() == DialogResult.OK)
                {
                    var msg = new DownloadRequest();

                    Pandora.Profile.Server.FillBoxMessage(msg);

                    msg.Filename = filename;

                    var form = new BoxServerForm(msg);

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        var response = form.Response as FileTransport;

                        if (response != null)
                        {
                            // Download succesful
                            try
                            {
                                var writer = new StreamWriter(SaveFile.FileName, false);
                                writer.Write(response.Text);
                                writer.Close();

                                sBar.Text = string.Format(Pandora.Localization.GetTextProvider()["Script.DownOk"], m_File, SaveFile.FileName);
                            }
                            catch (Exception err)
                            {
                                Pandora.Log.WriteError(err, "Can't write file {0} to {1}", filename, SaveFile.FileName);
                                MessageBox.Show(Pandora.Localization.GetTextProvider()["Server.CantWriteFile"]);

                                sBar.Text = string.Format(Pandora.Localization.GetTextProvider()["Script.GenericErr"]);
                            }
                        }
                        else
                        {
                            sBar.Text = Pandora.Localization.GetTextProvider()["Script.UnexpectedErr"];
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public void RequestConnection()
        {
            if (Pandora.Profile.Server.Enabled)
            {
                if (MessageBox.Show(Pandora.BoxForm as Form,
                                    Pandora.Localization.TextProvider["Misc.RequestConnection"],
                                    null,
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Disconnect();

                    TheBox.Forms.BoxServerForm form = new TheBox.Forms.BoxServerForm(false);
                    form.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show(Pandora.Localization.TextProvider["Errors.NoServer"]);
            }
        }
Beispiel #6
0
        public void RequestConnection()
        {
            if (Pandora.Profile.Server.Enabled)
            {
                if (MessageBox.Show(Pandora.BoxForm as Form,
                    Pandora.Localization.TextProvider["Misc.RequestConnection"],
                    null,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Disconnect();

                    TheBox.Forms.BoxServerForm form = new TheBox.Forms.BoxServerForm(false);
                    form.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show(Pandora.Localization.TextProvider["Errors.NoServer"]);
            }
        }
Beispiel #7
0
		private void miSpawn_Click(object sender, System.EventArgs e)
		{
			GetDatafile msg = new GetDatafile();
			Pandora.Profile.Server.FillBoxMessage( msg );
			msg.DataType = BoxDatafile.SpawnData;

			BoxServerForm form = new BoxServerForm( msg );

			if ( form.ShowDialog() == DialogResult.OK )
			{
				ReturnDatafile data = form.Response as ReturnDatafile;

				if ( data != null )
				{
					SpawnData sdata = data.Data as SpawnData;

					if ( sdata != null )
					{
						SpawnData.SpawnProvider = sdata;
						Pandora.Profile.Travel.ShowSpawns = true;
						SpawnData.SpawnProvider.RefreshSpawns();
					}
				}
			}
		}
Beispiel #8
0
		private void miProps_Click(object sender, System.EventArgs e)
		{
			GetDatafile msg = new GetDatafile();
			Pandora.Profile.Server.FillBoxMessage( msg );
			msg.DataType = BoxDatafile.PropsData;

			BoxServerForm form = new BoxServerForm( msg );

			if ( form.ShowDialog() == DialogResult.OK )
			{
				ReturnDatafile data = form.Response as ReturnDatafile;

				if ( data != null )
				{
					PropsData props = data.Data as PropsData;

					if ( props != null )
					{
						PropsData.Props = props;
					}
				}
			}
		}
Beispiel #9
0
		private void miBoxData_Click(object sender, System.EventArgs e)
		{
			GetDatafile msg = new GetDatafile();
			Pandora.Profile.Server.FillBoxMessage( msg );
			msg.DataType = BoxDatafile.BoxData;

			BoxServerForm form = new BoxServerForm( msg );

			if ( form.ShowDialog( this ) == DialogResult.OK )
			{
				ReturnDatafile data = form.Response as ReturnDatafile;

				if ( data != null )
				{
					BoxData bdata = data.Data as BoxData;

					if ( bdata != null )
					{
						Pandora.BoxData = bdata;
						Pandora.BoxForm.UpdateBoxData();
						Pandora.BoxData.Save();
					}
				}
			}
		}
Beispiel #10
0
		private void bLogin_Click(object sender, System.EventArgs e)
		{
			BoxServerForm form = new BoxServerForm( false );
			form.ShowDialog();
		}
Beispiel #11
0
		private void RemoteEdit()
		{
			if ( Folder != null && m_File != null )
			{
				string filename = System.IO.Path.Combine( Folder, m_File );
				TheBox.BoxServer.DownloadRequest msg = new DownloadRequest();
				Pandora.Profile.Server.FillBoxMessage( msg );
				msg.Filename = filename;

				BoxServerForm form = new BoxServerForm( msg );

				if ( form.ShowDialog() == DialogResult.OK )
				{
					TheBox.BoxServer.FileTransport response = form.Response as FileTransport;

					if ( response != null )
					{
						// Download succesful
						RemoteEditor f = new RemoteEditor( filename, response.Text );
						Pandora.Localization.LocalizeControl( f );
						f.Show();
						f.Closed += new EventHandler(form_Closed);
						m_Editors.Add( f );
					}
					else
					{
						sBar.Text = Pandora.Localization.TextProvider[ "Script.UnexpectedErr" ];
					}
				}
			}
		}
Beispiel #12
0
		/// <summary>
		/// Downloads the selected file from the server
		/// </summary>
		private void Download()
		{	
			if ( Folder != null && m_File != null )
			{
				string filename = System.IO.Path.Combine( Folder, m_File );

				SaveFile.Filter = GetFilter( filename );
				SaveFile.FileName = Path.GetFileNameWithoutExtension( filename );

				if ( SaveFile.ShowDialog() == DialogResult.OK )
				{
					TheBox.BoxServer.DownloadRequest msg = new DownloadRequest();

					Pandora.Profile.Server.FillBoxMessage( msg );

					msg.Filename = filename;

					BoxServerForm form = new BoxServerForm( msg );

					if ( form.ShowDialog() == DialogResult.OK )
					{
						TheBox.BoxServer.FileTransport response = form.Response as FileTransport;

						if ( response != null )
						{
							// Download succesful
							try
							{
								StreamWriter writer = new StreamWriter( SaveFile.FileName, false );
								writer.Write( response.Text );
								writer.Close();

								sBar.Text = string.Format( Pandora.Localization.TextProvider[ "Script.DownOk" ], m_File, SaveFile.FileName );
							}
							catch ( Exception err )
							{
								Pandora.Log.WriteError( err, "Can't write file {0} to {1}", filename, SaveFile.FileName );
								MessageBox.Show( Pandora.Localization.TextProvider[ "Server.CantWriteFile" ] );

								sBar.Text = string.Format( Pandora.Localization.TextProvider[ "Script.GenericErr" ] );
							}
						}
						else
						{
							sBar.Text = Pandora.Localization.TextProvider[ "Script.UnexpectedErr" ];
						}
					}
				}
			}
		}
Beispiel #13
0
		private void Box_Load(object sender, System.EventArgs e)
		{
            _splash.SetStatusText("Choosing language");
			Pandora.Localization.LocalizeControl( this );
			Pandora.Localization.LocalizeMenu( TrayMenu );

            _splash.SetStatusText("Repositioning");
			// Set position
            Location = _profileManager.Profile.General.WindowLocation;
			VerifyVisibility();
            ShowInTaskbar = _profileManager.Profile.General.ShowInTaskBar;

			// Display spawns
            if (_profileManager.Profile.Travel.ShowSpawns && SpawnData.SpawnProvider != null)
			{
                _splash.SetStatusText("Spawning...");
				SpawnData.SpawnProvider.RefreshSpawns();
			}

            _splash.SetStatusText("Artwork setup");
			// Set options on the art viewer
            Pandora.Art.RoomView = _profileManager.Profile.General.RoomView;
            Pandora.Art.ResizeTallItems = _profileManager.Profile.General.Scale;
            Pandora.Art.Animate = _profileManager.Profile.General.Animate;
            Pandora.Art.BackColor = _profileManager.Profile.General.ArtBackground.Color;

			// Go online
            if (_profileManager.Profile.Server.Enabled && _profileManager.Profile.Server.ConnectOnStartup)
			{
                _splash.SetStatusText("Connecting to BoxServer");
				BoxServerForm form = new BoxServerForm( true );
				form.ShowDialog();
			}

			// Startup programs
            _splash.SetStatusText("Launching startup programs");
            _profileManager.Profile.Launcher.PerformStartup();

            Text = string.Format(Pandora.Localization.TextProvider["Misc.BoxTitle"], _profileManager.Profile.Name, Pandora.BoxConnection.Connected ? Pandora.Localization.TextProvider["Misc.Online"] : Pandora.Localization.TextProvider["Misc.Offline"]);

			// Set startup tab
            if (_profileManager.Profile.General.StartupTab != null)
			{
				foreach ( TabPage page in BigTab.TabPages )
				{
                    if (page.Text == _profileManager.Profile.General.StartupTab)
					{
						BigTab.SelectedTab = page;
						break;
					}
				}
			}

            _splash.SetStatusText("Building tips and menus");

			// Tooltips
			Pandora.ToolTip.SetToolTip( pctCap, Pandora.Localization.TextProvider[ "Tips.Screenshot" ] );

			// Build profiles menu items
			MenuItem miNewProfile = new MenuItem( Pandora.Localization.TextProvider[ "Common.New" ] );
			miNewProfile.Click += new EventHandler(miNewProfile_Click);
			miProfile.MenuItems.Add( miNewProfile );

			MenuItem miExportProfile = new MenuItem( Pandora.Localization.TextProvider[ "Common.Export" ] );
			miExportProfile.Click += new EventHandler(miExportProfile_Click);
			miProfile.MenuItems.Add( miExportProfile );

			MenuItem miImportProfile = new MenuItem( Pandora.Localization.TextProvider[ "Common.Import" ] );
			miImportProfile.Click += new EventHandler(miImportProfile_Click);
			miProfile.MenuItems.Add( miImportProfile );

			miProfile.MenuItems.Add( new MenuItem( "-" ) );

			foreach( string s in TheBox.Options.Profile.ExistingProfiles )
			{
				MenuItem mi = new MenuItem( s );
				mi.Checked = s == _profileManager.Profile.Name;
				if ( !mi.Checked )
					mi.Click += new EventHandler(ChangeProfile);
				else
					mi.Enabled = false;

				miProfile.MenuItems.Add( mi );
			}

			bSetHue.Tag = new CommandCallback( SetHue );
			bSetHue.ContextMenu = Pandora.cmModifiers;

            _splash.Close();
			Utility.BringWindowToFront( this.Handle );
		}
Beispiel #14
0
        /// <summary>
        /// Sends a message to the BoxServer
        /// </summary>
        /// <param name="message">The message that must be sent</param>
        /// <returns>The message outcome</returns>
        public BoxMessage SendToServer(BoxMessage message)
        {
            if (!Connected)
            {
                // Not connected, request connection
                if (MessageBox.Show(null, Pandora.Localization.TextProvider["Misc.RequestConnection"], "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    BoxServerForm form = new BoxServerForm(false);
                    form.ShowDialog();
                }

                if (!Connected)
                {
                    return null;
                }
            }

            Pandora.Profile.Server.FillBoxMessage(message);

            BoxServerForm msgForm = new BoxServerForm(message);
            msgForm.ShowDialog();

            TheBox.Common.Utility.BringClientToFront();

            return msgForm.Response;
        }
Beispiel #15
0
 /// <summary>
 /// Sends a message to the server
 /// </summary>
 /// <param name="msg">The message being sent to the server</param>
 /// <param name="window">Specifies whether to use the connection form</param>
 /// <returns>The outcome of the transaction</returns>
 public BoxMessage ProcessMessage(BoxMessage msg, bool window)
 {
     if (window)
     {
         TheBox.Forms.BoxServerForm form = new TheBox.Forms.BoxServerForm(msg);
         form.ShowDialog();
         return form.Response;
     }
     else
     {
         return ProcessMessage(msg);
     }
 }