Пример #1
0
        /// <summary>
        /// Saving component position and other values.
        /// </summary>
        public static void SaveSetting(XPathHandler handler,
                                       IComponentSetting setting, string name, string type)
        {
            //TODO: Save first position values and then other.
            switch (type)
            {
            case "form":
                handler.SaveForm(@"/configuration/GUI/Forms/" + type +
                                 @"[@name=""$name""]".Replace("$name", name),
                                 (FormSetting)setting);
                break;

            case "toolbar":
                handler.SaveToolbar(@"/configuration/GUI/Toolbars/" +
                                    type + @"[@name=""$name""]".Replace("$name", name),
                                    (ToolbarSetting)setting);
                break;

            case "statusbar":
                handler.SaveStatusbar(@"/configuration/GUI/Statusbars/" +
                                      type + @"[@name=""$name""]".Replace("$name", name),
                                      (StatusbarSetting)setting);
                break;

            case "column":
                handler.SaveColumn(@"/configuration/GUI/MainWindow/Columns/" +
                                   type + @"[@name=""$name""]".Replace("$name", name),
                                   (ColumnSetting)setting);
                break;

            default:
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Get component position and other values.
        /// </summary>
        /// <param name="name"></param>
        public static void GetSetting(List <Setting> list, XPathHandler handler,
                                      IComponentSetting setting, string name, string type)
        {
            Setting settingName = new Setting(1, "Name", name);

            list.Add(settingName);

            string relPath = "";

            switch (type)
            {
            case "form":
                relPath = "GUI/Forms/";
                break;

            case "toolbar":
                relPath = "GUI/Toolbars/";
                break;

            case "statusbar":
                relPath = "GUI/Statusbars/";
                break;

            case "column":
                relPath = "GUI/MainWindow/Columns/";
                break;
            }

            string path = "/configuration/" + relPath + type +
                          @"[@name=""$name""]/*".Replace("$name", name);
            XPathNodeIterator iterator = handler.GetComponentSettings(path);

            switch (type)
            {
            case "form":
                SetFormValues((FormSetting)setting, iterator.Clone());
                SetPositionValues((FormSetting)setting, iterator.Clone());
                break;

            case "toolbar":
                SetPositionValues((ToolbarSetting)setting, iterator.Clone());
                SetVisibleValue((ToolbarSetting)setting, iterator.Clone());
                break;

            case "statusbar":
                SetVisibleValue((StatusbarSetting)setting, iterator.Clone());
                break;

            case "column":
                SetColumnValues((ColumnSetting)setting, iterator.Clone());
                break;

            default:
                break;
            }
        }
Пример #3
0
        /// <summary>
        /// Get component position and other values.
        /// </summary>
        /// <param name="name"></param>
        public static void GetSetting(List<Setting> list, XPathHandler handler,
                IComponentSetting setting, string name, string type)
        {
            Setting settingName = new Setting(1, "Name", name);
            list.Add(settingName);

            string relPath = "";
            switch (type)
            {
                case "form":
                    relPath = "GUI/Forms/";
                    break;
                case "toolbar":
                    relPath = "GUI/Toolbars/";
                    break;
                case "statusbar":
                    relPath = "GUI/Statusbars/";
                    break;
                case "column":
                    relPath = "GUI/MainWindow/Columns/";
                    break;
            }

            string path = "/configuration/" + relPath + type +
                    @"[@name=""$name""]/*".Replace("$name", name);
            XPathNodeIterator iterator = handler.GetComponentSettings(path);

            switch (type)
            {
                case "form":
                    SetFormValues((FormSetting) setting, iterator.Clone());
                    SetPositionValues((FormSetting) setting, iterator.Clone());
                    break;
                case "toolbar":
                    SetPositionValues((ToolbarSetting) setting, iterator.Clone());
                    SetVisibleValue((ToolbarSetting) setting, iterator.Clone());
                    break;
                case "statusbar":
                    SetVisibleValue((StatusbarSetting) setting, iterator.Clone());
                    break;
                case "column":
                    SetColumnValues((ColumnSetting) setting, iterator.Clone());
                    break;
                default:
                    break;
            }
        }
Пример #4
0
        /// <summary>
        /// Setting position info.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="iterator"></param>
        public static void SetPositionValues(IComponentSetting component,
                                             XPathNodeIterator iterator)
        {
            int x = -1;
            int y = -1;

            while (iterator.MoveNext())
            {
                XPathNavigator navigator = iterator.Current.Clone();

                switch (navigator.Name)
                {
                case "X":
                    try
                    {
                        x = Convert.ToInt32(navigator.Value);
                    }
                    catch (Exception)
                    {
                        x = -1;
                    }
                    break;

                case "Y":
                    try
                    {
                        y = Convert.ToInt32(navigator.Value);
                    }
                    catch (Exception)
                    {
                        y = -1;
                    }
                    break;

                default:
                    break;
                }
            }
            component.SetPosition(x, y);
        }
Пример #5
0
        /// <summary>
        /// Setting visible value info.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="iterator"></param>
        public static void SetVisibleValue(IComponentSetting component,
                                           XPathNodeIterator iterator)
        {
            bool visible = false;

            while (iterator.MoveNext())
            {
                XPathNavigator navigator = iterator.Current.Clone();

                switch (navigator.Name)
                {
                case "Visible":
                    try
                    {
                        visible = Convert.ToBoolean(navigator.Value);
                    }
                    catch (Exception)
                    {
                        visible = false;
                    }
                    break;

                default:
                    break;
                }
            }

            if (component is ToolbarSetting)
            {
                ToolbarSetting toolbar = (ToolbarSetting)component;
                toolbar.SetValues(visible);
            }

            if (component is StatusbarSetting)
            {
                StatusbarSetting statusbar = (StatusbarSetting)component;
                statusbar.SetValues(visible);
            }
        }
Пример #6
0
        /// <summary>
        /// Setting visible value info.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="iterator"></param>
        public static void SetVisibleValue(IComponentSetting component,
                XPathNodeIterator iterator)
        {
            bool visible = false;

            while (iterator.MoveNext())
            {
                XPathNavigator navigator = iterator.Current.Clone();

                switch (navigator.Name)
                {
                    case "Visible":
                        try
                        {
                            visible = Convert.ToBoolean(navigator.Value);
                        }
                        catch(Exception)
                        {
                            visible = false;
                        }
                        break;
                    default:
                        break;
                 }
            }

            if(component is ToolbarSetting)
            {
                ToolbarSetting toolbar = (ToolbarSetting) component;
                toolbar.SetValues(visible);
            }

            if(component is StatusbarSetting)
            {
                StatusbarSetting statusbar = (StatusbarSetting) component;
                statusbar.SetValues(visible);
            }
        }
Пример #7
0
        /// <summary>
        /// Setting position info.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="iterator"></param>
        public static void SetPositionValues(IComponentSetting component,
                XPathNodeIterator iterator)
        {
            int x = -1;
            int y = -1;

            while (iterator.MoveNext())
            {
                XPathNavigator navigator = iterator.Current.Clone();

                switch (navigator.Name)
                {
                    case "X":
                         try
                        {
                            x = Convert.ToInt32(navigator.Value);
                        }
                        catch(Exception)
                        {
                            x = -1;
                        }
                        break;
                    case "Y":
                        try
                        {
                            y = Convert.ToInt32(navigator.Value);
                        }
                        catch(Exception)
                        {
                            y = -1;
                        }
                        break;
                    default:
                        break;
                  }
             }
             component.SetPosition(x, y);
        }
Пример #8
0
 /// <summary>
 /// Saving component position and other values.
 /// </summary>
 public static void SaveSetting(XPathHandler handler,
         IComponentSetting setting, string name, string type)
 {
     //TODO: Save first position values and then other.
     switch (type)
     {
         case "form":
             handler.SaveForm(@"/configuration/GUI/Forms/" + type +
                     @"[@name=""$name""]".Replace("$name", name),
                     (FormSetting) setting);
             break;
         case "toolbar":
             handler.SaveToolbar(@"/configuration/GUI/Toolbars/" +
                     type + @"[@name=""$name""]".Replace("$name", name),
                     (ToolbarSetting) setting);
             break;
         case "statusbar":
             handler.SaveStatusbar(@"/configuration/GUI/Statusbars/" +
                     type + @"[@name=""$name""]".Replace("$name", name),
                     (StatusbarSetting) setting);
             break;
         case "column":
             handler.SaveColumn(@"/configuration/GUI/MainWindow/Columns/" +
                     type + @"[@name=""$name""]".Replace("$name", name),
                     (ColumnSetting) setting);
             break;
         default:
             break;
     }
 }