Example #1
0
        public AccountItemGUI(int nNumber, Form1 ParentForm, Panel parentpanel, List<Bitmap> IconBmp, string name, string address, Int64 balance, int icon, bool bEnabled)
        {
            m_IconBmpList = IconBmp;
            m_ParentForm=ParentForm;
            m_AccountNumber = nNumber;
            m_Parent= parentpanel;

            m_icon = icon;

            m_Inner = new GradientPanel(Color.FromArgb(96, 96, 96),Color.FromArgb(16, 16, 16),0);
            m_Inner.Location = new Point(0, (nNumber*70));
            m_Inner.BorderStyle = BorderStyle.FixedSingle;
            m_Inner.MouseEnter += General_MouseEnter;

            m_Image = new PictureBox();
            m_Image.BackColor = Color.Transparent;
            m_Image.Image = m_IconBmpList[m_icon];
            m_Image.Cursor = Cursors.Hand;
            m_Image.MouseClick += iconMouseClick;
            m_Image.MouseEnter += iconMouseEnter;
            m_Image.MouseLeave += iconMouseLeave;

            m_AccountName = new Label();
            m_AccountName.BackColor = Color.Transparent;
            m_AccountName.ForeColor = Color.White;
            m_AccountName.Font = new Font(Constants.FONTNAME, 12);
            m_AccountName.Text = name;
            m_AccountName.TextAlign = ContentAlignment.MiddleLeft;
            m_AccountName.AutoEllipsis = true;
            m_AccountName.MouseEnter += accountMouseEnter;
            m_AccountName.MouseLeave += accountMouseLeave;
            m_AccountName.MouseClick += accountMouseClick;

            m_EditName = new TextBox();
            m_EditName.Text = name;
            m_EditName.Font = new Font(Constants.FONTNAME, 12);
            m_EditName.BorderStyle = BorderStyle.None;
            m_EditName.Visible = false;
            m_EditName.BackColor = Color.FromArgb(192,192,192);
            //m_EditName.ForeColor = Color.f;
            m_EditName.LostFocus += onEditLostFocus;
            m_EditName.KeyDown += KeyDown;

            m_Address = new Label();
            m_Address.Font = new Font("Courier New", 9);
            m_Address.BackColor = Color.Transparent;
            m_Address.ForeColor = Color.FromArgb(192,192,192);
            m_Address.Text = address;
            m_Address.AutoEllipsis = true;
            m_Address.TextAlign = ContentAlignment.MiddleLeft;
            m_Address.MouseEnter += addressMouseEnter;
            m_Address.MouseLeave += addressMouseLeave;
            m_Address.MouseClick += addressMouseClick;
            m_Address.MouseDoubleClick += addressMouseClick;

            ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(m_Address, "Click to copy address");

            m_Amount = new Label();

            m_Amount.BackColor = Color.Transparent;
            m_Amount.Font = new Font(Constants.FONTNAME, 12);
            m_Amount.TextAlign = ContentAlignment.MiddleLeft;
            m_Amount.AutoEllipsis = true;
            m_Amount.MouseEnter += General_MouseEnter;
            m_Amount.TextAlign = ContentAlignment.MiddleRight;
            m_Amount.AutoSize = true;
            m_Amount.ForeColor = Color.FromArgb(255,255,220);

            m_Inner.Controls.Add(m_Image);
            m_Inner.Controls.Add(m_EditName);
            m_Inner.Controls.Add(m_AccountName);

            m_Inner.Controls.Add(m_Address);
            m_Inner.Controls.Add(m_Amount);

            SetBalance(balance);
            SetEnabled(bEnabled);
            m_Parent.Controls.Add(m_Inner);

            Resize();
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //GetInfo networkInfo = MicroCashFunctions.GetInfo();
            //GetHistory history = MicroCashFunctions.GetHistory("sSj4DdD5MExLgGBXrHxrNEr9WCfzBd2gx9");
            //int blockNumber = 123456;
            //BlockHeader networkBlock = MicroCashFunctions.GetBlockData(blockNumber);
            //GetInputs getinputs = MicroCashFunctions.GetInputs("sNvkB6KTsTyv5xPRo9Y4aq8D4AhnZZSEJE", 1000);

            /*
            ThinUser newuser = new ThinUser("user");
            for (int z = 0; z < 5; z++)
            {
                newuser.AddNewAccount("Savings Account");
            }
            newuser.Save();
            m_ThinUsers.Add(newuser);

            newuser = new ThinUser("Ahimoth");
            newuser.AddNewAccount("Savings Account");
            newuser.Save();
             * */

            trayMenu = new ContextMenu();
            trayMenu.MenuItems.Add("Exit", onExit);

            trayIcon      = new NotifyIcon();
            trayIcon.Text = "MicroCash";
            trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40);
            trayIcon.ContextMenu = trayMenu;
            trayIcon.Visible     = true;

            LoadSettings();
            m_ThinUser = m_ThinUsers[0];

            m_UserBMPList = new List<Bitmap>();
            m_UserBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.user_general.png")));
            m_UserBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.user_guy.png")));
            m_UserBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.user_guy2.png")));
            m_UserBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.user_woman.png")));

            m_AccountBMPList = new List<Bitmap>();
            m_AccountBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.account_sc.png")));
            m_AccountBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.account_mining.png")));
            m_AccountBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.account_savings.png")));
            m_AccountBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.account_checking.png")));
            m_AccountBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.account_heart.png")));
            m_AccountBMPList.Add(new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.account_star.png")));

            DoConnectionPanel();

            m_UserPanel = new GradientPanel(Color.FromArgb(80, 80,110), Color.FromArgb(30, 30, 40),0);
            m_UserPanel.BorderStyle = BorderStyle.FixedSingle;

            m_LeftPanel = new GradientPanel(Color.FromArgb(64, 64, 64),Color.FromArgb(32,32,32),0);
            m_LeftPanel.AutoScroll = true;
            m_LeftPanel.MouseEnter += General_MouseEnter;

            m_BotPanel = new GradientPanel(Color.FromArgb(80, 80, 110), Color.FromArgb(30, 30,40), 0);
            m_BotPanel.BorderStyle = BorderStyle.FixedSingle;

            m_AddNewAccount = new Label();
            m_AddNewAccount.Text = "Add Account";
            m_AddNewAccount.TextAlign = ContentAlignment.MiddleCenter;

            m_AddNewAccount.BorderStyle = BorderStyle.FixedSingle;
            m_AddNewAccount.BackColor = Color.Transparent;
            m_AddNewAccount.ForeColor = Color.White;
            m_AddNewAccount.MouseEnter += addMouseEnter;
            m_AddNewAccount.MouseLeave += addMouseLeave;
            m_AddNewAccount.Cursor = Cursors.Hand;
            m_AddNewAccount.Click += userNewAccountClick;
            m_BotPanel.Controls.Add(m_AddNewAccount);

            m_AddNewUser = new Label();
            m_AddNewUser.Text = "Add User";
            m_AddNewUser.TextAlign = ContentAlignment.MiddleCenter;
            m_AddNewUser.BorderStyle = BorderStyle.FixedSingle;
            m_AddNewUser.BackColor = Color.Transparent;
            m_AddNewUser.ForeColor = Color.White;
            m_AddNewUser.MouseEnter += addMouseEnter;
            m_AddNewUser.MouseLeave += addMouseLeave;
            m_AddNewUser.Cursor = Cursors.Hand;
            m_AddNewUser.Click += userNewUserClick;
            m_BotPanel.Controls.Add(m_AddNewUser);

            //m_LeftPanel.Controls.Add(m_Logo);

            m_RightPanel = new Panel();
            m_RightPanel.BackColor = Color.FromArgb(32,32,32);

            m_UserImage = new PictureBox();
            m_UserImage.BackColor = Color.Transparent;
            m_UserImage.Location = new Point(5, 5);
            m_UserImage.Size = new Size(70, 70);
            m_UserImage.BackgroundImageLayout = ImageLayout.Stretch;
            m_UserImage.BackgroundImage = m_UserBMPList[m_ThinUser.m_icon];
            m_UserImage.Cursor = Cursors.Hand;

            m_UserText = new Label();
            m_UserText.BackColor = Color.Transparent;
            //m_UserText.ForeColor = Color.White;

            m_UserText.Font = new Font(Constants.FONTNAME, 18);
            m_UserText.Text = m_ThinUser.m_name;
            m_UserText.Cursor = Cursors.Hand;
            m_UserText.TextAlign = ContentAlignment.MiddleLeft;
            m_UserText.ForeColor = Color.White;

            m_UserTotalSC = new Label();
            m_UserTotalSC.BackColor = Color.Transparent;
            m_UserTotalSC.ForeColor = Color.FromArgb(192, 192, 192);
            m_UserTotalSC.Font = new Font(Constants.FONTNAMEMONO, 7, FontStyle.Bold);
            m_UserTotalSC.Text = "Balance:";
            m_UserTotalSC.Cursor = Cursors.Hand;
            m_UserTotalSC.TextAlign = ContentAlignment.MiddleLeft;
            m_UserTotalSC.AutoSize = true;

            m_UserTotalInterest = new Label();
            m_UserTotalInterest.BackColor = Color.Transparent;
            m_UserTotalInterest.ForeColor = Color.FromArgb(192, 192, 192);
            m_UserTotalInterest.Font = new Font(Constants.FONTNAMEMONO, 7, FontStyle.Bold);
            m_UserTotalInterest.Text = "Interest:";
            m_UserTotalInterest.Cursor = Cursors.Hand;
            m_UserTotalInterest.TextAlign = ContentAlignment.MiddleLeft;
            m_UserTotalInterest.AutoSize = true;

            ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(m_UserTotalSC, "This is how much MicroCash you have for all your accounts.\nThe number in brackets is your percentage of all the MicroCash currently existing");
            ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(m_UserTotalInterest,
                "This is how much daily interest you get.\n\n"+
                "Each account in the MicroCash network requires a small daily fee,\n"+
                "These fees are then added up and given back to all the accounts proportionally\n"+
                "to the amount of MicroCash stored in each account. The more MicroCash in an\n"+
                "account the higher the percentage of interest you receive.");

            m_UserPanel.MouseEnter += userMouseEnter;
            m_UserPanel.MouseLeave += userMouseLeave;
            m_UserPanel.MouseClick += userMouseClick;
            m_UserText.MouseEnter += userMouseEnter;
            m_UserText.MouseLeave += userMouseLeave;
            m_UserText.MouseClick += userMouseClick;
            m_UserTotalSC.MouseEnter += userMouseEnter;
            m_UserTotalSC.MouseLeave += userMouseLeave;
            m_UserTotalSC.MouseClick += userMouseClick;
            m_UserTotalInterest.MouseEnter += userMouseEnter;
            m_UserTotalInterest.MouseLeave += userMouseLeave;
            m_UserTotalInterest.MouseClick += userMouseClick;

            m_UserImage.MouseClick += userAvatarClick;

            m_UserPanel.Controls.Add(m_UserImage);
            m_UserPanel.Controls.Add(m_UserText);
            m_UserPanel.Controls.Add(m_UserTotalSC);
            m_UserPanel.Controls.Add(m_UserTotalInterest);

            InitTabs();

            //this.Controls.Add(m_LogoPanel);
            this.Controls.Add(m_LeftPanel);
            this.Controls.Add(m_RightPanel);
            this.Controls.Add(m_UserPanel);
            this.Controls.Add(m_BotPanel);

            this.Resize += Form1_Resize;
            this.FormClosing += Form1_Close;

            //m_AccountItemsGUI[1] = new AccountItemGUI(1, m_LeftPanel, "Checking Account", "srTGvDYJzxHR752xTC3sAzDbwRadWWWecd", "100.00");
            //m_AccountItems[1] = new AccountItem(true,1,m_LeftPanel);
            switchUser();

            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 1000;
            timer.Enabled = true;
            timer.Tick += OnTimerEvent;

            OnTimerEvent(null, null);

            m_RPCThread = new Thread(new ThreadStart(RPCThread));
            m_RPCThread.Start();

            m_RPCMutex.WaitOne();
            //for(int x=0;x<5000;x++) DoTransactionTest();
            m_RPCMutex.ReleaseMutex();

            //DoTransactionTest();
        }
        void DoConnectionPanel()
        {
            m_bUpdateConnectionLog = false;
            m_bLoggedInGUI = m_bLoggedIn = false;

            m_LogItems = new List<string>();

            m_ConnectPanelTop = new GradientPanel(Color.FromArgb(120, 30, 30), Color.FromArgb(255, 80, 80), 0);
            m_ConnectPanelTop.BorderStyle = BorderStyle.FixedSingle;
            m_ConnectPanelTop.Cursor = Cursors.Hand;

            m_ConnectPanel = new GradientPanel(Color.FromArgb(255, 255, 255), Color.FromArgb(192, 192, 192), 0);
            m_ConnectPanel.BorderStyle = BorderStyle.FixedSingle;
            m_ConnectPanel.Visible = false;

            m_ConnectLogoBMP = new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.logosmall.png"));
            m_ConnectLogo = new PictureBox();
            m_ConnectLogo.BackColor = Color.Transparent;
            m_ConnectLogo.Location = new Point(3, 2);
            m_ConnectLogo.Size = new Size(200, 40);
            m_ConnectLogo.Image = Grayscale(m_ConnectLogoBMP);
            m_ConnectLogo.Cursor = Cursors.Hand;

            m_ConnectArrowBMP = new Bitmap(System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("MicroCash.Client.Thin.pngs.downarrow.png"));
            m_ConnectionArrow = new PictureBox();
            m_ConnectionArrow.BackColor = Color.Transparent;
            m_ConnectionArrow.Location = new Point(8, 5);
            m_ConnectionArrow.Size = new Size(108, 30);
            m_ConnectionArrow.Image = m_ConnectArrowBMP;
            m_ConnectionArrow.Cursor = Cursors.Hand;

            m_ConnectInfo = new Label();
            m_ConnectInfo.BackColor = Color.Transparent;
            m_ConnectInfo.ForeColor = Color.White;
            m_ConnectInfo.Font = new Font(Constants.FONTNAME, 8, FontStyle.Bold);
            m_ConnectInfo.Text = "Connecting...";
            m_ConnectInfo.Cursor = Cursors.Hand;
            m_ConnectInfo.TextAlign = ContentAlignment.MiddleLeft;

            m_ConnectType = new ComboBox();
            m_ConnectType.DropDownStyle = ComboBoxStyle.DropDownList;
            m_ConnectType.Font = new Font(Constants.FONTNAME, 8,FontStyle.Bold);
            m_ConnectType.Items.Add(" Connect: MicroCash Official Nodes");
            m_ConnectType.Items.Add(" Connect: Specific MicroCash Node");
            m_ConnectType.SelectedIndexChanged += onConnectTypeChange;

            m_ConnectTypeInfo = new Label();
            m_ConnectTypeInfo.Padding = new Padding(10);
            m_ConnectTypeInfo.BackColor = Color.White;
            m_ConnectTypeInfo.BorderStyle = BorderStyle.FixedSingle;

            m_ConnectTypeIP = new TextBox();

            m_ConnectTypeIP.Font = new Font(Constants.FONTNAME, 8, FontStyle.Bold);

            m_ConnectLog = new ListView();
            m_ConnectLog.BackColor = Color.FromArgb(192, 192, 192);
            m_ConnectLog.Columns.Add("log item");
            m_ConnectLog.FullRowSelect = true;
            m_ConnectLog.View = System.Windows.Forms.View.Details;
            m_ConnectLog.ShowItemToolTips = true;
            m_ConnectLog.HeaderStyle = ColumnHeaderStyle.None;

            m_ConnectInfo.MouseEnter += connectMouseEnter;
            m_ConnectInfo.MouseLeave += connectMouseLeave;
            m_ConnectInfo.MouseDown += connectMouseClick;
            m_ConnectPanelTop.MouseEnter += connectMouseEnter;
            m_ConnectPanelTop.MouseLeave += connectMouseLeave;
            m_ConnectPanelTop.MouseDown += connectMouseClick;
            m_ConnectLogo.MouseEnter += connectMouseEnter;
            m_ConnectLogo.MouseLeave += connectMouseLeave;
            m_ConnectLogo.MouseDown += connectMouseClick;
            m_ConnectionArrow.MouseEnter += connectMouseEnter;
            m_ConnectionArrow.MouseLeave += connectMouseLeave;
            m_ConnectionArrow.MouseDown += connectMouseClick;

            m_ConnectPanelTop.Controls.Add(m_ConnectionArrow);
            m_ConnectPanelTop.Controls.Add(m_ConnectInfo);
            m_ConnectPanelTop.Controls.Add(m_ConnectLogo);

            m_ConnectPanel.Controls.Add(m_ConnectLog);
            m_ConnectPanel.Controls.Add(m_ConnectTypeIP);
            m_ConnectPanel.Controls.Add(m_ConnectType);
            m_ConnectPanel.Controls.Add(m_ConnectTypeInfo);

            this.Controls.Add(m_ConnectPanelTop);
            this.Controls.Add(m_ConnectPanel);

            if (GlobalSettings.ConnectionType < 0 || GlobalSettings.ConnectionType > 1)
                GlobalSettings.ConnectionType = 0;
            m_ConnectType.SelectedIndex = GlobalSettings.ConnectionType;
            m_ConnectTypeIP.Text = GlobalSettings.RpcAddress;
            m_ConnectTypeIP.Validating += new CancelEventHandler(m_ConnectTypeIP_Validating);
            //selectConnectType(0);

            AddLogItem("Initializing client");
        }