{"id":21468986,"url":"https://github.com/joelumbley/time-with-complications","last_synced_at":"2025-10-03T17:57:18.388Z","repository":{"id":263032967,"uuid":"888802270","full_name":"JoeLumbley/Time-with-Complications","owner":"JoeLumbley","description":"Transform your desktop into a dynamic clock and calendar with this user-friendly application!","archived":false,"fork":false,"pushed_at":"2024-12-13T18:44:58.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T15:53:54.161Z","etag":null,"topics":["basic","clock-calendar","date-and-time","desktop-application","graphics","productivity","time-management","visual-basic-net","windows-forms"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic .NET","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoeLumbley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-15T03:09:01.000Z","updated_at":"2024-12-13T18:45:03.000Z","dependencies_parsed_at":"2024-11-15T18:31:38.345Z","dependency_job_id":"8075fc1f-72ec-4c98-806c-623363d8b651","html_url":"https://github.com/JoeLumbley/Time-with-Complications","commit_stats":null,"previous_names":["joelumbley/time-with-complications"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoeLumbley%2FTime-with-Complications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoeLumbley%2FTime-with-Complications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoeLumbley%2FTime-with-Complications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoeLumbley%2FTime-with-Complications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoeLumbley","download_url":"https://codeload.github.com/JoeLumbley/Time-with-Complications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243984336,"owners_count":20378962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basic","clock-calendar","date-and-time","desktop-application","graphics","productivity","time-management","visual-basic-net","windows-forms"],"created_at":"2024-11-23T09:12:18.040Z","updated_at":"2025-10-03T17:57:13.358Z","avatar_url":"https://github.com/JoeLumbley.png","language":"Visual Basic .NET","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Time🕒 with Complications\n\n**Make Your Screen a Clock 🕒 / Calendar 📅**\n\nTransform your desktop into a dynamic clock and calendar with this user-friendly application! \n\nDisplay the current time, date, and time zone information in both 12-hour and 24-hour formats. \n\nCustomize what you see, from the day of the week to military date formats, all while enjoying a responsive design that adapts to your window size. \n\n\n![007](https://github.com/user-attachments/assets/3d57c658-e7fd-422c-8adf-c5ab14407781)\n\n\n\nBuilt with smooth graphics and real-time updates, this app ensures you stay informed and stylishly organized. Perfect for anyone looking to enhance their workspace with functional aesthetics!\n\n\n\n\n\n\n\n\n\n## Features\n\n- **Dynamic Time Display**: Shows the current time in either 12-hour or 24-hour format.\n- **Customizable Information**: Users can choose to display different types of information, including:\n  - Long or short day of the week\n  - Long, medium, short or military date formats\n  - Current time zone and corresponding city\n  - Local time\n- **Responsive Design**: The application adjusts to changes in window size, ensuring a consistent user experience.\n- **Buffered Graphics**: Utilizes buffered graphics for smooth rendering and improved performance.\n\n\n\n![008](https://github.com/user-attachments/assets/8ead4d3b-ec3c-4778-8df2-e94a13070409)\n\n\n\n## Getting Started\n\nTo run the application, clone the repository and open the solution file in Visual Studio. \n\nBuild and run the project to start using the application.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Code Walkthrough\n\n```vb\nPublic Class Form1\n```\n- This line defines a new class called `Form1`, which represents the main window of the application.\n\n```vb\n  Private Context As BufferedGraphicsContext\n\n  Private Buffer As BufferedGraphics\n```\n- Here, we declare two private variables: `Context` to manage graphics rendering and `Buffer` to hold the graphics that will be drawn on the screen.\n\n```vb\n  Private Enum HourFormat\n    Twelve\n    TwentyFour\n  End Enum\n```\n- This creates an enumeration named `HourFormat` with two possible values: `Twelve` for 12-hour time and `TwentyFour` for 24-hour time.\n\n```vb\n  Private Hours As HourFormat = HourFormat.Twelve\n```\n- This line initializes a variable `Hours` to `HourFormat.Twelve`, meaning the app will start in 12-hour format.\n\n```vb\n  Private Enum InfoType\n    Time\n    LongDayOfWeek\n    ShortDayOfWeek\n    LongDate\n    MedDate\n    ShortDate\n    TimeZone\n    TimeZoneCity\n    LocalTime\n    MilitaryDate\n  End Enum\n```\n- This defines another enumeration called `InfoType`, which lists different types of information that can be displayed (like time, date, and time zone).\n\n```vb\n  Private Structure DisplayObject\n    Public Location As Point\n    Public Text As String\n    Public Font As Font\n    Public Type As InfoType\n  End Structure\n```\n- This creates a structure named `DisplayObject` that holds information about what to display on the screen. It includes the location of the text, the text itself, the font used, and the type of information.\n\n```vb\n  Private MainDisplay As DisplayObject\n\n  Private TopDisplay As DisplayObject\n\n  Private BottomDisplay As DisplayObject\n```\n- These lines declare three instances of `DisplayObject` for the main display (time), top display (day/date), and bottom display (additional info).\n\n```vb\n  Private ReadOnly AlineCenterMiddle As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}\n```\n- This creates a `StringFormat` object that centers text both horizontally and vertically.\n\n### Form Load Event\n\n```vb\n  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load\n```\n- This is an event handler that runs when the form is loaded.\n\n```vb\n    InitializeForm()\n\n    InitializeBuffer()\n```\n- These calls initialize the form's settings and the graphics buffer.\n\n```vb\n    TopDisplay.Type = InfoType.LongDayOfWeek\n\n    BottomDisplay.Type = InfoType.MedDate\n```\n- Here, we set the types of information to display in the top and bottom displays.\n\n```vb\n    Timer1.Interval = 20\n\n    Timer1.Enabled = True\n```\n- This sets a timer to update the displays every 20 milliseconds and enables it.\n\n```vb\n    Debug.Print($\"Program running... {Now.ToShortTimeString()}\")\n```\n- This prints a message to the debug console showing the current time when the program starts.\n\n### Form Resize Event\n\n```vb\n  Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize\n```\n- This event handler runs when the form is resized.\n\n```vb\n    If Not WindowState = FormWindowState.Minimized Then\n```\n- This checks if the window is not minimized.\n\n```vb\n      Dim FontSize As Integer = ClientSize.Width \\ 14\n```\n- This calculates the font size based on the width of the form.\n\n```vb\n      MainDisplay.Font = New Font(\"Segoe UI\", FontSize, FontStyle.Regular)\n```\n- This sets the font for the main display using the calculated size.\n\n```vb\n      MainDisplay.Location.X = ClientSize.Width \\ 2\n\n      MainDisplay.Location.Y = (ClientSize.Height + MenuStrip1.Height) \\ 2\n```\n- These lines center the main display in the form.\n\n```vb\n      TopDisplay.Location.X = ClientSize.Width \\ 2\n\n      TopDisplay.Location.Y = (ClientSize.Height + MenuStrip1.Height) \\ 2 - ClientSize.Width \\ 10\n\n      BottomDisplay.Location.X = ClientSize.Width \\ 2\n\n      BottomDisplay.Location.Y = (ClientSize.Height + MenuStrip1.Height) \\ 2 + ClientSize.Width \\ 10\n\n```\n- The same logic is applied to position the top and bottom displays.\n\n```vb\n      If Buffer IsNot Nothing Then\n\n        Buffer.Dispose()\n\n        Buffer = Nothing\n\n      End If\n```\n- This checks if the buffer exists and disposes of it to free up resources.\n\n\n\n![011](https://github.com/user-attachments/assets/e3331b02-f99f-48a1-99e7-ac39c254a9a6)\n\n\n\n\n### Timer Tick Event\n\n```vb\n  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick\n```\n- This event runs every time the timer ticks.\n\n```vb\n    UpdateDisplays()\n```\n- This calls a method to update the text displayed on the screen.\n\n```vb\n    If Not WindowState = FormWindowState.Minimized Then\n\n      Refresh() ' Calls OnPaint Sub\n\n    End If\n```\n- If the window is not minimized, it refreshes the display to show updated information.\n\n### OnPaint Event\n\n```vb\n  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)\n```\n- This is where the drawing happens. It overrides the default paint behavior.\n\n```vb\n    If Buffer Is Nothing Then\n\n      Buffer = Context.Allocate(e.Graphics, ClientRectangle)\n\n    End If\n```\n- If the buffer does not exist, it allocates a new one.\n\n```vb\n    DrawDisplays()\n\n    Buffer.Render(e.Graphics)\n```\n- Calls a method to draw the displays and then renders the buffer onto the screen.\n\n### Update Displays Method\n\n```vb\n  Private Sub UpdateDisplays()\n\n    UpdateMainDisplay()\n\n    UpdateTopDisplay()\n\n    UpdateBottomDisplay()\n\n  End Sub\n```\n- This method updates all the display areas by calling their respective update methods.\n\n### Draw Displays Method\n\n```vb\n  Private Sub DrawDisplays()\n```\n- This method handles the actual drawing of the text on the screen.\n\n```vb\n    If Buffer IsNot Nothing Then\n\n        Try\n\n            With Buffer.Graphics\n\n                .Clear(Color.Black) ' Clear the buffer with a black background\n\n                .CompositingMode = Drawing2D.CompositingMode.SourceOver\n                .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias\n                .SmoothingMode = Drawing2D.SmoothingMode.HighQuality\n                .PixelOffsetMode = Drawing2D.PixelOffsetMode.None\n                .CompositingQuality = Drawing2D.CompositingQuality.HighQuality\n```\n- It checks if the buffer exists, clears it with a black background, and sets various graphics quality options.\n\n```vb\n                .DrawString(MainDisplay.Text, MainDisplay.Font, Brushes.White, MainDisplay.Location, AlineCenterMiddle)\n\n                .DrawString(TopDisplay.Text, TopDisplay.Font, Brushes.LightGray, TopDisplay.Location, AlineCenterMiddle)\n\n                .DrawString(BottomDisplay.Text, BottomDisplay.Font, Brushes.LightGray, BottomDisplay.Location, AlineCenterMiddle)\n```\n- This draws the main, top, and bottom display texts using their respective fonts and colors.\n\n\n\n\n\n\n![010](https://github.com/user-attachments/assets/57ea2f05-9b87-482d-ba4d-a413902747a6)\n\n\n\n\n\n\n\n### UpdateMainDisplay Method\n\n```vb\n  Private Sub UpdateMainDisplay()\n```\n- This line defines a new method called `UpdateMainDisplay`. This method is responsible for updating the text displayed in the main display area of the application, which shows the current time.\n\n```vb\n    Select Case Hours\n```\n- Here, we start a `Select Case` statement to evaluate the `Hours` variable. This variable indicates whether the application is set to display time in 12-hour or 24-hour format.\n\n```vb\n      Case HourFormat.Twelve\n```\n- If `Hours` is set to `HourFormat.Twelve`, this block executes, meaning we will format the time in a 12-hour format.\n\n```vb\n        MainDisplay.Text = Now.ToShortTimeString()\n\n```\n- This line sets `MainDisplay.Text` to the current time formatted as hours and minutes in 12-hour format (e.g., \"3:45 PM\"). \n\n```vb\n      Case HourFormat.TwentyFour\n```\n- If `Hours` is set to `HourFormat.TwentyFour`, this block executes, meaning we will format the time in a 24-hour format.\n\n```vb\n        MainDisplay.Text = Now.ToString(\"HH:mm\")\n```\n- This line sets `MainDisplay.Text` to the current time formatted as hours and minutes in 24-hour format (e.g., \"15:45\").\n\n```vb\n    End Select\n\nEnd Sub\n```\n- The `End Select` statement closes the `Select Case` block, and `End Sub` marks the end of the `UpdateMainDisplay` method.\n\n\n\nThe `UpdateMainDisplay` method updates the text displayed in the main section of the application based on the current time format (12-hour or 24-hour) specified by the `Hours` variable. \n\n- If the application is in 12-hour mode, it formats the time to include AM/PM.\n- If it’s in 24-hour mode, it displays the time in a 24-hour format.\n\nThis method ensures that the user sees the current time in their preferred format. \n\n\n\n\n### UpdateTopDisplay Method\n\n```vb\n  Private Sub UpdateTopDisplay()\n```\n- This line defines a new method called `UpdateTopDisplay`. This method is responsible for updating the text displayed in the top display area of the application.\n\n```vb\n    Select Case TopDisplay.Type\n```\n- Here, we start a `Select Case` statement. This allows us to evaluate the `TopDisplay.Type` to determine what kind of information we need to show in the top display.\n\n```vb\n      Case InfoType.LongDayOfWeek\n\n        TopDisplay.Text = Now.DayOfWeek.ToString\n```\n- If `TopDisplay.Type` is `InfoType.LongDayOfWeek`, this line sets `TopDisplay.Text` to the full name of the current day of the week (e.g., \"Monday\"). `Now.DayOfWeek` gets the current day, and `ToString` converts it to a readable format.\n\n```vb\n      Case InfoType.ShortDayOfWeek\n\n        TopDisplay.Text = GetDayOfWeekAbbreviation(Now.DayOfWeek)\n```\n- If `TopDisplay.Type` is `InfoType.ShortDayOfWeek`, this line calls the `GetDayOfWeekAbbreviation` function, passing the current day of the week. This function returns a three-letter abbreviation (e.g., \"Mon\" for Monday).\n\n```vb\n      Case InfoType.LongDate\n\n        TopDisplay.Text = Now.ToLongDateString\n```\n- If `TopDisplay.Type` is `InfoType.LongDate`, this line sets `TopDisplay.Text` to the long date format (e.g., \"Monday, November 19, 2024\") using `Now.ToLongDateString`.\n\n```vb\n      Case InfoType.MedDate\n\n        TopDisplay.Text = Now.ToString(\"MMMM d, yyyy\")\n```\n- If `TopDisplay.Type` is `InfoType.MedDate`, this line formats the date in a medium style (e.g., \"November 19, 2024\") and assigns it to `TopDisplay.Text`.\n\n```vb\n      Case InfoType.ShortDate\n\n        TopDisplay.Text = Now.ToShortDateString\n```\n- If `TopDisplay.Type` is `InfoType.ShortDate`, this line sets `TopDisplay.Text` to a short date format (e.g., \"11/19/2024\").\n\n```vb\n      Case InfoType.MilitaryDate\n\n        TopDisplay.Text = Now.ToString(\"ddMMMyy\").ToUpper()\n```\n- If `TopDisplay.Type` is `InfoType.MilitaryDate`, this formats the date in a military style (e.g., \"19NOV24\") and converts it to uppercase.\n\n```vb\n      Case InfoType.TimeZone\n\n        TopDisplay.Text = TimeZoneInfo.Local.Id\n```\n- If `TopDisplay.Type` is `InfoType.TimeZone`, this line sets `TopDisplay.Text` to the ID of the local time zone (e.g., \"Pacific Standard Time\").\n\n```vb\n      Case InfoType.TimeZoneCity\n\n        TopDisplay.Text = GetTimeZoneCity(TimeZoneInfo.Local.Id)\n```\n- If `TopDisplay.Type` is `InfoType.TimeZoneCity`, this line calls the `GetTimeZoneCity` function, passing the local time zone ID. This function returns the name of a city associated with that time zone (e.g., \"Los Angeles\" for Pacific Standard Time).\n\n```vb\n      Case InfoType.LocalTime\n\n        TopDisplay.Text = \"Local Time\"\n```\n- If `TopDisplay.Type` is `InfoType.LocalTime`, this line simply sets `TopDisplay.Text` to the string \"Local Time\".\n\n```vb\n    End Select\n\n  End Sub\n```\n- The `End Select` statement closes the `Select Case` block, and `End Sub` marks the end of the `UpdateTopDisplay` method.\n\n\nThe `UpdateTopDisplay` method dynamically updates the text displayed in the top section of the application based on the type of information specified in `TopDisplay.Type`. It uses the `Select Case` statement to check the type and assigns the appropriate value to `TopDisplay.Text`. This allows the application to show different types of information, such as the current day, date, or time zone, depending on user preferences. \n\n\n\n\n\n\n\n\n\n\n### Update Bottom Display Method\n\n```vb\n  Private Sub UpdateBottomDisplay()\n\n    Select Case BottomDisplay.Type\n```\n- This method updates the text for the bottom display based on its type.\n\n```vb\n      Case InfoType.LongDayOfWeek\n\n        BottomDisplay.Text = Now.DayOfWeek.ToString\n\n    ' Other cases for different types...\n\n    End Select\n\n  End Sub\n```\n- Depending on the type of information, it sets the text to the current day of the week, date, time zone, etc.\n\n\n\n\n\n\n###  **TwentyFourHourMenuItem_Click Event**\nThis subroutine is triggered when the user clicks on the \"24-Hour\" menu item.\n\n```vb\nPrivate Sub TwentyFourHourMenuItem_Click(sender As Object, e As EventArgs) Handles TwentyFourHourMenuItem.Click\n```\n\n- **Check Current Format**:\n  ```vb\n  If Not Hours = HourFormat.TwentyFour Then Hours = HourFormat.TwentyFour\n  ```\n  - This line checks if the current time format (`Hours`) is not set to 24-hour format (`HourFormat.TwentyFour`). If it isn't, it updates `Hours` to `HourFormat.TwentyFour`.\n\n- **Check the Menu Item**:\n  ```vb\n  If Not TwentyFourHourMenuItem.Checked Then TwentyFourHourMenuItem.Checked = True\n  ```\n  - This line ensures that the \"24-Hour\" menu item is marked as checked.\n\n- **Uncheck the Other Option**:\n  ```vb\n  If TwelveHourMenuItem.Checked Then TwelveHourMenuItem.Checked = False\n  ```\n  - If the \"12-Hour\" menu item is currently checked, this line unchecks it, ensuring that only one option is selected at a time.\n\n###  **TwelveHourMenuItem_Click Event**\nThis subroutine is triggered when the user clicks on the \"12-Hour\" menu item.\n\n```vb\nPrivate Sub TwelveHourMenuItem_Click(sender As Object, e As EventArgs) Handles TwelveHourMenuItem.Click\n```\n\n- **Check Current Format**:\n  ```vb\n  If Not Hours = HourFormat.Twelve Then Hours = HourFormat.Twelve\n  ```\n  - Similar to the previous subroutine, this checks if the current time format is not set to 12-hour format. If it isn't, it updates `Hours` to `HourFormat.Twelve`.\n\n- **Check the Menu Item**:\n  ```vb\n  If Not TwelveHourMenuItem.Checked Then TwelveHourMenuItem.Checked = True\n  ```\n  - This ensures that the \"12-Hour\" menu item is marked as checked.\n\n- **Uncheck the Other Option**:\n  ```vb\n  If TwentyFourHourMenuItem.Checked Then TwentyFourHourMenuItem.Checked = False\n  ```\n  - If the \"24-Hour\" menu item is currently checked, this line unchecks it, ensuring only one option is selected.\n\n- Both event handlers allow the user to toggle between 12-hour and 24-hour time formats.\n- They ensure that only one format can be selected at a time by checking and unchecking the respective menu items.\n- The `Hours` variable is updated accordingly to reflect the user's choice, which will affect how the time is displayed in the application.\n\n\n\n![009](https://github.com/user-attachments/assets/bdfd477e-ac70-4298-aa49-0e4d7c661137)\n\n\n\n\nThis code creates a simple time display application that updates in real-time. It uses Windows Forms and VB.NET to manage graphics and handle user interactions. Each part of the code is designed to ensure that the display updates smoothly and provides relevant information to the user. \n\n\n\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE.txt file for more details.\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelumbley%2Ftime-with-complications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelumbley%2Ftime-with-complications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelumbley%2Ftime-with-complications/lists"}