Exemple #1
0
        /// <summary>
        /// Execute a form base application if another instance already running on
        /// the system activate previous one
        /// </summary>
        /// <param name="frmMain">main form</param>
        /// <returns>true if no previous instance is running</returns>
        internal static bool Run(System.Windows.Forms.Form frmMain)
        {
            if (IsAlreadyRunning())
            {
                //set focus on previously running app
                if (Program.args != null)
                {
                    if (Program.args.Length > 0)
                    {
                        CopyData copyData = new CopyData();
                        copyData.Channels.Add("1");
                        for (int i = 0; i < Program.args.Length; i++)
                        {
                            copyData.Channels["1"].Send(Program.args[i]);
                        }
                    }
                }

                SwitchToCurrentInstance();
                return(false);
            }
            Application.Run(frmMain);
            return(true);
        }
Exemple #2
0
        void Init()
        {
            Console.SetError(Console.Out);
            if (Properties.Settings.Default.firstRunGroupCreation)
            {
                Properties.Settings.Default.Upgrade();
            }
            //if (Properties.Settings.Default.showDisclaimer) {
            //    Disclaimer d=new Disclaimer();
            //    if (d.ShowDialog(this) == DialogResult.Yes) {
            //        Properties.Settings.Default.showDisclaimer = false;
            //        Properties.Settings.Default.Save();
            //    } else {
            //        exit();
            //        return;
            //    }
            //}
            //if (DateTime.Now.Ticks - Properties.Settings.Default.lastCheckForUpdate.Ticks > new TimeSpan(2, 0, 0, 0).Ticks) {
            //    Properties.Settings.Default.lastCheckForUpdate = DateTime.Now;
            //    Properties.Settings.Default.Save();
            //    checkUpdates(true);
            //}
            uiTSMainMenu.Renderer       = new CustomProfessionalToolStripRenderer();
            uiTSSearch.Renderer         = new CustomProfessionalToolStripRenderer();
            uiToolStripResults.Renderer = new CustomProfessionalToolStripRenderer();
            uiTSGroups.Renderer         = new CustomProfessionalToolStripRenderer();
            uiToolStripResults.Renderer = new CustomProfessionalToolStripRenderer();
            uiTSBtnOpen.Click          += uiTSMIOpenFiles_Click;
            uiTSBtnExplore.Click       += uiTSBtnExplore_Click;
            uiTSBtnCut.Click           += uiTSMICutFiles_Click;
            uiTSBtnCopy.Click          += uiTSMICopyFiles_Click;
            uiTSBtnCopyText.Click      += uiTSMICopyText_Click;
            uiTSBtnImagePreview.Click  += uiTSBtnImagePreview_Click;
            uiTSBtnSelectAll.Click     += uiTSMISelectAll_Click;
            uiTSBtnSelectNone.Click    += uiTSMISelectNone_Click;
            uiTSBtnResizeCols.Click    += uiTSBtnResizeCols_Click;
            ipf.Owner = this;
            tagHelp(this);
            loadHelp(uiTSMainMenu, null);
            this.SuspendLayout();
            uiGroupsTSContainer.Dock  = DockStyle.Fill;
            uiSearchTSContainer.Dock  = DockStyle.Fill;
            uiSplitGroupsResults.Dock = DockStyle.Fill;
            uiSplitInfoOptions.Dock   = DockStyle.Fill;
            uiSplitLeftRight.Dock     = DockStyle.Fill;
            uiTabAdvancedOptions.Dock = DockStyle.Fill;
            uiTabInfoPane.Dock        = DockStyle.Fill;
            this.ResumeLayout();
            g  = uiDGVResults.CreateGraphics();
            hd = new HardDisk(bw, resultWorker);
            hd.SearchComplete  += new SearchCompleteDelegate(hd_SearchComplete);
            hd.JobComplete     += new HardDisk.TreeEventHandler(hd_JobComplete);
            hd.FolderProcessed += new HardDisk.TreeEventHandler(hd_FolderProcessed);
            new FileDragDropHandler(uiTVGroups).FilesDropped += new DragDropOccured(fdd_FilesDropped);
            uiTSBtnAdvancedOptions_CheckedChanged(null, null);
            uiNotifyIcon.Icon = Properties.Resources.rf_icon_v2;
            this.Icon         = Properties.Resources.rf_icon_v2;
            DataCols.Add(new DataCol("icon", "", typeof(string), typeof(string)));
            DataCols.Add(new DataCol("path", "Path", typeof(Tree <FolderData>), typeof(string)));
            DataCols.Add(new DataCol("name", "Name", typeof(string), typeof(string)));
            DataCols.Add(new DataCol("ext", "Extension", typeof(string), typeof(string)));
            DataCols.Add(new DataCol("size", "Size(KB)", typeof(long), typeof(long)));
            DataCols.Add(new DataCol("type", "Type", typeof(string), typeof(string)));
            //DataCols.Add(new DataCol("created", "Created", typeof(long), typeof(string)));
            DataCols.Add(new DataCol("modified", "Modified", typeof(long), typeof(string)));

            for (int i = 0; i < DataCols.Count; i++)
            {
                setCol(uiDGVResults, DataCols[i].ID, DataCols[i].Name, DataCols[i].GridType);
            }
            uiDGVResults.Columns["size"].DefaultCellStyle.Format    = "n0";
            uiDGVResults.Columns["size"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            curResults = new DataTable("results");
            for (int i = 1; i < DataCols.Count; i++)
            {
                curResults.Columns.Add(DataCols[i].ID, DataCols[i].MemType);
            }
            curView = new DataView(curResults);
            //ToolStripMenuItem tsmi=new ToolStripMenuItem(
            //cmsAddSystemFolder.Items.Add("Start Menu Group", null, new EventHandler(cmsAddSystemFolderItem_Click));

            string[] s = Enum.GetNames(typeof(Environment.SpecialFolder));
            for (int i = 0; i < s.Length; i++)
            {
                s[i] = Environment.GetFolderPath((Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), s[i]));
            }
            Array.Resize <string>(ref s, s.Length + 1);
            s[s.Length - 1] = Path.Combine(System.Environment.GetEnvironmentVariable("ALLUSERSPROFILE"), "Start Menu");
            Array.Sort <string>(s);
            for (int i = 0; i < s.Length; i++)
            {
                if (!String.IsNullOrEmpty(s[i]))
                {
                    uiTSDDAddSysFolder.DropDownItems.Add(s[i], IconHandler.IconFromFileName(s[i], IconSize.Small).ToBitmap(), new EventHandler(uiTSMIAddSystemFolderItem_Click));
                }
            }

            ReadGroupList();
            if (Program.args != null)
            {
                if (Program.args.Length > 0)
                {
                    string temp;
                    //MessageBox.Show(PrintString(Program.args));
                    List <string> cmdArgs = new List <string>();
                    for (int i = 0; i < Program.args.Length; i++)
                    {
                        temp = Path.GetFullPath(Program.args[i]);
                        if (Directory.Exists(temp) | File.Exists(temp))
                        {
                            cmdArgs.Add(temp);
                        }
                    }
                    AddPaths(cmdArgs.ToArray());
                }
            }
            if (Properties.Settings.Default.firstRunGroupCreation)
            {
                CreateFirstRunGroup();
                Properties.Settings.Default.firstRunGroupCreation = false;
                Properties.Settings.Default.Save();
            }
            CopyData copyData = new CopyData();

            copyData.AssignHandle(this.Handle);
            copyData.Channels.Add("1");
            copyData.DataReceived += new DataReceivedEventHandler(copyData_DataReceived);
            //makePerty(this);
            this.Text = String.Format("{0} {1} {2}", Application.ProductName, Application.ProductVersion, Application.CompanyName);
            uiTSBtnInfoPane.Checked = Properties.Settings.Default.showInfoPane;
            this.Activate();
        }