Exemple #1
0
        void ExplodeGT2Vol(object o)
        {
            ThreadArgs tArgs = (ThreadArgs)o;

            try
            {
                string file = tArgs.volFile;
                if (!File.Exists(file))
                {
                    MessageBox.Show("Selected VOL file doesn't exist!", "GTVolTool");
                    return;
                }
                using (GT2Vol.VolFile vf = new GT2Vol.VolFile(file))
                {
                    gt2VolNotifyCalls = 0;
                    if (!vf.CheckAndCacheHeaderDetails())
                    {
                        MessageBox.Show("Incorrect or inconsistent VOL header", "GTVolTool");
                        return;
                    }
                    statusText.Text = "Exploding...";
                    vf.ParseToc(null);
                    gt2VolNotifyCalls = 0;
                    vf.Explode(tArgs.dir, tArgs.decompress, new GT2Vol.VolFile.ExplodeProgressCallback(GT2ExplodeCallback));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Caught the following exception while exploding:\n{0}", ex.Message), "GTVolTool");
            }
        }
Exemple #2
0
        private void DoRebuilding(object o)
        {
            ThreadArgs tArgs = (ThreadArgs)o;

            try
            {
                gt2VolNotifyCalls = 0;
                GT2Vol.Rebuilder r = new GT2Vol.Rebuilder();
                statusText.Text = "Scanning directory";
                List <GT2Vol.Rebuilder.FSEntry> entries = r.ScanAndCompress(tArgs.dir, false);
                if (entries.Count == 0)
                {
                    MessageBox.Show("There are no files in the directory!", "GT2VolTool");
                    return;
                }
                statusText.Text = "Building Header";
                GT2Vol.Rebuilder.HeaderInfo hi = r.BuildHeader(entries);
                statusText.Text = "Writing new VOL";
                r.WriteNewVol(tArgs.volFile, hi, entries, new GT2Vol.VolFile.ExplodeProgressCallback(GT2ExplodeCallback));
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Caught the following exception while building:\n{0}", ex.Message), "GT2VolTool");
            }
        }
Exemple #3
0
        private void CalculateMemoryThread(object obj)
        {
            ThreadArgs args = obj as ThreadArgs;

            lock (typeof(ThreadArgs)) {
                CalculateMemory(args);
            }
        }
Exemple #4
0
 public void RunTask(ThreadArgs arg)
 {
     this.Arg = arg;
     if (!isRunning)
     {
         Run();
     }
 }
Exemple #5
0
        private static void ActionThread(object aArgs)
        {
            ThreadArgs args = (ThreadArgs)aArgs;

            using (CpProxyOpenhomeOrgTestBasic1 proxy = new CpProxyOpenhomeOrgTestBasic1(args.Device))
            {
                uint val;
                do
                {
                    proxy.SyncGetUint(out val);
                } while (args.IncrementCount());
            }
        }
Exemple #6
0
        private static void SubscriptionThread(object aArgs)
        {
            ThreadArgs args = (ThreadArgs)aArgs;
            Semaphore  sem  = new Semaphore(0, 1);

            do
            {
                CpProxyOpenhomeOrgTestBasic1 proxy = new CpProxyOpenhomeOrgTestBasic1(args.Device);
                proxy.SetPropertyChanged(() => sem.Release());
                proxy.Subscribe();
                sem.WaitOne();
                proxy.Dispose();
            } while (args.IncrementCount());
        }
Exemple #7
0
        private void gt3VolToDir_Click(object sender, EventArgs e)
        {
            DisableButtons();
            ThreadArgs tArgs = new ThreadArgs();

            tArgs.dir     = dirNameTextBox.Text;
            tArgs.volFile = volNameTextBox.Text;
            Thread t = new Thread(new ParameterizedThreadStart(ExplodeGT3Vol));

            t.SetApartmentState(ApartmentState.MTA);
            t.Start(tArgs);
            while (!t.Join(100))
            {
                Application.DoEvents();
            }
            wfss.Send(new SendOrPostCallback(SetStatusText), "Finished");
            TryEnableButtons();
        }
Exemple #8
0
        void ExplodeGT3Vol(object o)
        {
            ThreadArgs tArgs = (ThreadArgs)o;

            try
            {
                string file = tArgs.volFile;
                if (!File.Exists(file))
                {
                    MessageBox.Show("Selected VOL file doesn't exist!", "GTVolTool");
                    return;
                }
                GT2Vol.GT3Vol vf = new GT2Vol.GT3Vol(file);
                gt2VolNotifyCalls = 0;
                statusText.Text   = "Exploding...";
                vf.Extract(tArgs.dir, tArgs.decompress, new GT2Vol.VolFile.ExplodeProgressCallback(GT2ExplodeCallback));
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Caught the following exception while exploding:\n{0}", ex.Message), "GTVolTool");
            }
        }
Exemple #9
0
        private void CalculateMemory(ThreadArgs args)
        {
            Action <long> StatusBarHandler = (num) =>
            {
                _statusBar.Text = "Memory: " + num.ToString() + " MB (" + args.dir.FullName + ")";
            };

            try{
                foreach (FileInfo file in args.dir.GetFiles())
                {
                    args.memory += file.Length;
                    _statusBar.Invoke(StatusBarHandler, new object[] { args.memory / 1024 / 1024 });
                }

                foreach (DirectoryInfo dir in args.dir.GetDirectories())
                {
                    args.dir = dir;
                    CalculateMemory(args);
                }
            }catch (Exception e) {
                Console.WriteLine(e.Message);
            }
        }
        private void RefreshfindAddress()
        {
            if (viewinvoices[listInvoices.SelectedIndex].longitude == 0 && viewinvoices[listInvoices.SelectedIndex].latitude == 0)
            {
                findAddress.Image = RRS.Properties.Resources.loading;

                _bw1 = new BackgroundWorker
                {
                    WorkerReportsProgress = true,
                    WorkerSupportsCancellation = true
                };
                _bw1.DoWork += bw1_DoWork;

                _bw1.RunWorkerCompleted += bw1_RunWorkerCompleted;
                string address = "";
                address = address + textStreet.Text;
                address = address + ", " + textCity.Text;
                address = address + ", " + textState.Text;
                address = address + ",  " + textZip.Text;

                List<object> compiled = new List<object>();
                compiled.Add(address);
                compiled.Add(listInvoices.SelectedIndex);
                ThreadArgs arguments = new ThreadArgs();
                arguments.address = address;
                arguments.selection = listInvoices.SelectedIndex;
                _bw1.RunWorkerAsync(arguments);
            }
            else
            {

                findAddress.Image = RRS.Properties.Resources.greencheck;
            }
        }
Exemple #11
0
        public ListViewPanel(Form parent)
        {
            this.Parent = parent;

            Size      = new Size(this.Parent.Width / 2, this.Parent.Height - 100);
            this.Dock = DockStyle.Right;

            _listView           = new ListView();
            _listView.Parent    = this;
            _listView.Dock      = DockStyle.Fill;
            _listView.View      = View.LargeIcon;
            _listView.LabelEdit = true;

            _listViewController = new ListViewController(this);

            _statusBar        = new StatusBar();
            _statusBar.Parent = this;
            _statusBar.Dock   = DockStyle.Bottom;

            //_contextMenuStrip = new ContextMenuStrip ();
            //_contextMenuStrip = _listView.ContextMenuStrip;
            _listView.ContextMenuStrip  = new ContextMenuStrip();
            _contextMenuStrip           = _listView.ContextMenuStrip;
            _contextMenuStrip.AutoClose = true;

            ToolStripMenuItem itemCheckMem = new ToolStripMenuItem("&CheckMemory");

            _contextMenuStrip.Items.Add(itemCheckMem);

            ToolStripMenuItem itemCheckMem100 = new ToolStripMenuItem("&CheckMemory100");

            _contextMenuStrip.Items.Add(itemCheckMem100);

            ToolStripMenuItem itemDelete = new ToolStripMenuItem("&Delete");

            itemDelete.Enabled = false;
            _contextMenuStrip.Items.Add(itemDelete);

            ToolStripMenuItem itemCopy = new ToolStripMenuItem("&Copy");

            _contextMenuStrip.Items.Add(itemCopy);
            itemCopy.Enabled = false;

            ToolStripMenuItem itemRename = new ToolStripMenuItem("&Rename");

            _contextMenuStrip.Items.Add(itemRename);
            itemRename.Enabled = false;

            ToolStripMenuItem itemMove = new ToolStripMenuItem("&Move");

            _contextMenuStrip.Items.Add(itemMove);
            itemMove.Enabled = false;

            _contextMenuStrip.ItemClicked += (object sender, ToolStripItemClickedEventArgs e) =>
            {
                if (((ContextMenuStrip)sender).Items[Constants.CHECKMEM] == e.ClickedItem)
                {
                    ThreadArgs args   = new ThreadArgs(_listViewController.CurrentDirectory);
                    Thread     thread = new Thread(CalculateMemoryThread);
                    thread.IsBackground = true;
                    thread.Start(args);
                    if (thread.ThreadState == System.Threading.ThreadState.Stopped)
                    {
                        _statusBar.Text = "Finished";
                    }
                }
                else if (((ContextMenuStrip)sender).Items[Constants.CHECKMEM100] == e.ClickedItem)
                {
                    ListboxForm lform = new ListboxForm(_listViewController.CurrentDirectory);
                    lform.Show();
                }
                else if (((ContextMenuStrip)sender).Items[Constants.DELETE] == e.ClickedItem)
                {
                    FileController ufile = new FileController(_listViewController.CurrentDirectory.FullName + Path.DirectorySeparatorChar +
                                                              (_listViewController.GetListViewItem().Text));
                    ufile.Delete();

                    _listViewController.Refresh();
                }
                else if (((ContextMenuStrip)sender).Items[Constants.COPY] == e.ClickedItem)
                {
                    FolderBrowserDialog fd = new FolderBrowserDialog();
                    fd.ShowNewFolderButton = false;
                    fd.ShowDialog();

                    FileController ufile = new FileController(_listViewController.CurrentDirectory.FullName + Path.DirectorySeparatorChar +
                                                              (_listViewController.GetListViewItem().Text));

                    ufile.CopyTo(fd.SelectedPath + Path.DirectorySeparatorChar);

                    _listViewController.Refresh();
                }
                else if (((ContextMenuStrip)sender).Items[Constants.RENAME] == e.ClickedItem)
                {
                    FileController ufile = new FileController(_listViewController.CurrentDirectory.FullName + Path.DirectorySeparatorChar +
                                                              (_listViewController.GetListViewItem().Text));

                    PopoutForm pForm = new PopoutForm(ufile);
                    pForm.Show();

                    ufile.Rename(ufile.NewName);

                    _listViewController.Refresh();
                }
                else if (((ContextMenuStrip)sender).Items[Constants.MOVE] == e.ClickedItem)
                {
                    FolderBrowserDialog fd = new FolderBrowserDialog();
                    fd.ShowNewFolderButton = false;
                    fd.ShowDialog();

                    FileController ufile = new FileController(_listViewController.CurrentDirectory.FullName + Path.DirectorySeparatorChar +
                                                              (_listViewController.GetListViewItem().Text));

                    ufile.MoveTo(fd.SelectedPath + Path.DirectorySeparatorChar);

                    _listViewController.Refresh();
                }
            };

            _listView.AfterLabelEdit += (object sender, LabelEditEventArgs e) =>
            {
                FileController ufile = new FileController(_listViewController.CurrentDirectory.FullName +
                                                          Path.DirectorySeparatorChar + e.Label);
                string newName = e.Label;
                newName = newName.Replace(Environment.NewLine, "");

                ufile.Rename(newName);
            };

            _listView.ItemSelectionChanged += (object sender, ListViewItemSelectionChangedEventArgs e) =>
            {
                string path = _listViewController.CurrentDirectory.FullName + Path.DirectorySeparatorChar + e.Item.Text;
                try{
                    if (!Directory.Exists(path))
                    {
                        Process.Start(path);
                    }
                }catch (Exception ee) {
                    Console.WriteLine(ee.Message);
                }

                _listViewController.SetListViewItem(e.Item);

                if (_listViewController.GetListViewItem() != null)
                {
                    foreach (ToolStripMenuItem item in _contextMenuStrip.Items)
                    {
                        item.Enabled = true;
                    }
                }
            };
        }
Exemple #12
0
        public static void Main(string[] aArgs)
        {
            Console.WriteLine("TestPerformanceCpCs - starting");
            InitParams initParams = new InitParams();
            using (Library lib = Library.Create(initParams))
            {
                SubnetList subnetList = new SubnetList();
                NetworkAdapter nif = subnetList.SubnetAt(0);
                uint subnet = nif.Subnet();
                subnetList.Dispose();
                var deviceListFactory = new CpUpnpDeviceListFactory(lib.StartCp(subnet));
                ICpDevice device = null;
                Semaphore sem = new Semaphore(0, 1);
                var deviceList = deviceListFactory.CreateListServiceType("openhome.org", "TestBasic", 1,
                        (aDeviceList, aDevice) =>
                        {
                            if (device != null)
                            {
                                throw new Exception("Found more than one device.  Giving up as test results will probably be invalid.");
                            }
                            device = aDevice;
                            device.AddRef();
                            sem.Release();
                        },
                        (aDeviceList, aDevice) =>
                        {
                            throw new Exception("ERROR: Device removed while test is running.");
                        });
                sem.WaitOne();

                // actions
                Console.WriteLine("");
                int[] threadCounts = { 1, 2, 4 };
                foreach (int threadCount in threadCounts)
                {
                    List<Thread> threads = new List<Thread>();
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads.Add(new Thread(ActionThread));
                    }
                    ThreadArgs threadArgs = new ThreadArgs(device, kTestDurationMs);
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads[i].Start(threadArgs);
                    }
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads[i].Join();
                    }
                    Console.WriteLine("Invoked {0} actions in {1}ms using {2} threads", threadArgs.Count, kTestDurationMs, threadCount);
                }

                // subscriptions
                Thread thread = new Thread(SubscriptionThread);
                ThreadArgs args = new ThreadArgs(device, kTestDurationMs);
                thread.Start(args);
                thread.Join();
                Console.WriteLine("\nCompleted {0} subscriptions in {1}ms\n", args.Count, kTestDurationMs);

                device.RemoveRef();
                deviceList.Dispose();
                Console.WriteLine("\nTests complete.  Press 'q' to exit.");
                while (Console.ReadKey(true).KeyChar != 'q') ;
            }
        }
        private void RefreshfindAddress()
        {
            if (listAllItems.SelectedIndex != -1)
            {
                if (viewinvoices[listAllItems.SelectedIndex].longitude == 0 && viewinvoices[listAllItems.SelectedIndex].latitude == 0)
                {
                    findAddress.Image = RRS.Properties.Resources.loading;
                    _bw1 = new BackgroundWorker
                    {
                        WorkerReportsProgress = true,
                        WorkerSupportsCancellation = true
                    };
                    _bw1.DoWork += bw1_DoWork;

                    _bw1.RunWorkerCompleted += bw1_RunWorkerCompleted;
                    string address = "";
                    address = address + textStreet.Text;
                    address = address + ", " + textCity.Text;
                    address = address + ", " + textState.Text;
                    address = address + ",  " + textZip.Text;
                    ThreadArgs threadargs = new ThreadArgs();
                    threadargs.address = address;
                    threadargs.list = 2;
                    threadargs.selection = listAllItems.SelectedIndex;
                    _bw1.RunWorkerAsync(threadargs);
                }
                else
                {
                    findAddress.Image = RRS.Properties.Resources.greencheck;
                }
            }
            if (listRouteItems.SelectedIndex != -1)
            {
                int index = 0;
                for (int i = 0; i < scheduledinvoicesorder.Count; i++)
                {
                    if (listRouteItems.SelectedIndex == scheduledinvoicesorder[i])
                    {
                        index= i;
                    }
                }
                if (scheduledinvoices[index].longitude == 0 && scheduledinvoices[index].latitude == 0)
                {
                    findAddress.Image = RRS.Properties.Resources.loading;
                    _bw1 = new BackgroundWorker
                    {
                        WorkerReportsProgress = true,
                        WorkerSupportsCancellation = true
                    };
                    _bw1.DoWork += bw1_DoWork;

                    _bw1.RunWorkerCompleted += bw1_RunWorkerCompleted;
                    string address = "";
                    address = address + textStreet.Text;
                    address = address + ", " + textCity.Text;
                    address = address + ", " + textState.Text;
                    address = address + ",  " + textZip.Text;
                    ThreadArgs threadargs = new ThreadArgs();
                    threadargs.address = address;
                    threadargs.list = 1;
                    threadargs.selection = index;

                    _bw1.RunWorkerAsync(threadargs);
                }
                else
                {
                    findAddress.Image = RRS.Properties.Resources.greencheck;
                }
            }
        }
Exemple #14
0
        public static void Main(string[] aArgs)
        {
            Console.WriteLine("TestPerformanceCpCs - starting");
            InitParams initParams = new InitParams();

            using (Library lib = Library.Create(initParams))
            {
                SubnetList     subnetList = new SubnetList();
                NetworkAdapter nif        = subnetList.SubnetAt(0);
                uint           subnet     = nif.Subnet();
                subnetList.Dispose();
                var       deviceListFactory = new CpUpnpDeviceListFactory(lib.StartCp(subnet));
                CpDevice  device            = null;
                Semaphore sem        = new Semaphore(0, 1);
                var       deviceList = deviceListFactory.CreateListServiceType("openhome.org", "TestBasic", 1,
                                                                               (aDeviceList, aDevice) =>
                {
                    if (device != null)
                    {
                        throw new Exception("Found more than one device.  Giving up as test results will probably be invalid.");
                    }
                    device = aDevice;
                    device.AddRef();
                    sem.Release();
                },
                                                                               (aDeviceList, aDevice) =>
                {
                    throw new Exception("ERROR: Device removed while test is running.");
                });
                sem.WaitOne();

                // actions
                Console.WriteLine("");
                int[] threadCounts = { 1, 2, 4 };
                foreach (int threadCount in threadCounts)
                {
                    List <Thread> threads = new List <Thread>();
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads.Add(new Thread(ActionThread));
                    }
                    ThreadArgs threadArgs = new ThreadArgs(device, kTestDurationMs);
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads[i].Start(threadArgs);
                    }
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads[i].Join();
                    }
                    Console.WriteLine("Invoked {0} actions in {1}ms using {2} threads", threadArgs.Count, kTestDurationMs, threadCount);
                }

                // subscriptions
                Thread     thread = new Thread(SubscriptionThread);
                ThreadArgs args   = new ThreadArgs(device, kTestDurationMs);
                thread.Start(args);
                thread.Join();
                Console.WriteLine("\nCompleted {0} subscriptions in {1}ms\n", args.Count, kTestDurationMs);

                device.RemoveRef();
                deviceList.Dispose();
                Console.WriteLine("\nTests complete.  Press 'q' to exit.");
                while (Console.ReadKey(true).KeyChar != 'q')
                {
                    ;
                }
            }
        }
Exemple #15
0
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释

        private void Set(ThreadArgs arg, InnerThread th)
        {
            arg.Recyle();
            ThreadCache.Set(th);
            Interlocked.Decrement(ref ThreadCount);
        }