Example #1
0
        /// <summary>
        /// GaGa implementation.
        /// </summary>
        /// <param name="streamsFilePath">
        /// Path for the streams file to use.
        /// </param>
        public GaGa(String streamsFilePath)
        {
            // streams file and loader:
            streamsFile = new StreamsFile(streamsFilePath, "GaGa.Resources.streams.ini");
            menuLoader = new StreamsMenuLoader(streamsFile);

            // gui components:
            container = new Container();

            notifyIcon = new NotifyIcon(container);
            notifyIcon.Visible = true;

            MenuRecreate();

            // error items:
            errorOpenItem = new MenuItem("Error opening streams file (click for details)", OnErrorOpenItemClick);
            errorReadItem = new MenuItem("Error reading streams file (click for details)", OnErrorReadItemClick);

            // constant items:
            editItem = new MenuItem("Edit streams file", OnEditItemClick);
            exitItem = new MenuItem("Exit", OnExitItemClick);

            // playing:
            player = new Player(notifyIcon);
        }
Example #2
0
        /// <summary>
        /// Can read or recreate a streams file, monitor changes,
        /// and add all the sections and items to a context menu.
        /// </summary>
        /// <param name="file">Streams file to read from.</param>
        public StreamsMenuLoader(StreamsFile file)
        {
            this.file = file;
            reader = new StreamsFileReader();

            lastUpdated = null;
        }
Example #3
0
 /// <summary>
 /// Raised by StreamsFileReader on a reading error.
 /// </summary>
 /// <param name="message">Error message.</param>
 /// <param name="file">Streams file that triggered the error.</param>
 /// <param name="line">Line text for the incorrect line.</param>
 /// <param name="linenumber">Line where the error happened.</param>
 public StreamsFileReadError(String message, StreamsFile file, String line, Int32 linenumber)
     : base(message)
 {
     File = file;
     Line = line;
     LineNumber = linenumber;
 }
Example #4
0
        /// <summary>
        /// An INIReader that reads lines from a streams file
        /// adding sections and key=value pairs to a context menu
        /// as submenus and clickable items.
        /// </summary>
        public StreamsFileReader()
        {
            file = null;
            menu = null;
            onClick = null;

            currentMenuItems = null;
            seenSubmenues = new Dictionary<String, MenuItem>();

            currentLineNumber = 0;
            currentLine = String.Empty;
        }
Example #5
0
        /// <summary>
        /// Read a streams file adding submenus items to a context menu.
        /// </summary>
        /// <param name="file">Streams file to read lines from.</param>
        /// <param name="menu">Target context menu.</param>
        /// <param name="onClick">Click event to attach to menu items.</param>
        public void Read(StreamsFile file, ContextMenu menu, EventHandler onClick)
        {
            this.file = file;
            this.menu = menu;
            this.onClick = onClick;

            // start at root:
            currentMenuItems = menu.MenuItems;

            try
            {
                foreach (String line in file.ReadLines())
                {
                    currentLineNumber++;
                    currentLine = line;
                    ReadLine(line);
                }
            }
            finally
            {
                ResetState();
            }
        }
Example #6
0
        /// <summary>
        /// Clear internal state.
        /// </summary>
        private void ResetState()
        {
            file = null;
            menu = null;
            onClick = null;

            currentMenuItems = null;
            seenSubmenues.Clear();

            currentLineNumber = 0;
            currentLine = String.Empty;
        }