Пример #1
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Get the current window handle.
            var window_interop_helper = new WindowInteropHelper(this);

            hwnd_handle = window_interop_helper.Handle;

            // Setup the global hotkey listner.
            global_hotkey_listner = new GlobalHotkeyListener(hwnd_handle);
            global_hotkey_listner.executeOverlayItem = ExecuteOverlayItem;

            // Add the hotkey listner.
            hwnd_source = HwndSource.FromHwnd(hwnd_handle);
            hwnd_source.AddHook(global_hotkey_listner.HwndHook);

            // Load saved overlay items.
            settings_manager = new OverlaySettingsManager(app_data_dir);
            settings_manager.LoadOverlayItems();
            for (int count = 0; count < settings_manager.OverlayItems.Count; count++)
            {
                OverlayItem temp_overlay_item = settings_manager.OverlayItems[count];
                AddOverlayItem(temp_overlay_item);
            }

            // Load and launch Applicaions
            apps_to_lauch_dialog.LoadApplications(app_data_dir);
        }
Пример #2
0
        public void SaveOverlayItems(BindingList <OverlayListBoxItem> overlay_list_box_items)
        {
            // Read in the overlay items xml into a single string.
            String temp_xml_string = File.ReadAllText(saved_overlay_items_path);

            XmlDocument temp_xml_doc = new XmlDocument();

            temp_xml_doc.LoadXml(temp_xml_string);

            // Get the root node to append to.
            XmlNode document_root = temp_xml_doc.DocumentElement;

            document_root.RemoveAll();

            for (int count = 0; count < overlay_list_box_items.Count; count++)
            {
                OverlayItem temp_item = overlay_list_box_items[count].OverlayItemData;

                // Add a OverlayItem xml child.
                AppendOverlayItemXML(temp_xml_doc, temp_item);
            }

            // Write the changes to the xml file.
            temp_xml_doc.Save(saved_overlay_items_path);
        }
Пример #3
0
        private void SaveOverlayItem(OverlayItem overlay_item, bool editing_item)
        {
            if (!editing_item)
            {
                OverlayItem temp_item = new OverlayItem();
                temp_item.HotKey          = overlay_item.HotKey;
                temp_item.ImagePath       = overlay_item.ImagePath;
                temp_item.PlayVisible     = overlay_item.PlayVisible;
                temp_item.SoundPath       = overlay_item.SoundPath;
                temp_item.SoundVolume     = overlay_item.SoundVolume;
                temp_item.StopVisible     = overlay_item.StopVisible;
                temp_item.DisplayDuration = overlay_item.DisplayDuration;

                // Save the overlay item to the xml file.
                settings_manager.SaveOverlayItem(temp_item);

                // Add the new OverlayItem.
                AddOverlayItem(temp_item);
            }
            else
            {
                // Update the editied OverlayItem.
                OverlayListBoxItem temp_overlay_list_box_item = (OverlayListBoxItem)overlay_lv.SelectedItem;
                temp_overlay_list_box_item.PopulateOverlayItem(overlay_item);

                // Resave the overlay list.
                settings_manager.SaveOverlayItems(OverlayListBoxItems);

                // Reset the hotkey bindings.
                RestGlobalHotkeys();
            }

            // Show the home screen.
            DisplayStartingScreen();
        }
Пример #4
0
 public void PopulateOverlayItem(OverlayItem overlay_item_to_dispaly)
 {
     this.ImagePath       = overlay_item_to_dispaly.ImagePath;
     this.HotKey          = overlay_item_to_dispaly.HotKey;
     this.PlayVisible     = overlay_item_to_dispaly.PlayVisible;
     this.StopVisible     = overlay_item_to_dispaly.StopVisible;
     this.OverlayItemData = overlay_item_to_dispaly;
 }
Пример #5
0
        private void ExecuteOverlayItem(int hotkey_id)
        {
            // Check to see if the user pressed a hotkey.
            foreach (OverlayListBoxItem temp_overlay_list_box_item in OverlayListBoxItems)
            {
                OverlayItem temp_overlay_item = temp_overlay_list_box_item.OverlayItemData;

                if (temp_overlay_item.HotKeyID == hotkey_id)
                {
                    string[] temp_time_parts = temp_overlay_item.DisplayDuration.Split(':');
                    int      minutes;
                    int.TryParse(temp_time_parts[0], out minutes);
                    int seconds;
                    int.TryParse(temp_time_parts[1], out seconds);
                    int miliseconds;
                    int.TryParse(temp_time_parts[2], out miliseconds);
                    TimeSpan temp_duration = new TimeSpan(0, 0, minutes, seconds, miliseconds);

                    // Set the end animation time out value.
                    if (temp_duration.Minutes > 0 || temp_duration.Seconds > 0 || temp_duration.Milliseconds > 0)
                    {
                        overlay_event_timer.StartTimer(temp_duration, OverlayItem_TimerElapsed);
                    }

                    if (File.Exists(temp_overlay_item.ImagePath))
                    {
                        Debug.WriteLine("ImagePath: " + temp_overlay_item.ImagePath);

                        // Display the selected image.
                        overlay_window.DisplayOverlay(temp_overlay_item.ImagePath);
                    }
                    else
                    {
                        // If there was no image to display, clear the last image.
                        overlay_window.ResetOverlay();
                    }

                    if (File.Exists(temp_overlay_item.SoundPath))
                    {
                        Debug.WriteLine("SoundVolume: " + temp_overlay_item.SoundVolume);

                        // Set the soud's volume level.
                        sound_manager.SetVolume(temp_overlay_item.SoundVolume);

                        // Play Overlay Sound
                        sound_manager.PlaySound(temp_overlay_item.SoundPath);

                        // Show stop button.
                        DisplayStop(temp_overlay_list_box_item);
                    }
                }
            }
        }
Пример #6
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            // Get the selected OverlayItem.
            OverlayListBoxItem temp_overlay_list_box_item = (OverlayListBoxItem)overlay_lv.SelectedItem;
            OverlayItem        temp_overlay_item          = temp_overlay_list_box_item.OverlayItemData;

            // Bind the sored OverlayItem to the AddOverlayItem dialog.
            add_overlay_item_container.DataContext = temp_overlay_item;

            // Show the add item screen.
            DisplayItemScreen("Edit Item");
        }
Пример #7
0
        private void SaveTimePicker(String duration_to_use)
        {
            // Hide the TimePicker dialog.
            time_picker_dialog.Visibility = System.Windows.Visibility.Collapsed;

            // Save the selected time.
            OverlayItem temp_item = (OverlayItem)add_overlay_item_container.DataContext;

            temp_item.DisplayDuration = duration_to_use;

            // Show the changed value.
            add_overlay_item_container.time_tb.Text = duration_to_use;
        }
Пример #8
0
        private void RestGlobalHotkeys()
        {
            // Remove previous hotkey bindings.
            global_hotkey_listner.UnRegisterGlobalHotkeys();

            // Rebind hotkeys.
            for (int count = 0; count < OverlayListBoxItems.Count; count++)
            {
                OverlayItem temp_item = OverlayListBoxItems[count].OverlayItemData;

                global_hotkey_listner.RegisterGlobalHotkey(temp_item);
            }
        }
Пример #9
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            OverlayItem temp_item = (OverlayItem)add_overlay_item_container.DataContext;

            if (AppTitle_txt.Text == "Edit Item")
            {
                SaveOverlayItem(temp_item, true);
            }
            else
            {
                SaveOverlayItem(temp_item, false);
            }
        }
Пример #10
0
        public void SaveOverlayItem(OverlayItem overlay_item)
        {
            // Read in the overlay items xml into a single string.
            String temp_xml_string = File.ReadAllText(saved_overlay_items_path);

            XmlDocument temp_xml_doc = new XmlDocument();

            temp_xml_doc.LoadXml(temp_xml_string);

            // Add a OverlayItem xml child.
            AppendOverlayItemXML(temp_xml_doc, overlay_item);

            // Write the changes to the xml file.
            temp_xml_doc.Save(saved_overlay_items_path);
        }
Пример #11
0
        private void SaveHotkeyDialog(String selected_hotkey)
        {
            // Hide the hotkey diallog.
            hotkey_dialog.Visibility = System.Windows.Visibility.Collapsed;

            // Save the enterted hotkey.
            if (!String.IsNullOrEmpty(selected_hotkey))
            {
                OverlayItem temp_item = (OverlayItem)add_overlay_item_container.DataContext;
                temp_item.HotKey = selected_hotkey;

                // Show the changed value.
                add_overlay_item_container.hotkey_tb.Text = selected_hotkey;
            }
        }
Пример #12
0
        private void AddOverlayItem(OverlayItem overlay_item)
        {
            // Register the hotkey with the global listner.
            global_hotkey_listner.RegisterGlobalHotkey(overlay_item);

            OverlayListBoxItem temp_overlay_list_box_item = new OverlayListBoxItem();

            temp_overlay_list_box_item.PopulateOverlayItem(overlay_item);

            // Add the OverlayItem to the list of displayed items.
            OverlayListBoxItems.Add(temp_overlay_list_box_item);

            // Show Play Button
            DisplayPlay(temp_overlay_list_box_item);
        }
Пример #13
0
        private void ImagePath_Click(object sender, RoutedEventArgs e)
        {
            String image_path = "";
            // Get the users chosen image.
            OpenFileDialog open_file_dialog = new OpenFileDialog();
            open_file_dialog.Title = "Choose Image";
            open_file_dialog.Filter = "Image Files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.gif) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.gif;|All Files (*.*)|*.*";

            if (open_file_dialog.ShowDialog() == true)
                image_path = open_file_dialog.FileName;

            OverlayItem temp_item = (OverlayItem)this.DataContext;
            temp_item.ImagePath = image_path;

            // Show the changed value.
            this.image_path_tb.Text = image_path;
        }
Пример #14
0
        private void SoundPath_Click(object sender, RoutedEventArgs e)
        {
            String sound_path = "";
            // Get the users chosen sound.
            OpenFileDialog open_file_dialog = new OpenFileDialog();
            open_file_dialog.Title = "Choose Sound";
            open_file_dialog.Filter = "Sound Files  (*.mp3, *.wav)|*.mp3; *.wav;|All Files (*.*)|*.*";

            if (open_file_dialog.ShowDialog() == true)
                sound_path = open_file_dialog.FileName;

            OverlayItem temp_item = (OverlayItem)this.DataContext;
            temp_item.SoundPath = sound_path;

            // Show the changed value.
            this.sound_path_tb.Text = sound_path;
        }
Пример #15
0
        private void AppendOverlayItemXML(XmlDocument xml_doc, OverlayItem overlay_item)
        {
            // Get the root node to append to.
            XmlNode document_root = xml_doc.DocumentElement;

            // <OverlayItem>
            XmlElement overlay_item_root_element = xml_doc.CreateElement("OverlayItem");

            //   <ImagePath>
            XmlElement image_path = xml_doc.CreateElement("ImagePath");

            image_path.InnerText = overlay_item.ImagePath;
            overlay_item_root_element.AppendChild(image_path);

            //   <SoundPath>
            XmlElement sound_path = xml_doc.CreateElement("SoundPath");

            sound_path.InnerText = overlay_item.SoundPath;
            overlay_item_root_element.AppendChild(sound_path);

            //   <HotKey>
            XmlElement hotkey = xml_doc.CreateElement("HotKey");

            hotkey.InnerText = overlay_item.HotKey;
            overlay_item_root_element.AppendChild(hotkey);

            //   <SoundVolume>
            XmlElement sound_volume = xml_doc.CreateElement("SoundVolume");

            sound_volume.InnerText = overlay_item.SoundVolume.ToString();
            overlay_item_root_element.AppendChild(sound_volume);

            //   <DisplayDuration>
            XmlElement dispaly_duration = xml_doc.CreateElement("DisplayDuration");

            dispaly_duration.InnerText = overlay_item.DisplayDuration;
            overlay_item_root_element.AppendChild(dispaly_duration);

            // Add the new overlay item xml to the end of the document.
            document_root.AppendChild(overlay_item_root_element);
        }
Пример #16
0
        public void RegisterGlobalHotkey(OverlayItem overlay_item)
        {
            int          virtual_key_code = (int)MOD_NONE;
            KeyConverter key_converter    = new KeyConverter();

            fsmodifers = (int)MOD_NONE;

            string[] temp_selected_keys = overlay_item.HotKey.Split('+');
            foreach (String temp_selected_key in temp_selected_keys)
            {
                Key temp_key = (Key)key_converter.ConvertFromString(temp_selected_key);
                if (!IsModiferKey(temp_key))
                {
                    virtual_key_code |= KeyInterop.VirtualKeyFromKey(temp_key);
                }
            }

            RegisterHotKey(this.hwnd_handle, current_hotkey_id, (uint)fsmodifers, (uint)virtual_key_code);

            overlay_item.HotKeyID = current_hotkey_id;

            current_hotkey_id++;
        }
Пример #17
0
 public OverlayListBoxItem()
 {
     overlay_item_data = new OverlayItem();
 }
Пример #18
0
        public void LoadOverlayItems()
        {
            overlay_items = new List <OverlayItem>();

            if (File.Exists(saved_overlay_items_path))
            {
                FileStream overlay_items_file = new FileStream(saved_overlay_items_path, FileMode.Open, FileAccess.Read);
                XmlReader  overlay_items_xml  = XmlReader.Create(overlay_items_file);

                bool        overlay_item_parent_found = false;
                String      temp_value        = "";
                OverlayItem temp_overlay_item = null;

                while (overlay_items_xml.Read())
                {
                    if (overlay_items_xml.IsStartElement() && overlay_items_xml.Name == "OverlayItem")
                    {
                        // Signal that a parent OverlayItem was found.
                        overlay_item_parent_found = true;

                        // Reset for the next OverlayItem.
                        temp_overlay_item = new OverlayItem();
                    }

                    if (overlay_item_parent_found && overlay_items_xml.IsStartElement())
                    {
                        if (overlay_items_xml.Name == "ImagePath")
                        {
                            // Read in the overlay image path.
                            temp_value = overlay_items_xml.ReadElementContentAsString();
                            temp_overlay_item.ImagePath = temp_value;
                        }
                        else if (overlay_items_xml.Name == "SoundPath")
                        {
                            // Read in the overlay sound path.
                            temp_value = overlay_items_xml.ReadElementContentAsString();
                            temp_overlay_item.SoundPath = temp_value;
                        }
                        else if (overlay_items_xml.Name == "HotKey")
                        {
                            // Read in the overlay image path.
                            temp_value = overlay_items_xml.ReadElementContentAsString();
                            temp_overlay_item.HotKey = temp_value;
                        }
                        else if (overlay_items_xml.Name == "SoundVolume")
                        {
                            // Read in the overlay sound volume.
                            temp_value = overlay_items_xml.ReadElementContentAsString();
                            double temp_volume = 0;
                            double.TryParse(temp_value, out temp_volume);
                            temp_overlay_item.SoundVolume = temp_volume;
                        }
                        else if (overlay_items_xml.Name == "DisplayDuration")
                        {
                            temp_value = overlay_items_xml.ReadElementContentAsString();
                            temp_overlay_item.DisplayDuration = temp_value;
                        }
                    }

                    if (overlay_items_xml.NodeType == XmlNodeType.EndElement && overlay_items_xml.Name == "OverlayItem")
                    {
                        // Signal the end of a overlay item.
                        overlay_item_parent_found = false;

                        // Add the loaded OverlayItem to the list.
                        overlay_items.Add(temp_overlay_item);
                    }
                }

                overlay_items_file.Close();
            }
        }
Пример #19
0
        private void DisplayDuration_Click(object sender, RoutedEventArgs e)
        {
            OverlayItem temp_item = (OverlayItem)this.DataContext;

            showTimePickerDialog(temp_item.DisplayDuration);
        }
Пример #20
0
        private void HotKey_Click(object sender, RoutedEventArgs e)
        {
            OverlayItem temp_item = (OverlayItem)this.DataContext;

            showHotkeyDialog(temp_item.HotKey);
        }