protected void Page_Load(object sender, EventArgs e) { Log.Logger log = new Log.Logger("HOO.WebClient", this.GetType()); log.Entry.MethodName = "Page_Load"; log.Entry.StepName = "Log started."; log.Debug("Another log online message."); IHOOService Channel = BackServiceHelper.ConnectToBackService(); log.Entry.StepName = "Loading Universes from DB."; try { var allUniverses = Channel.GetAllUniverses(); gvUniverses.DataSource = allUniverses; gvUniverses.DataBind(); } catch (Exception ex) { log.Error(ex); } /* MySqlDBHelper dh = new MySqlDBHelper(SensitiveData.ConnectionString); DBCommandResult res = dh.GetAllUniverses (); if (res.ResultCode == 0) { gvUniverses.DataSource = res.Tag; gvUniverses.DataBind (); } */ }
public UniverseHelper() { //this._dh = new MySqlDBHelper(SensitiveData.ConnectionString); this._mdh = new MongoDBHelper(); this.Universe = new Universe (); this.log = new Log.Logger("HOO.SvcLib", typeof(UniverseHelper)); }
private List <VirtualCacheWithBackgroundRefresh> CreateVCs(int ThreadCount) { //VirtualCache.Persisted = true; List <VirtualCacheWithBackgroundRefresh> vcs = new List <VirtualCacheWithBackgroundRefresh>(); // Use a profile that uses more resources to accomodate more data in-memory (faster!). var profile = new Profile { MemoryLimitInPercent = 98, MaxStoreCount = ThreadCount, BTreeSlotLength = 250 }; for (int i = 0; i < ThreadCount; i++) { var vc = new VirtualCacheWithBackgroundRefresh(string.Format("MyCacheStore{0}", i), true, null, profile); if (_logger == null) { _logger = vc.Logger; _logger.LogLevel = Log.LogLevels.Verbose; _logger.Information("Start of VirtualCache demo."); } vcs.Add(vc); } return(vcs); }
public StarHelper(Star s) { // this._dh = new MySqlDBHelper (SensitiveData.ConnectionString); this._mdh = new MongoDBHelper(); this.Star = s; this.log = new Log.Logger("HOO.SvcLib", typeof(StarHelper)); }
public StarOrbitalBodyHelper(StarOrbitalBody starOrbitalBody) { // _dh = new MySqlDBHelper (SensitiveData.ConnectionString); this._mdh = new MongoDBHelper(); OrbitalBody = starOrbitalBody; this.log = new Log.Logger("HOO.SvcLib", typeof(StarOrbitalBodyHelper)); }
public GalaxyHelper() { // this._dh = new MySqlDBHelper(SensitiveData.ConnectionString); this._mdh = new MongoDBHelper(); this.Galaxy = new Galaxy (); this.log = new Log.Logger("HOO.SvcLib", typeof(GalaxyHelper)); }
public void Run() { var ThreadCount = 5; VirtualCache cache; List <Action> actions = new List <Action>(); // Use a profile that uses more resources to accomodate more data in-memory (faster!). var profile = new Profile { MemoryLimitInPercent = 99, MaxStoreCount = 1, BTreeSlotLength = 150 }; cache = new VirtualCache("MyCacheStore", true, null, profile); if (_logger == null) { _logger = cache.Logger; _logger.LogLevel = Log.LogLevels.Verbose; _logger.Information("Start of VirtualCache multi-clients simulation demo."); } // create threads that will populate Virtual Cache and retrieve the items. for (int i = 0; i < ThreadCount; i++) { var vcIndex = i; actions.Add(() => { if (Populate(cache, vcIndex % 2 == 0, vcIndex * MaxCacheEntries)) { RetrieveAll(cache, vcIndex * MaxCacheEntries); } }); } Console.WriteLine("Starting client simulation threads."); List <Task> tasks = new List <Task>(); foreach (var a in actions) { var t = TaskRun(a); if (t == null) { continue; } tasks.Add(t); } // wait until all threads are finished. if (_threaded) { Task.WaitAll(tasks.ToArray()); } Console.WriteLine("Before VirtualCache dispose."); cache.Dispose(); Console.WriteLine("VirtualCache was disposed."); Console.WriteLine("End of VirtualCache demo."); Console.WriteLine("'Cached' & 'Accessed all' {0} records across {1} simulated clients.", MaxCacheEntries * ThreadCount, ThreadCount); }
public WebServer(int port) { Log = new Log.Logger("WebServer on port " + port.ToString()); Address = "*:" + port.ToString(); Log.Write(LogSeverity.Info, "Creating a web server on {0}.", Address); Listener = new HttpListener(); Listener.Prefixes.Add("http://" + Address + "/"); }
static void Main(string[] args) { try { string filename = DateTime.Now.ToString("MMddTHHmmss") + "_listing.txt"; List <FileInformation> files1 = new List <FileInformation>(); List <DirectoryInformation> directories1 = new List <DirectoryInformation>(); if (args.Length != 2) { Usage(); } else { if (!Directory.Exists(args[0])) { Console.WriteLine("Error: Directory \"{0}\" not found.\n", args[0]); Usage(); } if (!Directory.Exists(args[1])) { Console.WriteLine("Error: Output directory \"{0}\" not found.\n", args[1]); Usage(); } Log.Logger logger = new Log.Logger(Path.Combine(args[1], filename)); while (!FindNextFilePInvokeRecursiveParalleled(args[0], out files1, out directories1, logger)) { Thread.Sleep(1000); } files1.Sort((a, b) => string.Compare(a.FullPath, b.FullPath)); directories1.Sort((a, b) => string.Compare(a.FullPath, b.FullPath)); foreach (var filedata in files1) { logger.WriteLine(filedata.ToString()); } foreach (var filedata in directories1) { logger.WriteLine(filedata.ToString()); } logger.Close(); CompressFile(args[1] + "\\" + filename); Console.WriteLine("Done!"); } } catch (Exception exception) { //TODO: If I crash I will not output the listing Console.WriteLine(exception.Message); Console.WriteLine(exception.StackTrace); } }
public Storage(string begin_message_delimiter, string end_message_delimiter) { // initialize the logger object logger = new Log.Logger(); // initialize the list of storages storage = new List <StorageForSocket>(); // initialize message delimiters BEGIN_MESSAGE_DELIMITER = begin_message_delimiter; END_MESSAGE_DELIMITER = end_message_delimiter; }
protected Controller() { this.oConnection = B1Connection.getInstance(); this.oDBFacade = DBFacade.getInstance(); this.uiUtils = new UIUtils(oConnection.Company, oConnection.App); this.modeMonitors = new LinkedList <FormMode>(); this.properties = Properties.getInstance(); this.log = Logger.getInstance(); log.setProperties(properties); log.setUiUtils(uiUtils); initAddon(); log.prepare(); log.log("Addon iniciado", Logger.LogType.INFO, null, false); }
public GUICollection(GUIWindows.GUI parent_, Communication com_, Models.CardCollection CardCollection_) { InitializeComponent(); logger = new Log.Logger(); // attach parent parent = parent_; // attach controller ctrl = new Controllers.CollectionController(this, com_, CardCollection_); // init uninitialized data listDecksGUI = new List <Models.DeckGUIModel>(); listDeckContentGUI = new List <Models.DeckItemGUIModel>(); selectedDeckID = -1; editModeON = false; // create an invisibile image that will become the zoomed in image whenever auser right clicks a card from the collection zoomedImage = new Image(); zoomedImage.Width = 250; zoomedImage.Height = 346; zoomedImage.VerticalAlignment = VerticalAlignment.Top; zoomedImage.HorizontalAlignment = HorizontalAlignment.Left; zoomedImage.Visibility = Visibility.Hidden; zoomedImage.Stretch = Stretch.Fill; grdParent.Children.Add(zoomedImage); // add all card images and attached buttons to two lists for easy access listGuiImages = new List <Image>() { cardImage1, cardImage2, cardImage3, cardImage4, cardImage5, cardImage6, cardImage7, cardImage8, cardImage9, cardImage10 }; listGuiCardButtons = new List <Button>() { btnCard1, btnCard2, btnCard3, btnCard4, btnCard5, btnCard6, btnCard7, btnCard8, btnCard9, btnCard10 }; // load the first 10 cards in the collection to GUI loadCardsToGUI(ctrl.filteredCollection, ctrl.currentIndex); // init server response timer checkServerResponse.Interval = new TimeSpan(0, 0, 0, 0, 250); checkServerResponse.Tick += checkServerResponse_Tick; // start loading page data and start listening ctrl.loadPageData(); beginListening(); }
public SimpleCardGUIModel(Models.Card card, int width = 75, int height = 104) { logger = new Log.Logger(); // Border Border = new Border(); Border.Width = width; Border.Height = height; Border.VerticalAlignment = VerticalAlignment.Top; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = new Thickness(0); Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; // Image Image = new Image(); try { if (card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, cardBackPath), UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}{2}/{3}.jpg", AppDomain.CurrentDomain.BaseDirectory, cardsPath, card.Set, card.Name), UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Border.Child = Image; }
public CardGUIModel(Models.CardWithGameProperties Card_, GUIPages.GUIGameRoom parent_, Thickness margin, Visibility visibility) { logger = new Log.Logger(); Card = Card_; parent = parent_; // Border Border = new Border(); Border.Width = 73; Border.Height = 100; Border.VerticalAlignment = VerticalAlignment.Top; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = margin; Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; Border.Visibility = visibility; // Button Btn = new Button(); Btn.Style = parent.FindResource("cardButtonStyle") as Style; Btn.Cursor = System.Windows.Input.Cursors.Hand; Btn.Click += cardButton_Click; Border.Child = Btn; // Image Image = new Image(); try { if (Card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/GUI/CardBack.png", UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/Cards/" + Card.Name + ".png", UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Image.MouseRightButtonUp += parent.cardImage_MouseRightButtonUp; Image.MouseRightButtonDown += parent.cardImage_MouseRightButtonDown; Btn.Content = Image; }
public void Run() { List <Action> actions = new List <Action>(); List <VirtualCacheBase> vcs = new List <VirtualCacheBase>(); // create threads that will populate Virtual Cache and retrieve the items. for (int i = 0; i < ThreadCount; i++) { // Set "isPersisted" flag true if wanting to persist cached data across runs. // Non-persisted run (default) causes VirtualCache to be used as memory extender // utilizing disk for extending cached data capacity beyond what can fit in memory to // what Disk can accomodate. var vc = new VirtualCache(string.Format("MyCacheStore{0}", i), true); if (_logger == null) { _logger = vc.Logger; _logger.LogLevel = Log.LogLevels.Verbose; _logger.Information("Start of VirtualCache demo."); } // function to execute by the thread. actions.Add(() => { Populate(vc, i % 2 == 0); RetrieveAll(vc); var name = vc.Name; vc.Dispose(); Console.WriteLine("VirtualCache {0} was disposed.", name); }); vcs.Add(vc); } List <Task> tasks = new List <Task>(); // launch or start the threads all at once. foreach (var a in actions) { var t = TaskRun(a); if (t == null) { continue; } tasks.Add(t); } // wait until all threads are finished. if (_threaded) { Task.WaitAll(tasks.ToArray()); } Console.WriteLine("End of VirtualCache demo."); }
public SelectGUI_CardGUIModel(CardGUIModel cardGUI, GUIWindows.GUISelect parent_, Thickness margin) { logger = new Log.Logger(); this.cardGUI = cardGUI; parent = parent_; // Border Border = new Border(); Border.Width = 73; Border.Height = 100; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = margin; Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; TranslateTransform t = new TranslateTransform(0, 0); Border.RenderTransform = t; Border.Visibility = Visibility.Visible; // Button Btn = new Button(); Btn.Style = parent.FindResource("cardButtonStyle") as Style; Btn.Cursor = System.Windows.Input.Cursors.Hand; Btn.Click += Btn_Click; Border.Child = Btn; // Image Image = new Image(); try { if (cardGUI.Card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/GUI/CardBack.png", UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/Cards/" + cardGUI.Card.Name + ".png", UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Btn.Content = Image; }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { accountManager = new AccountManager(); var user = accountManager.GetLastAccount(); if (null != user) { txtLoginUser.Text = user.UserName; } } catch (Exception ex) { MessageBox.Show(ex.Message, "载入账户信息"); } logger = new Log.Logger(CommonPath.LogDirectoryPath); }
public PrintService(System.IO.Stream stream, Log.Logger log) : base(stream, log) { var pi = stream.GetType().GetProperty("Socket", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (pi != null) { var endPoint = ((System.Net.Sockets.Socket)pi.GetValue(stream, null)).RemoteEndPoint as System.Net.IPEndPoint; if (endPoint != null) { RemoteIP = endPoint.Address; } } else { RemoteIP = new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }); } }
public void Run() { ExceptionGenerator exceptionGenerator = new ExceptionGenerator(); Log.Logger log = new Log.Logger(); try { exceptionGenerator.StackOverflow(); exceptionGenerator.IndexOutOfRange(new int[4] { 31, 4, 11, 8 }); // Will never happen } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); log.writeMessageLog(e); } catch (StackOverflowException e) { Console.WriteLine(e.Message); log.writeMessageLog(e); } try { exceptionGenerator.IndexOutOfRange(new int[4] { 31, 4, 11, 8 }); } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); log.writeMessageLog(e); } try { exceptionGenerator.DoSomeMath(-1, 3); } catch (ArgumentException e) { Console.WriteLine(e.Message); log.writeMessageLog(e); } Console.ReadKey(); }
public GUIGameRoom(GUIWindows.GUI parent_, Communication com_, int GameRoomID_, int DeckID_, Models.CardCollection CardCollection_) { InitializeComponent(); parent = parent_; ctrl = new Controllers.GameRoomController(this, com_, GameRoomID_, DeckID_, CardCollection_); logger = new Log.Logger(); grdOwnGrave.Children.Add(new Models.CardGUIModel(null, this, AnimationConstants.graveInitialPosition, Visibility.Hidden).Border); grdOppGrave.Children.Add(new Models.CardGUIModel(null, this, AnimationConstants.graveInitialPosition, Visibility.Hidden).Border); initButtons(); initTimers(); initLists(); initZoomedInImage(); ctrl.loadPageData(); beginListening(); }
/// <summary> /// Construct new print job using specified SOP instance UID. If passed SOP instance UID is missing, new UID will /// be generated /// </summary> /// <param name="sopInstance">New print job SOP instance uID</param> /// <param name="printer">The printer.</param> /// <param name="originator">The originator.</param> /// <param name="log">The log.</param> /// <param name="session">The session.</param> /// <exception cref="System.ArgumentNullException">printer</exception> /// / public PrintJob(DicomUID sopInstance, Printer printer, string originator, Log.Logger log, FilmSession session) { if (printer == null) { throw new ArgumentNullException("printer"); } Log = log; if (sopInstance == null || sopInstance.UID == string.Empty) { SOPInstanceUID = DicomUID.Generate(); } else { SOPInstanceUID = sopInstance; } Add(DicomTag.SOPClassUID, SOPClassUID); Add(DicomTag.SOPInstanceUID, SOPInstanceUID); Printer = printer; Status = PrintJobStatus.Pending; PrinterName = Printer.PrinterAet; Session = session; Originator = originator; if (CreationDateTime == DateTime.MinValue) { CreationDateTime = DateTime.Now; } PrintJobFolder = SOPInstanceUID.UID; var receivingFolder = Environment.CurrentDirectory + @"\PrintJobs"; FullPrintJobFolder = string.Format(@"{0}\{1}", receivingFolder.TrimEnd('\\'), PrintJobFolder); FilmBoxFolderList = new List <string>(); }
public void Run() { // Use a profile that uses more resources to accomodate more data in-memory (faster!). var profile = new Profile { MemoryLimitInPercent = 98, MaxStoreCount = 1, BTreeSlotLength = 250 }; using (Sop.Caching.VirtualCache vc = new Sop.Caching.VirtualCache("MyCacheStore", true, null, profile)) { _logger = vc.Logger; _logger.LogLevel = Log.LogLevels.Verbose; _logger.Information("Start of VirtualCache demo."); Populate(vc); RetrieveAll(vc); _logger.Information("End of VirtualCache demo."); _logger.Information("You just 'cached' & 'accessed all' {0} records.", MaxCacheEntries); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Log.Logger.Init(); Logger = Log.Logger.GetLogger(nameof(WebApplication), () => { return(new { client_ip = HttpContext.Current.Request.UserHostAddress, client_os = HttpContext.Current.Request.Browser.Platform, browser = string.Format("{0} v{1}", HttpContext.Current.Request.Browser.Browser, HttpContext.Current.Request.Browser.Version ), }); }); }
public GUIGameRoom(GUIWindows.GUI parent, Communication com, int GameRoomID, int DeckID, string OwnNickName, string OppNickName, Models.CardCollection CardCollection) { InitializeComponent(); this.parent = parent; ownNickName = OwnNickName; oppNickName = OppNickName; ctrl = new Controllers.GameRoomController(this, com, GameRoomID, DeckID, CardCollection); logger = new Log.Logger(); grdOwnGrave.Children.Add(new Models.CardGUIModel(null, this, AnimationAndEventsConstants.graveInitialPosition, Visibility.Hidden).Border); grdOppGrave.Children.Add(new Models.CardGUIModel(null, this, AnimationAndEventsConstants.graveInitialPosition, Visibility.Hidden).Border); initButtons(); initTimers(); initLists(); initZoomedInImage(); initOtherVariables(); ctrl.loadPageData(); beginListening(); }
/// <summary> /// Virtual Cache Constructor. Virtual Cache now defaults to being a Memory Extender. /// I.e. - Persisted static property defaults to false. Set VirtualCache.Persisted to true /// if wanting to persist the cached data across application runs. /// </summary> /// <param name="storePath">Data Store URI path or the Store name.</param> /// <param name="clusteredData">true (default) will configure the Store to save /// data together with the Keys in the Key Segment (a.k.a. - clustered), /// false will configure Store to save data in its own Data Segment. For small to medium sized /// data, Clustered is recommended, otherwise set this to false.</param> /// <param name="storeFileName">Valid complete file path where to create the File to contain the data Store. /// It will be created if it does not exist yet. Leaving this blank will create the Store within the default /// SOP SystemFile, or in the referenced File portion of the storePath, if storePath has a directory path.</param> /// <param name="fileConfig">File Config should contain description how to manage data allocations on disk and B-Tree /// settings for all the Data Stores of the File. If not set, SOP will use the default configuration.</param> public VirtualCacheBase(string storePath, bool clusteredData = true, string storeFileName = null, Sop.Profile fileConfig = null) { if (string.IsNullOrWhiteSpace(storePath)) { throw new ArgumentNullException("storePath"); } Initialize(fileConfig, Persisted); Server.SystemFile.Store.Locker.Invoke(() => { SetupStoreFile(storePath, storeFileName, fileConfig); _store = Server.StoreNavigator.GetStorePersistentKey <CacheKey, CacheEntry>(storePath, new StoreParameters <CacheKey> { IsDataInKeySegment = clusteredData, AutoFlush = !clusteredData, StoreKeyComparer = new CacheKeyComparer(), MruManaged = false }); Logger = new Log.Logger(string.Format("{0}{2}{1}.txt", _server.Path, _store.Name, System.IO.Path.DirectorySeparatorChar)); Logger.Verbose("Created/retrieved store {0}.", _store.Name); }); }
public void Run() { const int LoopCount = 3; Sop.Caching.VirtualCache vc = new Sop.Caching.VirtualCache("MyCacheStore", true); for (int i = 0; i < LoopCount; i++) { _logger = vc.Logger; _logger.LogLevel = Log.LogLevels.Verbose; _logger.Information("Start of VirtualCache MemoryCache Compare demo."); try { ObjectCache oc = MemoryCache.Default; if (i == 0) { Populate(vc); } else { Populate(vc); } //Populate(oc); RetrieveAll(vc); RetrieveAll(oc); Compare(vc, oc); _logger.Information("End of VirtualCache MemoryCache Compare demo."); vc.Commit(true); } catch (TransactionRolledbackException) { vc.Dispose(); vc = new Sop.Caching.VirtualCache("MyCacheStore"); } } vc.Dispose(); }
public OculusPlayback() { log = new Log.Logger("Oculus"); initializationParameters = new OVRTypes.InitParams() { LogCallback = (_, level, msg) => { switch (level) { case OVRTypes.LogLevel.Info: case OVRTypes.LogLevel.Debug: log.Info(msg); break; case OVRTypes.LogLevel.Error: log.Error(msg); break; } } }; initializationParameters.Flags |= OVRTypes.InitFlags.RequestVersion; initializationParameters.Flags |= OVRTypes.InitFlags.MixedRendering; }
protected void Page_Load(object sender, EventArgs e) { int uid = 0; if (Request["uid"] != null && int.TryParse(Request["uid"], out uid)) { IHOOService Channel = BackServiceHelper.ConnectToBackService(); Log.Logger log = new Log.Logger("HOO.WebClient", this.GetType()); log.Entry.MethodName = "Page_Load"; log.Entry.StepName = "Loading Universes from DB."; try { Session["Universe"] = Channel.GetUniverseById(uid); gvGalaxies.DataSource = ((Universe)Session["Universe"]).Galaxies; gvGalaxies.DataBind(); } catch (Exception ex) { log.Error(ex); } } }
protected override void OnInit(EventArgs e) { base.OnInit (e); if (Session ["Universe"] != null) { this.ActiveUniverse = (Universe)Session ["Universe"]; this._gid = this.ActiveUniverse.Galaxies [0]._id; } if (Session ["Player"] != null) { this.ActivePlayer = (Player)Session ["Player"]; } if (Request ["gid"] != null && long.TryParse (Request ["gid"], out _gid)) { } Channel = BackServiceHelper.ConnectToBackService(); log = new Log.Logger("HOO.WebClient", this.GetType()); }
public CardGUIModel(Models.CardWithGameProperties Card_, GUIPages.GUIGameRoom parent_, Thickness margin, Visibility visibility, int shieldNumber = -1) { logger = new Log.Logger(); Card = Card_; parent = parent_; ShieldNumber = shieldNumber; // Border Border = new Border(); Border.Width = 75; Border.Height = 100; Border.VerticalAlignment = VerticalAlignment.Top; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = margin; Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; Border.Visibility = visibility; //Grid Grd = new Grid(); // Button Btn = new Button(); Btn.Style = parent.FindResource("cardButtonStyle") as Style; Btn.Cursor = System.Windows.Input.Cursors.Hand; Btn.Click += cardButton_Click; Border.Child = Grd; // Image Image = new Image(); try { if (Card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, cardBackPath), UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}{2}/{3}.jpg", AppDomain.CurrentDomain.BaseDirectory, cardsPath, Card.Set, Card.Name), UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Image.MouseRightButtonUp += parent.cardImage_MouseRightButtonUp; Image.MouseRightButtonDown += parent.cardImage_MouseRightButtonDown; Btn.Content = Image; Grd.Children.Add(Btn); if (shieldNumber != -1) { // Textblock TxtBlock = new TextBlock(); TxtBlock.Text = shieldNumber.ToString(); TxtBlock.FontSize = 15; TxtBlock.Foreground = Brushes.White; TxtBlock.FontWeight = FontWeights.Bold; TxtBlock.HorizontalAlignment = HorizontalAlignment.Left; TxtBlock.VerticalAlignment = VerticalAlignment.Top; TxtBlock.Margin = new Thickness(10, 5, 0, 0); Grd.Children.Add(TxtBlock); } }
private void init(Card card, Window parent, Thickness margin, bool clickable, int shieldNumber = -1) { logger = new Log.Logger(); Card = card; this.parent = parent; // Border Border = new Border(); Border.Width = 75; Border.Height = 100; Border.HorizontalAlignment = HorizontalAlignment.Left; Border.Margin = margin; Border.BorderThickness = new Thickness(5); Border.BorderBrush = Brushes.Transparent; TranslateTransform t = new TranslateTransform(0, 0); Border.RenderTransform = t; Border.Visibility = Visibility.Visible; // Grid Grd = new Grid(); // Button Btn = new Button(); Btn.Style = parent.FindResource("cardButtonStyle") as Style; Btn.Cursor = System.Windows.Input.Cursors.Hand; if (clickable) { Btn.Click += Btn_Click; } Border.Child = Grd; // Image Image = new Image(); try { if (card == null) { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, cardBackPath), UriKind.Absolute)); } else { Image.Source = new System.Windows.Media.Imaging.BitmapImage( new Uri( string.Format("{0}{1}{2}/{3}.jpg", AppDomain.CurrentDomain.BaseDirectory, cardsPath, card.Set, card.Name), UriKind.Absolute)); } } catch (Exception ex) { logger.Log(ex.ToString()); } Image.Stretch = Stretch.UniformToFill; Btn.Content = Image; Grd.Children.Add(Btn); if (shieldNumber != -1) { // Textblock TxtBlock = new TextBlock(); TxtBlock.Text = shieldNumber.ToString(); TxtBlock.FontSize = 15; TxtBlock.Foreground = Brushes.White; TxtBlock.FontWeight = FontWeights.Bold; TxtBlock.HorizontalAlignment = HorizontalAlignment.Left; TxtBlock.VerticalAlignment = VerticalAlignment.Top; TxtBlock.Margin = new Thickness(10, 5, 0, 0); Grd.Children.Add(TxtBlock); } }
private B1Connection() { notifyIcon = new NotifyIcon(); this.logger = Log.Logger.getInstance(); }
public Controller() { logger = new Log.Logger(); Listening = false; }
static bool FindNextFilePInvokeRecursiveParalleled(string path, out List <FileInformation> files, out List <DirectoryInformation> directories, Log.Logger logger) { List <FileInformation> fileList = new List <FileInformation>(); object fileListLock = new object(); List <DirectoryInformation> directoryList = new List <DirectoryInformation>(); object directoryListLock = new object(); IntPtr findHandle = INVALID_HANDLE_VALUE; List <Tuple <string, DateTime> > info = new List <Tuple <string, DateTime> >(); try { path = path.EndsWith(@"\") ? path : path + @"\"; findHandle = FindFirstFileW(path + @"*", out WIN32_FIND_DATAW findData); if (findHandle != INVALID_HANDLE_VALUE) { do { if (findData.cFileName != "." && findData.cFileName != "..") { string fullPath = path + findData.cFileName; if (findData.dwFileAttributes.HasFlag(FileAttributes.Directory) && !findData.dwFileAttributes.HasFlag(FileAttributes.ReparsePoint)) { var dirdata = new DirectoryInformation { FullPath = fullPath, LastWriteTime = findData.ftLastWriteTime.ToDateTime() }; directoryList.Add(dirdata); } else if (!findData.dwFileAttributes.HasFlag(FileAttributes.Directory)) { var filedata = new FileInformation { FullPath = fullPath, LastWriteTime = findData.ftLastWriteTime.ToDateTime() }; fileList.Add(filedata); } } } while (FindNextFile(findHandle, out findData)); directoryList.AsParallel().ForAll(x => { List <FileInformation> subDirectoryFileList = new List <FileInformation>(); List <DirectoryInformation> subDirectoryDirectoryList = new List <DirectoryInformation>(); if (FindNextFilePInvokeRecursive(x.FullPath, out subDirectoryFileList, out subDirectoryDirectoryList, logger)) { lock (fileListLock) { fileList.AddRange(subDirectoryFileList); } lock (directoryListLock) { directoryList.AddRange(subDirectoryDirectoryList); } } }); } } catch (Exception exception) { Console.WriteLine(exception.ToString()); if (findHandle != INVALID_HANDLE_VALUE) { FindClose(findHandle); } files = null; directories = null; return(false); } if (findHandle != INVALID_HANDLE_VALUE) { FindClose(findHandle); } files = fileList; directories = directoryList; return(true); }
//Code based heavily on https://stackoverflow.com/q/47471744 static bool FindNextFilePInvokeRecursive(string path, out List <FileInformation> files, out List <DirectoryInformation> directories, Log.Logger logger) { List <FileInformation> fileList = new List <FileInformation>(); List <DirectoryInformation> directoryList = new List <DirectoryInformation>(); IntPtr findHandle = INVALID_HANDLE_VALUE; List <Tuple <string, DateTime> > info = new List <Tuple <string, DateTime> >(); try { findHandle = FindFirstFileW(path + @"\*", out WIN32_FIND_DATAW findData); if (findHandle != INVALID_HANDLE_VALUE) { do { if (findData.cFileName != "." && findData.cFileName != "..") { string fullPath = path + @"\" + findData.cFileName; if (findData.dwFileAttributes.HasFlag(FileAttributes.Directory) && !findData.dwFileAttributes.HasFlag(FileAttributes.ReparsePoint)) { var dirdata = new DirectoryInformation { FullPath = fullPath, LastWriteTime = findData.ftLastWriteTime.ToDateTime() }; directoryList.Add(dirdata); List <FileInformation> subDirectoryFileList = new List <FileInformation>(); List <DirectoryInformation> subDirectoryDirectoryList = new List <DirectoryInformation>(); if (FindNextFilePInvokeRecursive(fullPath, out subDirectoryFileList, out subDirectoryDirectoryList, logger)) { fileList.AddRange(subDirectoryFileList); directoryList.AddRange(subDirectoryDirectoryList); } } else if (!findData.dwFileAttributes.HasFlag(FileAttributes.Directory)) { var filedata = new FileInformation { FullPath = fullPath, LastWriteTime = findData.ftLastWriteTime.ToDateTime(), Size = (long)findData.nFileSizeLow + (long)findData.nFileSizeHigh * 4294967296 }; fileList.Add(filedata); } } } while (FindNextFile(findHandle, out findData)); } } catch (Exception exception) { Console.WriteLine(exception.ToString()); if (findHandle != INVALID_HANDLE_VALUE) { FindClose(findHandle); } files = null; directories = null; return(false); } if (findHandle != INVALID_HANDLE_VALUE) { FindClose(findHandle); } files = fileList; directories = directoryList; return(true); }
public GameRoomGUIModel(GameRoom room, string myNickName, GUIPages.GUILobbyRoom parent_) { logger = new Log.Logger(); Parent = parent_; ID = room.RoomID; if (myNickName == room.Owner) { OwnRoom = true; } else { OwnRoom = false; } guestNickName = room.Guest; ColumnDefinition cd = new ColumnDefinition(); BrushConverter bc = new BrushConverter(); // Border Border = new Border(); Border.Height = 100; Border.Margin = new Thickness(10); Border.CornerRadius = new CornerRadius(20); Border.Background = Brushes.Black; Border.Opacity = 0.8; Border.BorderThickness = new Thickness(2); Border.BorderBrush = Brushes.LightGray; // GRID cd.Width = GridLength.Auto; grid.ColumnDefinitions.Add(cd); cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd); cd = new ColumnDefinition(); cd.Width = GridLength.Auto; grid.ColumnDefinitions.Add(cd); // PLAYER1 BORDER borderForP1.CornerRadius = new CornerRadius(10); borderForP1.Background = Brushes.Gold; borderForP1.Margin = new Thickness(25, 23, 0, 23); borderForP1.Padding = new Thickness(5, 0, 5, 0); borderForP1.BorderBrush = Brushes.White; borderForP1.BorderThickness = new Thickness(2); // PLAYER1 LABEL labelForP1.Content = room.Owner; labelForP1.FontSize = 25; labelForP1.Foreground = Brushes.Black; labelForP1.VerticalAlignment = VerticalAlignment.Center; labelForP1.FontWeight = FontWeights.Bold; borderForP1.Child = labelForP1; // IMAGE try { VSimage.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Images/GUI/VS.png", UriKind.Absolute)); } catch (Exception) { logger.Log("Couldn't load 'versus image' in game room " + ID); } VSimage.Width = 60; VSimage.Margin = new Thickness(25, 0, 25, 0); // PLAYER2 BORDER borderForP2.CornerRadius = new CornerRadius(10); borderForP2.HorizontalAlignment = HorizontalAlignment.Left; borderForP2.Background = Brushes.Gold; borderForP2.Margin = new Thickness(0, 23, 20, 23); borderForP2.Padding = new Thickness(5, 0, 5, 0); borderForP2.BorderBrush = Brushes.White; borderForP2.BorderThickness = new Thickness(2); // PLAYER2 LABEL labelForP2.Content = room.Guest; labelForP2.FontSize = 25; labelForP2.Foreground = Brushes.Black; labelForP2.VerticalAlignment = VerticalAlignment.Center; labelForP2.FontWeight = FontWeights.Bold; borderForP2.Child = labelForP2; dp.Children.Add(borderForP1); dp.Children.Add(VSimage); dp.Children.Add(borderForP2); grid.Children.Add(dp); // STATE stateLabel.Content = room.State; stateLabel.FontSize = 23; stateLabel.Foreground = Brushes.White; stateLabel.HorizontalAlignment = HorizontalAlignment.Center; stateLabel.VerticalAlignment = VerticalAlignment.Center; stateLabel.FontWeight = FontWeights.Bold; grid.Children.Add(stateLabel); Grid.SetColumn(stateLabel, 1); // mainButton Style style = Parent.FindResource("buttonStyle") as Style; mainButton.Style = style; mainButton.HorizontalAlignment = HorizontalAlignment.Right; mainButton.VerticalAlignment = VerticalAlignment.Top; mainButton.Cursor = System.Windows.Input.Cursors.Hand; mainButton.Background = Brushes.Black; mainButton.Foreground = Brushes.White; mainButton.FontSize = 20; mainButton.Margin = new Thickness(10, 10, 10, 0); mainButton.Width = 110; mainButton.Click += btnMain_Click; // if it's your room then you can close it if (OwnRoom) { mainButton.Content = "Close"; mainButtonIsJoin = false; } else { // if it's not your room then you can join it if it's free, otherwise you can't do anything mainButton.Content = "Join"; mainButtonIsJoin = true; if (room.Guest != "*") { mainButton.IsEnabled = false; } } // readyButton readyButton.Style = style; readyButton.HorizontalAlignment = HorizontalAlignment.Right; readyButton.VerticalAlignment = VerticalAlignment.Bottom; readyButton.Cursor = System.Windows.Input.Cursors.Hand; readyButton.Background = Brushes.Black; readyButton.Foreground = Brushes.White; readyButton.FontSize = 20; readyButton.Margin = new Thickness(10, 0, 10, 10); readyButton.Width = 110; readyButton.Content = "Ready"; readyButton.IsEnabled = false; readyButton.Click += btnReady_Click; grid.Children.Add(mainButton); grid.Children.Add(readyButton); Grid.SetColumn(mainButton, 2); Grid.SetColumn(readyButton, 2); Border.Child = grid; }