Exemplo n.º 1
0
        void DrawArea(Graphics g, Brush brush, Brush textBrush, Pen pen, _Rect r, string text, string header = null, bool selected = false)
        {
            var rf = ToRectangle(r);

            if (brush != null)
            {
                g.FillRectangle(brush, rf);
            }

            if (header != null)
            {
                var sz = g.MeasureString(header, Styles.HeaderFont);
                g.FillRectangle(Brushes.White, new Rectangle((int)r.Left, (int)(r.Top - sz.Height), (int)sz.Width, (int)sz.Height));
                g.DrawString(header, Styles.HeaderFont, textBrush, new Point((int)r.Left, (int)(r.Top - sz.Height)));
            }

            if (text != null)
            {
                var sz = g.MeasureString(text, Styles.TextFont);
                g.DrawString(text, Styles.TextFont, textBrush, new Point((int)(r.Left + 0.5 * (r.Width - sz.Width)), (int)(r.Top + 0.5 * (r.Height - sz.Height))));
            }

            if (pen != null)
            {
                g.DrawRectangle(pen, rf);

                if (selected)
                {
                    g.DrawRectangle(pen, rf.Left - 3, rf.Top - 3, 6, 6);
                    g.DrawRectangle(pen, rf.Right - 3, rf.Top - 3, 6, 6);
                    g.DrawRectangle(pen, rf.Left - 3, rf.Bottom - 3, 6, 6);
                    g.DrawRectangle(pen, rf.Right - 3, rf.Bottom - 3, 6, 6);
                }
            }
        }
Exemplo n.º 2
0
        private void PieOnMouseMove(object sender, MouseEventArgs e)
        {
            var ht  = FlexPie.HitTest(e.Location);
            var par = new _Rect(center.X - radius, center.Y - radius, 2 * radius, 2 * radius);
            var el  = ht.ChartElement;

            if (par.Contains(e.X, e.Y))
            {
                el = ChartElement.PlotArea;
            }
            HoverElement = el;
        }
Exemplo n.º 3
0
        public override void Update(double x1, double y1, double x2, double y2)
        {
            var e     = (AEllipse)Annotation;
            var r     = new _Rect(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x2 - x1), Math.Abs(y2 - y1));
            var start = new PointF((float)r.Left, (float)r.Top);
            var end   = new PointF((float)r.Right, (float)r.Bottom);

            start    = _layer.Chart.PointToData(start);
            end      = _layer.Chart.PointToData(end);
            e.Width  = 2 * r.Width;
            e.Height = 2 * r.Height;
        }
Exemplo n.º 4
0
        public override void Update(double x1, double y1, double x2, double y2)
        {
            var p     = (APolygon)Annotation;
            var r     = new _Rect(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x2 - x1), Math.Abs(y2 - y1));
            var start = new PointF((float)r.Left, (float)r.Top);
            var end   = new PointF((float)r.Right, (float)r.Bottom);

            start               = _layer.Chart.PointToData(start);
            end                 = _layer.Chart.PointToData(end);
            p.Points[0]         = start;
            p.Points[1]         = new PointF(end.X, start.Y);
            p.Points[2]         = end;
            p.Points[3]         = new PointF(start.X, end.Y);
            p.Style.StrokeColor = Color.DarkGray;
            p.Style.FillColor   = Color.FromArgb(64, Color.DarkGray);
        }
Exemplo n.º 5
0
        private static int GetEdge(_Rect rc)
        {
            int uEdge;

            if (rc.top == rc.left && rc.bottom > rc.right)
            {
                uEdge = (int)_ABEdge.ABE_LEFT;
            }
            else if (rc.top == rc.left && rc.bottom < rc.right)
            {
                uEdge = (int)_ABEdge.ABE_TOP;
            }
            else if (rc.top > rc.left)
            {
                uEdge = (int)_ABEdge.ABE_BOTTOM;
            }
            else
            {
                uEdge = (int)_ABEdge.ABE_RIGHT;
            }
            return(uEdge);
        }
Exemplo n.º 6
0
        private void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            _MinMaxInfo mmi = (_MinMaxInfo)Marshal.PtrToStructure(lParam, typeof(_MinMaxInfo));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            int MONITOR_DEFAULTTONEAREST = 0x00000002;

            System.IntPtr monitor = UnsafeNativeMethods.MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != System.IntPtr.Zero)
            {
                _MonitorInfo monitorInfo = new _MonitorInfo();
                UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);
                _Rect rcWorkArea    = monitorInfo.rcWork;
                _Rect rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);

                var metroWindow   = AssociatedObject as MetroWindow;
                var ignoreTaskBar = metroWindow != null && (metroWindow.IgnoreTaskbarOnMaximize);
                var x             = ignoreTaskBar ? monitorInfo.rcMonitor.left : monitorInfo.rcWork.left;
                var y             = ignoreTaskBar ? monitorInfo.rcMonitor.top : monitorInfo.rcWork.top;
                mmi.ptMaxSize.X = ignoreTaskBar ? Math.Abs(monitorInfo.rcMonitor.right - x) : Math.Abs(monitorInfo.rcWork.right - x);
                mmi.ptMaxSize.Y = ignoreTaskBar ? Math.Abs(monitorInfo.rcMonitor.bottom - y) : Math.Abs(monitorInfo.rcWork.bottom - y);

                // only do this on maximize
                if (!ignoreTaskBar && AssociatedObject.WindowState == WindowState.Maximized)
                {
                    mmi.ptMaxTrackSize.X = mmi.ptMaxSize.X;
                    mmi.ptMaxTrackSize.Y = mmi.ptMaxSize.Y;
                    mmi = AdjustWorkingAreaForAutoHide(monitor, mmi);
                }
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Exemplo n.º 7
0
 public Rectangle ToRectangle(_Rect r)
 {
     return(new Rectangle((int)r.Left, (int)r.Top, (int)r.Width, (int)r.Height));
 }
Exemplo n.º 8
0
        void Draw(Graphics g)
        {
            var fc = FlexChart;

            var axr = new _Rect();
            var ayr = new _Rect();
            var par = new _Rect();

            if (fc != null)
            {
                axr = ((IChart)fc).AxisX.Rect;
                ayr = ((IChart)fc).AxisY.Rect;
                par = ((IChart)fc).GetPlotRect();
            }
            else
            {
                if (FlexPie != null)
                {
                    par = new _Rect(center.X - radius, center.Y - radius, 2 * radius, 2 * radius);
                }
            }

            if (HoverElement == ChartElement.AxisX)
            {
                DrawArea(g, Styles.HoverFill, Styles.HoverText, Styles.HoverPen, axr, null, "X-Axis");
            }
            else if (HoverElement == ChartElement.AxisY)
            {
                if (hoverAxis == fc.AxisY)
                {
                    DrawArea(g, Styles.HoverFill, Styles.HoverText, Styles.HoverPen, ayr, null, "Y-Axis");
                }
                else
                {
                    DrawArea(g, Styles.HoverFill, Styles.HoverText, Styles.HoverPen, ((IAxis)hoverAxis).Rect, null, "Y-Axis");
                }
            }
            else if (HoverElement == ChartElement.PlotArea)
            {
                DrawArea(g, Styles.HoverFill, Styles.HoverText, Styles.HoverPen, par, null, "Plot Area");
            }
            else if (HoverElement == ChartElement.Legend)
            {
                DrawArea(g, Styles.HoverFill, Styles.HoverText, Styles.HoverPen, GetLegendRect(), null, "Legend");
            }

            if (SelectedElement == ChartElement.AxisX)
            {
                DrawArea(g, null, null, Styles.SelectionPen, axr, null, null, true);
            }
            else if (SelectedElement == ChartElement.AxisY)
            {
                DrawArea(g, null, null, Styles.SelectionPen, selectedAxis == fc.AxisY ? ayr : ((IAxis)selectedAxis).Rect, null, null, true);
            }
            else if (SelectedElement == ChartElement.PlotArea)
            {
                DrawArea(g, null, null, Styles.SelectionPen, par, null, null, true);
            }
            else if (SelectedElement == ChartElement.Legend)
            {
                DrawArea(g, null, null, Styles.SelectionPen, GetLegendRect(), null, null, true);
            }
            else if (SelectedElement == ChartElement.Header)
            {
                DrawArea(g, null, null, Styles.SelectionPen, chart.Header.GetRect(), null, null, true);
            }
            else if (SelectedElement == ChartElement.Footer)
            {
                DrawArea(g, null, null, Styles.SelectionPen, chart.Footer.GetRect(), null, null, true);
            }
        }
Exemplo n.º 9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            #region SRP

            Employee emp = new Employee();
            emp.FirstName = "Ali";
            emp.AddToDB(emp);

            _Employee emp1 = new _Employee();
            emp1.FirstName = "Deneme";

            EmployeeManager manager = new EmployeeManager(emp1);
            manager.Insert();

            EmployeeManager manager2 = new EmployeeManager(new MessageService(), emp1);
            manager2.SendMessage("Test");

            #endregion

            #region OCP

            OCPClient manager1 = new OCPClient(new NormalTicket());
            manager1.Sale(100);

            OCPClient manager3 = new OCPClient(new StudentTicket());
            manager3.Sale(100);

            #endregion

            #region LSP

            #region BadPractice

            Shape  s  = new Square(5, 10);
            double d1 = s.GetArea();

            Shape  s1 = new Rect(3, 5);
            double d2 = s1.GetArea();


            #endregion

            #region BestPractice


            AbstractShape s3 = new _Square(3);
            s3.GetArea();

            AbstractShape s4 = new _Rect(3, 5);
            s4.GetArea();

            AbstractShape s5 = new _Circle(5);

            MessageBox.Show(s5.Diagonal.ToString());


            #endregion

            #endregion

            //Interface Segregation Principle
            #region ISP

            #region BadPractice

            JuniorDeveloper j = new JuniorDeveloper();
            j.UseSolid();

            SeniorDeveloper ss = new SeniorDeveloper();
            ss.UseSolid();

            #endregion

            #region BestPractice

            JDeveloper j1 = new JDeveloper();
            j1.UseOOP();


            SDeveloper s3 = new SDeveloper();
            s3.UseOOP();
            s3.UseSolid();


            #endregion

            #endregion

            #region DIP

            #region BadPractice

            IOService service = new IOService(new DBIO());
            service.Write("asdasda", "asddsa");

            #endregion

            //read işlemleri için

            _IOService _service = new _IOService(new _ExcelIO());
            _service.Read("asdsad", "ssadasd");
            _service.Write("adsdas", "asdasd");

            _IOService _service2 = new _IOService(new _TextIO());
            _service2.Read("asdasd", "asdasd");
            _service2.Write("asdasd", "asdsad");

            _IOService _service3 = new _IOService(new _DBIO());
            _service3.Read("sadasd", "asdasd");



            #endregion
        }