|
Why are you concerned about the "file size" and not the run-time profile / working set?
Did you try "compressing" it?
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
Because I know my pet project has fine memory profile, beside it's a completely different question.
But there is a big difference for the user if they try to download the app, and it's 130MB, instead of 300KB.
Plus why the f*** it's 120Mb. It's as big as a game here! But it's just a simple desktop app...
|
|
|
|
|
Super Lloyd wrote: BTW what is the "framework dependent" deployment mode?
Framework-dependent deployment. As the name implies, framework-dependent deployment (FDD) relies on the presence of a shared system-wide version of .NET Core on the target system. Because .NET Core is already present, your app is also portable between installations of .NET Core. [...]
Self-contained deployment. Unlike FDD, a self-contained deployment (SCD) doesn't rely on the presence of shared components on the target system. All components, including both the .NET Core libraries and the .NET Core runtime, are included with the application and are isolated from other .NET Core applications.
It answers the "why" also, on the same page
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
It is as I thought. The circle is now complete!
|
|
|
|
|
I' making a very simple app to drag files from my desktop or explorer into a WPF ListBoxView, these files will be auto backed up on a specific day and time. I have the dragging files into the ListBoxView working fine. Can even insert Multiple selected at one time. I can rearrange my list order by dragging and dropping fine as well. My issue is I can't seem to trigger it to remove the file I drag out of the ListBoxView control to remove it from the List. Can anyone help ??
My Xaml
<Label Grid.Row="0" Content="Files to be copied..." Background="{x:Null}" Foreground="White" HorizontalAlignment="Center"/>
<ListBox Grid.Row="1"
x:Name="dropList"
Margin="10"
SelectionMode="Extended"
AllowDrop="True"
Drop="DropList_Drop"
Foreground="White"
Background="#FF333337"
Height="Auto"
Width="Auto"
VerticalAlignment="Stretch"
MouseMove="DropList_MouseMove"
PreviewDragLeave="DropList_PreviewDragLeave" >
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem x:Name="Options"
Header="Options..."
Click="Options_Click"
Foreground="Black"/>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
My C#
private void DropList_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string data in files)
{
if (!dropList.Items.Contains(data))
dropList.Items.Add(data);
}
}
else
{
object data = e.Data.GetData(typeof(string));
dragSource.Items.Remove(data);
dropList.Items.Add(data);
}
}
private void DropList_MouseMove(object sender, MouseEventArgs e)
{
Point mousePos = e.GetPosition(null);
Vector diff = startPoint - mousePos;
if (e.LeftButton == MouseButtonState.Pressed &&
(Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
{
dragSource = dropList;
object data = GetDataFromListBox(dragSource, e.GetPosition(dropList));
if (data != null)
{
DragDrop.DoDragDrop(dropList, data, DragDropEffects.Move);
}
}
}
private void DropList_PreviewDragLeave(object sender, DragEventArgs e)
{
if (Mouse.LeftButton == MouseButtonState.Released)
{
dragSource = dropList;
object data = GetDataFromListBox(dragSource, e.GetPosition(dropList));
if (data != null && dropList.Items.Contains(data))
dropList.Items.Remove(data);
}
}
modified 23-May-19 13:01pm.
|
|
|
|
|
Quote: My issue is I can't seem to trigger it to remove the file I drag out of the ListBoxView control to remove it from the List.
If you are just "removing", there is no "dragging", unless it's to a "trash bin". Then do the "remove" in the drop event for the "trash".
Otherwise, you simply delete the entry; usually with a right-click context menu or a delete key.
(Though a trash bin does not make sense in this context because you are dealing with "file names", and not actual files in terms of what's removed).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thank you I managed to get it to work using the Drag to trash like you suggested. I simply added a Stack panel that stretched Horizontally to give the user plenty of room to click on added an icon and label, works perfect. Although if you help me figure out how to catch multiple selected files being dragged from the ListBoxView to the trash It would be better, right now it's single file only. Having the option to drag one or multi is nice.
I will go ahead and mark this solved since you did help me solve the original issue.
|
|
|
|
|
For a multi-select, you should start thinking of using an ObservableCollection and updating that; that way changes are reflected back to the ListBox and you're not updating the ListBox yourself (and can ignore any ListBox events).
The multi-selections represent keys into your ObservableCollection; which could br shadowed with a dictionary.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I have the following XAML that creates a Gear icon in a button. It works well with one problem... because the icon is made up of 2 Geometrys, the mouseover 'flickers' when the mouse pointer is in between them.
<Window.Resources>
<SolidColorBrush x:Key="normalColor">#0026FF</SolidColorBrush>
<SolidColorBrush x:Key="hoverColor">#E62DFF</SolidColorBrush>
<SolidColorBrush x:Key="pressedColor">#7F7818</SolidColorBrush>
<SolidColorBrush x:Key="disabledColor">#808080</SolidColorBrush>
<Geometry x:Key="settingsIconOutter">
M911 2215 c-34 -39 -36 -45 -54 -153 l-12 -73 -70 -30 -70 -29 -40
29 c-106 76 -117 81 -167 81 -67 0 -89 -14 -195 -122 -127 -130 -134 -176 -43
-305 28 -39 50 -74 50 -78 0 -4 -12 -38 -26 -75 l-27 -68 -51 -7 c-106 -14
-146 -26 -176 -57 l-30 -30 0 -177 0 -177 28 -26 c40 -38 59 -45 151 -59 58
-9 85 -17 88 -28 3 -9 16 -40 30 -70 l24 -55 -29 -40 c-77 -107 -82 -118 -82
-168 0 -67 14 -89 122 -195 131 -128 177 -134 309 -40 l74 53 65 -27 c72 -30
72 -30 91 -149 10 -63 17 -80 44 -107 l33 -33 177 0 178 0 32 35 c27 28 35 47
45 107 18 117 18 116 92 148 l67 28 77 -54 c70 -49 83 -54 131 -54 30 0 64 5
76 11 32 16 186 169 203 201 8 15 14 51 14 81 0 48 -5 61 -54 131 l-54 77 28
67 c32 74 31 74 150 93 63 10 80 17 107 44 l33 33 0 177 0 177 -33 33 c-26 26
-45 34 -102 44 -116 19 -126 22 -132 39 -3 10 -16 40 -28 69 l-23 51 49 69
c96 133 90 184 -40 316 -47 49 -98 95 -113 103 -15 8 -51 14 -80 14 -49 0 -61
-5 -132 -55 l-78 -54 -37 18 c-20 10 -52 24 -72 30 -34 11 -37 15 -43 64 -15
107 -27 147 -58 177 l-30 30 -178 0 -178 0 -31 -35z m309 -111 c0 -34 35 -204
46 -221 8 -13 40 -30 81 -43 37 -13 94 -36 125 -51 32 -16 68 -29 81 -29 13 0
61 27 107 60 46 33 86 60 89 60 4 0 36 -29 71 -65 49 -50 62 -69 55 -80 -93
-135 -115 -170 -115 -186 0 -11 13 -45 29 -77 15 -31 38 -87 50 -124 12 -36
27 -71 34 -76 7 -6 53 -17 102 -26 50 -9 100 -19 113 -21 21 -5 22 -10 22
-100 0 -109 16 -94 -134 -120 -48 -8 -94 -19 -102 -25 -7 -7 -20 -35 -30 -63
-9 -29 -32 -84 -50 -124 -19 -40 -34 -81 -34 -92 0 -10 28 -60 62 -111 l62
-91 -67 -66 -66 -67 -90 62 c-49 34 -99 62 -110 62 -12 0 -47 -13 -79 -29 -31
-15 -87 -38 -124 -50 -36 -12 -71 -28 -76 -34 -6 -7 -18 -53 -27 -102 -8 -50
-18 -100 -21 -112 -4 -22 -9 -23 -99 -23 -109 0 -94 -16 -120 134 -8 48 -19
94 -25 102 -7 7 -35 21 -63 30 -29 9 -81 30 -116 45 -93 42 -113 39 -213 -30
l-85 -60 -67 68 -68 68 61 85 c70 97 75 125 37 191 -13 23 -37 77 -52 120 -15
43 -34 82 -43 86 -9 5 -64 17 -124 26 l-107 18 0 97 0 97 109 18 c124 20 139
30 160 105 7 25 28 78 48 118 24 52 32 82 28 100 -3 15 -33 63 -65 107 l-59
80 69 69 68 69 69 -50 c116 -84 136 -89 206 -49 23 13 77 37 120 52 43 15 82
34 86 43 5 9 17 64 27 124 l18 107 98 0 c54 0 98 -3 98 -6z
</Geometry>
<Geometry x:Key="settingsIconInner">
M970 1601 c-154 -49 -279 -176 -324 -330 -25 -84 -21 -230 7 -311 73
-206 247 -330 462 -330 153 1 245 34 345 126 71 66 111 128 140 214 29 87 25
256 -9 339 -58 144 -177 253 -320 295 -75 22 -229 20 -301 -3z m293 -164 c71
-32 141 -102 175 -175 38 -81 38 -193 0 -274 -34 -73 -103 -142 -176 -176 -81
-38 -193 -38 -274 0 -73 34 -142 103 -176 176 -36 76 -38 192 -5 265 85 184
282 264 456 184z
</Geometry>
<Style TargetType="{x:Type Button}"
x:Key="settingsButton">
<Setter Property="Height" Value="120"/>
<Setter Property="Width" Value="120"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Viewbox>
<Grid>
<Path x:Name="outerPath" Data="{StaticResource settingsIconOutter}" Fill="{StaticResource normalColor}" />
<Path x:Name="innerPath" Data="{StaticResource settingsIconInner}" Fill="{StaticResource normalColor}" />
</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsMouseOver" Value="true">
<Setter TargetName="outerPath" Property="Fill" Value="{StaticResource hoverColor}" />
<Setter TargetName="innerPath" Property="Fill" Value="{StaticResource hoverColor}" />
</Trigger>
<Trigger Property="Button.IsPressed" Value="true">
<Setter TargetName="outerPath" Property="Fill" Value="{StaticResource pressedColor}" />
<Setter TargetName="innerPath" Property="Fill" Value="{StaticResource pressedColor}" />
</Trigger>
<Trigger Property="Button.IsEnabled" Value="false">
<Setter TargetName="outerPath" Property="Fill" Value="{StaticResource disabledColor}" />
<Setter TargetName="innerPath" Property="Fill" Value="{StaticResource disabledColor}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<pre>
<Button Style="{StaticResource settingsButton}"/>
<Button Style="{StaticResource settingsButton}"
IsEnabled="False"
Margin="20,0,0,0"/>
Paste this into a Window and you'll see what I mean.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 9-May-19 16:02pm.
|
|
|
|
|
Set the grid's background to transparent:
<ControlTemplate>
<Viewbox>
<Grid Background="Transparent">
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hmm, I'm positive I tried that. But that fixed it.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm trying to get a simple datagrid to work. I've been Googling and searching and can't figure this out.
Entity
public class PurchaseOrderEntity : _EntityBase
{
private int _Quantity;
public int Quantity
{
get { return _Quantity; }
set
{
if (_Quantity != value)
{
_Quantity = value;
RaisePropertyChanged("Quantity");
}
}
}
private int _SizeId;
public int SizeId
{
get { return _SizeId; }
set
{
if (_SizeId != value)
{
_SizeId = value;
RaisePropertyChanged("SizeId");
}
}
}
}
View Model
private List<PurchaseOrderEntity> _PurchaseOrders;
public List<PurchaseOrderEntity> PurchaseOrders
{
get { return _PurchaseOrders; }
set
{
if (_PurchaseOrders != value)
{
_PurchaseOrders = value;
RaisePropertyChanged("PurchaseOrders");
}
}
}
private PurchaseOrderEntity _SelectedPurchaseOrder;
public PurchaseOrderEntity SelectedPurchaseOrder
{
get { return _SelectedPurchaseOrder; }
set
{
if (_SelectedPurchaseOrder != value)
{
_SelectedPurchaseOrder = value;
RaisePropertyChanged("SelectedPurchaseOrder");
}
}
}
DataGrid
<DataGrid Grid.Row="2"
Margin="5"
x:Name="lumberGrid"
ItemsSource="{Binding PurchaseOrders}"
SelectedItem="{Binding SelectedPurchaseOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="LightGray"
VerticalGridLinesBrush="LightGray"
AutoGenerateColumns="False"
CanUserAddRows="True"
CanUserDeleteRows="True"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
BorderBrush="SteelBlue"
BorderThickness="1"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
VerticalAlignment="Stretch">
<pre>
<DataGrid.Columns>
<DataGridTextColumn Header="Quantity"
Binding="{Binding Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Width="85"/>
<DataGridTemplateColumn Header="Size"
Width="85">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Path=DataContext.LumberSizes, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
DisplayMemberPath="Caption"
SelectedValuePath="Id"
SelectedValue="{Binding SizeId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
When I run the code, then click on the new row, a red border apprears around the datagrid, and the output window shows this message:
System.Windows.Data Error: 23 : Cannot convert '{NewItemPlaceholder}' from type 'NamedObject' to type 'Jayhawk.Entities.PurchaseOrderEntity' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: TypeConverter cannot convert from MS.Internal.NamedObject.
at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 7 : ConvertBack cannot convert value '{NewItemPlaceholder}' (type 'NamedObject'). BindingExpression:Path=SelectedPurchaseOrder; DataItem='AddEditPOViewModel' (HashCode=11892013); target element is 'DataGrid' (Name='lumberGrid'); target property is 'SelectedItem' (type 'Object') NotSupportedException:'System.NotSupportedException: TypeConverter cannot convert from MS.Internal.NamedObject.
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
at MS.Internal.Data.ObjectTargetConverter.ConvertBack(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertBackHelper(IValueConverter converter, Object value, Type sourceType, Object parameter, CultureInfo culture)'
What am I doing wrong here??
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
SelectedItem="{Binding SelectedPurchaseOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
99% of the population would use the selected item changed event handler.
(and I would use a "form" for adding new records).
(MVVM sucks again in this case)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
This is a heads up data entry form. The user needs to be able to enter a lot of data quickly. Stopping to grab the mouse is not really what they're looking for.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
This feels like work arounds. I'll do an entry form is all else fails, but it has to be possible to do what I want. I've seen data entry grids before.
Gerry Schmitz wrote: (I though it was "heads-down")
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You can do data entry in a data grid. You just wind up writing a lot more code and it gets very difficult to extend as soon as the user comes up with something weird.
And, you're always sitting "at the bottom" when adding a new record.
Combine the two: e.g.
CTRL+N: pops up the form for a new record.
PF5: pops up a form for the current record in grid (edit)
CTRL+D: delete the current record in grid.
CTRL+S: Save the current form / record (keep form open if in "data entry mode")
ESC: release the form.
Extra credits: Navigate in form.
(Keyboard preview key down and handled at the "form" / window / user control level)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I think your List<> in the viewmodel should be an ObservableCollection<>
I would also test it without the combobox in the grid (I NEVER allow complex controls in a data grid).
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
See my reply to Gerry
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
But but a combobox is going to slow down data entry, an auto complete textbox might be better with some validation after they leave the control.
I would try really hard to move the data entry to a panel instead of within the grid.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
Hi,
Could you please help me figure out how I could bind "SelectedItems" of a listbox?
Here I have a 'listbox_2' that contains a list of fruits and vegetables
There's another 'listbox_1' that contains groups of fruits and vegetables (under a list<of string=""> format...maybe is it my first error? Should it rather be a list of fruits/vegetables?) and a recipe.
I would like that on each group selection (in listbox_1), the corresponding fruits and vegetables would be selected (in listbox_2)...and make it possible to modify that list
https://i.imgur.com/nENJTCY.jpg
Unfortunately, the way to achieve this behavior stays obscure to me...could you please help?
Here's what I've set up untill now:
C#
public partial class MainWindow : Window
{
ItemList il;
GroupList gl;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
il = new ItemList();
ICollectionView cvs = CollectionViewSource.GetDefaultView(il);
cvs.SortDescriptions.Add(new SortDescription("_type", ListSortDirection.Ascending));
cvs.SortDescriptions.Add(new SortDescription("_name", ListSortDirection.Ascending));
cvs.GroupDescriptions.Add(new PropertyGroupDescription("_type"));
ListBox2.ItemsSource = cvs;
gl = new GroupList();
ICollectionView cvt = CollectionViewSource.GetDefaultView(gl);
ListBox1.ItemsSource = cvt;
}
}
public class Item
{
public string _type { get; set; }
public string _name { get; set; }
public Item()
{
}
}
public class ItemList : ObservableCollection<Item> {
public ItemList() {
base.Add(new Item() { _type = "fruit", _name = "apple" });
base.Add(new Item() { _type = "vegetable", _name = "potato" });
base.Add(new Item() { _type = "fruit", _name = "banana" });
base.Add(new Item() { _type = "vegetable", _name = "tomato" });
base.Add(new Item() { _type = "fruit", _name = "pear" });
base.Add(new Item() { _type = "vegetable", _name = "salad" });
base.Add(new Item() { _type = "fruit", _name = "orange" });
base.Add(new Item() { _type = "vegetable", _name = "onion" });
}
}
public class Group
{
public string _groupname { get; set; }
public List<String> _members { get; set; }
public string _recipe { get; set; }
public Group()
{
}
}
public class GroupList : ObservableCollection<Group>
{
public GroupList()
{
base.Add(new Group() { _groupname = "Group_1", _members = new List<String>() { "apple", "salad" }, _recipe = "Do this and do that" });
base.Add(new Group() { _groupname = "Group_2", _members = new List<String>() { "banana", "onion" }, _recipe = "Don't do that and do this" });
}
}
XAML
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
Loaded="Window_Loaded">
<Grid>
<Label Margin="12,0,378,283" Content="Group"></Label>
<Label Margin="190,0,200,283" Content="Members"></Label>
<Label Margin="309,0,81,283" Content="Recipe"></Label>
<TextBox Margin="309,34,12,12" DataContext="{Binding SelectedItem, ElementName=ListBox1}" Text="{Binding Path=_recipe, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<ListBox Margin="12,34,378,12" Name="ListBox1" SelectionMode="Single">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding _groupname}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox Margin="190,34,199,12" Name="ListBox2" SelectionMode="Multiple" SelectedValuePath="_name">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding _name}" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander Header="{Binding Name}" IsExpanded="True">
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
</ListBox>
</Grid>
</Window>
EDIT: from my reading, it seams that listboxes couldn't 'easily' bind 'SelectedItems'..maybe then a solution to bind to a checkbox component inside the listbox item?
Thanks for any kind help!
|
|
|
|
|
|
Does Microsoft have documentation for
System.Windows.Controls.DataVisualization.Charting
What is the URL?
|
|
|
|
|
|