Menu

IBorder - Why?

Help
2006-11-24
2013-04-23
  • Nobody/Anonymous

    I used Sourcegrid for a long time (actual runs 4.0.0.3). I love this Grid it have fantastic functions. Many thanks for that.

    I see that you change from 4.0.0.3 to 4.0.0.4 the Border functions. You create a interface (IBorder) and in a Cell you only returns that interface. With this changes i cannot upgrade to 4.0.0.4 because i must change the border "on the fly" and i have a lot of calls on the Cell.View.Border, but now that didn't runs :(

    I must first cast the element to RectangleBorder thats not very nice.

    Can you tell me why you change to IBorder? I see that this interface implement nothing of the functions of RectangleBorder and that is what i didn't understand. If you have abstract the RectangleBorder to create simply other borders it was very clear...

    Internel you always used RectangleBorder :) Did you change the calls of the IView.Border? Or exist another function to get the Border and change Top, Bottom,..., seperatly?

    Best regards
    Carsten

     
    • Davide Icardi

      Davide Icardi - 2006-11-24

      I have created and used an IBorder interface for 2 reasons:

      -First I want to support different style of borders. RectangleBorder is quite limited, support only one kind of border. I have created some other IBorder derived class (currently not published but I hope to publish it soon ...) to support rounded border, gradient borders, ...  The IBorder interface has only the minimal methods required for a border, and I think that it is always a good idea to have light interface so you can implement it easily.
      As you can see the View classes instance a RectangleBorder as the default value but then use only the IBorder methods. Internally I don't need to read the specific properties of RectangleBorder structure.

      -The second reason is performance. RectangleBorder drawing code is quite heavy. I want to create a light version of a border that draw the default cell border very fast.

      Consider that you can still use RectangleBorder. If you need to read the current border instance maybe you can simply wrap the code in an utility method, or create a customized View class. I known that it is a little boring but I think that the advantages are more than the disadvantages.

      Anyway I appreciate any discussions about the architecture

      Davide

       
    • Firgor

      Firgor - 2006-11-27

      Many thanks for the fast answer.

      Now i understand what you want and i agree that it is always desirable to have a lightweight interface.

      Little description why i think i missed something...

      In my application the user can set the border of a cell like in Excel and i search for methods in the interface to manipulate the border directly without to know which border is used at the moment. Now i must cast the IBorder to RectangleBorder to have methods to set the border or to check which part in the rectangle is set.

      I found only the enum RectanglePartType and the method GetPointPartType to have access on the information which part in the rectangle is set (Border). But nothing else.
      How can you set the border or manipulate them from external? I look at the selection examples but here you use the RectangleBorder properties.

      with kind regards
      Carsten

       
      • Davide Icardi

        Davide Icardi - 2006-11-27

        I think that you can create a code like this (pseudo code):

        void ChangeBorder(View, ...)
        {
        if (View.Border is RectangleBorder)
        {
          RectangleBorder rectBorder = (RectangleBorder)View.Border;
         
          //TODO here change the RectangleBorder 

        }
        else
        {
          //Here you can chose if set a default border or don't do nothing.
          // I think that in your case is better to set a default border.
          // So you can assume that you always have a RectangleBorder instance.
          View.Border = new RectangleBorder(...);
        }
        }

        You can use a similar code and change the border anyway you like. If you have a form to edit the Border you can simply check the type of the Border. If the Border is of type RectangleBorder you can use exactly the previous code otherwise create a new default RectangleBorder instance.

        Davide

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.