Esempio n. 1
0
        public void createForm(string childFormTypeStr, int idx)
        {
            JCComponentConfig compConfig = config.components[JCConfig.getTypeIdx(childFormTypeStr)];

            if (compConfig.forms[idx] != null)
            {
                compConfig.forms[idx].Invoke((MethodInvoker) delegate() { compConfig.forms[idx].Focus(); });
            }
            else
            {
                Form childForm = (Form)(JCConfig.getConstructor(childFormTypeStr)).Invoke(new object[] { this, idx });
                childForm.Show();
            }
        }
Esempio n. 2
0
        public static JCConfig read()
        {
            JCConfig result = null;

            if (File.Exists(Application.StartupPath + "\\config.xml"))
            {
                XmlSerializer ser = new XmlSerializer(typeof(JCConfig));
                using (FileStream fs = File.OpenRead(Application.StartupPath + "\\config.xml"))
                {
                    try
                    {
                        result = (JCConfig)ser.Deserialize(fs);
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.ToString());
                    }
                }
            }
            if (result == null)
            {
                result = new JCConfig();
            }
            if (result.components.Length < ChildFormsTypes.Length)
            {
                Array.Resize(ref result.components, ChildFormsTypes.Length);
            }
            for (int c = 0; c < ChildFormsTypes.Count(); c++)
            {
                if (result.components[c] == null)
                {
                    result.components[c] = (JCComponentConfig)getConstructor(ConfigComponentsTypes[c]).Invoke(new object[] {});
                }
            }
            return(result);
        }
Esempio n. 3
0
        private NotifyIcon notifyIcon;                          // the icon that sits in the system tray

        private void InitializeContext()
        {
            components = new System.ComponentModel.Container();
            notifyIcon = new NotifyIcon(components)
            {
                ContextMenuStrip = new ContextMenuStrip(),
                Icon             = new Icon(IconFileName),
                Text             = DefaultTooltip,
                Visible          = true
            };
            notifyIcon.ContextMenuStrip.Opening += ContextMenuStrip_Opening;
            notifyIcon.MouseUp += notifyIcon_MouseUp;
            config              = JCConfig.read();
            esConnect();

            for (int c = 0; c < JCConfig.ChildFormsTypes.Count(); c++)
            {
                for (int c0 = 0; c0 < JCConfig.ChildFormsCount[c]; c0++)
                {
                    string title = JCConfig.ChildFormsTitles[c];
                    if (JCConfig.ChildFormsCount[c] > 1)
                    {
                        title += " " + (c0 + 1).ToString();
                    }
                    ToolStripMenuItem mi = new ToolStripMenuItem(title);
                    string            childFormTypeStr = JCConfig.ChildFormsTypes[c];
                    int idx = c0;
                    mi.Click += new EventHandler(delegate(object obj, EventArgs ea)
                    {
                        createForm(childFormTypeStr, idx);
                    });
                    notifyIcon.ContextMenuStrip.Items.Add(mi);
                    if (config.components[c].formStates[c0].active)
                    {
                        createForm(JCConfig.ChildFormsTypes[c], c0);
                    }
                }
            }



            notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());

            miExpertSync.Click += esItem_Click;
            notifyIcon.ContextMenuStrip.Items.Add(miExpertSync);

            notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());

            ToolStripMenuItem miExit = new ToolStripMenuItem("Выход");

            miExit.Click += exitItem_Click;
            notifyIcon.ContextMenuStrip.Items.Add(miExit);

#if DEBUG
            notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());

            MessageEventArgs[] testMessages = new MessageEventArgs[] {
                new MessageEventArgs {
                    vfoa = 7000000, trx = false
                },
                new MessageEventArgs {
                    vfoa = 10000000, trx = false
                },
                new MessageEventArgs {
                    vfoa = 14000000, trx = false
                },
                new MessageEventArgs {
                    vfoa = 7000000, trx = true
                }
            };
            foreach (MessageEventArgs msg in testMessages)
            {
                ToolStripMenuItem mi = new ToolStripMenuItem(msg.vfoa.ToString() + ' ' + msg.trx.ToString());
                mi.Click += new EventHandler(delegate(object sender, EventArgs e) {
                    esMessage(null, msg);
                });
                notifyIcon.ContextMenuStrip.Items.Add(mi);
            }
#endif
        }