예제 #1
0
 public Receiver(TcpClient connectedSocket, bool automaticAnswer, string pathDest, SettingsForm settingsForm)
 {
     this.connectedSocket = connectedSocket;
     this.automaticAnswer = automaticAnswer;
     this.pathDest        = pathDest;
     this.settingsForm    = settingsForm;
 }
예제 #2
0
 public ClientTCP(string pathFile, bool IsFolder, string userName, IPEndPoint endPoint, SettingsForm settingsForm)
 {
     this.pathFile     = pathFile;
     this.userName     = userName;
     this.endPoint     = endPoint;
     this.IsFolder     = IsFolder;
     this.settingsForm = settingsForm;
 }
예제 #3
0
        static void Main(String[] args)
        {
            //if the mutex is owned enter and launch the program
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                try
                {
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.EnableVisualStyles();

                    Options options = new Options();
                    KeyReg  keyReg  = new KeyReg();

                    //check if user is already logged
                    if (options.Name.Equals("DefaultName"))
                    {
                        FirstRegistrationForm registrationForm = new FirstRegistrationForm(options);
                        Task task = new Task(() => { registrationForm.ShowDialog(); });
                        task.RunSynchronously();
                    }

                    if (args.Length > 0)
                    {
                        //create SettingsForm passing args
                        Console.WriteLine(args[0]);
                        settingsForm = new SettingsForm(args[0]);
                    }
                    else
                    {
                        settingsForm = new SettingsForm(null);
                    }
                    Application.Run(settingsForm);
                }
                catch (Exception e)
                { Console.WriteLine(e.ToString()); }
                finally
                {
                    //release mutex
                    mutex.ReleaseMutex();
                }
            }
            else
            {
                if (args.Length > 0)
                {
                    Boolean repeat = true;
                    int     i      = 0;
                    while (repeat)
                    {
                        NamedPipeClientStream pipe = new NamedPipeClientStream(".", "RibbitPipe", PipeAccessRights.FullControl,
                                                                               PipeOptions.WriteThrough, System.Security.Principal.TokenImpersonationLevel.None, System.IO.HandleInheritability.None);
                        repeat = false;
                        i++;
                        try
                        {
                            pipe.Connect(3000);
                            byte[] argbytes = Encoding.UTF8.GetBytes(args[0]);
                            byte[] bytes    = new byte[argbytes.Length + 4];
                            Buffer.BlockCopy(BitConverter.GetBytes((Int32)argbytes.Length), 0, bytes, 0, 4);
                            Buffer.BlockCopy(argbytes, 0, bytes, 4, argbytes.Length);
                            pipe.Write(bytes, 0, bytes.Length);
                        }
                        catch (System.IO.IOException e)
                        {
                            if (i < 2)
                            {
                                repeat = true;
                            }
                            Console.WriteLine(e.ToString());
                        }
                        catch (TimeoutException e)
                        {
                            if (i < 2)
                            {
                                repeat = true;
                            }
                            Console.WriteLine(e.ToString());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                        finally
                        {
                            pipe.Flush();
                            pipe.Close();
                        }
                    }
                }
                else
                {
                    //program already open
                    MessageBox.Show("Program is already running!!");
                }
            }
        }
예제 #4
0
        public SharingForm(List <User> userList, ConcurrentDictionary <SharingForm, String> sharingFormList, string sourcePath, Options options, SettingsForm settingsForm, Flag isCreated)
        {
            InitializeComponent();
            this.sourcePath      = sourcePath;
            this.options         = options;
            this.sharingFormList = sharingFormList;
            this.settingsForm    = settingsForm;
            this.isCreated       = isCreated;
            userCollection       = new ObservableCollection <User>(userList);

            SettingList();
            PrintList();
            EditTitleBar();

            //set delegate
            addItemDelegate     = new AddRemoveChangeItem(this.AddItemMethod);
            removeItemDelegate  = new AddRemoveChangeItem(this.RemoveItemMethod);
            changeItemDelegate  = new AddRemoveChangeItem(this.ChangeItemMethod);
            closeThreadDelegate = new CloseThread(this.CloseForm);

            threadList = new HashSet <Thread>();
        }
예제 #5
0
 public ServerUDP(List <User> userList, ConcurrentDictionary <SharingForm, String> sharingFormList, SettingsForm settingsForm)
 {
     this.settingsForm    = settingsForm;
     this.closeServerUDP  = false;
     this.sharingFormList = sharingFormList;
     this.userList        = userList;
     this.queue           = new ConcurrentQueue <Tuple <byte[], IPEndPoint> >();
     this.newData         = new AutoResetEvent(false);
     this.closeThread     = new ManualResetEvent(false);
 }