public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
                                  object value, Type destinationType)
 {
     if (destinationType == typeof(string) && value is StiBorderSide)
     {
         if (value == null)
         {
             return("null");
         }
         else
         {
             StiBorderSide side = value as StiBorderSide;
             if (side.side == StiBorderSides.Top)
             {
                 return("(" + StiLocalization.Get("PropertyMain", "TopSide") + ")");
             }
             if (side.side == StiBorderSides.Bottom)
             {
                 return("(" + StiLocalization.Get("PropertyMain", "BottomSide") + ")");
             }
             if (side.side == StiBorderSides.Left)
             {
                 return("(" + StiLocalization.Get("PropertyMain", "LeftSide") + ")");
             }
             if (side.side == StiBorderSides.Right)
             {
                 return("(" + StiLocalization.Get("PropertyMain", "RightSide") + ")");
             }
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
        protected override void Localize()
        {
            this.headerControl.Title = StiLocalization.Get("NavigatorRT", "PageCreateNewReport");

            AutomationProperties.SetName(buttonSave, StiLocalization.Get("NavigatorRT", "SaveReport"));
            labelRequiredFields.Text = StiLocalization.Get("NavigatorRT", "RequiredFields");
            label1.Text                   = StiLocalization.Get("NavigatorRT", "AddCustomReportLabel1");
            labelStep1.Text               = StiLocalization.Get("NavigatorRT", "AddCustomReportStep1");
            labelCategory.Text            = StiLocalization.Get("NavigatorRT", "Category");
            radioCurrentCategory.Content  = StiLocalization.Get("NavigatorRT", "AddCustomReportCurrentCategory");
            radioNewCategory.Content      = StiLocalization.Get("NavigatorRT", "AddCustomReportCreateNewCategory");
            labelCategoryDescription.Text = StiLocalization.Get("NavigatorRT", "AddCustomReportCategoryDesc");
            labelStep2.Text               = StiLocalization.Get("NavigatorRT", "AddCustomReportStep2");
            labelReport.Text              = StiLocalization.Get("Components", "StiReport");
            labelReportName.Text          = StiLocalization.Get("NavigatorRT", "ReportName");
            labelReportDescription.Text   = StiLocalization.Get("PropertyMain", "ReportDescription");
            labelDataName.Text            = StiLocalization.Get("NavigatorRT", "AddCustomReportDataName");
            labelStep3.Text               = StiLocalization.Get("NavigatorRT", "AddCustomReportStep3");
            radioCurrentReport.Content    = StiLocalization.Get("NavigatorRT", "AddCustomReportUseCurrentReport");
            radioNewDocument.Content      = StiLocalization.Get("NavigatorRT", "AddCustomReportNewDocument");
            radioNewReport.Content        = StiLocalization.Get("NavigatorRT", "AddCustomReportNewReport");
            labelLoadDocument.Text        = StiLocalization.Get("NavigatorRT", "AddCustomReportLoadDocument");
            buttonLoadDocument.Content    = StiLocalization.Get("NavigatorRT", "LoadDocument");
            labelNewReport.Text           = StiLocalization.Get("NavigatorRT", "AddCustomReportLabelNewReport");
            buttonLoadReport.Content      = StiLocalization.Get("NavigatorRT", "LoadReport");
            buttonLoadData.Content        = StiLocalization.Get("NavigatorRT", "LoadData");
        }
 private void Localize()
 {
     tbWeb.Text    = StiLocalization.Get("FormColorBoxPopup", "Web");
     tbSystem.Text = StiLocalization.Get("FormColorBoxPopup", "System");
     tbCustom.Text = StiLocalization.Get("FormColorBoxPopup", "Custom");
     btOther.Text  = StiLocalization.Get("FormColorBoxPopup", "Others");
 }
Exemplo n.º 4
0
        async private void btPreview_Click(object sender, RoutedEventArgs e)
        {
            viewerCotnrol.ShowProgressBar(StiLocalization.Get("DesignerFx", "LoadingReport"));

            StiReport report = viewerCotnrol.Report;

            if (report == null)
            {
                return;
            }

            viewerCotnrol.Report = null;

            //Set Variables
            report["Name"]    = tbName.Text;
            report["Surname"] = tbSurname.Text;
            report["Email"]   = tbEmail.Text;
            report["Address"] = tbAddress.Text;
            report["Sex"]     = rbMale.IsChecked.Value;

            await report.RenderAsync();

            viewerCotnrol.Report = report;

            viewerCotnrol.HideProgressBar();
        }
Exemplo n.º 5
0
        public override StiDataParameter AddParameter()
        {
            var parameter = new StiDataParameter(
                StiLocalization.Get("PropertyMain", "Parameter"), string.Empty, (int)NpgsqlTypes.NpgsqlDbType.Varchar, 0);

            Parameters.Add(parameter);
            return(parameter);
        }
        protected override void Localize()
        {
            this.headerControl.Title = StiLocalization.Get("NavigatorRT", "PageCategoryReports");

            AutomationProperties.SetName(buttonPinReport, StiLocalization.Get("NavigatorRT", "Pin"));
            AutomationProperties.SetName(buttonAddReport, StiLocalization.Get("NavigatorRT", "AddReports"));
            AutomationProperties.SetName(buttonRemove, StiLocalization.Get("NavigatorRT", "RemoveReport"));
        }
        public static int GetWidthOfHatchStyle(Graphics g, Font font, int index)
        {
            HatchStyle hatchStyle = StiBrushes.HatchStyles[index];
            string     str        = StiLocalization.Get("PropertyHatchStyle", hatchStyle.ToString());

            int strWidth = (int)g.MeasureString(str, font).Width;

            return(strWidth + 40);
        }
Exemplo n.º 8
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
                                  object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         HatchStyle hatchStyle = (HatchStyle)value;
         return(StiLocalization.Get("PropertyHatchStyle", hatchStyle.ToString()));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Exemplo n.º 9
0
        protected override void Localize()
        {
            this.headerControl.Title = StiLocalization.Get("NavigatorRT", "PageCategoryReports");

            AutomationProperties.SetName(buttonUserReports, StiLocalization.Get("NavigatorRT", "CustomReports"));
            AutomationProperties.SetName(buttonAddReport, StiLocalization.Get("NavigatorRT", "AddReports"));
            AutomationProperties.SetName(buttonDeleteCategory, StiLocalization.Get("NavigatorRT", "DeleteCategory"));

            labelReportsNotFound.Text = StiLocalization.Get("NavigatorRT", "ReportsNotFound");
        }
Exemplo n.º 10
0
        private void Localize()
        {
            if (demoButtonLabel == null)
            {
                return;
            }

            demoButtonLabel.Text = StiLocalization.Get("NavigatorRT", "ReportsDemo");
            demoButtonLabel.Text = StiLocalization.Get("NavigatorRT", "AddCustomReports");
            groupDemo.Header     = StiLocalization.Get("NavigatorRT", "Demo");
        }
Exemplo n.º 11
0
        async private void BlankPage_Loaded(object sender, RoutedEventArgs e)
        {
            viewerCotnrol.ShowProgressBar(StiLocalization.Get("DesignerFx", "LoadingReport"));

            byte[]    buffer = Convert.FromBase64String(reportStr);
            StiReport report = new StiReport();
            await report.LoadAsync(buffer);

            await report.RenderAsync();

            viewerCotnrol.Report = report;

            viewerCotnrol.HideProgressBar();
        }
Exemplo n.º 12
0
        private async void ButtonUserReportsClick(object sender, RoutedEventArgs e)
        {
            if (NavigatorReportsType == ReportsType.Demo)
            {
                NavigatorReportsType = ReportsType.Custom;
                AutomationProperties.SetName(buttonUserReports, StiLocalization.Get("NavigatorRT", "CustomReports"));
            }
            else
            {
                NavigatorReportsType = ReportsType.Demo;
                AutomationProperties.SetName(buttonUserReports, StiLocalization.Get("NavigatorRT", "DemoReports"));
            }

            await FillDataAsync();
        }
        private void DrawItem(bool web, object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index != -1)
            {
                Color  color     = Color.Empty;
                string colorName = null;

                if (web)
                {
                    color     = StiColors.Colors[e.Index];
                    colorName = StiLocalization.Get("PropertyColor", color.Name);
                }
                else
                {
                    color     = StiColors.SystemColors[e.Index];
                    colorName = StiLocalization.Get("PropertySystemColors", color.Name);
                }

                var g    = e.Graphics;
                var rect = e.Bounds;
                if ((e.State & DrawItemState.Selected) > 0)
                {
                    rect.Width--;
                }

                var colorRect = new Rectangle(rect.X + 2, rect.Y + 2, 22, rect.Height - 5);
                var textRect  = new Rectangle(colorRect.Right + 2, rect.Y, rect.Width - colorRect.X, rect.Height);

                StiControlPaint.DrawItem(g, rect, e.State, SystemColors.Window, SystemColors.ControlText);

                using (var brush = new SolidBrush(color))
                {
                    g.FillRectangle(brush, colorRect);
                }
                g.DrawRectangle(Pens.Black, colorRect);

                using (var sf = new StringFormat())
                {
                    if (this.RightToLeft == RightToLeft.Yes)
                    {
                        sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                    }

                    g.DrawString(colorName, Font, Brushes.Black, textRect, sf);
                }
            }
        }
Exemplo n.º 14
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
                                         object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                if (value == null)
                {
                    return("null");
                }
                else
                {
                    StiCap cap = value as StiCap;
                    return(StiLocalization.Get("PropertyEnum", typeof(StiCapStyle).Name + Enum.GetName(typeof(StiCapStyle), cap.Style), false));
                }
            }

            if (destinationType == typeof(InstanceDescriptor) && value != null)
            {
                #region StiCap
                StiCap cap = (StiCap)value;


                Type[] types = new Type[] {
                    typeof(int),
                    typeof(StiCapStyle),
                    typeof(int),
                    typeof(bool),
                    typeof(Color)
                };

                ConstructorInfo info = typeof(StiCap).GetConstructor(types);
                if (info != null)
                {
                    object[] objs = new object[]        {
                        cap.Width,
                        cap.Style,
                        cap.Height,
                        cap.Fill,
                        cap.Color
                    };

                    return(CreateNewInstanceDescriptor(info, objs));
                }
                #endregion
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
        public override string TestConnection(string connectionString)
        {
            try
            {
                using (var sqlConnection = new NpgsqlConnection(connectionString))
                {
                    sqlConnection.Open();
                    sqlConnection.Close();

                    return(StiLocalization.Get("DesignerFx", "ConnectionSuccessfull"));
                }
            }
            catch (Exception e)
            {
                return($"{StiLocalization.Get("DesignerFx", "ConnectionError")}: {e.Message}");
            }
        }
Exemplo n.º 16
0
        private async void buttonLoadReport_Click(object sender, RoutedEventArgs e)
        {
            viewerCotnrol.ShowProgressBar(StiLocalization.Get("DesignerFx", "LoadingReport"));

            if (listBoxReports.SelectedIndex != -1)
            {
                string fileName = null;
                switch (listBoxReports.SelectedIndex)
                {
                case 0:
                    fileName = "StimulsoftResources\\Sample\\SimpleList.mrt";
                    break;

                case 1:
                    fileName = "StimulsoftResources\\Sample\\MultiColumnList.mrt";
                    break;

                case 2:
                    fileName = "StimulsoftResources\\Sample\\MasterDetail.mrt";
                    break;

                case 3:
                    fileName = "StimulsoftResources\\Sample\\TwoMastersOnOneDetail.mrt";
                    break;
                }

                if (fileName != null)
                {
                    StorageFile storage = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileName);

                    var report = new StiReport();
                    await report.LoadAsync(storage);

                    report.RegBusinessObject("Data", "Data", new Data());
                    await report.RenderAsync();

                    viewerCotnrol.Report = report;
                }
            }
            else
            {
                await StiMessageBox.ShowAsync("Report is not selected!", "Error", StiMessageBoxButton.Ok);
            }

            viewerCotnrol.HideProgressBar();
        }
Exemplo n.º 17
0
        public static int GetMaxWidthOfCapStyles(Graphics g, Font font)
        {
            Array obj = Enum.GetValues(typeof(StiCapStyle));

            int maxWidth = 0;

            for (int k = 0; k < obj.Length; k++)
            {
                object capStyle = obj.GetValue(k);
                string locName  = StiLocalization.Get("PropertyEnum", typeof(StiCapStyle).Name + Enum.GetName(typeof(StiCapStyle), capStyle), false);

                int strWidth = (int)g.MeasureString(locName, font).Width;

                maxWidth = Math.Max(maxWidth, strWidth);
            }
            return(maxWidth + 60);
        }
Exemplo n.º 18
0
        async private void btPreview_Click(object sender, RoutedEventArgs e)
        {
            viewerCotnrol.ShowProgressBar(StiLocalization.Get("DesignerFx", "LoadingReport"));

            StiReport report = viewerCotnrol.Report;

            if (report != null)
            {
                viewerCotnrol.Report = null;

                ((StiText)report.Pages["Page1"].Components["Text1"]).Text.Value = textBox1.Text;
                await report.RenderAsync();

                viewerCotnrol.Report = report;
            }

            viewerCotnrol.HideProgressBar();
        }
        public static void DrawHatchStyle(DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                var g    = e.Graphics;
                var rect = e.Bounds;
                if ((e.State & DrawItemState.Selected) > 0)
                {
                    rect.Width--;
                }
                var hatchRect = new Rectangle(rect.X + 2, rect.Y + 2, 19, rect.Height - 5);

                #region Fill
                StiControlPaint.DrawItem(g, rect, e.State, SystemColors.Window, SystemColors.ControlText);
                #endregion

                using (var brush = new HatchBrush(StiBrushes.HatchStyles[e.Index], Color.Black, Color.White))
                {
                    g.FillRectangle(brush, hatchRect);
                }

                g.DrawRectangle(Pens.Black, hatchRect);

                #region Paint name
                using (var font = new Font("Arial", 8))
                {
                    using (var stringFormat = new StringFormat())
                    {
                        stringFormat.LineAlignment = StringAlignment.Center;
                        stringFormat.FormatFlags   = StringFormatFlags.NoWrap;
                        stringFormat.Trimming      = StringTrimming.EllipsisCharacter;

                        var    hatchStyle = StiBrushes.HatchStyles[e.Index];
                        string name       = StiLocalization.Get("PropertyHatchStyle", hatchStyle.ToString());

                        e.Graphics.DrawString(name,
                                              font, Brushes.Black,
                                              new Rectangle(25, rect.Top, rect.Width - 18, 16),
                                              stringFormat);
                    }
                }
                #endregion
            }
        }
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
                                  object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         Color  color     = (Color)value;
         string colorName = null;
         if (color.IsSystemColor)
         {
             colorName = StiLocalization.Get("PropertySystemColors", color.Name, false);
             if (colorName == null)
             {
                 return(color.Name);
             }
         }
         else if (color.IsKnownColor)
         {
             colorName = StiLocalization.Get("PropertyColor", color.Name);
         }
         else
         {
             if (color.A == 255)
             {
                 return
                     (color.R.ToString() + "," +
                      color.G.ToString() + "," +
                      color.B.ToString());
             }
             else
             {
                 return
                     (color.A.ToString() + "," +
                      color.R.ToString() + "," +
                      color.G.ToString() + "," +
                      color.B.ToString());
             }
         }
         return(colorName);
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
        private void UpdateSecondaryTile(string tileId)
        {
            var exists = SecondaryTile.Exists(tileId);

            if (exists == secondaryTileExits)
            {
                return;
            }

            if (exists)
            {
                buttonPinReport.Content = "";
                AutomationProperties.SetName(buttonPinReport, StiLocalization.Get("NavigatorRT", "Unpin"));
            }
            else
            {
                buttonPinReport.Content = "";
                AutomationProperties.SetName(buttonPinReport, StiLocalization.Get("NavigatorRT", "Pin"));
            }

            secondaryTileExits = exists;
        }
Exemplo n.º 22
0
        public static int GetMaxWidthOfPenStyles(Graphics g, Font font)
        {
            Array obj = Enum.GetValues(typeof(StiPenStyle));

            int maxWidth = 0;

            for (int k = 0; k < obj.Length; k++)
            {
                string str     = ((StiPenStyle)obj.GetValue(k)).ToString();
                string locName = StiLocalization.Get("PropertyEnum", "StiPenStyle" + str);

                if (locName != null)
                {
                    str = locName;
                }

                int strWidth = (int)g.MeasureString(str, font).Width;

                maxWidth = Math.Max(maxWidth, strWidth);
            }
            return(maxWidth + 60);
        }
Exemplo n.º 23
0
        protected override void OnPaint(PaintEventArgs p)
        {
            base.OnPaint(p);

            Graphics g = p.Graphics;

            Rectangle colorRect = Rectangle.Empty;
            Rectangle textRect  = Rectangle.Empty;

            Rectangle buttonRect  = StiControlPaint.GetButtonRect(this.ClientRectangle, true, RightToLeft);
            Rectangle contentRect = StiControlPaint.GetContentRect(this.ClientRectangle, true, RightToLeft);
            Rectangle rect        = new Rectangle(0, 0, Width - 1, Height - 1);

            if (showColorBox)
            {
                if (showColorName)
                {
                    colorRect = new Rectangle(rect.X + 4, rect.Y + 4, 22, Height - 9);
                    if (RightToLeft == RightToLeft.Yes)
                    {
                        colorRect.X = rect.Width - colorRect.Width - 4;
                    }
                }
                else
                {
                    colorRect = new Rectangle(rect.X + 4, rect.Y + 4,
                                              Width - buttonRect.Width - 10, Height - 9);

                    if (RightToLeft == RightToLeft.Yes)
                    {
                        colorRect.X = rect.Width - colorRect.Width - 4;
                    }
                }
            }

            if (showColorName)
            {
                if (showColorBox)
                {
                    textRect = new Rectangle(colorRect.Right + 2, 1,
                                             Width - colorRect.Width - buttonRect.Width - 4, Height - 2);

                    if (RightToLeft == RightToLeft.Yes)
                    {
                        textRect.X = contentRect.X - 4;
                    }
                }
                else
                {
                    textRect = new Rectangle(2, 1, Width - buttonRect.Width - 2, Height - 2);
                    if (RightToLeft == RightToLeft.Yes)
                    {
                        textRect.X = contentRect.X - 4;
                    }
                }
            }

            #region Paint focus
            if (this.Focused)
            {
                Rectangle focusRect = GetContentRect();
                focusRect.X -= 1;
                focusRect.Y += 1;
                focusRect.Width--;
                focusRect.Height -= 2;
                ControlPaint.DrawFocusRectangle(g, focusRect);
            }
            #endregion

            #region Paint color
            if (showColorBox)
            {
                using (var brush = new SolidBrush(SelectedColor))
                    g.FillRectangle(brush, colorRect);
                if (this.Enabled)
                {
                    g.DrawRectangle(Pens.Black, colorRect);
                }
                else
                {
                    g.DrawRectangle(SystemPens.ControlDark, colorRect);
                }
            }
            #endregion

            #region Paint color name
            if (showColorName)
            {
                using (var sf = new StringFormat())
                {
                    sf.LineAlignment = StringAlignment.Center;
                    sf.FormatFlags   = StringFormatFlags.NoWrap;

                    if (this.RightToLeft == RightToLeft.Yes)
                    {
                        sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                    }

                    string colorName = null;
                    if (SelectedColor.IsSystemColor)
                    {
                        colorName = StiLocalization.Get("PropertySystemColors", SelectedColor.Name);
                    }
                    else if (SelectedColor.IsKnownColor)
                    {
                        colorName = StiLocalization.Get("PropertyColor", SelectedColor.Name);
                    }
                    else
                    {
                        colorName =
                            StiLocalization.Get("FormColorBoxPopup", "Color") +
                            "[A=" + SelectedColor.A.ToString() +
                            ", R=" + SelectedColor.R.ToString() +
                            ", G=" + SelectedColor.G.ToString() +
                            ", B=" + SelectedColor.B.ToString() + "]";
                    }

                    if (this.Enabled)
                    {
                        using (var brush = new SolidBrush(this.ForeColor))
                        {
                            g.DrawString(colorName, Font, brush, textRect, sf);
                        }
                    }
                    else
                    {
                        g.DrawString(colorName, Font, SystemBrushes.ControlDark, textRect, sf);
                    }
                }
            }
            #endregion
        }
Exemplo n.º 24
0
        protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (viewerControl == null)
            {
                viewerControl = new StiViewerControl();

                #region Add Button

                if (viewerControl.ToolbarPanel != null)
                {
                    var stackPanel = new StackPanel
                    {
                        Orientation = Orientation.Horizontal,
                        Margin      = new Thickness(8, 0, 8, 0)
                    };

                    var demoButton = new RibbonButton
                    {
                        VerticalAlignment = VerticalAlignment.Center,
                        MinWidth          = 75,
                        Height            = 92,
                        Content           = CreateButtonContent(ref demoButtonLabel, StiLocalization.Get("NavigatorRT", "ReportsDemo"), "ms-appx:///Images/Home.png")
                    };
                    demoButton.Click += DemoButtonClick;

                    var addReportButton = new RibbonButton
                    {
                        VerticalAlignment = VerticalAlignment.Center,
                        MinWidth          = 75,
                        Height            = 92,
                        Content           = CreateButtonContent(ref demoButtonLabel, StiLocalization.Get("NavigatorRT", "AddCustomReports"), "ms-appx:///Images/AddCustomReport.png")
                    };
                    addReportButton.Click += AddReportButtonClick;

                    stackPanel.Children.Add(demoButton);
                    stackPanel.Children.Add(addReportButton);

                    groupDemo = new RibbonGroup
                    {
                        Header  = StiLocalization.Get("NavigatorRT", "Demo"),
                        Content = stackPanel
                    };

                    viewerControl.ToolbarPanel.Children.Insert(0, groupDemo);
                }

                #endregion
            }
            else
            {
                if (viewerControl.Parent != null)
                {
                    ((Grid)viewerControl.Parent).Children.Remove(viewerControl);
                }
            }

            var currentReport = e.Parameter as StiReport;
            gridRoot.Children.Add(viewerControl);
            viewerControl.Report = currentReport;

            StiLocalization.LocalizationChanged += ThisLocalizationChanged;
        }
Exemplo n.º 25
0
        public static void DrawCapStyle(DrawItemEventArgs e)
        {
            Graphics  g          = e.Graphics;
            Rectangle rect       = e.Bounds;
            Rectangle borderRect = new Rectangle(rect.X + 2, rect.Y + 2, 52, 14);

            #region Fill
            rect.Width--;
            StiControlPaint.DrawItem(g, rect, e.State, SystemColors.Window, SystemColors.ControlText);
            #endregion

            #region Paint border style
            Array obj = Enum.GetValues(typeof(StiCapStyle));

            using (Pen pen = new Pen(Color.DimGray, 1))
            {
                StiCapStyle capStyle = StiCapStyle.None;
                if (e.Index != -1)
                {
                    capStyle = (StiCapStyle)obj.GetValue(e.Index);
                }

                g.FillRectangle(Brushes.White, borderRect);

                int           yCenter = borderRect.Top + borderRect.Height / 2;
                int           xStep   = borderRect.Width / 4;
                PointF[]      points  = null;
                SmoothingMode mode    = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.AntiAlias;
                switch (capStyle)
                {
                    #region None
                case StiCapStyle.None:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    break;
                    #endregion

                    #region Arrow
                case StiCapStyle.Arrow:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    Rectangle capArrowRECT = new Rectangle(borderRect.Right - xStep - 4, borderRect.Y + 2, 5, 11);
                    g.SmoothingMode = mode;
                    points          = new PointF[] { new PointF(capArrowRECT.Right, capArrowRECT.Y + (float)(capArrowRECT.Height / 2)),
                                                     new PointF(capArrowRECT.Left, capArrowRECT.Y),
                                                     new PointF(capArrowRECT.Left, capArrowRECT.Bottom) };
                    using (Brush capBrush = new SolidBrush(Color.DimGray))
                    {
                        g.FillPolygon(capBrush, points);
                    }
                    break;
                    #endregion

                    #region Open
                case StiCapStyle.Open:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    Rectangle capOpenRECT = new Rectangle(borderRect.Right - xStep - 4, borderRect.Y + 4, 5, 7);
                    points = new PointF[] { new PointF(capOpenRECT.X, capOpenRECT.Y),
                                            new PointF(capOpenRECT.Right, capOpenRECT.Y + (float)(capOpenRECT.Height / 2)),
                                            new PointF(capOpenRECT.X, capOpenRECT.Bottom) };
                    using (Pen openPen = new Pen(Color.DimGray))
                    {
                        g.DrawLines(openPen, points);
                    }
                    break;
                    #endregion

                    #region Stealth
                case StiCapStyle.Stealth:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    Rectangle capStealthRECT = new Rectangle(borderRect.Right - xStep - 9, borderRect.Y + 2, 10, 11);
                    points = new PointF[] { new PointF(capStealthRECT.X, capStealthRECT.Y),
                                            new PointF(capStealthRECT.Right, capStealthRECT.Y + (float)(capStealthRECT.Height / 2)),
                                            new PointF(capStealthRECT.X, capStealthRECT.Bottom),
                                            new PointF(capStealthRECT.X + (float)(capStealthRECT.Width / 3), capStealthRECT.Y + (float)(capStealthRECT.Height / 2)),
                                            new PointF(capStealthRECT.X, capStealthRECT.Y) };
                    using (Brush capBrush = new SolidBrush(Color.DimGray))
                    {
                        g.FillPolygon(capBrush, points);
                    }
                    break;
                    #endregion

                    #region Diamond
                case StiCapStyle.Diamond:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    Rectangle capDiamondRECT = new Rectangle(borderRect.Right - xStep - 6, borderRect.Y + 3, 8, 9);
                    points = new PointF[] { new PointF(capDiamondRECT.X, capDiamondRECT.Y + (float)(capDiamondRECT.Height / 2)),
                                            new PointF(capDiamondRECT.X + (float)(capDiamondRECT.Width / 2), capDiamondRECT.Y),
                                            new PointF(capDiamondRECT.Right, capDiamondRECT.Y + (float)(capDiamondRECT.Height / 2)),
                                            new PointF(capDiamondRECT.X + (float)(capDiamondRECT.Width / 2), capDiamondRECT.Bottom) };
                    using (Brush diamondBrush = new SolidBrush(Color.DimGray))
                    {
                        g.FillPolygon(diamondBrush, points);
                    }
                    break;
                    #endregion

                    #region Oval
                case StiCapStyle.Oval:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    Rectangle capOvalRECT = new Rectangle(borderRect.Right - xStep - 4, borderRect.Y + 4, 6, 6);
                    using (Brush ovalBrush = new SolidBrush(Color.DimGray))
                    {
                        g.FillEllipse(ovalBrush, capOvalRECT);
                    }
                    break;
                    #endregion

                    #region Square
                case StiCapStyle.Square:
                    g.DrawLine(pen, borderRect.X + xStep, yCenter, borderRect.Right - xStep, yCenter);
                    Rectangle capSquareRECT = new Rectangle(borderRect.Right - xStep - 4, borderRect.Y + 4, 6, 6);
                    g.SmoothingMode = mode;
                    using (Brush squareBrush = new SolidBrush(Color.DimGray))
                    {
                        g.FillRectangle(squareBrush, capSquareRECT);
                    }
                    break;
                    #endregion
                }
                g.SmoothingMode = mode;
            }

            g.DrawRectangle(Pens.Black, borderRect);
            #endregion

            #region Paint name
            using (Font font = new Font("Arial", 8))
            {
                using (StringFormat stringFormat = new StringFormat())
                {
                    stringFormat.LineAlignment = StringAlignment.Center;

                    object capStyle = obj.GetValue(e.Index);
                    string locName  = StiLocalization.Get("PropertyEnum", typeof(StiCapStyle).Name + Enum.GetName(typeof(StiCapStyle), capStyle), false);

                    e.Graphics.DrawString(locName, font, Brushes.Black,
                                          new Rectangle(55, rect.Top + 4, rect.Width - 18, 10),
                                          stringFormat);
                }
            }
            #endregion
        }
Exemplo n.º 26
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
                                         object value, Type destinationType)
        {
            #region Find constructor
            ConstructorInfo currentInfo = null;
            if (value != null)
            {
                ConstructorInfo[] cnInfos = value.GetType().GetConstructors();

                foreach (ConstructorInfo cnInfo in cnInfos)
                {
                    if (cnInfo.GetCustomAttributes(typeof(StiUniversalConstructorAttribute), false).Length > 0)
                    {
                        currentInfo = cnInfo;
                        break;
                    }
                }
                if (currentInfo == null)
                {
                    if (destinationType == typeof(string))
                    {
                        return(string.Empty);
                    }
                    return(base.ConvertTo(context, culture, value, destinationType));
                }
            }
            #endregion

            if (destinationType == typeof(string) && currentInfo != null)
            {
                object [] attrs =
                    currentInfo.GetCustomAttributes(typeof(StiUniversalConstructorAttribute), false);

                string name = ((StiUniversalConstructorAttribute)attrs[0]).Name;

                string displayName = StiLocalization.Get("PropertyMain", name, false);
                if (string.IsNullOrEmpty(displayName))
                {
                    return(string.Format("({0})", name));
                }
                ;
                return(string.Format("({0})", displayName));
            }

            if (destinationType == typeof(InstanceDescriptor) && value != null && currentInfo != null)
            {
                CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
                try
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);

                    #region Create parameters list
                    ParameterInfo[] pars = currentInfo.GetParameters();

                    Type[]   types = new Type[pars.Length];
                    object[] objs  = new object[pars.Length];

                    for (int index = 0; index < pars.Length; index++)
                    {
                        types[index] = pars[index].ParameterType;
                        string propertyName = pars[index].Name.Substring(0, 1).ToUpper(System.Globalization.CultureInfo.InvariantCulture) +
                                              pars[index].Name.Substring(1);

                        PropertyInfo prop = value.GetType().GetProperty(propertyName);
                        if (prop == null)
                        {
                            throw new ArgumentException(
                                      string.Format("Property '{0}' not present in '{1}'",
                                                    propertyName, value.GetType().ToString()));
                        }
                        objs[index] = prop.GetValue(value, null);
                    }
                    #endregion

                    return(new InstanceDescriptor(currentInfo, objs));
                }
                finally
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;
                }
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
        private async void ButtonSaveClick(object sender, RoutedEventArgs e)
        {
            #region Check

            string categoryStr;
            if (radioNewCategory.IsChecked == true)
            {
                textBoxCategory.Text = CheckName(textBoxCategory.Text);
                if (textBoxCategory.Text.Length == 0)
                {
                    textBoxCategory.Focus(FocusState.Pointer);
                    return;
                }

                categoryStr = textBoxCategory.Text;
            }
            else
            {
                categoryStr = (string)comboBoxCategory.SelectedItem;
            }

            textBoxReportName.Text = CheckName(textBoxReportName.Text);
            if (textBoxReportName.Text.Length == 0)
            {
                textBoxReportName.Focus(FocusState.Pointer);
                return;
            }

            if (CheckReportName(textBoxCategory.Text, textBoxReportName.Text))
            {
                var message = string.Format(StiLocalization.Get("NavigatorRT", "FailedAddReport"), textBoxCategory.Text);
                await StiMessageBox.ShowAsync(message, StiLocalization.Get("PropertyMain", "ReportName"), StiMessageBoxButton.Ok);

                textBoxReportName.Focus(FocusState.Pointer);
                return;
            }

            textBoxDataName.Text = CheckName(textBoxDataName.Text);
            if (radioNewReport.IsChecked == true && textBoxDataName.Text.Length == 0)
            {
                textBoxDataName.Focus(FocusState.Pointer);
                return;
            }

            #endregion

            ShowProgress();
            StiReport reportTemp = null;
            if (radioCurrentReport.IsChecked == true)
            {
                reportTemp = currentReport;
            }
            else if (radioNewDocument.IsChecked == true)
            {
                reportTemp = newReport;
            }
            else if (radioNewReport.IsChecked == true)
            {
                if (dataSet != null)
                {
                    newReport.RegBusinessObject(textBoxDataName.Text, dataSet);
                }

                var error = false;
                try
                {
                    await newReport.RenderAsync();
                }
                catch
                {
                    error = true;
                }

                if (error)
                {
                    await StiMessageBox.ShowAsync(StiLocalization.Get("NavigatorRT", "RenderingError"),
                                                  StiLocalization.Get("NavigatorRT", "Error"), StiMessageBoxButton.Ok);

                    HideProgress();
                    return;
                }

                reportTemp = newReport;
            }

            await StiCustomReportsHelper.AddCustomReportAsync(groups, reportTemp, categoryStr, textBoxCategoryDescriptino.Text, textBoxReportName.Text, textBoxReportDescription.Text);

            HideProgress();

            BackButtonClick(null, null);
        }
        private async void StiSplashControlLoaded(object sender, RoutedEventArgs e)
        {
            panelProgress.Children.Clear();

            var item = new StiSplashLoadingItemControl(StiLocalization.Get("NavigatorRT", "ProgressInformations"), 0);

            panelProgress.Children.Add(item);

            item = new StiSplashLoadingItemControl(StiLocalization.Get("NavigatorRT", "ViewerImagesInitialization"), 1);
            panelProgress.Children.Add(item);
            bool result = await StiReportImagesStore.InitStoreAsync();

            if (!result)
            {
                goto errorLabel;
            }

            item = new StiSplashLoadingItemControl(StiLocalization.Get("NavigatorRT", "IndicatorImageInitialization"), 1);
            panelProgress.Children.Add(item);
            result = await StiIndicatorsImagesStore.InitStoreAsync();

            if (!result)
            {
                goto errorLabel;
            }

            #region Check

            StiReport report = null;

            if (!string.IsNullOrEmpty(args))
            {
                StorageFile storageFile;
                report = new StiReport();

                if (args.EndsWith(".mrt", System.StringComparison.Ordinal))
                {
                    storageFile = await StiResourcesStorageHelper.LoadResourceFileAsync("StimulsoftResources\\Navigator\\Reports\\" + args);

                    if (storageFile != null)
                    {
                        await report.LoadAsync(storageFile);

                        report.RegBusinessObject("Data", "Data", StiDemoCategoryPage.GetData());

                        await report.RenderAsync();
                    }
                }
                else if (args.EndsWith(".mdc", System.StringComparison.Ordinal))
                {
                    storageFile = await StiResourcesStorageHelper.LoadResourceFileFromLocalFolderAsync("StimulsoftResources\\Navigator\\CustomReports\\Reports\\" + args);

                    if (storageFile != null)
                    {
                        await report.LoadDocumentAsync(storageFile);
                    }
                }
            }
            else if (fileActivated != null)
            {
                var storageFile = (StorageFile)fileActivated;

                report = new StiReport();
                await report.LoadDocumentAsync(storageFile);

                if (storageFile.DisplayName.EndsWith("DeleteFile", System.StringComparison.Ordinal))
                {
                    await storageFile.DeleteAsync();
                }
            }

            if (report != null)
            {
                var frame = Window.Current.Content as Frame;

                if (frame == null)
                {
                    frame = new Frame();
                    Window.Current.Content = frame;
                }

                frame.Navigate(typeof(MainPage), report);
                return;
            }
            #endregion

            item = new StiSplashLoadingItemControl(StiLocalization.Get("NavigatorRT", "Starting"), 0);
            panelProgress.Children.Add(item);

            var rootFrame = new Frame();
            rootFrame.Navigate(typeof(StiDemoReportsPage));
            Window.Current.Content = rootFrame;

            return;

errorLabel:
            item = new StiSplashLoadingItemControl(StiLocalization.Get("NavigatorRT", "FailedLoadResources"), 2);
            panelProgress.Children.Add(item);
        }
Exemplo n.º 29
0
        public static string ConvertTextOptionsToLocalizedString(StiTextOptions op, char separator, bool wordWrap)
        {
            string boolTrueStr  = StiLocalization.Get("PropertyEnum", "boolTrue");
            string boolFalseStr = StiLocalization.Get("PropertyEnum", "boolFalse");

            if (wordWrap)
            {
                return(string.Format(
                           "{0}={1}\n{2}={3}\n{4}={5}\n{6}={7}\n{8}={9}\n{10}={11}\n{12}={13}\n{14}={15}",
                           StiLocalization.Get("PropertyMain", "HotkeyPrefix"),
                           StiLocalization.Get("PropertyEnum", "HotkeyPrefix" + op.HotkeyPrefix.ToString()),

                           StiLocalization.Get("PropertyMain", "LineLimit"),
                           op.LineLimit ? boolTrueStr : boolFalseStr,

                           StiLocalization.Get("PropertyMain", "RightToLeft"),
                           op.RightToLeft ? boolTrueStr : boolFalseStr,

                           StiLocalization.Get("PropertyMain", "Trimming"),
                           StiLocalization.Get("PropertyEnum", "StringTrimming" + op.Trimming.ToString()),

                           StiLocalization.Get("PropertyMain", "WordWrap"),
                           op.WordWrap ? boolTrueStr : boolFalseStr,

                           StiLocalization.Get("PropertyMain", "Angle"),
                           op.Angle,

                           StiLocalization.Get("PropertyMain", "FirstTabOffset"),
                           op.FirstTabOffset,

                           StiLocalization.Get("PropertyMain", "DistanceBetweenTabs"),
                           op.DistanceBetweenTabs));
            }
            else
            {
                return(string.Format(
                           "{0}={1}{2} {3}={4}{5} {6}={7}{8} {9}={10}{11} {12}={13}{14} {15}={16}{17} {18}={19}{20} {21}={22}",
                           StiLocalization.Get("PropertyMain", "HotkeyPrefix"),
                           StiLocalization.Get("PropertyEnum", "HotkeyPrefix" + op.HotkeyPrefix.ToString()), separator,

                           StiLocalization.Get("PropertyMain", "LineLimit"),
                           op.LineLimit ? boolTrueStr : boolFalseStr, separator,

                           StiLocalization.Get("PropertyMain", "RightToLeft"),
                           op.RightToLeft ? boolTrueStr : boolFalseStr, separator,

                           StiLocalization.Get("PropertyMain", "Trimming"),
                           StiLocalization.Get("PropertyEnum", "StringTrimming" + op.Trimming.ToString()), separator,

                           StiLocalization.Get("PropertyMain", "WordWrap"),
                           op.WordWrap ? boolTrueStr : boolFalseStr, separator,

                           StiLocalization.Get("PropertyMain", "Angle"),
                           op.Angle, separator,

                           StiLocalization.Get("PropertyMain", "FirstTabOffset"),
                           op.FirstTabOffset, separator,

                           StiLocalization.Get("PropertyMain", "DistanceBetweenTabs"),
                           op.DistanceBetweenTabs));
            }
        }
Exemplo n.º 30
0
        public static void DrawPenStyle(DrawItemEventArgs e)
        {
            Graphics  g          = e.Graphics;
            Rectangle rect       = e.Bounds;
            Rectangle borderRect = new Rectangle(rect.X + 2, rect.Y + 2, 52, 14);

            #region Fill
            rect.Width--;
            StiControlPaint.DrawItem(g, rect, e.State, SystemColors.Window, SystemColors.ControlText);
            #endregion

            #region Paint border style
            Array obj = Enum.GetValues(typeof(StiPenStyle));

            using (Pen pen = new Pen(Color.Black, 2))
            {
                StiPenStyle penStyle = StiPenStyle.Solid;
                if (e.Index != -1)
                {
                    penStyle = (StiPenStyle)obj.GetValue(e.Index);
                }
                pen.DashStyle = StiPenUtils.GetPenStyle(penStyle);

                g.FillRectangle(Brushes.White, borderRect);

                int center = rect.Top + rect.Height / 2;

                if (penStyle == StiPenStyle.Double)
                {
                    pen.Width = 1;
                    g.DrawLine(pen, 2, center - 1, 54, center - 1);
                    g.DrawLine(pen, 2, center + 1, 54, center + 1);
                }
                else if (penStyle != StiPenStyle.None)
                {
                    g.DrawLine(pen, 2, center, 54, center);
                }
            }

            g.DrawRectangle(Pens.Black, borderRect);
            #endregion

            #region Paint name
            using (Font font = new Font("Arial", 8))
            {
                using (StringFormat stringFormat = new StringFormat())
                {
                    stringFormat.LineAlignment = StringAlignment.Center;

                    string name = ((StiPenStyle)obj.GetValue(e.Index)).ToString();

                    string locName = StiLocalization.Get("PropertyEnum", "StiPenStyle" + name);

                    if (locName != null)
                    {
                        name = locName;
                    }

                    e.Graphics.DrawString(name,
                                          font, Brushes.Black,
                                          new Rectangle(55, rect.Top + 4, rect.Width - 18, 10),
                                          stringFormat);
                }
            }
            #endregion
        }