示例#1
0
文件: wiwAdo.cs 项目: miquik/mkdb
 public wiwAdo(wx.Window _pc, wx.Sizer _ps)
     : base(wx.Orientation.wxHORIZONTAL)
 {
     int fl = wx.Alignment.wxALIGN_CENTRE_VERTICAL|wx.Direction.wxRIGHT;
     _props = new wdbAdoProps();
     _btn_first = new wx.Button(_pc, -1, "|<", wx.Button.wxDefaultPosition, new Size(20, -1));
     _btn_prev = new wx.Button(_pc, -1, "<", wx.Button.wxDefaultPosition, new Size(20, -1));
     _ado_text = new wx.TextCtrl(_pc, -1, "Ado", wx.Button.wxDefaultPosition, new Size(100, -1));
     _btn_next = new wx.Button(_pc, -1, ">", wx.Button.wxDefaultPosition, new Size(20, -1));
     _btn_last = new wx.Button(_pc, -1, ">|", wx.Button.wxDefaultPosition, new Size(20, -1));
     _btn_new = new wx.Button(_pc, -1, "+", wx.Button.wxDefaultPosition, new Size(20, -1));
     _btn_canc = new wx.Button(_pc, -1, "-", wx.Button.wxDefaultPosition, new Size(20, -1));
     this.Add(_btn_first, 0, fl, 2);
     this.Add(_btn_prev, 0, fl, 2);
     this.Add(_ado_text, 0, fl, 2);
     this.Add(_btn_next, 0, fl, 2);
     this.Add(_btn_last, 0, fl, 2);
     this.Add(_btn_new, 0, fl, 2);
     this.Add(_btn_canc, 0, fl, 2);
     _p_container = _pc;
     _p_sizer = _ps;
     _sizer_item = null;
     _ado_cur_index++;
     string name = "Ado" + _ado_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
 }
示例#2
0
文件: wiwApp.cs 项目: miquik/mkdb
 public wiwApp(wx.Window _pc, wx.Sizer _ps)
     : base(null)
 {
     _props = new wdbAppProps();
     SetDefaultProps("Project");
     SetWidgetProps();
 }
示例#3
0
        public wifInnerFrame(wx.Window _parent, int _id, string _title, Point _pos, Size _size, uint _style)
            : base(_parent, _id, _pos, _size, wx.Panel.wxRAISED_BORDER | wx.Panel.wxFULL_REPAINT_ON_RESIZE)
        {
            wintitle = _title;
            style = _style;
            m_sizing = mSizing.NONE;
            m_resizeBorder = 10;
            //
            title_bar = new wifInnerTitleBar(this, -1, _title, new Point(0, 0), new Size(this.Width, 20), _style);
            // frame_content = new wifInnerFrameContent(this, -1, new Point(0, 0), wx.Panel.wxDefaultSize);
            frame_content = new wx.Panel(this, -1, new Point(0, 0), wx.Panel.wxDefaultSize, 0);
            //
            wx.BoxSizer sizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
            sizer.Add(title_bar, 0, wx.Stretch.wxGROW | wx.Direction.wxRIGHT, 2);
            wx.BoxSizer horiSizer = new wx.BoxSizer(wx.Orientation.wxHORIZONTAL);
            horiSizer.Add(frame_content, 1, wx.Stretch.wxGROW);
            sizer.Add(horiSizer, 1, wx.Stretch.wxGROW | wx.Direction.wxBOTTOM | wx.Direction.wxRIGHT, 2);
            SetSizer(sizer);
            this.AutoLayout = true;
            Layout();

            m_minSize = title_bar.MinSize;
            m_minSize.Width += 8;
            m_minSize.Height += 10;
            m_baseMinSize = m_minSize;

            this.EVT_MOTION(new wx.EventListener(OnMouseMotion));
            this.EVT_LEFT_DOWN(new wx.EventListener(OnLeftDown));
            this.EVT_LEFT_UP(new wx.EventListener(OnLeftUp));
            this.EVT_UPDATE_UI(this.ID, new wx.EventListener(OnUpdateUI));
        }
示例#4
0
文件: if.cs 项目: miquik/mkdb
 public InnerTitleBar(wx.Window _parent, int _id, string _title, Point _pos, Size _size, uint _style)
     : base(_parent, _id, _pos, _size, 0)
 {
     style = _style;
     SetSize(this.Width, 12);
     this.EVT_PAINT(new wx.EventListener(OnPaint));
 }
示例#5
0
文件: wdbApp.cs 项目: miquik/mkdb
 public wdbApp(wx.Window _pc, wx.Sizer _ps)
     : base("Project")
 {
     this.ImageIndex = 0;
     this.SelectedImageIndex = 0;
     _elem = new wiwApp(_pc, _ps);
     _elem.InsertWidget();
     this.Text = _elem.Properties.Name;
 }
示例#6
0
 public wdbBoxSizer(wx.Window _pc, wx.Sizer _ps)
     : base("Sizer")
 {
     this.ImageIndex = 10;
     this.SelectedImageIndex = 10;
     _elem = new wiwBoxSizer(_pc, _ps);
     _elem.InsertWidget();
     this.Text = _elem.Properties.Name;
 }
示例#7
0
文件: wdbButton.cs 项目: miquik/mkdb
 public wdbButton(wx.Window _pc, wx.Sizer _ps)
     : base("Button")
 {
     this.ImageIndex = 1;
     this.SelectedImageIndex = 1;
     _elem = new wiwButton(_pc, _ps);
     _elem.InsertWidget();
     this.Text = _elem.Properties.Name;
 }
示例#8
0
文件: wdbListbox.cs 项目: miquik/mkdb
 public wdbListbox(wx.Window _pc, wx.Sizer _ps)
     : base("ListBox")
 {
     this.ImageIndex = 1;
     this.SelectedImageIndex = 1;
     _elem = new wiwListbox(_pc, _ps);
     _elem.InsertWidget();
     this.Text = _elem.Properties.Name;
 }
示例#9
0
文件: wiwButton.cs 项目: miquik/mkdb
 // public wiwButton(wx.Window _pc, wx.Sizer _ps, string _label, Point _pos, Size _sz, uint _style)
 // 	: base(_pc, _label, _pos, _sz, _style)
 public wiwButton(wx.Window _pc, wx.Sizer _ps)
     : base(_pc, "Button", wx.Button.wxDefaultPosition, wx.Button.wxDefaultSize, wx.Button.wxBU_EXACTFIT)
 {
     _props = new wdbButtonProps();
     _btn_cur_index++;
     string name = "Button" + _btn_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
     _p_sizer = _ps;
     _sizer_item = null;
 }
示例#10
0
文件: wiwListbox.cs 项目: miquik/mkdb
 public wiwListBox(wx.Window _pc, wx.Sizer _ps)
     : base(_pc, wx.ListBox.wxDefaultPosition, wx.ListBox.wxDefaultSize, null)
 {
     _props = new wdbListBoxProps();
     _lbox_cur_index++;
     string name = "ListBox" + _lbox_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
     _p_sizer = _ps;
     _sizer_item = null;
 }
示例#11
0
文件: if.cs 项目: miquik/mkdb
 protected void DrawTitleBar(wx.DC dc)
 {
     int margin = 2;
     int height = this.Font.PointSize + 2*margin;
     // title_bar.SetSize(0, 0, this.Width, height);
     // dc.Pen = new wx.Pen(new wx.Colour(0, 0, 255));
     dc.Pen = new wx.Pen(wx.Colour.wxCYAN, 1);
     dc.Brush = new wx.Brush(wx.Colour.wxCYAN, wx.FillStyle.wxNORMAL);
     dc.DrawRectangle(margin, margin, this.Width-margin, height);
     // dc.DrawLine(margin, height/2, this.Width-margin, height/2);
 }
示例#12
0
文件: wiwLabel.cs 项目: miquik/mkdb
 // public wiwButton(wx.Window _pc, wx.Sizer _ps, string _label, Point _pos, Size _sz, uint _style)
 // 	: base(_pc, _label, _pos, _sz, _style)
 public wiwLabel(wx.Window _pc, wx.Sizer _ps)
     : base(_pc, "Label", wx.Button.wxDefaultPosition, wx.Button.wxDefaultSize, wx.Button.wxBU_EXACTFIT)
 {
     _props = new wdbLabelProps();
     _label_cur_index++;
     string name = "Label" + _label_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
     _p_sizer = _ps;
     _sizer_item = null;
 }
示例#13
0
 public wiwCombobox(wx.Window _pc, wx.Sizer _ps)
     : base(_pc, wx.Choice.wxDefaultPosition, wx.Choice.wxDefaultSize, null)
 {
     _props = new wdbComboBoxProps();
     _cmb_cur_index++;
     string name = "ComboBox" + _cmb_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
     _p_sizer = _ps;
     _sizer_item = null;
 }
示例#14
0
 public wiwBoxSizer(wx.Window _pc, wx.Sizer _ps)
     : base(wx.Orientation.wxVERTICAL)
 {
     _props = new wdbBoxSizerProps();
     _frame_cur_index++;
     string name = "BoxSizer" + _frame_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
     _p_container = _pc;
     _p_sizer = _ps;
     _sizer_item = null;
 }
示例#15
0
 public wiwGridSizer(wx.Window _pc, wx.Sizer _ps)
     : base(2, 2, 0, 0)
 {
     _props = new wdbGridSizerProps();
     _grid_cur_index++;
     string name = "GridSizer" + _grid_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
     _p_container = _pc;
     _p_sizer = _ps;
     _sizer_item = null;
 }
示例#16
0
文件: wdbFrame.cs 项目: miquik/mkdb
 public wdbFrame(wx.Window _pc, wx.Sizer _ps)
     : base("Frame")
 {
     this.ImageIndex = 5;
     this.SelectedImageIndex = 5;
     // Create a wxWindow on the top of canvas panel.
     wx.Frame hfrm = new wx.Frame(null, -1, "");
     _elem = new wiwFrame(hfrm);
     _elem.InsertWidget();
     wx.Window win = (wx.Window)_elem;
     Win32Utils.SetParent(win.GetHandle(), Common.Instance().Canvas.Handle);
     wiwFrame wf = (wiwFrame)_elem;
     this.Text = wf.Name;
 }
示例#17
0
 public wiwTextEdit(wx.Window _pc, wx.Sizer _ps)
     : base(1, 2, 0, 0)
 {
     _props = new wdbTextEditProps();
     this.AddGrowableCol(1);
     _sub_label = new wx.StaticText(_pc, -1, "TextEdit");
     _sub_text = new wx.TextCtrl(_pc, -1, "");
     this.Add(_sub_label, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|wx.Direction.wxLEFT, 5);
     this.Add(_sub_text, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|wx.Stretch.wxEXPAND|wx.Direction.wxRIGHT, 5);
     _p_container = _pc;
     _p_sizer = _ps;
     _sizer_item = null;
     _text_cur_index++;
     string name = "TextEdit" + _text_cur_index.ToString();
     SetDefaultProps(name);
     SetWidgetProps();
 }
示例#18
0
文件: if.cs 项目: miquik/mkdb
 public InnerFrame(wx.Window _parent, int _id, string _title, Point _pos, Size _size, uint _style)
     : base(_parent, _id, _pos, _size, wx.Panel.wxRAISED_BORDER | wx.Panel.wxFULL_REPAINT_ON_RESIZE)
 {
     wintitle = _title;
     style = _style;
     //
     title_bar = new InnerTitleBar(this, -1, wx.Panel.wxDefaultPosition, wx.Panel.wxDefaultSize, _style);
     frame_content = new wx.Panel(this, -1, wx.Panel.wxDefaultPosition, wx.Panel.wxDefaultSize, 0);
     //
     wx.BoxSizer sizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
     sizer.Add(title_bar, 0, wx.Stretch.wxGROW | wx.Direction.wxRIGHT, 2);
     wx.BoxSizer horiSizer = new wx.BoxSizer(wx.Orientation.wxHORIZONTAL);
     horiSizer.Add(frame_content, 1, wx.Stretch.wxGROW);
     sizer.Add(horiSizer, 1, wx.Stretch.wxGROW | wx.Direction.wxBOTTOM | wx.Direction.wxRIGHT, 2);
     SetSizer(sizer);
     this.AutoLayout = true;
     Layout();
 }
示例#19
0
        public DetailsFrame(wx.Window parent, string title, string text)
            : base(parent, title)
        {
            textTC = new wx.TextCtrl(this, wx.Window.wxID_ANY, text,
                                     wx.Window.wxDefaultPosition, wx.Window.wxDefaultSize,
                                     wx.WindowStyles.TE_MULTILINE);
            wx.BoxSizer topSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
            {
                wx.BoxSizer boxSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
                {
                    boxSizer.Add(textTC, 1, wx.SizerFlag.wxEXPAND);
                }
                topSizer.Add(boxSizer, 1, wx.SizerFlag.wxEXPAND|wx.SizerFlag.wxALL, 5);
            }
            this.Sizer = topSizer ;
            topSizer.SetSizeHints(this);
            this.Size = new System.Drawing.Size(640, 480);
            this.CenterOnParent();

            EVT_CLOSE(new wx.EventListener(OnClose));
        }
示例#20
0
文件: wiwFrame.cs 项目: miquik/mkdb
        // public wiwFrame(wx.Window _parent, string _title, Point _pos, Size _size, uint _style) :
        // 	base(_parent, wx.Panel.wxID_ANY, new Point(5, 5), new Size(300, 300), wx.Panel.wxRAISED_BORDER | wx.Panel.wxFULL_REPAINT_ON_RESIZE)
        public wiwFrame(wx.Window _parent)
            : base(_parent, -1, new Point(5, 5), new Size(300, 300), wx.Panel.wxRAISED_BORDER | wx.Panel.wxFULL_REPAINT_ON_RESIZE)
        {
            m_sizing = mSizing.NONE;
            m_resizeBorder = 12;
            _real_pos = new Point(0, 0);
            _real_size = new Size(300, 300);
            // this.AutoLayout = true;
            // Layout();
            this.EVT_MOTION(new wx.EventListener(OnMouseMotion));
            this.EVT_LEFT_DOWN(new wx.EventListener(OnLeftDown));
            this.EVT_LEFT_UP(new wx.EventListener(OnLeftUp));
            this.EVT_PAINT(new wx.EventListener(OnPaint));
            this.EVT_SIZE(new wx.EventListener(OnSize));

            _props = new wdbFrameProps();
            _frame_cur_index++;
            string temp_name = "Frame" + _frame_cur_index.ToString();
            SetDefaultProps(temp_name);
            SetWidgetProps();
            InitPyClassFile();
            LoadXmlActions();
        }
示例#21
0
        public SearchFrame(wx.Frame parent, int id, string title, Size size, Point pos, wx.WindowStyles style)
            : base(parent, id, title, pos, size, style)
        {
            this.DoControls ();
            this.DoControlsProperties ();
            this.DoLayout ();

            this.SetSize (new Size (640, 480));

            EVT_MENU ((int)Id.quitFileMenu, new wx.EventListener (OnQuitMenuClick));
            EVT_MENU ((int) Id.aboutHelpMenu, new wx.EventListener(OnAboutMenu));
            EVT_MENU((int) Id.showTermsOptionsMenu, new wx.EventListener(OnShowTermsMenu));
            EVT_MENU((int) Id.showDocumentsOptionsMenu, new wx.EventListener(OnShowDocumentsMenu));
            EVT_BUTTON ((int)Id.termsBtn, new wx.EventListener (OnTermsBtnClick));
            EVT_BUTTON ((int)Id.documentsBtn, new wx.EventListener (OnDocumentsBtnClick));
            EVT_BUTTON((int) Id.searchBtn, new wx.EventListener(OnSearchBtnClick));
            EVT_SIZE(new wx.EventListener(OnSizeChanged));

            tfIdf = new TfIdfCalc(new StandardTextProcessor(new PorterStemmerAlgorithm.Stemmer2()));

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                this.BackgroundColour = wx.SystemSettings.GetColour(wx.SystemColour.wxSYS_COLOUR_BTNFACE);
        }
示例#22
0
文件: MainForm.cs 项目: miquik/mkdb
 void CheckParentForWidget(WidgetTreeNode _c, WidgetTreeNode _s, out wx.Window _rc)
 {
     _rc = null;
     if (_c == null)
     {
         _rc = (wx.Window)_s.Widget.ParentContainer;
     } else
     {
         _rc = (wx.Window)_c.Widget;
     }
 }
示例#23
0
文件: MainForm.cs 项目: miquik/mkdb
 void CheckParentForSizer(WidgetTreeNode _c, WidgetTreeNode _s, out wx.Window _rc, out wx.Sizer _rs)
 {
     _rc = null;
     _rs = null;
     if (_c != null) _rc = (wx.Window)_c.Widget;
     if (_s != null)
     {
         _rs = (wx.Sizer)_s.Widget;
         _rc = _s.Widget.ParentContainer;
     }
 }
示例#24
0
 protected void OnSize(object sender, wx.Event e)
 {
     SetBufferSize(this.Width, this.Height);
     Graphics clientDC = Graphics.FromHwnd(this.GetHandle());
     offScreenDC.FillRectangle(Brushes.Black, 0, 0, this.Width, this.Height);
     DrawTitleBar(offScreenDC);
     clientDC.DrawImage(offScreenBmp, this.Left, this.Top);
     e.Skip();
     /*
     SetBufferSize(this.Width, this.Height);
     Graphics clientDC = Graphics.FromHwnd(this.GetHandle());
     memDC.FillRectangle(Brushes.Black, 0, 0, this.Width, this.Height);
     DrawTitleBar(memDC);
     IntPtr hdc = clientDC.GetHdc();
     IntPtr hMemdc = memDC.GetHdc();
     Win32Utils.BitBlt(hdc, 0, 0, this.Width, this.Height,
         hMemdc, 0, 0, Win32Utils.TernaryRasterOperations.SRCCOPY);
     clientDC.ReleaseHdc(hdc);
     memDC.ReleaseHdc(hMemdc);
     */
 }
示例#25
0
 public wifInnerTitleBar(wx.Window _parent, int _id, string _title, Point _pos, Size _size, uint _style)
     : base(_parent, _id, _pos, _size, 0)
 {
     m_style = _style;
     m_title_text =_title;
     //
     m_col1 = SystemColors.ActiveCaption;
     byte r, g, b;
     r = (byte)Math.Min( 255, m_col1.R + 30 );
     g = (byte)Math.Min( 255, m_col1.G + 30 );
     b = (byte)Math.Min( 255, m_col1.B + 30 );
     m_col2 = Color.FromArgb(255, r, g, b);
     this.MinSize = new Size(100, 20);
     //
     /* .... */
     // Bitmap
     ResourceManager rs = new ResourceManager("mkdb.MainForm", Assembly.GetExecutingAssembly());
     m_close = (Image)rs.GetObject("close");
     m_close_dis = (Image)rs.GetObject("close_disabled");
     m_minimize = (Image)rs.GetObject("minimize");
     m_minimize_dis = (Image)rs.GetObject("minimize_disabled");
     m_maximize = (Image)rs.GetObject("maximize");
     m_maximize_dis = (Image)rs.GetObject("maximize_disabled");
     /* .... */
     this.EVT_PAINT(new wx.EventListener(OnPaint));
     this.EVT_SIZE(new wx.EventListener(OnSize));
     // !!!
     SetBufferSize(this.Width, this.Height);
 }
示例#26
0
 protected void OnSize(object sender, wx.Event e)
 {
     Graphics dc = Graphics.FromHwnd(this.GetHandle());
     dc.FillRectangle(Brushes.Orange, new Rectangle(0, 0, this.Width, this.Height));
 }
示例#27
0
 public wifInnerFrameContent(wx.Window _parent, int _id, Point _pos, Size _size)
     : base(_parent, _id, _pos, _size, 0)
 {
     this.EVT_PAINT(new wx.EventListener(OnPaint));
     this.EVT_SIZE(new wx.EventListener(OnSize));
 }
示例#28
0
 protected void OnUpdateUI(object sender, wx.Event e)
 {
     title_bar.Title = this.Title;
     e.Skip();
     // e.Skip();
 }
示例#29
0
        protected void OnMouseMotion(object sender, wx.Event evt)
        {
            wx.MouseEvent e = (wx.MouseEvent)evt;
            if (m_sizing != mSizing.NONE)
            {
                Graphics dc = Graphics.FromHwnd((IntPtr)m_parent_hwnd);
                Brush _brush = new HatchBrush(HatchStyle.Cross, Color.White, Color.Black);
                // Brush _brush = new SolidBrush(Color.Orange);
                Pen _pen = new Pen(_brush, 2.0f);
                // Point _pos = Parent.ClientToScreen(Position);
                Point _pos = Parent.ClientAreaOrigin;
                dc.Clear(m_parent_back);
                if ( m_curX >= 0 && m_curY >= 0 )
                    dc.DrawRectangle(_pen, _pos.X, _pos.Y, m_curX, m_curY);

                if ( m_sizing == mSizing.RIGHT || m_sizing == mSizing.RIGHTBOTTOM )
                    m_curX = e.Position.X + m_difX;
                else
                    m_curX = this.Size.Width;

                if ( m_sizing == mSizing.BOTTOM || m_sizing == mSizing.RIGHTBOTTOM )
                    m_curY = e.Position.Y + m_difY;
                else
                    m_curY = this.Size.Height;

                // User min size
                Size minSize = this.MinSize;
                if ( m_curX < minSize.Width )	m_curX = minSize.Width;
                if ( m_curY < minSize.Height ) 	m_curY = minSize.Height;

                // Internal min size
                if ( m_curX < m_minSize.Width )		m_curX = m_minSize.Width;
                if ( m_curY < m_minSize.Height ) 	m_curY = m_minSize.Height;

                System.Drawing.Size maxSize = this.MaxSize;
                if ( m_curX > maxSize.Width && maxSize.Width != wx.Panel.wxDefaultCoord ) m_curX = maxSize.Width;
                if ( m_curY > maxSize.Height && maxSize.Height != wx.Panel.wxDefaultCoord ) m_curY = maxSize.Height;

                dc.DrawRectangle(_pen, _pos.X, _pos.Y, m_curX, m_curY);
                // dc.ReleaseHdc();
            }
            else
            {
                int x, y;
                x = this.ClientSize.Width;
                y = this.ClientSize.Height;

                if ( ( e.Position.X >= x - m_resizeBorder && e.Position.Y >= y - m_resizeBorder ) ||
                    ( e.Position.X < m_resizeBorder && e.Position.Y < m_resizeBorder ) )
                {
                    this.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_SIZENWSE);
                }
                else if ( ( e.Position.X < m_resizeBorder && e.Position.Y >= y - m_resizeBorder ) ||
                         ( e.Position.X > x - m_resizeBorder && e.Position.Y < m_resizeBorder ) )
                {
                    this.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_SIZENESW);
                }
                else if ( e.Position.X >= x - m_resizeBorder || e.Position.X < m_resizeBorder )
                {
                    this.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_SIZEWE);
                }
                else if ( e.Position.Y >= y - m_resizeBorder || e.Position.Y < m_resizeBorder )
                {
                    this.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_SIZENS);
                }
                else
                {
                    this.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_ARROW);
                }
                title_bar.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_ARROW);
                frame_content.Cursor = new wx.Cursor(wx.StockCursor.wxCURSOR_ARROW);
            }
        }
示例#30
0
        protected void OnLeftUp(object sender, wx.Event e)
        {
            if ( m_sizing != mSizing.NONE )
            {
                m_sizing = mSizing.NONE;
                ReleaseMouse();
                Graphics dc = Graphics.FromHwnd((IntPtr)m_parent_hwnd);
                dc.Clear(m_parent_back);
                SetSize(0, 0, m_curX, m_curY);
                title_bar.SetSize(0, 0, m_curX - 8, 20);

                /*
                if (m_inner_frame_resized != null)
                {
                    wx.CommandEvent _event = new wx.CommandEvent(wxEVT_INNER_FRAME_RESIZED, this.ID);
                    this.EventHandler.ProcessEvent(_event);
                }
                */
                /*
                wxCommandEvent event( wxEVT_INNER_FRAME_RESIZED, GetId() );
                event.SetEventObject( this );
                GetEventHandler()->ProcessEvent( event );
                */
                m_curX = m_curY = -1;
            }
        }
示例#31
0
        private void button1_Click(object sender, EventArgs e)
        {
            //资产名数组
            zc[] asset = new zc[29];
            //for (int i_ = 0; i_ < 30; i_++)
            //{
            //    asset[i_] = new zc();
            //}
            int             i      = 0;
            string          strcon = ConfigurationManager.ConnectionStrings["strCon"].ConnectionString;
            MySqlConnection conn   = new MySqlConnection(strcon);

            conn.Open();
            MySqlCommand    select      = new MySqlCommand("select assetname from asset", conn);
            MySqlDataReader select_read = select.ExecuteReader();

            while (select_read.Read())
            {
                asset[i].assetname = select_read["assetname"].ToString();
                i += 1;
            }
            conn.Close();

            //威胁列表数组

            /*link[] link = new link[18];
             * for(int i_=0;i_<18;i_++)
             * {
             *  link[i_] = new link();
             * }*/

            wx[] menace = new wx[16];
            for (int i_ = 0; i_ < 16; i_++)
            {
                menace[i_] = new wx();
            }
            string[] _menacename = new string[16] {
                "操作错误", "滥用授权", "特权升级", "行为抵赖",
                "拒绝服务", "恶意代码", "篡改", "社会工程", "垃圾邮件", "窃听数据", "物理破坏", "网络仿冒",
                "意外故障", "通信中断", "电源中断", "灾难"
            };

            for (i = 0; i < 16; i++)
            {
                menace[i].menacename = _menacename[i];
                //link[i].menacename = _menacename[i];
            }

            //脆弱性列表数组
            vulnerability_dou[] vulnerablity = new vulnerability_dou[16];
            for (int i_ = 0; i_ < 16; i_++)
            {
                vulnerablity[i_] = new vulnerability_dou();
            }
            vulnerablity[0].vulnerabilityname  = "存在弱口令"; vulnerablity[0].dou = 4;
            vulnerablity[1].vulnerabilityname  = "权限分配不明晰"; vulnerablity[1].dou = 3;
            vulnerablity[2].vulnerabilityname  = "设备质量不过关"; vulnerablity[2].dou = 2;
            vulnerablity[3].vulnerabilityname  = "没及时更新病毒库"; vulnerablity[3].dou = 3;
            vulnerablity[4].vulnerabilityname  = "对硬件的保护疏忽"; vulnerablity[4].dou = 2;
            vulnerablity[5].vulnerabilityname  = "没有坚固的防御机制"; vulnerablity[5].dou = 4;
            vulnerablity[6].vulnerabilityname  = "没有专业的安全专家"; vulnerablity[6].dou = 3;
            vulnerablity[7].vulnerabilityname  = "信息审查过程不严密"; vulnerablity[7].dou = 4;
            vulnerablity[8].vulnerabilityname  = "系统和软件配置不当"; vulnerablity[8].dou = 2;
            vulnerablity[9].vulnerabilityname  = "安全管理机制不合理"; vulnerablity[9].dou = 3;
            vulnerablity[10].vulnerabilityname = "没有数据备份等补救措施"; vulnerablity[10].dou = 3;
            vulnerablity[11].vulnerabilityname = "没有灵敏的应急响应机制"; vulnerablity[11].dou = 3;
            vulnerablity[12].vulnerabilityname = "使用的通信加密方式落后"; vulnerablity[12].dou = 3;
            vulnerablity[13].vulnerabilityname = "无日志文件或日志不完整"; vulnerablity[13].dou = 2;
            vulnerablity[14].vulnerabilityname = "开启过多无谓的端口和服务"; vulnerablity[14].dou = 3;
            vulnerablity[15].vulnerabilityname = "系统没有及时更新或修补漏洞"; vulnerablity[15].dou = 4;

            /*威胁对应脆弱性列表
             * link[0].value[0] = 1; link[0].value[1] = 1;
             * link[1].value[0] = 1; link[1].value[1] = 1;
             * link[2].value[0] = 1; link[2].value[1] = 1;
             * link[3].value[0] = 1; link[3].value[1] = 1;
             * link[4].value[0] = 1; link[4].value[1] = 1;
             * link[5].value[0] = 1; link[5].value[1] = 1;
             * link[6].value[0] = 1; link[6].value[1] = 1;
             * link[7].value[0] = 1; link[7].value[1] = 1;
             * link[8].value[0] = 1; link[8].value[1] = 1;
             * link[9].value[0] = 1; link[9].value[1] = 1;
             * link[10].value[0] = 1; link[10].value[1] = 1;
             * link[11].value[0] = 1; link[11].value[1] = 1;
             * link[12].value[0] = 1; link[12].value[1] = 1;
             * link[13].value[0] = 1; link[13].value[1] = 1;
             * link[14].value[0] = 1; link[14].value[1] = 1;
             * link[15].value[0] = 1; link[15].value[1] = 1;
             * link[16].value[0] = 1; link[16].value[1] = 1;
             * link[17].value[0] = 1; link[17].value[1] = 1;*/

            //每一项脆弱性的漏洞数目总和
            int[] sum = new int[16] {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            //二维数组保存若干个资产和脆弱性构成的漏洞总数对该脆弱性漏洞总和的比例,即第i个资产的第j个脆弱性有x个漏洞,它占比为x/sum
            double[,] temp = new double[16, 16];
            double[] dou_num = new double[16];
            //临时参数,保存资产名及脆弱性名,方便传入数据库语句编写
            string[] assetname_temp         = new string[29];
            string[] vulnerabilityname_temp = new string[16];

            conn.Open();
            //循环脆弱性列表
            int j = 0;

            for (i = 0; i < vulnerablity.Length; i++)
            {
                //临时变量用于循环,flag的值用于写入判断
                j = 0;
                int i_ = 0;

                Boolean         Flag1       = false;
                MySqlCommand    select1     = new MySqlCommand("select assetname,vulnerability_name,weight_num from vulnerability where vulnerability_name='" + vulnerablity[i].vulnerabilityname + "'", conn);
                MySqlDataReader datareader1 = select1.ExecuteReader();
                //从数据库中提取该脆弱性的所有项
                while (datareader1.Read())
                {
                    //循环累加到sum(漏洞总数)
                    sum[i] += Convert.ToInt16(datareader1["weight_num"]);
                    Flag1   = true;
                }
                datareader1.Close();

                //若存在该脆弱性的项,开始计算脆弱性占比及脆弱因子
                if (Flag1 == true)
                {
                    MySqlCommand    select2     = new MySqlCommand("select assetname,vulnerability_name,weight_num from vulnerability where vulnerability_name='" + vulnerablity[i].vulnerabilityname + "'", conn);
                    MySqlDataReader datareader2 = select2.ExecuteReader();
                    while (datareader2.Read())
                    {
                        //double转换为实数
                        temp[i, j]                = (double)Convert.ToInt16(datareader2["weight_num"]) / sum[i];
                        temp[i, j]                = Math.Round(temp[i, j], 2);
                        dou_num[j]                = temp[i, j] * vulnerablity[i].dou;
                        dou_num[j]                = Math.Round(dou_num[j], 2);
                        assetname_temp[j]         = datareader2["assetname"].ToString();
                        vulnerabilityname_temp[j] = datareader2["vulnerability_name"].ToString();
                        //j为一个临时累加器
                        j += 1;
                    }
                    datareader2.Close();
                    for (i_ = 0; i_ < j; ++i_)
                    {
                        //更新表中的漏洞占比及弱点因子dou_num[i_]
                        string       cmd    = "update vulnerability set coefficient=" + temp[i, i_] + ",vf=" + dou_num[i_] + " where assetname='" + assetname_temp[i_] + "' and vulnerability_name='" + vulnerabilityname_temp[i_] + "'";
                        MySqlCommand update = new MySqlCommand(cmd, conn);
                        update.ExecuteNonQuery();
                    }
                }
            }
            conn.Close();

            //临时参数,保存资产名及脆弱性名及威胁名,方便传入数据库语句编写
            zc[] asset_temp = new zc[29];
            wx[,] menace_temp = new wx[29, 16];

            for (int i_ = 0; i_ < 29; i_++)
            {
                for (int j__ = 0; j__ < 16; j__++)
                {
                    menace_temp[i_, j__] = new wx();
                }
            }

            crx[] crx_temp = new crx[29];

            //读取资产放入asset_temp类
            conn.Open();
            Boolean Flag = true;

            while (Flag == true)
            {
                j = 0;
                string          cmd        = "select assetname,assetvalue from asset where assetvalue>0";
                MySqlCommand    select1    = new MySqlCommand(cmd, conn);
                MySqlDataReader asset_read = select1.ExecuteReader();
                while (asset_read.Read())
                {
                    asset_temp[j].assetname  = asset_read["assetname"].ToString();
                    asset_temp[j].assetvalue = Convert.ToDouble(asset_read["assetvalue"]);
                    j++;
                }
                Flag = false;
                asset_read.Close();
            }

            int[] j_ = new int[j];
            for (i = 0; i < j; i++)
            {
                j_[i] = 0;
            }
            //读取某资产的威胁放入menace_temp类
            for (i = 0; i < j; i++)
            {
                string          cmd         = "select assetname,menacename,threat from menace where assetname='" + asset_temp[i].assetname + "'";
                MySqlCommand    select1     = new MySqlCommand(cmd, conn);
                MySqlDataReader menace_read = select1.ExecuteReader();
                while (menace_read.Read())
                {
                    menace_temp[i, j_[i]].menacename  = menace_read["menacename"].ToString();
                    menace_temp[i, j_[i]].menacescore = Convert.ToDouble(menace_read["threat"]);
                    j_[i]++;
                }
                menace_read.Close();
            }

            //读取所有脆弱性放入crx
            i = 0;
            string          cmd1               = "select assetname,vulnerability_name,vf from vulnerability";
            MySqlCommand    select3            = new MySqlCommand(cmd1, conn);
            MySqlDataReader vulnerability_read = select3.ExecuteReader();

            while (vulnerability_read.Read())
            {
                crx_temp[i].assetname          = vulnerability_read["assetname"].ToString();
                crx_temp[i].vulnerability_name = vulnerability_read["vulnerability_name"].ToString();
                crx_temp[i].vf = Convert.ToDouble(vulnerability_read["vf"]);
                i++;
            }
            vulnerability_read.Close();

            //ia,ib为循环变量
            //fxzmz=风险值名字,fxz=风险值,zhfxz=综合风险值,fxzz=风险总值
            //j为实际资产数量,j_[i]为实际威胁数
            int ia = 0;
            int ib = 0;
            int ic = 0;

            string[][][] fxzmz = new string[asset_temp.Length][][];
            string[,] fxdj  = new string[j, 16];
            double[,,] fxz  = new double[j, 16, 16];
            double[,] zhfxz = new double[j, 16];
            double[] fxzz = new double[asset_temp.Length];
            for (int aaa = 0; aaa < asset_temp.Length; aaa++)
            {
                fxzz[aaa] = 0;
            }


            double[,] vf = new double[29, 16];
            int[] flag = new int[16];
            for (ia = 0; ia < 16; ia++)
            {
                flag[ia] = 0;
            }
            string          cmd2                = "select assetname,vulnerability_name,vf from vulnerability";
            MySqlCommand    select4             = new MySqlCommand(cmd2, conn);
            MySqlDataReader vulnerability_read1 = select4.ExecuteReader();

            //威胁对应脆弱性关系
            while (vulnerability_read1.Read())
            {
                if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[0].vulnerabilityname)
                {
                    vf[flag[0], 0] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[0]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[1].vulnerabilityname)
                {
                    vf[flag[1], 1] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[1]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[2].vulnerabilityname)
                {
                    vf[flag[2], 2] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[2]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[3].vulnerabilityname)
                {
                    vf[flag[3], 3] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[3]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[4].vulnerabilityname)
                {
                    vf[flag[4], 4] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[4]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[5].vulnerabilityname)
                {
                    vf[flag[5], 5] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[5]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[6].vulnerabilityname)
                {
                    vf[flag[6], 6] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[6]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[7].vulnerabilityname)
                {
                    vf[flag[7], 7] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[7]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[8].vulnerabilityname)
                {
                    vf[flag[8], 8] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[8]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[9].vulnerabilityname)
                {
                    vf[flag[9], 9] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[9]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[10].vulnerabilityname)
                {
                    vf[flag[10], 10] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[10]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[11].vulnerabilityname)
                {
                    vf[flag[11], 11] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[11]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[12].vulnerabilityname)
                {
                    vf[flag[12], 12] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[12]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[13].vulnerabilityname)
                {
                    vf[flag[13], 13] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[13]++;
                }
                else if (vulnerability_read1["vulnerability_name"].ToString() == vulnerablity[14].vulnerabilityname)
                {
                    vf[flag[14], 14] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[14]++;
                }
                else
                {
                    vf[flag[15], 15] = Convert.ToDouble(vulnerability_read1["vf"]);
                    flag[15]++;
                }
            }
            vulnerability_read1.Close();


            for (ia = 0; ia < j; ia++)
            {
                double zcjz = asset_temp[ia].assetvalue;
                for (ib = 0; ib < j_[ia]; ib++)
                {
                    double wxyz = menace_temp[ia, ib].menacescore;
                    for (ic = 0; ic < i; ic++)
                    {
                        if (asset_temp[ia].assetname == crx_temp[ic].assetname)
                        {
                            fxz[ia, ib, ic] = zcjz * wxyz * crx_temp[ic].vf;
                            zhfxz[ia, ib]   = Math.Max(fxz[ia, ib, ic], zhfxz[ia, ib]);
                        }
                    }

                    if (zhfxz[ia, ib] > 20)
                    {
                        fxdj[ia, ib] = "极高";
                    }
                    else if (zhfxz[ia, ib] > 15 && zhfxz[ia, ib] < 20)
                    {
                        fxdj[ia, ib] = "高";
                    }
                    else if (zhfxz[ia, ib] > 10 && zhfxz[ia, ib] < 15)
                    {
                        fxdj[ia, ib] = "中";
                    }
                    else if (zhfxz[ia, ib] > 5 && zhfxz[ia, ib] < 10)
                    {
                        fxdj[ia, ib] = "低";
                    }
                    else
                    {
                        fxdj[ia, ib] = "极低";
                    }
                }
            }



            Label[] asname = new Label[j + 1];
            asname[0]          = new Label();
            asname[0].Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
            asname[0].AutoSize = true;
            asname[0].Location = new Point(label1.Location.X, label1.Location.Y + 30);
            asname[0].Text     = asset_temp[0].assetname;
            Controls.Add(asname[0]);

            Label[] asvalue = new Label[j + 1];
            asvalue[0]          = new Label();
            asvalue[0].Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
            asvalue[0].AutoSize = true;
            asvalue[0].Location = new Point(label5.Location.X, label5.Location.Y + 30);
            asvalue[0].Text     = asset_temp[0].assetvalue.ToString("f2");;
            //Controls.Add(asvalue[0]);

            for (ia = 0; ia < j; ia++)
            {
                asname[ia + 1]          = new Label();
                asname[ia + 1].Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
                asname[ia + 1].AutoSize = true;
                asname[ia + 1].Location = new Point(label1.Location.X, asname[ia].Location.Y + 30 * j_[ia]);;
                asname[ia + 1].Text     = asset_temp[ia + 1].assetname;
                Controls.Add(asname[ia + 1]);

                asvalue[ia + 1]          = new Label();
                asvalue[ia + 1].Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
                asvalue[ia + 1].AutoSize = true;
                asvalue[ia + 1].Location = new Point(label5.Location.X, asname[ia].Location.Y + 30 * j_[ia]);
                asvalue[ia + 1].Text     = asset_temp[ia + 1].assetvalue.ToString("f2");;
                Controls.Add(asvalue[ia]);

                for (ib = 0; ib < j_[ia]; ib++)
                {
                    int   a      = asname[ia].Location.Y + 30 * ib;
                    Label mename = new Label();
                    mename.Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
                    mename.AutoSize = true;
                    mename.Location = new Point(label2.Location.X, a);
                    mename.Text     = menace_temp[ia, ib].menacename;
                    Controls.Add(mename);

                    Label mevalue = new Label();
                    mevalue.Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
                    mevalue.AutoSize = true;
                    mevalue.Location = new Point(label6.Location.X, a);
                    mevalue.Text     = menace_temp[ia, ib].menacescore.ToString("f2");
                    Controls.Add(mevalue);

                    Label zhfxzlabel = new Label();
                    zhfxzlabel.Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);
                    zhfxzlabel.AutoSize = true;
                    zhfxzlabel.Location = new Point(label3.Location.X, a);
                    zhfxzlabel.Text     = zhfxz[ia, ib].ToString("f2");
                    Controls.Add(zhfxzlabel);

                    Label fxdjlabel = new Label();
                    fxdjlabel.Font     = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular);;
                    fxdjlabel.AutoSize = true;
                    fxdjlabel.Location = new Point(label4.Location.X, a);
                    fxdjlabel.Text     = fxdj[ia, ib].ToString();
                    Controls.Add(fxdjlabel);
                }
            }
        }