Exemplo n.º 1
0
 public GridView(MainForm parent, ref configurationGrid layout)
 {
     InitializeComponent();
     _gv = new Controls.GridView(parent, ref layout, this);
     _gv.KeyDown += GridView_KeyDown;
     Controls.Add(_gv);
     _gv.Dock = DockStyle.Fill;
     _layout = layout;
     fullScreenToolStripMenuItem.Checked = layout.FullScreen;
     alwaysOnTopToolStripMenuItem.Checked = layout.AlwaysOnTop;
     Cg = layout;
 }
Exemplo n.º 2
0
        public GridView(MainForm parent, string layout)
        {
            InitializeComponent();
            _gv = new Controls.GridView();
            Controls.Add(_gv);
            _gv.Dock = DockStyle.Fill;
            _gv._parent = parent;

            string t = layout;
            string[] rc = t.Split('x');
            _gv.Cols = Convert.ToInt32(rc[0]);
            _gv.Rows = Convert.ToInt32(rc[1]);
        }
Exemplo n.º 3
0
        public PlayerVLC(string titleText, MainForm mf)
        {
            MF = mf;
            InitializeComponent();
            var arguments = new[] { "--file-caching="+MainForm.Conf.VLCFileCache };
            _mFactory = new MediaPlayerFactory(arguments);
            _mPlayer = _mFactory.CreatePlayer<IDiskPlayer>();

            _mPlayer.Events.PlayerPositionChanged += EventsPlayerPositionChanged;
            _mPlayer.Events.TimeChanged += EventsTimeChanged;
            _mPlayer.Events.MediaEnded += EventsMediaEnded;
            _mPlayer.Events.PlayerStopped += EventsPlayerStopped;

            _mPlayer.WindowHandle = pnlMovie.Handle;

             if (_mPlayer.Volume>=trackBar2.Minimum && _mPlayer.Volume<=trackBar2.Maximum)
                trackBar2.Value = _mPlayer.Volume;

             RenderResources();
             _titleText = titleText;
             chkRepeatAll.Checked = MainForm.VLCRepeatAll;
        }
Exemplo n.º 4
0
        public MainForm(bool silent, string command)
        {
            if (Conf.StartupForm != "iSpy")
            {
                SilentStartup = true;
            }

            SilentStartup = SilentStartup || silent || Conf.Enable_Password_Protect || Conf.StartupMode == 1;

            //need to wrap initialize component
            if (SilentStartup)
            {
                ShowInTaskbar = false;
                ShowIcon = false;
                WindowState = FormWindowState.Minimized;
            }
            else
            {
                switch (Conf.StartupMode)
                {
                    case 0:
                        _mWindowState = new PersistWindowState {Parent = this, RegistryPath = @"Software\ispy\startup"};
                        break;
                    case 2:
                        WindowState = FormWindowState.Maximized;
                        break;
                    case 3:
                        WindowState = FormWindowState.Maximized;
                        FormBorderStyle = FormBorderStyle.None;
                        break;
                }
            }

            InitializeComponent();

            if (!SilentStartup)
            {
                if (Conf.StartupMode == 0)
                    _mWindowState = new PersistWindowState {Parent = this, RegistryPath = @"Software\ispy\startup"};
            }

            RenderResources();

            _startCommand = command;

            Windows7Renderer r = Windows7Renderer.Instance;
            toolStripMenu.Renderer = r;
            statusStrip1.Renderer = r;

            _pnlCameras.BackColor = Conf.MainColor.ToColor();

            RemoteManager = new McRemoteControlManager.RemoteControlDevice();
            RemoteManager.ButtonPressed += RemoteManagerButtonPressed;

            SetPriority();
            Arrange(false);

            _jst = new JoystickDevice();
            bool jsactive = false;
            string[] sticks = _jst.FindJoysticks();
            foreach (string js in sticks)
            {
                string[] nameid = js.Split('|');
                if (nameid[1] == Conf.Joystick.id)
                {
                    Guid g = Guid.Parse(nameid[1]);
                    jsactive = _jst.AcquireJoystick(g);
                }
            }

            if (!jsactive)
            {
                _jst.ReleaseJoystick();
                _jst = null;
            }
            else
            {
                _tmrJoystick = new Timer(100);
                _tmrJoystick.Elapsed += TmrJoystickElapsed;
                _tmrJoystick.Start();
            }
            try
            {
                INetworkListManager mNlm = new NetworkListManager();
                var icpc = (IConnectionPointContainer) mNlm;
                //similar event subscription can be used for INetworkEvents and INetworkConnectionEvents
                Guid tempGuid = typeof (INetworkListManagerEvents).GUID;
                icpc.FindConnectionPoint(ref tempGuid, out _mIcp);
                if (_mIcp != null)
                {
                    _mIcp.Advise(this, out _mCookie);
                }
            }
            catch (Exception)
            {
                _mIcp = null;
            }
            InstanceReference = this;
        }
Exemplo n.º 5
0
 private void Importer_Load(object sender, EventArgs e)
 {
     mainForm = (MainForm) Owner;
 }
Exemplo n.º 6
0
        private bool Sftp(string server, int port, bool passive, string username, string password, string filename, int counter, byte[] contents, out string error, bool rename)
        {
            bool failed = false;

            error = "";
            try
            {
                int i = 0;
                filename = filename.Replace("{C}", counter.ToString(CultureInfo.InvariantCulture));
                if (rename)
                {
                    filename += ".tmp";
                }

                while (filename.IndexOf("{", StringComparison.Ordinal) != -1 && i < 20)
                {
                    filename = String.Format(CultureInfo.InvariantCulture, filename, Helper.Now);
                    i++;
                }

                var methods = new List <AuthenticationMethod> {
                    new PasswordAuthenticationMethod(username, password)
                };

                var con = new ConnectionInfo(server, port, username, methods.ToArray());
                using (var client = new SftpClient(con))
                {
                    client.Connect();

                    var filepath = filename.Trim('/').Split('/');
                    var path     = "";
                    for (var iDir = 0; iDir < filepath.Length - 1; iDir++)
                    {
                        path += filepath[iDir] + "/";
                        try
                        {
                            client.CreateDirectory(path);
                        }
                        catch
                        {
                            //directory exists
                        }
                    }
                    if (path != "")
                    {
                        client.ChangeDirectory(path);
                    }

                    filename = filepath[filepath.Length - 1];

                    using (Stream stream = new MemoryStream(contents))
                    {
                        client.UploadFile(stream, filename);
                        if (rename)
                        {
                            try
                            {
                                //delete target file?
                                client.DeleteFile(filename.Substring(0, filename.Length - 4));
                            }
                            catch (Exception)
                            {
                            }
                            client.RenameFile(filename, filename.Substring(0, filename.Length - 4));
                        }
                    }

                    client.Disconnect();
                }


                MainForm.LogMessageToFile("SFTP'd " + filename + " to " + server + " port " + port, "SFTP");
            }
            catch (Exception ex)
            {
                error  = ex.Message;
                failed = true;
            }
            return(!failed);
        }
Exemplo n.º 7
0
        public bool FTP(string server, int port, bool passive, string username, string password, string filename, int counter, byte[] contents, out string error, bool rename, bool useSFTP)
        {
            bool failed = false;

            if (useSFTP)
            {
                return(Sftp(server, port, passive, username, password, filename, counter, contents, out error, rename));
            }
            try
            {
                var target = new Uri(server + ":" + port);
                int i      = 0;
                filename = filename.Replace("{C}", counter.ToString(CultureInfo.InvariantCulture));
                if (rename)
                {
                    filename += ".tmp";
                }

                while (filename.IndexOf("{", StringComparison.Ordinal) != -1 && i < 20)
                {
                    filename = String.Format(CultureInfo.InvariantCulture, filename, Helper.Now);
                    i++;
                }

                //try uploading
                //directory tree
                var           filepath = filename.Trim('/').Split('/');
                var           path     = "";
                FtpWebRequest request;
                for (var iDir = 0; iDir < filepath.Length - 1; iDir++)
                {
                    path               += filepath[iDir] + "/";
                    request             = (FtpWebRequest)WebRequest.Create(target + path);
                    request.Credentials = new NetworkCredential(username, password);
                    request.Method      = WebRequestMethods.Ftp.MakeDirectory;
                    try { request.GetResponse(); }
                    catch
                    {
                        //directory exists
                    }
                }

                request             = (FtpWebRequest)WebRequest.Create(target + filename);
                request.Credentials = new NetworkCredential(username, password);
                request.UsePassive  = passive;
                //request.UseBinary = true;
                request.Method        = WebRequestMethods.Ftp.UploadFile;
                request.ContentLength = contents.Length;

                Stream requestStream = request.GetRequestStream();
                requestStream.Write(contents, 0, contents.Length);
                requestStream.Close();

                var response = (FtpWebResponse)request.GetResponse();
                if (response.StatusCode != FtpStatusCode.ClosingData)
                {
                    MainForm.LogErrorToFile("FTP Failed: " + response.StatusDescription, "FTP");
                    failed = true;
                }

                response.Close();

                if (rename && !failed)
                {
                    //delete existing
                    request             = (FtpWebRequest)WebRequest.Create(target + filename.Substring(0, filename.Length - 4));
                    request.Credentials = new NetworkCredential(username, password);
                    request.UsePassive  = passive;
                    //request.UseBinary = true;
                    request.Method = WebRequestMethods.Ftp.DeleteFile;
                    filename       = "/" + filename;

                    try
                    {
                        response = (FtpWebResponse)request.GetResponse();
                        if (response.StatusCode != FtpStatusCode.ActionNotTakenFileUnavailable &&
                            response.StatusCode != FtpStatusCode.FileActionOK)
                        {
                            MainForm.LogErrorToFile("FTP Delete Failed: " + response.StatusDescription, "FTP");
                            failed = true;
                        }

                        response.Close();
                    }
                    catch
                    {
                        //Logger.LogExceptionToFile(ex, "FTP");
                        //ignore
                    }

                    //rename file
                    if (!failed)
                    {
                        request             = (FtpWebRequest)WebRequest.Create(target + filename);
                        request.Credentials = new NetworkCredential(username, password);
                        request.UsePassive  = passive;
                        //request.UseBinary = true;
                        request.Method = WebRequestMethods.Ftp.Rename;
                        filename       = "/" + filename;

                        request.RenameTo = filename.Substring(0, filename.Length - 4);

                        response = (FtpWebResponse)request.GetResponse();
                        if (response.StatusCode != FtpStatusCode.FileActionOK)
                        {
                            MainForm.LogErrorToFile("FTP Rename Failed: " + response.StatusDescription, "FTP");
                            failed = true;
                        }
                        response.Close();
                    }
                }
                if (!failed)
                {
                    MainForm.LogMessageToFile("FTP'd " + filename + " to " + server + ":" + port, "FTP");
                }
                error = failed ? "FTP Failed. Check Log" : "";
            }
            catch (Exception ex)
            {
                error  = ex.Message;
                failed = true;
            }
            return(!failed);
        }