示例#1
0
        public void SaveSettings(string showFilePath, BitmapSource source, DisplayMatrix displayMatrix)
        {
            ShowSettings showSettings = this.Models.FirstOrDefault(m => m.GetType() == typeof(ShowSettings)) as ShowSettings;

            this.Models.RemoveAll(m => m.GetType() == typeof(ShowSettings));

            if (showSettings == null)
            {
                showSettings = new ShowSettings();
            }

            showSettings.PrimaryDisplayMatrix = displayMatrix;
            showSettings.ShowPath             = showFilePath;

            string imagePath = showFilePath + ".png";

            using (var stream = new FileStream(imagePath, FileMode.Create))
            {
                PngBitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(source));
                encoder.Save(stream);
            }

            showSettings.ImagePath = imagePath;
            this.Models.Insert(0, showSettings);
        }
        private void SetPointFlag(RectangleF rect)
        {
            Matrix matrix = DisplayMatrix.Clone();

            if (!matrix.IsInvertible)
            {
                return;
            }
            matrix.Invert();

            PointF[] fs = new PointF[] { rect.Location, new PointF(rect.Right, rect.Bottom) };
            matrix.TransformPoints(fs);
            PointLayout.PixelToPointMatrix.TransformPoints(fs);
            RectangleF rectangle = RectangleF.FromLTRB(Math.Min(fs[0].X, fs[1].X), Math.Min(fs[0].Y, fs[1].Y),
                                                       Math.Max(fs[0].X, fs[1].X), Math.Max(fs[0].Y, fs[1].Y));

            foreach (LayoutPoint point in PointLayout.Points)
            {
                if (rectangle.Contains((int)Math.Round(point.Point.X), (int)Math.Round(point.Point.Y)))
                {
                    point.Selected = true;
                }
                else
                {
                    point.Selected = false;
                }
            }
        }
        private void SetPointFlag(PointF pixel, float distance)
        {
            Matrix matrix = DisplayMatrix.Clone();

            if (!matrix.IsInvertible)
            {
                return;
            }
            matrix.Invert();

            PointF[] fs = new PointF[] { pixel };
            matrix.TransformPoints(fs);
            PointLayout.PixelToPointMatrix.TransformPoints(fs);


            foreach (LayoutPoint point in PointLayout.Points)
            {
                point.Selected = false;
            }

            foreach (LayoutPoint point in PointLayout.Points)
            {
                if (Math.Sqrt(Math.Pow(fs[0].X - point.Point.X, 2) + Math.Pow(fs[0].Y - point.Point.Y, 2)) < distance)
                {
                    point.Selected = true;
                    break;
                }
            }
        }
示例#4
0
        void zoomCanvas_ObjectDoubleTap(object sender, ObjectSelectedEventArgs e)
        {
            if (this.isLocked)
            {
                ShowView      view   = e.AffectedObject;
                Rect          bounds = view.Bounds;
                DisplayMatrix data   = view.Model.DisplayMatrix;

                double margin       = 0.95;
                double scaleFactorX = margin * zoomCanvas.ActualWidth / (view.ActualWidth * data.Scale.X);
                double scaleFactorY = margin * zoomCanvas.ActualHeight / (view.ActualHeight * data.Scale.Y);
                double scaleFactor  = Math.Min(scaleFactorX, scaleFactorY);
                Vector scale        = new Vector(scaleFactor, scaleFactor);

                DisplayMatrix newTransform = new DisplayMatrix();
                newTransform.Center      = zoomCanvas.CurrentView.Center;
                newTransform.Orientation = zoomCanvas.CurrentView.Orientation;
                newTransform.Scale       = scale;

                Point p1 = newTransform.TransformMatrix.Transform(data.Center);

                Vector offset = new Vector(zoomCanvas.ActualWidth / 2, zoomCanvas.ActualHeight / 2);
                Vector p2     = offset - new Vector(p1.X, p1.Y);

                Point center = zoomCanvas.CurrentView.Center + p2;

                ZoomViewTo(center, 0, scale);
            }
            else
            {
                showContext.SendToFront(e.AffectedObject.Model);
            }
        }
示例#5
0
        public ShowModel()
        {
            Color        = Colors.White;
            DefaultColor = Colors.White;
            FontSize     = 24;
            CanRotate    = false;

            IsGhost  = false;
            IsLocked = true;

            AssociatedTagValue = null;

            DisplayMatrixMode      = ShowModelDisplayMatrixMode.Primary;
            PrimaryDisplayMatrix   = new DisplayMatrix();
            SecondaryDisplayMatrix = new DisplayMatrix();
        }
示例#6
0
        public ZoomCanvas()
        {
            this.IsRotateEnabled       = false;
            this.ZoomCenter            = ZoomCenterMode.ManipulationCentered;
            this.LayoutUpdated        += new EventHandler(ZoomCanvas_LayoutUpdated);
            this.RenderTransformOrigin = new Point(0.5, 0.5);

            CurrentView              = new DisplayMatrix();
            CurrentView.ViewChanged += CurrentView_ViewChanged;
            CurrentView.Center       = new Point(0, 0);

            doubleTapTimer.Interval = TimeSpan.FromMilliseconds(1000);
            doubleTapTimer.Tick    += new EventHandler(doubleTapTimer_Tick);

            updateTimer          = new DispatcherTimer();
            updateTimer.Interval = TimeSpan.FromMilliseconds(15);
            updateTimer.Tick    += new EventHandler(updateTimer_Tick);
            updateTimer.Start();
        }
示例#7
0
        public void FlyTo(Rect rect, double newOrientation, TimeSpan delta)
        {
            StopFlyTo();
            Rect          currentRect = DisplayMatrix.MatrixToBounds(this.ZoomMatrix, this.RenderSize);
            DisplayMatrix temp        = DisplayMatrix.BoundsToMatrix(rect, this.RenderSize);

            Point newCenter = (rect.TopLeft + new Vector(rect.Width / 2, rect.Height / 2));

            newCenter = new Point(-newCenter.X, -newCenter.Y);
            double scaleX = currentRect.Size.Width / rect.Size.Width;
            double scaleY = currentRect.Size.Height / rect.Size.Height;

            Vector newScale = this.ZoomMatrix.Scale * Math.Min(scaleX, scaleY);

            newScale = new Vector(1 / temp.Scale.X, 1 / temp.Scale.Y);
            AnimateUtility.AnimateElementPoint(this.ZoomMatrix, DisplayMatrix.CenterProperty, newCenter, 0, delta.TotalSeconds);
            AnimateUtility.AnimateElementVector(this.ZoomMatrix, DisplayMatrix.ScaleProperty, newScale, 0, delta.TotalSeconds);
            AnimateUtility.AnimateElementDouble(this.ZoomMatrix, DisplayMatrix.OrientationProperty, newOrientation, 0, delta.TotalSeconds);
        }
示例#8
0
        public async Task <ResponseModel> Postdata()
        {
            string AEMEmployeeID; string Model; string Category; string SalesDate; string SecurityCode;

            AEMEmployeeID = Model = Category = SalesDate = SecurityCode = string.Empty;

            bool          dataFlag       = true;
            DisplayMatrix _DisplayMatrix = new DisplayMatrix();

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }
            try
            {
                var provider = await Request.Content.ReadAsMultipartAsync <InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider());

                //access form data
                NameValueCollection formData = provider.FormData;

                foreach (var key in provider.FormData.AllKeys)
                {
                    string k = key;
                    foreach (var val in provider.FormData.GetValues(key))
                    {
                        // Trace.WriteLine(string.Format("{0}: {1}", key, val));
                        switch (key)
                        {
                        case "SalesDate":
                            SalesDate = val;
                            break;

                        case "Category":
                            Category = val;
                            break;

                        case "Model":
                            Model = val;
                            break;

                        case "AEMEmployeeID":
                            AEMEmployeeID = val;
                            break;

                        case "SecurityCode":
                            SecurityCode = val;
                            break;
                        }
                    }
                }

                if (AEMEmployeeID == "" || AEMEmployeeID == string.Empty)
                {
                    dataFlag = false;
                }
                #region feedback saving
                if (dataFlag)
                {
                    object[] data = new object[5];
                    data[0] = SalesDate;
                    data[1] = Category;
                    data[2] = Model;
                    data[3] = AEMEmployeeID;
                    data[4] = Convert.ToInt32(DBOperation.Insert);

                    DataSet dsResult = new DataSet();
                    int     retValue = 0;
                    if (SecurityCode.Contains("IFB"))
                    {
                        retValue = _conn.ExecutionMethod("IFBDISPLAYMATRIXCRUDWITHMODELUSINGAPP", ref data, DBOperation.ViewAll, ref dsResult);
                    }
                    else if (SecurityCode.Contains("GCL"))
                    {
                        retValue = _TsmConn.ExecutionMethod("IFBDISPLAYMATRIXCRUDWITHMODELUSINGAPP", ref data, DBOperation.ViewAll, ref dsResult);
                    }

                    //if (SecurityCode == IFB)

                    //    else if (SecurityCode == GCL)
                    //        retValue = _TsmConn.ExecutionMethod("IFBDISPLAYMATRIXCRUDWITHMODELUSINGAPP", ref data, DBOperation.ViewAll, ref dsResult);

                    dataFlag = retValue == 0 ? true : false;
                }
                #endregion
                _objResponseModel.responseData   = "";
                _objResponseModel.responseStatus = dataFlag;
                _objResponseModel.responseCode   = dataFlag == true ? "1" : "0";
                _objResponseModel.responseText   = dataFlag == true ? "Your details updated" : "Sorry! data not saved.";

                return(_objResponseModel);
            }
            catch (System.Exception e)
            {
                dataFlag = false;
                _objResponseModel.responseData   = "";
                _objResponseModel.responseStatus = dataFlag;
                _objResponseModel.responseCode   = dataFlag == true ? "1" : "0";
                _objResponseModel.responseText   = e.ToString();

                return(_objResponseModel);
            }
        }
示例#9
0
        void DrawScreen()
        {
            if (DisplayMode == DISP_MATRIX)
            {
                int maxCellLength = 0;
                for (int y = 0; y < DisplayMatrix.MatrixHeight; y++)
                {
                    for (int x = 0; x < DisplayMatrix.MatrixWidth; x++)
                    {
                        if (maxCellLength < DisplayMatrix.GetCell(y, x).ToString().Length)
                        {
                            maxCellLength = DisplayMatrix.GetCell(y, x).ToString().Length;
                        }
                    }
                }

                maxCellLength++; // because we need spacing

                if (WindowWidth - 6 < maxCellLength * DisplayMatrix.MatrixWidth)
                {
                    maxCellLength = (WindowWidth - 8) / DisplayMatrix.MatrixWidth;
                }

                if (maxCellLength < 2 || DisplayMatrix.MatrixHeight >= (WindowHeight - 4))
                {
                    SetAlert("Error", "Matrix too big to display", 2);
                }
            }

            ResetScreen();

            // draw title bars and window borders
            for (int x = 0; x < WindowWidth; x++)
            {
                ScreenBackground[x, 0] = AlertEnabled ? (int)ConsoleColor.DarkCyan : (int)ConsoleColor.Cyan;
                ScreenForeground[x, 0] = (int)ConsoleColor.Black;
                Screen[x, 0]           = '-';
                ScreenBackground[x, WindowHeight - 2] = AlertEnabled ? (int)ConsoleColor.DarkCyan : (int)ConsoleColor.Cyan;
                ScreenForeground[x, WindowHeight - 2] = (int)ConsoleColor.Black;
                Screen[x, WindowHeight - 2]           = '-';
                ScreenBackground[x, WindowHeight - 1] = (int)ConsoleColor.Green;
                ScreenForeground[x, WindowHeight - 1] = (int)ConsoleColor.Black;
                Screen[x, WindowHeight - 1]           = '-';
            }
            for (int y = 0; y < WindowHeight - 1; y++)
            {
                ScreenBackground[0, y] = AlertEnabled ? (int)ConsoleColor.DarkCyan : (int)ConsoleColor.Cyan;
                ScreenForeground[0, y] = (int)ConsoleColor.Black;
                Screen[0, y]           = '|';
                ScreenBackground[WindowWidth - 1, y] = AlertEnabled ? (int)ConsoleColor.DarkCyan : (int)ConsoleColor.Cyan;
                ScreenForeground[WindowWidth - 1, y] = (int)ConsoleColor.Black;
                Screen[WindowWidth - 1, y]           = '|';
            }

            WriteCentered(" " + MainTitleText + " ", 0);
            WriteUpperLeft(" " + PromptText + " ", 1, WindowHeight - 1);

            // draw content
            if (DisplayMode == DISP_TEXT)
            {
                WriteUpperLeft(MainText, 2, 2);
            }
            else if (DisplayMode == DISP_MENU)
            {
                int y    = 2;
                int jump = (WindowHeight - 5) / MenuOptions.Count();
                foreach (var opt in MenuOptions)
                {
                    ScreenForeground[3, y] = (int)ConsoleColor.Black;
                    ScreenForeground[4, y] = (int)ConsoleColor.Black;
                    ScreenBackground[3, y] = AlertEnabled ? (int)ConsoleColor.DarkYellow : (int)ConsoleColor.Yellow;
                    ScreenBackground[4, y] = AlertEnabled ? (int)ConsoleColor.DarkYellow : (int)ConsoleColor.Yellow;
                    Screen[3, y]           = opt.Key;
                    Screen[4, y]           = '.';
                    WriteUpperLeft(opt.Value, 7, y);
                    y += jump;
                }
            }
            else if (DisplayMode == DISP_MATRIX)
            {
                int sign = 0, dec = 0, exp = 0;
                int maxCellLength = 0;
                for (int y = 0; y < DisplayMatrix.MatrixHeight; y++)
                {
                    for (int x = 0; x < DisplayMatrix.MatrixWidth; x++)
                    {
                        if (maxCellLength < DisplayMatrix.GetCell(y, x).ToString().Length)
                        {
                            maxCellLength = DisplayMatrix.GetCell(y, x).ToString().Length;
                        }
                    }
                }

                maxCellLength += 1;

                if (WindowWidth - 6 < maxCellLength * DisplayMatrix.MatrixWidth)
                {
                    maxCellLength = (WindowWidth - 8) / DisplayMatrix.MatrixWidth;
                }

                if (maxCellLength < 2 || DisplayMatrix.MatrixHeight < (WindowHeight - 4))
                {
                    // draw augment separator
                    if (DisplayMatrix.border > 0)
                    {
                        for (int y = 0; y < DisplayMatrix.MatrixHeight; y++)
                        {
                            Screen[3 + maxCellLength * DisplayMatrix.border, y + 2] = '|';
                        }
                    }

                    // draw left bracket
                    Screen[2, 2] = '/';
                    for (int y = 0; y < (DisplayMatrix.MatrixHeight - 2); y++)
                    {
                        Screen[2, y + 3] = '|';
                    }
                    Screen[2, DisplayMatrix.MatrixHeight + 1] = '\\';

                    // draw contents
                    double toDraw;
                    for (int y = 0; y < DisplayMatrix.MatrixHeight; y++)
                    {
                        for (int x = 0; x < DisplayMatrix.MatrixWidth; x++)
                        {
                            toDraw = DisplayMatrix.GetCell(y, x);
                            if (toDraw.ToString().Contains("-"))
                            {
                                sign = 2;
                            }
                            else
                            {
                                sign = 0;
                            }
                            if (toDraw.ToString().Contains("."))
                            {
                                dec = 1;
                            }
                            else
                            {
                                dec = 0;
                            }
                            if (toDraw.ToString().Contains("E"))
                            {
                                exp = 1;
                            }
                            else
                            {
                                exp = 0;
                            }
                            WriteRightAlign(DisplayMatrix.GetCell(y, x).ToString("G" + (maxCellLength - (dec + sign + exp))), 4 + maxCellLength * x, y + 2, maxCellLength - 1);
                        }
                    }

                    // draw right bracket
                    Screen[4 + (DisplayMatrix.MatrixWidth) * maxCellLength, 2] = '\\';
                    for (int y = 0; y < (DisplayMatrix.MatrixHeight - 2); y++)
                    {
                        Screen[4 + DisplayMatrix.MatrixWidth * maxCellLength, y + 3] = '|';
                    }
                    Screen[4 + DisplayMatrix.MatrixWidth * maxCellLength, DisplayMatrix.MatrixHeight + 1] = '/';

                    // draw highlights
                    if (MatrixRowHighlight >= 0)
                    {
                        for (int x = 1; x < WindowWidth - 1; x++)
                        {
                            ScreenBackground[x, MatrixRowHighlight + 2] = AlertEnabled ? (int)ConsoleColor.DarkBlue : (int)ConsoleColor.Blue;
                        }
                    }
                    if (MatrixColumnHighlight >= 0)
                    {
                        for (int y = 1; y < WindowHeight - 2; y++)
                        {
                            for (int x = maxCellLength * MatrixColumnHighlight + 4; x < maxCellLength * (MatrixColumnHighlight + 1) + 4; x++)
                            {
                                ScreenBackground[x, y] = AlertEnabled ? (int)ConsoleColor.DarkBlue : (int)ConsoleColor.Blue;
                            }
                        }
                    }
                    if (MatrixRowHighlight >= 0 && MatrixColumnHighlight >= 0)
                    {
                        for (int x = maxCellLength * MatrixColumnHighlight + 4; x < maxCellLength * (MatrixColumnHighlight + 1) + 4; x++)
                        {
                            ScreenBackground[x, MatrixRowHighlight + 2] = AlertEnabled ? (int)ConsoleColor.Gray : (int)ConsoleColor.White;
                            ScreenForeground[x, MatrixRowHighlight + 2] = (int)ConsoleColor.Black;
                        }
                    }
                }
            }

            if (AlertEnabled)
            {
                DrawAlert();
            }
        }
示例#10
0
 private Rect GetBounds()
 {
     return(DisplayMatrix.MatrixToBounds(this.Model.DisplayMatrix, this.RenderSize));
 }