'분류 전체보기'에 해당되는 글 714건

  1. 2019.03.21 list depp copy , clone 하는 간단한 방법
  2. 2019.02.26 OpenCV, Face API를 이용해서 얼굴 검출하기 2번째
  3. 2019.02.25 Face API를 이용하여 얼굴 검색 및 비교해서 동일인 찾기
  4. 2019.02.14 listbox 스크롤 안될때 확인해야하는점
  5. 2019.01.22 리스트에 빈칸없이 꽉 차게 넣는 로직 알고리즘
  6. 2018.11.13 라디오 컨트롤 바인딩
  7. 2018.10.23 스크롤시 프로그램창 자체가 움직일때 해결
  8. 2018.08.31 WPF Title Icon 제거하기
  9. 2018.08.29 WPF 강제 소프트웨어 렌더링 설정
  10. 2018.08.07 ViewBox에서 폰트사이즈 고정하기
  11. 2018.05.02 WPF에서 GIF 돌리기 컨트롤 1
  12. 2018.03.07 Xaml에 Binding을 하지 않고 컨버터를 쓰고 싶을때
  13. 2017.10.19 wpf FlipView
  14. 2017.09.12 Listview , Button MouseOver, Selcted Color 제거
  15. 2017.09.06 Converter를 쓰지 않고 바인딩된 TextBlock에 글자를 추가하고 싶을때
  16. 2017.08.22 LIST의 UI에 즉각적으로 바인딩 업데이트를 하고 싶을때..
  17. 2017.08.08 MVVM 하위 컨트롤 바인딩
  18. 2017.08.08 ViewModel 끼리의 통신
  19. 2017.08.07 해상도에 따른 이미지 크기 변경
  20. 2017.07.25 CommandParameter를 이용하여 List 안에 버튼 파라미터 전달
  21. 2017.07.24 List Object를 Copy 해보자. (ICloneable)
  22. 2017.07.21 non-ASCII를 없애보자.
  23. 2017.07.21 Base 모델 클래스에 있는 데이터를 상속 클래스에 COPY 하기
  24. 2017.07.18 listbox에서 오른쪽 정렬하고 싶을때
  25. 2017.07.17 [WPF] NavagionManager
  26. 2017.07.17 MVVM Button Click Command 사용법
  27. 2016.10.24 MVVM을 쓰면서... 3
  28. 2016.10.24 UWP(윈도우 유니버설 응용 프로그램)
  29. 2016.10.04 Huying PC방 버전(2016.8~2016.9)
  30. 2016.08.23 ListBox Drag and Drop
wpf2019. 3. 21. 17:44

List를 그대로 대입시켜버리면 해당 객체가 바뀌기때문에


clone, deep copy를 해야한다.


List<Book> books_2 = books_1.ConvertAll(book => new Book());



내가 봤을때는 이게 가장 나은 방법같다.

https://stackoverflow.com/questions/14007405/how-create-a-new-deep-copy-clone-of-a-listt

Posted by 동동(이재동)
wpf2019. 2. 26. 16:56

얼굴 인식 2번쨰

Face API를 항상 호출하면 1분에 20번(무료 버전 기준) 호출 제한을 넘기때문에

일단 openCV 에서 얼굴을 최대한 감지한후 호출을 해야 호출 제한에 어느정도 자유롭다.

일단 openCVSharp을 설치하면

CascadeClassifier class의 DetactMultiScale을 이용해서 사람 얼굴을 감지할수 있다.

private readonly CascadeClassifier _localFaceDetector = new CascadeClassifier();
_localFaceDetector.Load("Data/haarcascade_frontalface_alt.xml");

_grabber.NewFrameProvided += (s, e) =>
{
var rects = _localFaceDetector.DetectMultiScale(e.Frame.Image, 1.3, 1, 0, new OpenCvSharp.Size(200, 200));
.
.
//Face API를 이용해서 얼굴 찾기

이런식으로 1차적으로 openCV 얼굴 검출 2차 Face API를 이용해서 얼굴 찾기 하면 된다.

프레임별로 얼굴을 찾는 부분을 호출 하기 때문에 2초 정도 안에는 다시 FaceAPI를 호출하지 못하도록 구현해야한다.


DetectMultiScale을 이용해서 검출할수 있는 최대 인원 및 최소 사이즈를 설정할수 있다. 샘플에서는 얼굴 크기가 200 이상인사람만 찾도록 구현했다.

샘플은 웹캠이 구동되고 얼굴을 비추면 첨보는 사람면 등록을 , 등록된 사람이면 userData의 이름 및 성별등등을 출력해준다. Face API는 최대한 호출되지 않도록 openCV에서 얼굴이 완전히 검출 되었을때만 사용했다.


FaceApiTest2.zip













Posted by 동동(이재동)
wpf2019. 2. 25. 15:34

  Face api 1.0 


https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250

face api를 사용하기 위해선 face api를 사용하기 위한 key와 End Point를 받아야 한다.

end point는 이런식으로 되어 있다.
https://koreacentral.api.cognitive.microsoft.com/face/v1.0/

나머지는 api 사용법대로 사용 하면 된다.


openCV를 이용해서 카메라를 띄우고 FrameGrabber를 이용해서 해당이미지 사진을 올린다.

원리는 이렇다

FaceDetect를 이용해서 사람을 찾고 찾을경우 Find similer를 이용하여 FaceList에서 검색한다.

만약 없을경우 add Face를 이용하여 사람을 등록한다. 그룹을 이용해서 할수도 있다.

나머진 샘플을 이용해보자


FaceApiTest.zip


Posted by 동동(이재동)
wpf2019. 2. 14. 15:34

Libox를 감싸는 패널에  StackPanel이 있으면 안된다.


 Grid를 사용해야 하며 


만약 WrapPanel을 이용할경우


ControlTemplate대신 ItemPanelTemplate을 이용해야한다.




Posted by 동동(이재동)
wpf2019. 1. 22. 16:37


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        private int index = 0;
        private ObservableCollection<FranchiseModel> list = new ObservableCollection<FranchiseModel>();
 
        public void Next()
        {
            list.Clear();
 
            while (list.Count < 3)
            {
                list.Add(Data[index]);
                index++;
 
                if (index >= Data.Count)
                {
                    index = 0;
                }
            }
 
            FranchiseLists = list;
        }



예를들어 Data에는 10개의 값이 있고 


list에는 3개씩 꽉차게 보여주고 싶다 하면


인덱스를 봤을때

0,1,2 3,4,5 6,7,8 9,10,0


이렇게 10개가 찼을때 다시 젤첨의 0번째 인덱스를 보여주게 함으로써 빈값이 없게 만든다.


list를 항아리라 생각하면 쉽다. while문을 돌면서 무조건 3개를 차게 한다.


이렇게 하면 만약 항상 list는 3개가 되기때문에 빈칸없는 정보를 보여줄때 쓰면 좋다.



Posted by 동동(이재동)
wpf2018. 11. 13. 16:20


namespace WpfRadioButton
{
    using System;
    using System.ComponentModel;
    using System.Globalization;
    using System.Windows;
    using System.Windows.Data;
    using System.Windows.Markup;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ViewModel vm = new ViewModel();
        public MainWindow()
        {
            InitializeComponent();

            DataContext = vm;
        }
    }

    [ValueConversion(typeof(bool), typeof(Enum))]
    public class EnumToBoolExtension : MarkupExtensionIValueConverter
    {
        #region IValueConverter
        
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return parameter.Equals(value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ((bool) value) == true ? parameter : DependencyProperty.UnsetValue;
        }

        #endregion

        #region MarkupExtension

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }

        #endregion
    }

    public enum Direction
    {
           North,
        Easth,
        West,
        South
    }

    public class ViewModel : INotifyPropertyChanged
    {
        public Direction direction;

        public Direction Direction
        {
            get
            {
                return this.direction;
            }

            set
            {
                this.direction = value;
                this.RaisePropertyChanged("Direction");
            }
        }

        #region NotifyPropertyChanged Methods

        public void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;

            if (handler != null)
            {
                handler(thisnew PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}


<Window x:Class="WpfRadioButton.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:local="clr-namespace:WpfRadioButton"
        Title="RadioButton" Height="200" Width="300">
    <Grid DataContext="{Binding}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <RadioButton Grid.Row="0" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="North" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.North}}"/>
        <RadioButton Grid.Row="1" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="East" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.Easth}}"/>
        <RadioButton Grid.Row="2" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="West" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.West}}"/>
        <RadioButton Grid.Row="3" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="South" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.South}}"/>
        <TextBlock Grid.Row="4" Margin="5" VerticalAlignment="Center" Text="{Binding Direction}"/>
    </Grid>
</Window>

출처 : https://zamjad.wordpress.com/2014/03/01/radio-button-in-mvvm/

Posted by 동동(이재동)
wpf2018. 10. 23. 09:48
<ScrollViewer PanningMode="Both" x:Name="ScrollViewer"ManipulationBoundaryFeedback="ScrollViewer_ManipulationBoundaryFeedback">
    <StackPanel Width="300">
    </StackPanel>
</ScrollViewer>



private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
    e.Handled = true;
}


Posted by 동동(이재동)
wpf2018. 8. 31. 12:53
public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
 
        protected override void OnSourceInitialized(EventArgs e)
        {
            IconHelper.RemoveIcon(this);
        }
    }



public static class IconHelper
    {
        [DllImport("user32.dll")]
        static extern int GetWindowLong(IntPtr hwnd, int index);
 
        [DllImport("user32.dll")]
        static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
 
        [DllImport("user32.dll")]
        static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, 
                   int x, int y, int width, int height, uint flags);
 
        [DllImport("user32.dll")]
        static extern IntPtr SendMessage(IntPtr hwnd, uint msg, 
                   IntPtr wParam, IntPtr lParam);
 
        const int GWL_EXSTYLE = -20;
        const int WS_EX_DLGMODALFRAME = 0x0001;
        const int SWP_NOSIZE = 0x0001;
        const int SWP_NOMOVE = 0x0002;
        const int SWP_NOZORDER = 0x0004;
        const int SWP_FRAMECHANGED = 0x0020;
        const uint WM_SETICON = 0x0080;
 
        public static void RemoveIcon(Window window)
        {
            // Get this window's handle
            IntPtr hwnd = new WindowInteropHelper(window).Handle;
 
            // Change the extended window style to not show a window icon
            int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
 
            // Update the window's non-client area to reflect the changes
            SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | 
                  SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
        }
 
    }


Posted by 동동(이재동)
wpf2018. 8. 29. 17:25

app.xaml.cs 에서 onStartup에서 


RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;


렌더모드를 소프트웨어 온리로 바꿨더니


Mediaelement 의 4k GPU 사용량이 100에서 많이 줄어들었다.


DID같은경우는 너무 GPU가 높으니 하드웨어 렌더링보다는 소프트웨어 렌더링을 이용해야겠다.



참고 : https://blogs.msdn.microsoft.com/jgoldb/2010/06/22/software-rendering-usage-in-wpf/



Posted by 동동(이재동)
wpf2018. 8. 7. 12:23
<Viewbox StretchDirection="DownOnly" >
     <Label Content="Enable" FontSize="10" FontStretch="Normal" />
</Viewbox>


'wpf' 카테고리의 다른 글

WPF Title Icon 제거하기  (0) 2018.08.31
WPF 강제 소프트웨어 렌더링 설정  (0) 2018.08.29
WPF에서 GIF 돌리기 컨트롤  (1) 2018.05.02
Xaml에 Binding을 하지 않고 컨버터를 쓰고 싶을때  (0) 2018.03.07
wpf FlipView  (0) 2017.10.19
Posted by 동동(이재동)
wpf2018. 5. 2. 17:34


샘플 소스 참조~


WpfAnimatedGif-master.zip


Posted by 동동(이재동)
wpf2018. 3. 7. 17:34

대부분 컨버터는 바인딩을 걸고 쓰지만 아래와 같이 영문버전 한글버전 식으로 컨버터를 쓰고 싶다면

이미지소스 에 바인딩을 걸어 버리면 된다.



1
2
3
4
5
 <Image  Stretch="None" Visibility="{Binding IsShowInfoWordImage, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Image.Source>
                            <Binding Source="/BANAPRESSO_KIOSK;component/Images/order_list_info_words.png" Converter="{StaticResource GlobalImageNameConverter}" />
                        </Image.Source>
</Image>

Posted by 동동(이재동)
wpf2017. 10. 19. 16:27

https://www.codeproject.com/Articles/741026/WPF-FlipView


나중에 정리

Posted by 동동(이재동)
wpf2017. 9. 12. 12:40

listview
1
2
3
4
5
6
7
8
9
10
11
12
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListViewItem}">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>


button


1
2
3
4
5
6
7
8
9
10
11
12
13
14
 <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Border Background="{TemplateBinding Background}">
                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
</Button.Style>


Posted by 동동(이재동)
wpf2017. 9. 6. 12:13

예를 들면 3이라는 숫자가 바인딩 되어 있고

이걸 3개월로 바꾸고 싶으면 Converter를 쓰면 되지만 일일이 만들기가 엄청 귀찮다


 <TextBlock Text="{Binding Month, StringFormat={}{0}개월}"/>


돈도 

<TextBlock Text="{Binding Money,StringFormat='##,#'}" />


이렇게 하면 300,000 형식으로 나온다.



Posted by 동동(이재동)
wpf2017. 8. 22. 12:41

물론 ViewModel에서는 MVVM Light 라이브러리에 있는 NotifyProperty가 알아서 해주겠지만


Model 같은경우는 자기가 만들면 된다.


에를 들면 ObservableCollection에서 어떤 Property를 수정하였을때 즉각적으로 바인딩된 UI에 적용하고 싶다면


Model에 INotifyPropertyChanged 인터페이스를 구축하면 된다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    public class OrderedMenuItem : INotifyPropertyChanged
    {
        public int Index { get; set; }
 
        private int _orderCount;
 
        public int OrderCount
        {
            get { return _orderCount; }
            set
            {
                if (_orderCount != value)
                {
                    _orderCount = value;
                    NotifyPropertyChanged("OrderCount");
                }
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        public void NotifyPropertyChanged(string propName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(thisnew PropertyChangedEventArgs(propName));
        }
    }


참고 : http://www.wpf-tutorial.com/data-binding/responding-to-changes/


Posted by 동동(이재동)
wpf2017. 8. 8. 16:18

예를들어 View의 UserControl의 DataContext에 데이터를 주입하고

 <local:CardCancelControl DataContext="{Binding CardCancelData}" />


이런식으로...

유저컨트롤에서 버튼 커맨드를 넣었을때


 <Button Content="확인" Command="{Binding DataContext.CardCancelCommand}"  CommandParameter="Cancel" />


이런식으로 넣으면 안된다. datacontext안에 서 command를 호출하기 때문이다


이렇게 할려면 상위에서 DataContext를 빼야 작동한다.


그러면 상위에서 호출되게 할려면 어떻게 해야할까.


 <Button Content="확인" Command="{Binding Path=DataContext.CardCancelCommand,

                        RelativeSource={RelativeSource Mode=FindAncestor,

                        AncestorType={x:Type local:PopupControl}}}" CommandParameter="Cancel" />


이렇게 하면 된다.

참고 : https://stackoverflow.com/questions/3404707/access-parent-datacontext-from-datatemplate


Posted by 동동(이재동)
wpf2017. 8. 8. 15:38

MvvmLight를 사용한다는 기준으로 작성한다.


1
2
3
4
        private void ExcuteSettingCommand()
        {
            MessengerInstance.Send(SettingEnum.OpenSettingPopup);
        }


MessngerInstance를 이용하여

일단 보내는 값을 object형태 (여기서는 enum)로 보낸다.


받는 ViewModel에서는


1
2
3
4
5
6
7
8
9
  public PopupViewModel()
        {
            MessengerInstance.Register<SettingEnum>(this, c => SettingExcute(c));
        }
 
        public void SettingExcute(SettingEnum result)
        {
            //some code
        }


이런식으로 등록하면 통신이 된다.

Posted by 동동(이재동)
wpf2017. 8. 7. 11:29

일반적으로 Grid라든지 컨트롤들은 자동으로 해상도에 맞게 조절해주지만


이미지는 크기가 정해져 있어서 이미지 크기가 유동적으로 변하지 않는다.


그래서 만약 Grid를 사용할때 퍼센트를 이용해서 분할하였다면 이미지를 사용한 Row나 column은 이미지가 짤릴경우가 있다.


이럴때는 ViewBox로 그 Row를 감싸면 깔끔해진다.



Posted by 동동(이재동)
wpf2017. 7. 25. 17:41

List는 List<ConvertOrderKey>이런식으로 자료가 들어가 있고


ItemTemplate안에는 

<Button Content="주문확인" Width="70" Command="{Binding ElementName=xListView, Path = DataContext.OrderClickCommand}" CommandParameter="{Binding}" />


이런식으로 구현하였다.

커맨드 파라미터는 그냥 ConvertOrderKey모델 전체를 넘겼다.


viewModel에서는


1
2
3
4
5
6
7
8
9
10
11
12
13
14
 private RelayCommand<ConvertOrderKey> _orderClickCommand;
 
        public RelayCommand<ConvertOrderKey> OrderClickCommand
        {
            get
            {
                return _orderClickCommand
                  ?? (_orderClickCommand = new RelayCommand<ConvertOrderKey>(
                    param =>
                    {
                        var temp = param;
                    }));
            }
        }

이렇게 구현하였다.

param에 모델데이터가 전부 넘어온다.


Posted by 동동(이재동)
wpf2017. 7. 24. 15:03

List<Object Class> 의 리스트를 duplicate 해서 새로운 리스트를 만들고 그안에 object property를 수정하고 싶었다.


하지만 list를 duplicate 했더라도 안에 프로퍼티를 바꾸면 오리지널 데이터까지 바뀌어졌다.
그래서 해당 obejct class 에 ICloneable interface를 사용하여서 해결하였다.

이렇게 object에 interface를 선언하고

1
2
3
4
5
6
7
8
9

public class OrderItem : ICloneable
    {     
        public int GroupCount { get; set; }
 
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }

구현 하면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
private static List<OrderItem> GroupOrderItemByName(List<OrderItem> orderList)
        {
            var groupOrderItemList = new List<OrderItem>();
            var result = orderList.GroupBy(s => s.Name).ToList();
 
            foreach (var item in result)
            {
                var orderItem = (OrderItem)item.ToList()[0].Clone();
                orderItem.GroupCount = item.Count();
                groupOrderItemList.Add(orderItem);
            }
            
             return groupOrderItemList;
         }


참고 : https://stackoverflow.com/questions/6569486/creating-a-copy-of-an-object-in-c-sharp



Posted by 동동(이재동)
wpf2017. 7. 21. 15:51

소켓통신 하는도중 

Int형을 String형으로 받으면 

"1\u0018어쩌구저쩌구"

이런식으로 들어왔다.

이럴때 Non-Ascii를 제거하는 코드 이다..


1
2
3
String test = "스트링";
 
Regex.Replace(test, @"[^\u001F-\u007F]+"string.Empty);


제일 좋은건 그냥 Int는 Int형식으로 받는게 가장 깔끔하다..


어쩔수 없을때만 쓰자

참고 : https://stackoverflow.com/questions/123336/how-can-you-strip-non-ascii-characters-from-a-string-in-c



Posted by 동동(이재동)
wpf2017. 7. 21. 15:13

내가 하고 싶었던거는


이렇게 BASE Model Class가 있고

1
2
3
4
5
public class OrderKey
    {
        public string nTempOrderID { get; set; }
        public string nOrderID { get; set; }
    }


OrderKey를 상속받는 클래스가 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class ConvertOrderKey : OrderKey
    {
        public List<OrderItem> OrderItemList { get; set; }
 
        public void CopyFromBase(OrderKey orderKey)
        {
            // copy base class properties.
            foreach (PropertyInfo prop in orderKey.GetType().GetProperties())
            {
                PropertyInfo prop2 = orderKey.GetType().GetProperty(prop.Name);
                prop2.SetValue(this, prop.GetValue(orderKey, null), null);
            }
        }
    }

ConvertOrderKey는 OrderKey를 상속받고 추가로 List를 하나 더 추가하는것이였다.


CopyFromBase라는 메소드를 만들어서 단순히 orderkey에 있는 내용을 전부 클래스에 복사한다.

이렇게 하면


1
2
3
4
5
6
7
8
9
10
11
 public static void ConvertData(ObservableCollection<OrderKey> orderKey)
        {   
            var covertOrderKeyList = new ObservableCollection<ConvertOrderKey>();
            foreach (var item in orderKey)
            {
                ConvertOrderKey cok = new ConvertOrderKey();
                cok.CopyFromBase(item);
                cok.OrderItemList = new List<OrderItem>();
                covertOrderKeyList.Add(cok);
            }
        }
 

이런식으로 기존 Base 클래스 List안에 있는것들에 있는것들을 상속받은 Class로 Copy하고

추가로 OrderITemList값을 지정할수 있다.


참고 : https://social.msdn.microsoft.com/Forums/vstudio/en-US/2105f08f-50ce-47a3-8e2a-3e62634d4cbc/copy-properties-from-base-class-to-derived-class-without-manually-mapping-them?forum=csharpgeneral

'wpf' 카테고리의 다른 글

List Object를 Copy 해보자. (ICloneable)  (0) 2017.07.24
non-ASCII를 없애보자.  (0) 2017.07.21
listbox에서 오른쪽 정렬하고 싶을때  (0) 2017.07.18
[WPF] NavagionManager  (0) 2017.07.17
MVVM Button Click Command 사용법  (0) 2017.07.17
Posted by 동동(이재동)
wpf2017. 7. 18. 16:43

보통 기본 리스트박스로 만들면 이렇게 item 이 들어간다.


enter image description here


만약 

enter image description here


이렇게 하고 싶다면

<ListBox>
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ListBox.ItemContainerStyle>
    </ListBox>


출처 : https://stackoverflow.com/questions/20934261/align-grid-column-to-right

'wpf' 카테고리의 다른 글

non-ASCII를 없애보자.  (0) 2017.07.21
Base 모델 클래스에 있는 데이터를 상속 클래스에 COPY 하기  (0) 2017.07.21
[WPF] NavagionManager  (0) 2017.07.17
MVVM Button Click Command 사용법  (0) 2017.07.17
MVVM을 쓰면서...  (3) 2016.10.24
Posted by 동동(이재동)
wpf2017. 7. 17. 16:58

Grid 같은 패널에 Add,Clear 하면서 임시로 nagiation처럼 되도록 하는 방법이 있지만


Frame을 이용하면 더 깔끔하게 가능하다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
    public static class NavigationManager
    {
        private static Frame _mainContentFrame;
 
        public static void SetFrame(Frame frame)
        {
            _mainContentFrame = frame;
        }
 
        public static void Navigate(UserControl page)
        {
            _mainContentFrame.Navigate(page);
        }
    }


Xaml


1
2
3
<Grid x:Name="xMainWindowPanel">
        <Frame x:Name="xMainFrame" NavigationUIVisibility="Hidden" />
</Grid>


사용법


1
2
3
4
5
  private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            NavigationManager.SetFrame(xMainFrame);
            xMainFrame.Navigate(new LoginPage());
        }

추가...

naviagte를 하게 되면 이전 페이지가 필요 있으면 메모리에 남게 되므로 메모리 관리에 문제가 있을수 있다.

 public static void Navigate(UserControl page)
        {
            _mainContentFrame.Navigate(page);

            while (_mainContentFrame.CanGoBack == true)
            {
                _mainContentFrame.RemoveBackEntry();
            }
        }

RemoveBackEntry()로 지워주자


Posted by 동동(이재동)
wpf2017. 7. 17. 16:54

일단 Command를 만든다.

1
2
        private bool _deleteCommand = true;
        public RelayCommand DeleteCommand { get; private set; }
 


ViewModel 생성자에 넣기

1
2
3
4
5
 public MainViewModel()
        {
            DeleteCommand = new RelayCommand(ExcuteDeleteCommand, () => _deleteCommand);
            OrderMenuList = new ObservableCollection<OrderMenu>();
        }



1
2
3
4
 private void ExcuteDeleteCommand()
        {
            OrderMenuList.RemoveAt(OrderMenuList.Count - 1);
        }


xaml코드에는


1
<Button x:Name="xdelete" Content="삭제"  Height="50" Margin="20" Command="{Binding DeleteCommand}" />


여러가지 파라미터를 사용하고 싶으면 여기 참고

https://msdn.microsoft.com/en-us/magazine/dn237302.aspx

'wpf' 카테고리의 다른 글

listbox에서 오른쪽 정렬하고 싶을때  (0) 2017.07.18
[WPF] NavagionManager  (0) 2017.07.17
MVVM을 쓰면서...  (3) 2016.10.24
ListBox Drag and Drop  (0) 2016.08.23
app.config 수정 edit  (0) 2016.07.15
Posted by 동동(이재동)
wpf2016. 10. 24. 15:37

6년동안 MVVM을 쓰면서.. 느낀점을 알아보자..


일단 MVVM이란


Model : 보통 Data를 담는 그릇정도로 생각

View :  디스플레이 사용자가 보여지는것, UI, 디자이너의 영역이라고 정의해두자.

ViewMode: View의 표현을 담당한다고 보면 된다. 보통 View에 Data를 표현해준다.  

보통 ViewModel이 변경되면 View에 자동으로 업데이트 하는 방식으로 구현된다.


MVVM을 사용했을때 장점은 머가 있었을까...

-일단 View와 비지니스 로직의 연결이다. 뷰나 비지니스 로직 둘중에 하나가 변경 되더라도 다른 부분에 영향을 미치지 않는다. 따라서 디자이너와의 협업 시스템이 정말 용의 하다. 실제로 디자이너랑 엄청 편리하게 작업을 해왔다.


-ICommand의 각종 이벤트나 익터렉션 처리를 ICommand를 호출해서 사용하는데 간단하게 이야기 하면

이벤트를 뷰모델과 연결하는 방법이다. 근데 은근히 귀찮고 짜증나서 사용하기가 싫다. 그냥 BeHind로 하고 싶다!!!!!


-Binding 사용가능

등등


장점만 있는거 같지만 단점도 많다..


가장 중요한 귀찮다!! 귀찮다!! 귀찮다!

페이지 하나 만들려고 해도 VIewModel을 따로 만들어야 하니 귀찮니즘땜에 죽겠다.

그리고 이벤트 연결 그냥 비하인드에 해도 되는데 ICommmand 쓰면 코드가 몇줄이나 늘어난다.

그리고 디버깅도 더 힘들다.

그리고 View처리가 복잡해지면 ViewModel Class가 엄청나게 커진다.


이렇게 장단점이 있기때문에 상황에 맞게 잘사용해야할꺼 같다..

무조건 MVVM을 고집하는건 좀 아닌거 같다는 생각이 든다.












'wpf' 카테고리의 다른 글

[WPF] NavagionManager  (0) 2017.07.17
MVVM Button Click Command 사용법  (0) 2017.07.17
ListBox Drag and Drop  (0) 2016.08.23
app.config 수정 edit  (0) 2016.07.15
[WPF] IsolatedStorageManager  (0) 2016.06.08
Posted by 동동(이재동)
Windows10 App2016. 10. 24. 15:20

8에서 10으로 바뀌면서 가장 크게 바뀐게 유니버설로 바뀐것이다.

이제, 윈도우 10, 유니버설 응용 프로그램 플랫폼의 이름은 범용 윈도우 플랫폼 (UWP)로 변경되었다. PC, 태블릿, 휴대 전화,로 Windows 스토어의 Windows 10 장치를 대상으로 현대 완전히 몰입 애플리케이션을 구축 할 수 있다.


개발은 HTML과 C# With Xaml로 개발 가능하다.


개발하기 위해서 필요한것

-비쥬얼 스튜디오

-개발자 모드 On

-앱개발자 등록


'Windows10 App' 카테고리의 다른 글

윈도우즈 스토어 앱에서 윈도우 버전 알기  (0) 2015.07.03
Posted by 동동(이재동)
포트폴리오2016. 10. 4. 16:42

중국에서 사용되고 있는 Huying PC방 버전


-PC방에서 이용중인 사용자들을 볼수 있고 비슷한 게임을 즐기는 사람과 게임 정보 공유및 친구를 사귈수 있음

-핸드폰으로 WECHAT 정보를 입력하면 자동으로 프로그램에 QR코드와 정보가 업데이트 됨

-광고로 수입 낼수 있음

-게임방 음식 메뉴를 고를수 있으며 앱을 이용하여 쉽게 결제 가능



Posted by 동동(이재동)
wpf2016. 8. 23. 15:41

일단 참고


http://www.c-sharpcorner.com/uploadfile/dpatra/drag-and-drop-item-in-listbox-in-wpf/



'wpf' 카테고리의 다른 글

MVVM Button Click Command 사용법  (0) 2017.07.17
MVVM을 쓰면서...  (3) 2016.10.24
app.config 수정 edit  (0) 2016.07.15
[WPF] IsolatedStorageManager  (0) 2016.06.08
프로그램 죽을때 바로 재시작하게 하기  (0) 2016.05.19
Posted by 동동(이재동)