Example #1
0
 private void StopServerPipe()
 {
     try {
         ClientPipeConnection pipe = new ClientPipeConnection(PipeName);
         if (pipe.TryConnect())
         {
             pipe.Close();
         }
     } catch {
         // Log exception
     }
 }
Example #2
0
        public MainForm(string wzToLoad, bool usingPipes, bool firstrun)
        {
            InitializeComponent();
            if (firstrun)
                new AboutForm().ShowDialog();
#if DEBUG
            debugToolStripMenuItem.Visible = true;
#endif
            WindowState = ApplicationSettings.Maximized ? FormWindowState.Maximized : FormWindowState.Normal;
            Size = ApplicationSettings.WindowSize;
            if (!usingPipes) return;

            try
            {
                IInterProcessConnection clientConnection = null;
                clientConnection = new ClientPipeConnection("HaRepacker4", ".");
                clientConnection.Connect();
                if (wzToLoad != null)
                    clientConnection.Write(wzToLoad);
                clientConnection.Close();
                if (wzToLoad != null)
                    Environment.Exit(1337);
                return;
            }
            catch
            {
                try
                {
                    Program.PipeManager = new PipeManager("HaRepacker4", new PipeRequestHandler(OnPipeRequest));
                    Program.PipeManager.Initialize();
                }
                catch
                {
                    Warning.Error("Could not initialize piping system");
                }
            }
            if (wzToLoad != null && File.Exists(wzToLoad))
            {
                short version;
                WzMapleVersion encVersion = WzTool.DetectMapleVersion(wzToLoad, out version);
                encryptionBox.SelectedIndex = (int)encVersion;
                LoadWzFileThreadSafe(wzToLoad, MainPanel, false);
                //Program.WzMan.OpenAWzFile(wzToLoad, encVersion, version, false, MainPanel);
            }
        }
Example #3
0
 private void button1_Click(object sender, System.EventArgs e)
 {
     if (textBox1.Text != "") {
         DateTime dt = DateTime.Now;
         // This cycle is used only when you want to run numerous name pipes requests
         // and measure the performance. In the general case it is not needed.
         for (int i = 0; i < 1; i++) {
             IInterProcessConnection clientConnection = null;
             try {
                 clientConnection = new ClientPipeConnection("MyPipe", ".");
                 clientConnection.Connect();
                 clientConnection.Write(textBox1.Text);
                 Activity.AppendText(clientConnection.Read() + Environment.NewLine);
                 clientConnection.Close();
             }
             catch (Exception ex) {
                 clientConnection.Dispose();
                 throw (ex);
             }
         }
         this.duration.Text = DateTime.Now.Subtract(dt).Milliseconds.ToString();
     }
 }
Example #4
0
 private void StopServerPipe()
 {
     try
     {
         ClientPipeConnection pipe = new ClientPipeConnection(_pipeName);
         if (pipe.TryConnect())
         {
             pipe.Close();
         }
     }
     catch
     {
         // Log exception
     }
 }